From 966959f5f666af40dee4f5db47c036be4707e50a Mon Sep 17 00:00:00 2001 From: Dominik Biedebach Date: Tue, 28 Feb 2023 00:26:03 +0100 Subject: [PATCH] fix(core): fix destroyed view causing errors on dispatchTransaction --- .../DestroyingEditor/Vue/index.html | 0 .../DestroyingEditor/Vue/index.vue | 49 +++++++++++++++++++ packages/core/src/Editor.ts | 6 +++ 3 files changed, 55 insertions(+) create mode 100644 demos/src/Experiments/DestroyingEditor/Vue/index.html create mode 100644 demos/src/Experiments/DestroyingEditor/Vue/index.vue diff --git a/demos/src/Experiments/DestroyingEditor/Vue/index.html b/demos/src/Experiments/DestroyingEditor/Vue/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/demos/src/Experiments/DestroyingEditor/Vue/index.vue b/demos/src/Experiments/DestroyingEditor/Vue/index.vue new file mode 100644 index 00000000000..4d6e170dbb6 --- /dev/null +++ b/demos/src/Experiments/DestroyingEditor/Vue/index.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index ba545511b25..7cd43caf49c 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -320,6 +320,12 @@ export class Editor extends EventEmitter { * @param transaction An editor state transaction */ private dispatchTransaction(transaction: Transaction): void { + // if the editor / the view of the editor was destroyed + // the transaction should not be dispatched as there is no view anymore. + if (this.view.isDestroyed) { + return + } + if (this.isCapturingTransaction) { if (!this.capturedTransaction) { this.capturedTransaction = transaction