diff --git a/manifest.json b/manifest.json index 4a4b751..f0f99f6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.1.3", + "version": "1.1.4", "minAppVersion": "0.11.13", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/main.ts b/src/main.ts index a4dbd8b..ff6b39a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -166,6 +166,7 @@ export default class ExcalidrawPlugin extends Plugin { el.setAttribute("w",fwidth); el.setAttribute("h",fheight); el.onClickEvent((ev)=>{ + if(ev.target instanceof Element && ev.target.tagName.toLowerCase() != "img") return; let src = el.getAttribute("src"); if(src) this.openDrawing(this.app.vault.getAbstractFileByPath(src) as TFile,ev.ctrlKey); }); @@ -398,17 +399,17 @@ export default class ExcalidrawPlugin extends Plugin { private async addEventListeners(plugin: ExcalidrawPlugin) { const notice = new Notice( - "Thank you for updating to Excalidraw 1.1!\n"+ - "This is a temporary notice which will be removed in about a week's time.\n"+ - "I have much improved how drawings are embedded.\n"+ - "You no longer need a codeblock, simply embed Excalidraw like any other drawing: " + + "Welcome to Excalidraw 1.1!\n\n"+ + "This is a temporary notice. I will remove this in a week.\n\n"+ + "I have improved embedding of drawings. "+ + "You no longer need a code block, simply embed Excalidraw like any other image: " + "![[my drawing.excalidraw]] or ![[my drawing.excalidraw|500|left]] or "+ - "![[my drawing.excalidraw|right-wrap]] etc. you get the idea.\n"+ - "ALT+Enter and CTRL+ALT+Enter on the filename will open up the Excalidraw editor.\n"+ - "Click and CTRL+Click on the image in preview mode will again bring up the editor as expected.\n\n"+ + "![[my drawing.excalidraw|right-wrap]] or ![alt-text|500](my drawing.excalidraw) etc.\n\n"+ + "ALT+Enter and CTRL+ALT+Enter on the filename will open the drawing in the Excalidraw editor. "+ + "Click and CTRL+Click on the image in preview mode will also open the editor as expected.\n\n"+ "MIGRATION\n"+ - "I have added a Migration command to the Command Palette. Selecting this will search and replace all the "+ - "excalidraw codeblocks in your vault to the new format.", 60000); + 'See "Migrate" in Command Palette. Selecting this will convert all the '+ + "excalidraw code blocks in your vault to the new embed format.", 60000); const closeDrawing = async (filePath:string) => { const leaves = plugin.app.workspace.getLeavesOfType(VIEW_TYPE_EXCALIDRAW); @@ -426,13 +427,13 @@ export default class ExcalidrawPlugin extends Plugin { const reloadDrawing = async (oldPath:string, newPath: string) => { const file = plugin.app.vault.getAbstractFileByPath(newPath); if(!(file && file instanceof TFile)) return; - const leaves = plugin.app.workspace.getLeavesOfType(VIEW_TYPE_EXCALIDRAW); + let leaves = plugin.app.workspace.getLeavesOfType(VIEW_TYPE_EXCALIDRAW); for (let i=0;i { @@ -609,7 +610,7 @@ export default class ExcalidrawPlugin extends Plugin { const activeLeafChangeEventHandler = (leaf:WorkspaceLeaf) => { if(plugin.activeExcalidrawView) { plugin.activeExcalidrawView.save(); - plugin.triggerEmbedUpdates(); + plugin.triggerEmbedUpdates(plugin.activeExcalidrawView.file.path); } plugin.activeExcalidrawView = (leaf.view.getViewType() == VIEW_TYPE_EXCALIDRAW) ? leaf.view as ExcalidrawView : null; if(plugin.activeExcalidrawView) @@ -645,11 +646,11 @@ export default class ExcalidrawPlugin extends Plugin { await this.saveData(this.settings); } - public triggerEmbedUpdates(){ + public triggerEmbedUpdates(filepath?:string){ const e = document.createEvent("Event") e.initEvent(RERENDER_EVENT,true,false); document - .querySelectorAll("svg[class^='excalidraw-svg']") + .querySelectorAll("div[class^='excalidraw-svg']"+ (filepath ? "[src='"+filepath+"']" : "")) .forEach((el) => el.dispatchEvent(e)); } diff --git a/versions.json b/versions.json index bb3756c..3121ec4 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.1.3": "0.11.13" + "1.1.4": "0.11.13" }