return headContentLines.slice(startLineIndex + 1, endLineIndex).join('\n');
}
+/**
+ * Setup a serializer filter for <br> tags to ensure they're not rendered
+ * within code blocks and that we use newlines there instead.
+ * @param {Editor} editor
+ */
+function setupBrFilter(editor) {
+ editor.serializer.addNodeFilter('br', function(nodes) {
+ for (const node of nodes) {
+ if (node.parent && node.parent.name === 'code') {
+ const newline = new tinymce.html.Node.create('#text');
+ newline.value = '\n';
+ node.replace(newline);
+ }
+ }
+ });
+}
+
/**
* @param {WysiwygConfigOptions} options
* @return {function(Editor)}
window.editor = editor;
});
+ editor.on('PreInit', () => {
+ setupBrFilter(editor);
+ });
+
function editorChange() {
const content = editor.getContent();
if (options.darkMode) {
statusbar: false,
menubar: false,
paste_data_images: false,
- extended_valid_elements: 'pre[*],svg[*],div[drawio-diagram],details[*],summary[*],div[*],li[class]',
+ extended_valid_elements: 'pre[*],svg[*],div[drawio-diagram],details[*],summary[*],div[*],li[class|checked]',
automatic_uploads: false,
custom_elements: 'doc-root,code-block',
valid_children: [