]> BookStack Code Mirror - bookstack/commitdiff
On WYSIWYG details unwrap, provided better restore of cursor
authorDan Brown <redacted>
Thu, 24 Feb 2022 15:02:23 +0000 (15:02 +0000)
committerDan Brown <redacted>
Thu, 24 Feb 2022 15:02:23 +0000 (15:02 +0000)
Also prevents the toolbar from sticking around after the details block
was removed.

resources/js/wysiwyg/plugins-details.js

index 9b5287947c406d026b7ce2bc21c69eaa589f45e0..bcecf7131e5eeb1125f32ca9d79a05b6e091e7da 100644 (file)
@@ -169,6 +169,7 @@ function setSummary(editor, summaryContent) {
  */
 function unwrapDetailsInSelection(editor) {
     const details = editor.selection.getNode().closest('details');
+    const selectionBm = editor.selection.getBookmark();
 
     if (details) {
         const elements = details.querySelectorAll('details > *:not(summary, doc-root), doc-root > *');
@@ -180,7 +181,9 @@ function unwrapDetailsInSelection(editor) {
             details.remove();
         });
     }
+
     editor.focus();
+    editor.selection.moveToBookmark(selectionBm);
 }
 
 /**