From d55177315f0fc4ecd4525e17fb1899b21b4ef681 Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 4 Sep 2024 18:56:27 +0200 Subject: [PATCH] fix(Table): Fix pasting content with newlines to table cells Fixes: #5737 Signed-off-by: Jonas --- src/nodes/Table/TableCell.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/nodes/Table/TableCell.js b/src/nodes/Table/TableCell.js index 1fb82baaf27..69666465e11 100644 --- a/src/nodes/Table/TableCell.js +++ b/src/nodes/Table/TableCell.js @@ -69,19 +69,17 @@ export default TableCell.extend({ } const { state } = view + const { schema } = state const childNodes = [] - let newLineAdded = false slice.content.descendants((node, pos) => { if (node.isText) { - childNodes.push(state.schema.text(node.textContent, node.marks)) - newLineAdded = false - } else if (!newLineAdded) { - childNodes.push(state.schema.text('\n')) - newLineAdded = true + childNodes.push(schema.text(node.textContent, node.marks)) + } else if (childNodes.length !== 0 && node.type === schema.nodes.hardBreak) { + childNodes.push(node) } }) - const newNode = state.schema.node('paragraph', [], childNodes) + const newNode = schema.node('paragraph', [], childNodes) slice.content = Fragment.empty.addToStart(newNode) }, },