On WYSIWYG details unwrap, provided better restore of cursor

Also prevents the toolbar from sticking around after the details block
was removed.
This commit is contained in:
Dan Brown 2022-02-24 15:02:23 +00:00
parent 9283f28e31
commit 1e112f78d8
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

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