From: Dan Brown Date: Thu, 24 Feb 2022 15:02:23 +0000 (+0000) Subject: On WYSIWYG details unwrap, provided better restore of cursor X-Git-Tag: v22.02~1^2~4 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/1e112f78d8d54d5802575cc47e332598bc1d2893 On WYSIWYG details unwrap, provided better restore of cursor Also prevents the toolbar from sticking around after the details block was removed. --- diff --git a/resources/js/wysiwyg/plugins-details.js b/resources/js/wysiwyg/plugins-details.js index 9b5287947..bcecf7131 100644 --- a/resources/js/wysiwyg/plugins-details.js +++ b/resources/js/wysiwyg/plugins-details.js @@ -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); } /**