Skip to content

Commit

Permalink
Merge pull request #6317 from nextcloud/backport/6316/stable28
Browse files Browse the repository at this point in the history
[stable28] fix(Table): Fix pasting content with newlines to table cells
  • Loading branch information
mejo- authored Sep 5, 2024
2 parents 258b112 + 2a5dcee commit 6702d1c
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 @@ -64,19 +64,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 6702d1c

Please sign in to comment.