Skip to content

Commit

Permalink
pkp/pkp-lib#9366 Resolve forced_root_block issue with having empty st…
Browse files Browse the repository at this point in the history
…ring value
  • Loading branch information
blesildaramirez committed Jan 15, 2025
1 parent b244401 commit 310c521
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/Form/fields/FieldRichText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export default {
return {
...init,
...{
// This will not have any impact on TinyMCE 6.0+ ,
// Need to set to <div> wrapper, to resolve deprecated option forced_root_block of empty string
// @see https://github.com/tinymce/tinymce/discussions/7342
forced_root_block: '',
forced_root_block: 'div',
toolbar_groups: {
formatgroup: {
Expand Down Expand Up @@ -91,6 +91,15 @@ export default {
return;
}
});
editor.on('PostProcess', function (ed) {
// TinyMCE by default inserts a wrapper <p> around the content
// for each editor. We need to set forced_root_block with value "div"
// to use this as the wrapper, and then remove as a workaround to a
// deprecated option & value "{ forced_root_block: '' }"
// @see https://github.com/tinymce/tinymce/discussions/7342
ed.content = ed.content.replace(/^<div>(.*)<\/div>$/, '$1');
});
},
},
};
Expand Down

0 comments on commit 310c521

Please sign in to comment.