mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +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")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.canvasInstance.isInitialized()) return;
|
||||
|
||||
// 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.
|
||||
const isNewSceneVersion = this.canvasInstance.isNewSceneVersion();
|
||||
|
||||
@@ -76,6 +76,10 @@ export default class Canvas {
|
||||
return this.currentSceneVersion === SCENE_VERSION_INITIAL;
|
||||
}
|
||||
|
||||
isInitialized() {
|
||||
return !!this.excalidrawApi;
|
||||
}
|
||||
|
||||
resetScene(theme: Theme) {
|
||||
this.excalidrawApi.updateScene({
|
||||
elements: [],
|
||||
@@ -194,4 +198,4 @@ function CanvasElement(opts: ExcalidrawProps) {
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user