From de390538572272cc4359b866aed7991d7b50c3ff Mon Sep 17 00:00:00 2001 From: zsviczian Date: Mon, 22 Jul 2024 22:01:36 +0200 Subject: [PATCH] 2.2.10 --- manifest.json | 2 +- package.json | 2 +- src/ExcalidrawView.ts | 1 + src/Scripts.ts | 12 ++++++++++++ src/dialogs/Messages.ts | 13 +++++++++---- src/utils/WeakArray.ts | 11 +++++++++++ tsconfig.dev.json | 2 +- tsconfig.json | 2 +- 8 files changed, 37 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index 667ad80..37acb0b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.2.9", + "version": "2.2.10", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/package.json b/package.json index efff239..ea0e8f1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "dependencies": { "@popperjs/core": "^2.11.8", - "@zsviczian/excalidraw": "0.17.1-obsidian-31", + "@zsviczian/excalidraw": "0.17.1-obsidian-32", "chroma-js": "^2.4.2", "clsx": "^2.0.0", "colormaster": "^1.2.1", diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index 4655619..63d11e0 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -1718,6 +1718,7 @@ export default class ExcalidrawView extends TextFileView { this.clearPreventReloadTimer(); this.clearEmbeddableIsEditingSelfTimer(); + this.plugin.scriptEngine?.removeViewEAs(this); this.excalidrawAPI = null; if(this.draginfoDiv) { this.ownerDocument.body.removeChild(this.draginfoDiv); diff --git a/src/Scripts.ts b/src/Scripts.ts index 6f18c31..c12e67f 100644 --- a/src/Scripts.ts +++ b/src/Scripts.ts @@ -33,8 +33,20 @@ export class ScriptEngine { this.registerEventHandlers(); } + public removeViewEAs(view: ExcalidrawView) { + const eas = new Set(); + this.eaInstances.forEach((ea) => { + if (ea.targetView === view) { + eas.add(ea); + ea.destroy(); + } + }); + this.eaInstances.removeObjects(eas); + } + public destroy() { this.eaInstances.forEach((ea) => ea.destroy()); + this.eaInstances.clear(); this.eaInstances = null; this.scriptIconMap = null; this.plugin = null; diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index f9437f1..543ae8a 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -18,13 +18,18 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, "2.2.10": ` -## New -- Area, Group, Frame, and Clipped-Frame references to images now also work when pasting images to Excalidraw. -- New reference type ${String.fromCharCode(96)}clippedframe=${String.fromCharCode(96)} works in the same way as ${String.fromCharCode(96)}frame=${String.fromCharCode(96)} but will display the elements clipped by the frame. ${String.fromCharCode(96)}clippedframe=${String.fromCharCode(96)} will always display the image with zero padding. -- New command palette action: ${String.fromCharCode(96)}Frame Settings${String.fromCharCode(96)} gives you fine-grained control over how frames are rendered. Frame settings will also be reflected in image exports. For example, if you hide the frame name or outline, then in exports they will not be visible. +
+ +
## Fixed +- Drastically degraded rendering performance when zoomed in and when arrows with labels are used. [#8267](https://github.com/excalidraw/excalidraw/pull/8267), [#8266](https://github.com/excalidraw/excalidraw/pull/8266), [#1893](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1893) - Frame title font in exports. + +## New +- Area, Group, Frame, and Clipped-Frame references to images now also work when pasting images to Excalidraw. +- The new reference type ${String.fromCharCode(96)}clippedframe=${String.fromCharCode(96)} works in the same way as ${String.fromCharCode(96)}frame=${String.fromCharCode(96)} but will display the elements clipped by the frame. ${String.fromCharCode(96)}clippedframe=${String.fromCharCode(96)} will always display the image with zero padding. +- New command palette action: ${String.fromCharCode(96)}Frame Settings${String.fromCharCode(96)} gives you fine-grained control over how frames are rendered. Frame settings will also be reflected in image exports. For example, if you hide the frame name or outline, then in exports they will not be visible. `, "2.2.9": ` ## New diff --git a/src/utils/WeakArray.ts b/src/utils/WeakArray.ts index 866c30b..e0655a8 100644 --- a/src/utils/WeakArray.ts +++ b/src/utils/WeakArray.ts @@ -15,4 +15,15 @@ export class WeakArray { } }); } + + removeObjects(objectsToRemove: Set) { + this.weakArray = this.weakArray.filter((ref) => { + const obj = ref.deref(); + return obj && !objectsToRemove.has(obj); + }); + } + + clear() { + this.weakArray = []; + } } \ No newline at end of file diff --git a/tsconfig.dev.json b/tsconfig.dev.json index 7bc6b25..dd513ec 100644 --- a/tsconfig.dev.json +++ b/tsconfig.dev.json @@ -3,7 +3,7 @@ "baseUrl": ".", "sourceMap": false, "module": "ES2015", - "target": "es2017", //es2017 because script engine requires for async execution + "target": "es2018", //es2017 because script engine requires for async execution "allowJs": true, "noImplicitAny": true, "moduleResolution": "node", diff --git a/tsconfig.json b/tsconfig.json index 3441940..041eda3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "baseUrl": ".", "sourceMap": false, "module": "es2015", - "target": "es2017", //es2017 because script engine requires for async execution + "target": "es2018", //es2017 because script engine requires for async execution //es2018 for named capture groups "allowJs": true, "noImplicitAny": true, "moduleResolution": "node",