Fixes issue where inline-only content would disappear when unwrapping a
details block element.
"-doc-root[doc-root|#text]",
"-li[details]",
"+code-block[pre]",
"-doc-root[doc-root|#text]",
"-li[details]",
"+code-block[pre]",
- "+doc-root[code-block]"
+ "+doc-root[p|h1|h2|h3|h4|h5|h6|blockquote|code-block|div]"
].join(','),
plugins: gatherPlugins(options),
contextmenu: false,
].join(','),
plugins: gatherPlugins(options),
contextmenu: false,
* @param {Editor} editor
* @param {String} url
*/
* @param {Editor} editor
* @param {String} url
*/
+import {blockElementTypes} from "./util";
function register(editor, url) {
function register(editor, url) {
unwrapDetailsEditable(detailsEl);
detailsEl.attr('contenteditable', 'false');
unwrapDetailsEditable(detailsEl);
detailsEl.attr('contenteditable', 'false');
- const wrap = tinymce.html.Node.create('doc-root', {contenteditable: 'true'});
+ const rootWrap = tinymce.html.Node.create('doc-root', {contenteditable: 'true'});
+ let previousBlockWrap = null;
+
for (const child of detailsEl.children()) {
for (const child of detailsEl.children()) {
- if (child.name !== 'summary') {
- wrap.append(child);
+ if (child.name === 'summary') continue;
+ const isBlock = blockElementTypes.includes(child.name);
+
+ if (!isBlock) {
+ if (!previousBlockWrap) {
+ previousBlockWrap = tinymce.html.Node.create('p');
+ rootWrap.append(previousBlockWrap);
+ }
+ previousBlockWrap.append(child);
+ } else {
+ rootWrap.append(child);
+ previousBlockWrap = null;
- detailsEl.append(wrap);
+ detailsEl.append(rootWrap);
--- /dev/null
+
+
+export const blockElementTypes = [
+ 'p',
+ 'h1',
+ 'h2',
+ 'h3',
+ 'h4',
+ 'h5',
+ 'h6',
+ 'div',
+ 'blockquote',
+ 'pre',
+ 'code-block',
+ 'details',
+ 'ul',
+ 'ol',
+ 'table'
+];
\ No newline at end of file