Suppress the autosave restore if it is identical
authorAlexander Ebert <ebert@woltlab.com>
Mon, 26 Jun 2023 16:06:45 +0000 (18:06 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 26 Jun 2023 16:06:45 +0000 (18:06 +0200)
Fixes WoltLab/editor#62

ts/WoltLabSuite/Core/Component/Ckeditor/Autosave.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Autosave.js

index 04837f780e323cafcab9b436813c5c7e42dccd6e..02d0810d189d2d1d5b43b394a75645613ab3e752 100644 (file)
@@ -99,6 +99,12 @@ export function setupRestoreDraft(editor: ClassicEditor, identifier: string): vo
   }
 
   const originalValue = editor.data.get();
+
+  // Check if the stored value is identical to the current value.
+  if (originalValue === value.html) {
+    return;
+  }
+
   editor.data.set(value.html);
 
   const wrapper = document.createElement("div");
index 4696c0b0c8cc6561ce922fd298ffdf38669c3197..c43e32b1c6017899141a470db4e5c87c07f6f105 100644 (file)
@@ -80,6 +80,10 @@ define(["require", "exports", "../../Core", "../../Language", "../../StringUtil"
             return;
         }
         const originalValue = editor.data.get();
+        // Check if the stored value is identical to the current value.
+        if (originalValue === value.html) {
+            return;
+        }
         editor.data.set(value.html);
         const wrapper = document.createElement("div");
         wrapper.classList.add("ckeditor5__restoreDraft");