Skip to content

Commit 88e27a3

Browse files
committed
do not save on Excalidraw Error popup
1 parent ea3103b commit 88e27a3

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/core/managers/ObserverManager.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ExcalidrawPlugin from "src/core/main";
33
import { CustomMutationObserver } from "src/utils/debugHelper";
44
import { getExcalidrawViews, isObsidianThemeDark } from "src/utils/obsidianUtils";
55
import { App, Notice, TFile } from "obsidian";
6+
import { ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
67

78
export class ObserverManager {
89
private plugin: ExcalidrawPlugin;
@@ -183,17 +184,20 @@ export class ObserverManager {
183184
//The user clicks settings, or "open another vault", or the command palette
184185
const modalContainerObserverFn: MutationCallback = async (m: MutationRecord[]) => {
185186
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(modalContainerObserverFn,`ExcalidrawPlugin.modalContainerObserverFn`, m);
187+
const view = this.plugin.activeExcalidrawView;
186188
if (
187189
(m.length !== 1) ||
188190
(m[0].type !== "childList") ||
189191
(m[0].addedNodes.length !== 1) ||
190-
(!this.plugin.activeExcalidrawView) ||
191-
this.plugin.activeExcalidrawView?.semaphores?.viewunload ||
192-
(!this.plugin.activeExcalidrawView?.isDirty())
192+
(!view) ||
193+
view.semaphores?.viewunload ||
194+
(!view.isDirty())
193195
) {
194196
return;
195197
}
196-
this.plugin.activeExcalidrawView.save();
198+
199+
const { errorMessage } = (view.excalidrawAPI as ExcalidrawImperativeAPI).getAppState();
200+
if (!errorMessage) this.plugin.activeExcalidrawView.save();
197201
};
198202

199203
this.modalContainerObserver = DEBUGGING

src/shared/Dialogs/Messages.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
1818
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
1919
`,
2020
"2.15.1":`
21+
## Fixed
22+
- Pasting an oversized image resulted in an error message and Excalidraw dumping the scene. [#2453](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2453), [#9878](https://github.com/excalidraw/excalidraw/issues/9878)
23+
2124
## New
2225
- New option in settings under "Zoom and Pan". Pan with right mouse button (Miro‑style): right‑click and drag to pan the canvas. Press 'm' for the context menu (disabled while editing text). 🙏 [@mfuria](https://github.com/mfuria) for making this happen! [#2450](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2450), [#329](https://github.com/zsviczian/excalidraw/pull/329)
2326
- Insert image in the main toolbar now opens a dropdown menu of options: Insert from system, insert from Vault, insert LaTeX. [#2448](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2448)

0 commit comments

Comments
 (0)