diff --git a/manifest.json b/manifest.json index 6b4b466..eae913b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.2.1", + "version": "2.2.2", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawData.ts b/src/ExcalidrawData.ts index 88839bd..64416cf 100644 --- a/src/ExcalidrawData.ts +++ b/src/ExcalidrawData.ts @@ -973,7 +973,7 @@ export class ExcalidrawData { //update text in scene based on textElements Map //first get scene text elements const elementsMap = arrayToMap(this.scene.elements); - const texts = this.scene.elements?.filter((el: any) => el.type === "text") as Mutable[]; + const texts = this.scene.elements?.filter((el: any) => el.type === "text" && !el.isDeleted) as Mutable[]; for (const te of texts) { const container = getContainerElement(te, elementsMap); const originalText = diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index f050645..7375fff 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -1309,7 +1309,11 @@ export default class ExcalidrawView extends TextFileView { this.app.workspace.onLayoutReady(async () => { debug(`ExcalidrawView.onload app.workspace.onLayoutReady, file: ${self.file?.name}, isActiveLeaf: ${self.app.workspace.activeLeaf === self.leaf}, is activeExcalidrawView set: ${Boolean(self.plugin.activeExcalidrawView)}`); //implemented to overcome issue that activeLeafChangeEventHandler is not called when view is initialized from a saved workspace, since Obsidian 1.6.0 - if (self.app.workspace.activeLeaf === self.leaf) { + let counter = 0; + while(counter++<50 && !Boolean(self.plugin.activeLeafChangeEventHandler)) { + await(sleep(50)); + } + if (Boolean(self.plugin.activeLeafChangeEventHandler) && (self.app.workspace.activeLeaf === self.leaf)) { self.plugin.activeLeafChangeEventHandler(self.leaf); } self.canvasNodeFactory.initialize(); @@ -2318,17 +2322,25 @@ export default class ExcalidrawView extends TextFileView { } } - public initializeToolsIconPanelAfterLoading() { + public async initializeToolsIconPanelAfterLoading() { if(this.semaphores.viewunload) return; const api = this.excalidrawAPI; if (!api) { return; } const st = api.getAppState(); + //since Obsidian 1.6.0 onLayoutReady calls happen asynchronously compared to starting Excalidraw view + //these validations are just to make sure that initialization is complete + let counter = 0; + while(!this.plugin.scriptEngine && counter++<50) { + sleep(50); + } + const panel = this.toolsPanelRef?.current; - if (!panel) { + if (!panel || !this.plugin.scriptEngine) { return; } + panel.setTheme(st.theme); panel.setExcalidrawViewMode(st.viewModeEnabled); panel.setPreviewMode( @@ -2817,7 +2829,7 @@ export default class ExcalidrawView extends TextFileView { //@ts-ignore textElement.link = link; } - if (this.textMode == TextMode.parsed) { + if (this.textMode === TextMode.parsed && !textElement?.isDeleted) { const {text, x, y, width, height} = refreshTextDimensions( textElement,null,elementsMap,parseResult ); @@ -4021,14 +4033,16 @@ export default class ExcalidrawView extends TextFileView { if(el.length === 1) { const container = getContainerElement(el[0],elementsMap); const clone = cloneElement(el[0]); - const {text, x, y, width, height} = refreshTextDimensions(el[0], container, elementsMap, parsedText); + if(!el[0]?.isDeleted) { + const {text, x, y, width, height} = refreshTextDimensions(el[0], container, elementsMap, parsedText); - clone.x = x; - clone.y = y; - clone.width = width; - clone.height = height; - clone.originalText = parsedText; - clone.text = text; + clone.x = x; + clone.y = y; + clone.width = width; + clone.height = height; + clone.originalText = parsedText; + clone.text = text; + } elements[elements.indexOf(el[0])] = clone; this.updateScene({elements}); diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index 210d35e..1db5987 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,12 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"2.2.2":` +## Fixed +- ExcaliBrain stopped working with 2.2.0 + +![I apologize](https://github.com/zsviczian/obsidian-excalidraw-plugin/assets/14358394/3b05aa28-788d-4329-9721-798ad58a6ca2) +`, "2.2.1":` ## Fixed - Text height becomes unreadable after 2.2.0 update [#1784](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1784)