Skip to content

Commit

Permalink
fix(Table): Fix pasting content with newlines to table cells
Browse files Browse the repository at this point in the history
Fixes: #5737

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Sep 4, 2024
1 parent 2361f85 commit d551773
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/nodes/Table/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand Down

0 comments on commit d551773

Please sign in to comment.