]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/lexical/html/index.ts
Lexical: Source code input changes
[bookstack] / resources / js / wysiwyg / lexical / html / index.ts
index 5018e10b4f2c3c4ef75a4af7f8efcfd0abbd1378..de5e53bb8c489f8abd34e6dbea6e3c80314f05ce 100644 (file)
@@ -85,7 +85,18 @@ export function $generateHtmlFromNodes(
     $appendNodesToHTML(editor, topLevelNode, container, selection);
   }
 
-  return container.innerHTML;
+  const nodeCode = [];
+  for (const node of container.childNodes) {
+    if ("outerHTML" in node) {
+      nodeCode.push(node.outerHTML)
+    } else {
+      const wrap = document.createElement('div');
+      wrap.appendChild(node.cloneNode(true));
+      nodeCode.push(wrap.innerHTML);
+    }
+  }
+
+  return nodeCode.join('\n');
 }
 
 function $appendNodesToHTML(