mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
1.9.1
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "1.9.0",
|
||||
"version": "1.9.1",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/lz-string": "^1.3.34",
|
||||
"@zsviczian/excalidraw": "0.15.2-obsidian-1",
|
||||
"@zsviczian/excalidraw": "0.15.2-obsidian-2",
|
||||
"chroma-js": "^2.4.2",
|
||||
"clsx": "^1.2.1",
|
||||
"colormaster": "^1.2.1",
|
||||
|
||||
@@ -258,7 +258,7 @@ export class ExcalidrawData {
|
||||
public autoexportPreference: AutoexportPreference = AutoexportPreference.inherit;
|
||||
private textMode: TextMode = TextMode.raw;
|
||||
public loaded: boolean = false;
|
||||
private files: Map<FileId, EmbeddedFile> = null; //fileId, path
|
||||
public files: Map<FileId, EmbeddedFile> = null; //fileId, path
|
||||
private equations: Map<FileId, { latex: string; isLoaded: boolean }> = null; //fileId, path
|
||||
private compatibilityMode: boolean = false;
|
||||
selectedElementIds: {[key:string]:boolean} = {}; //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/609
|
||||
|
||||
@@ -112,7 +112,6 @@ import { emulateCTRLClickForLinks, externalDragModifierType, internalDragModifie
|
||||
import { setDynamicStyle } from "./utils/DynamicStyling";
|
||||
import { MenuLinks } from "./menu/MenuLinks";
|
||||
import { InsertPDFModal } from "./dialogs/InsertPDFModal";
|
||||
import { get } from "http";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
@@ -216,7 +215,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
public excalidrawWrapperRef: React.MutableRefObject<any> = null;
|
||||
public toolsPanelRef: React.MutableRefObject<any> = null;
|
||||
private parentMoveObserver: MutationObserver;
|
||||
public linksAlwaysOpenInANewPane: boolean = false; //override the need for SHIFT+CTRL+click
|
||||
public linksAlwaysOpenInANewPane: boolean = false; //override the need for SHIFT+CTRL+click (used by ExcaliBrain)
|
||||
private hookServer: ExcalidrawAutomate;
|
||||
public lastSaveTimestamp: number = 0; //used to validate if incoming file should sync with open file
|
||||
private onKeyUp: (e: KeyboardEvent) => void;
|
||||
@@ -1012,7 +1011,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
keys.altKey = true;
|
||||
}
|
||||
const leaf = getLeaf(this.plugin,this.leaf,keys);
|
||||
await leaf.openFile(file, subpath ? { active: false, eState: { subpath } } : undefined); //if file exists open file and jump to reference
|
||||
await leaf.openFile(file, subpath ? { active: !this.linksAlwaysOpenInANewPane, eState: { subpath } } : undefined); //if file exists open file and jump to reference
|
||||
//view.app.workspace.setActiveLeaf(leaf, true, true); //0.15.4 ExcaliBrain focus issue
|
||||
} catch (e) {
|
||||
new Notice(e, 4000);
|
||||
@@ -1480,10 +1479,25 @@ export default class ExcalidrawView extends TextFileView {
|
||||
];
|
||||
}
|
||||
|
||||
const waitForExcalidraw = async () => {
|
||||
let counter = 0;
|
||||
while (
|
||||
(self.semaphores.justLoaded ||
|
||||
!self.isLoaded ||
|
||||
!self.excalidrawAPI ||
|
||||
self.excalidrawAPI?.getAppState()?.isLoading) &&
|
||||
counter++<100
|
||||
) await sleep(50); //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/734
|
||||
}
|
||||
|
||||
const filenameParts = getEmbeddedFilenameParts(state.subpath);
|
||||
if(filenameParts.hasBlockref) {
|
||||
setTimeout(()=>self.zoomToElementId(filenameParts.blockref, filenameParts.hasGroupref),300);
|
||||
setTimeout(async () => {
|
||||
await waitForExcalidraw();
|
||||
setTimeout(()=>self.zoomToElementId(filenameParts.blockref, filenameParts.hasGroupref));
|
||||
});
|
||||
}
|
||||
|
||||
if(filenameParts.hasSectionref) {
|
||||
query = [`# ${filenameParts.sectionref}`]
|
||||
} else if (state.line && state.line > 0) {
|
||||
@@ -1492,15 +1506,38 @@ export default class ExcalidrawView extends TextFileView {
|
||||
|
||||
if (query) {
|
||||
setTimeout(async () => {
|
||||
let counter = 0;
|
||||
while (!self.excalidrawAPI && counter++<100) await sleep(50); //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/734
|
||||
|
||||
await waitForExcalidraw();
|
||||
|
||||
const api = self.excalidrawAPI;
|
||||
if (!api) {
|
||||
return;
|
||||
if (!api) return;
|
||||
if (api.getAppState().isLoading) return;
|
||||
|
||||
const elements = api.getSceneElements() as ExcalidrawElement[];
|
||||
|
||||
if(query.length === 1 && query[0].startsWith("[")) {
|
||||
const partsArray = REGEX_LINK.getResList(query[0]);
|
||||
let parts = partsArray[0];
|
||||
if(parts) {
|
||||
const linkText = REGEX_LINK.getLink(parts);
|
||||
if(linkText) {
|
||||
const file = self.plugin.app.metadataCache.getFirstLinkpathDest(linkText, self.file.path);
|
||||
if(file) {
|
||||
let fileId:FileId[] = [];
|
||||
self.excalidrawData.files.forEach((ef,fileID) => {
|
||||
if(ef.file?.path === file.path) fileId.push(fileID);
|
||||
});
|
||||
if(fileId.length>0) {
|
||||
const images = elements.filter(el=>el.type === "image" && fileId.includes(el.fileId));
|
||||
if(images.length>0) {
|
||||
this.preventAutozoom();
|
||||
setTimeout(()=>self.zoomToElements(!api.getAppState().viewModeEnabled, images));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const elements = api.getSceneElements();
|
||||
|
||||
|
||||
self.selectElementsMatchingQuery(
|
||||
elements,
|
||||
query,
|
||||
@@ -1508,7 +1545,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
filenameParts.hasSectionref,
|
||||
filenameParts.hasGroupref
|
||||
);
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
|
||||
super.setEphemeralState(state);
|
||||
@@ -1791,7 +1828,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
if(this.getSceneVersion(inData.scene.elements) !== this.previousSceneVersion) {
|
||||
this.setDirty(3);
|
||||
}
|
||||
await this.updateScene({elements: sceneElements});
|
||||
this.updateScene({elements: sceneElements});
|
||||
if(reloadFiles) this.loadSceneFiles();
|
||||
} catch(e) {
|
||||
errorlog({
|
||||
@@ -1871,9 +1908,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
this.excalidrawWrapperRef.current?.firstElementChild?.focus();
|
||||
}
|
||||
//debug({where:"ExcalidrawView.loadDrawing",file:this.file.name,before:"this.loadSceneFiles"});
|
||||
this.loadSceneFiles();
|
||||
this.updateContainerSize(null, true);
|
||||
this.initializeToolsIconPanelAfterLoading();
|
||||
this.onAfterLoadScene();
|
||||
} else {
|
||||
this.instantiateExcalidraw({
|
||||
elements: excalidrawData.elements,
|
||||
@@ -1915,6 +1950,12 @@ export default class ExcalidrawView extends TextFileView {
|
||||
);
|
||||
}
|
||||
|
||||
private onAfterLoadScene() {
|
||||
this.loadSceneFiles();
|
||||
this.updateContainerSize(null, true);
|
||||
this.initializeToolsIconPanelAfterLoading();
|
||||
}
|
||||
|
||||
public setDirty(debug?:number) {
|
||||
//console.log(debug);
|
||||
this.semaphores.dirty = this.file?.path;
|
||||
@@ -2230,11 +2271,11 @@ export default class ExcalidrawView extends TextFileView {
|
||||
(api: ExcalidrawImperativeAPI) => {
|
||||
this.excalidrawAPI = api;
|
||||
api.setLocalFont(this.plugin.settings.experimentalEnableFourthFont);
|
||||
this.loadSceneFiles();
|
||||
this.updateContainerSize(null, true);
|
||||
this.excalidrawContainer = this.excalidrawWrapperRef?.current?.firstElementChild;
|
||||
this.excalidrawContainer?.focus();
|
||||
this.initializeToolsIconPanelAfterLoading();
|
||||
setTimeout(() => {
|
||||
this.onAfterLoadScene();
|
||||
this.excalidrawContainer = this.excalidrawWrapperRef?.current?.firstElementChild;
|
||||
this.excalidrawContainer?.focus();
|
||||
});
|
||||
},
|
||||
);
|
||||
}, [excalidrawRef]);
|
||||
@@ -3530,7 +3571,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
}
|
||||
setTimeout(()=>this.removeLinkTooltip(),500);
|
||||
|
||||
const event = e?.detail?.nativeEvent;
|
||||
let event = e?.detail?.nativeEvent;
|
||||
if(this.handleLinkHookCall(element,element.link,event)) return;
|
||||
if(this.openExternalLink(element.link, !isSHIFT(event) && !isCTRL(event) && !isMETA(event) && !isALT(event) ? element : undefined)) return;
|
||||
|
||||
@@ -3543,6 +3584,10 @@ export default class ExcalidrawView extends TextFileView {
|
||||
}
|
||||
}
|
||||
|
||||
if (!event.shiftKey && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
||||
event = {shiftKey: true, ctrlKey: false, metaKey: false, altKey: false};
|
||||
}
|
||||
|
||||
this.linkClick(
|
||||
event,
|
||||
null,
|
||||
|
||||
@@ -17,6 +17,17 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
|
||||
|
||||
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://cdn.ko-fi.com/cdn/kofi3.png?v=3" height=45></a></div>
|
||||
`,
|
||||
"1.9.1":`
|
||||
## Updates from Excalidraw.com
|
||||
- "Unlock all elements" - new action available via the context menu [#5894](https://github.com/excalidraw/excalidraw/pull/5894)
|
||||
- Minor improvements to improve the speed [#6560](https://github.com/excalidraw/excalidraw/pull/6560)
|
||||
- Retain Seed on Shift Paste [#6509](https://github.com/excalidraw/excalidraw/pull/6509)
|
||||
|
||||
## New/Fixed
|
||||
- Clicking on the link handle (top right corner) will open the link in the same window
|
||||
- CTRL/CMD click on a link will open the link in a new tab and will focus on the new tab
|
||||
- Linking to parts of images. In some cases clicking search results, links, or backlinks did not focus on the right element according to the link. Fixed.
|
||||
`,
|
||||
"1.9.0":`
|
||||
<div class="excalidraw-videoWrapper"><div>
|
||||
<iframe src="https://www.youtube.com/embed/nB4cOfn0xAs" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
|
||||
25
yarn.lock
25
yarn.lock
@@ -1896,11 +1896,6 @@
|
||||
"resolved" "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz"
|
||||
"version" "4.0.0"
|
||||
|
||||
"@types/parse5@^6.0.3":
|
||||
"integrity" "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g=="
|
||||
"resolved" "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz"
|
||||
"version" "6.0.3"
|
||||
|
||||
"@types/prettier@^2.1.5":
|
||||
"integrity" "sha512-QzSuZMBuG5u8HqYz01qtMdg/Jfctlnvj1z/lYnIDXs/golxw0fxtRAHd9KrzjR7Yxz1qVeI00o0kiO3PmVdJ9w=="
|
||||
"resolved" "https://registry.npmjs.org/@types/prettier/-/prettier-2.4.3.tgz"
|
||||
@@ -2004,13 +1999,6 @@
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/xmlserializer@^0.6.3":
|
||||
"integrity" "sha512-C4sPQn2oNQmXwk6oI1sY5mHcd1MJNOH2IXk4QFqxGBI9hSjrAOTP8Th/LsXqEU+E96dfaNrH+ZBTXfOWEGXOWQ=="
|
||||
"resolved" "https://registry.npmjs.org/@types/xmlserializer/-/xmlserializer-0.6.3.tgz"
|
||||
"version" "0.6.3"
|
||||
dependencies:
|
||||
"@types/parse5" "^6.0.3"
|
||||
|
||||
"@types/yargs-parser@*":
|
||||
"integrity" "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw=="
|
||||
"resolved" "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.1.tgz"
|
||||
@@ -2284,10 +2272,10 @@
|
||||
dependencies:
|
||||
"@zerollup/ts-helpers" "^1.7.18"
|
||||
|
||||
"@zsviczian/excalidraw@0.14.2-obsidian-5":
|
||||
"integrity" "sha512-Wav3VDhapWY60lFHF6UPFAwPPn1lCoRW/eesll8w4Xt4jBmz61NVtnsAmJmCEovwzZnFZwfsJ633Fbh1VYStyA=="
|
||||
"resolved" "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.14.2-obsidian-5.tgz"
|
||||
"version" "0.14.2-obsidian-5"
|
||||
"@zsviczian/excalidraw@0.15.2-obsidian-2":
|
||||
"integrity" "sha512-TrXKrCYSMZMjNWVxNorV7vty7vLphponHDjh4MOKXW+3YmFx91Spzmp7GXhPr1IBTUDgcW+U5KXWvU77uuFJmg=="
|
||||
"resolved" "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.15.2-obsidian-2.tgz"
|
||||
"version" "0.15.2-obsidian-2"
|
||||
|
||||
"abab@^2.0.3", "abab@^2.0.5":
|
||||
"integrity" "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q=="
|
||||
@@ -9394,11 +9382,6 @@
|
||||
"resolved" "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz"
|
||||
"version" "2.2.0"
|
||||
|
||||
"xmlserializer@^0.6.1":
|
||||
"integrity" "sha512-FNb0eEqqUUbnuvxuHqNuKH8qCGKqxu+558Zi8UzOoQk8Z9LdvpONK+v7m3gpKVHrk5Aq+0nNLsKxu/6OYh7Umw=="
|
||||
"resolved" "https://registry.npmjs.org/xmlserializer/-/xmlserializer-0.6.1.tgz"
|
||||
"version" "0.6.1"
|
||||
|
||||
"xtend@^4.0.2":
|
||||
"integrity" "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
|
||||
"resolved" "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz"
|
||||
|
||||
Reference in New Issue
Block a user