fix(BlockEditor): handle newline characters in inline nodes by inserting br elements
This commit is contained in:
@@ -38,7 +38,15 @@ export function inlineToDom(nodes, doc) {
|
|||||||
const fragment = d.createDocumentFragment();
|
const fragment = d.createDocumentFragment();
|
||||||
if (!Array.isArray(nodes) || nodes.length === 0) return fragment;
|
if (!Array.isArray(nodes) || nodes.length === 0) return fragment;
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
fragment.appendChild(buildNode(d, node));
|
if (node.text?.includes('\n')) {
|
||||||
|
const parts = node.text.split('\n');
|
||||||
|
for (let i = 0; i < parts.length; i++) {
|
||||||
|
if (parts[i]) fragment.appendChild(buildNode(d, { ...node, text: parts[i] }));
|
||||||
|
if (i < parts.length - 1) fragment.appendChild(d.createElement('br'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fragment.appendChild(buildNode(d, node));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user