mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
fix(canvas): error when trying to save due to uninitialized API
This commit is contained in:
@@ -357,6 +357,9 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
if (options.is("databaseReadonly")) {
|
if (options.is("databaseReadonly")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.canvasInstance.isInitialized()) return;
|
||||||
|
|
||||||
// changeHandler is called upon any tiny change in excalidraw. button clicked, hover, etc.
|
// changeHandler is called upon any tiny change in excalidraw. button clicked, hover, etc.
|
||||||
// make sure only when a new element is added, we actually save something.
|
// make sure only when a new element is added, we actually save something.
|
||||||
const isNewSceneVersion = this.canvasInstance.isNewSceneVersion();
|
const isNewSceneVersion = this.canvasInstance.isNewSceneVersion();
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ export default class Canvas {
|
|||||||
return this.currentSceneVersion === SCENE_VERSION_INITIAL;
|
return this.currentSceneVersion === SCENE_VERSION_INITIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isInitialized() {
|
||||||
|
return !!this.excalidrawApi;
|
||||||
|
}
|
||||||
|
|
||||||
resetScene(theme: Theme) {
|
resetScene(theme: Theme) {
|
||||||
this.excalidrawApi.updateScene({
|
this.excalidrawApi.updateScene({
|
||||||
elements: [],
|
elements: [],
|
||||||
@@ -194,4 +198,4 @@ function CanvasElement(opts: ExcalidrawProps) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user