This commit is contained in:
zsviczian
2024-05-20 12:25:53 +02:00
parent 2b86ba2128
commit ff1d7b44b4
4 changed files with 33 additions and 13 deletions

View File

@@ -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",

View File

@@ -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<ExcalidrawTextElement>[];
const texts = this.scene.elements?.filter((el: any) => el.type === "text" && !el.isDeleted) as Mutable<ExcalidrawTextElement>[];
for (const te of texts) {
const container = getContainerElement(te, elementsMap);
const originalText =

View File

@@ -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,6 +4033,7 @@ export default class ExcalidrawView extends TextFileView {
if(el.length === 1) {
const container = getContainerElement(el[0],elementsMap);
const clone = cloneElement(el[0]);
if(!el[0]?.isDeleted) {
const {text, x, y, width, height} = refreshTextDimensions(el[0], container, elementsMap, parsedText);
clone.x = x;
@@ -4029,6 +4042,7 @@ export default class ExcalidrawView extends TextFileView {
clone.height = height;
clone.originalText = parsedText;
clone.text = text;
}
elements[elements.indexOf(el[0])] = clone;
this.updateScene({elements});

View File

@@ -17,6 +17,12 @@ 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>
`,
"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)