Skip to content

Commit

Permalink
fix: traverse through nodes in order to determine the correct copy-pa…
Browse files Browse the repository at this point in the history
…ste behavior

Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Mar 14, 2024
1 parent e61a6da commit 0ede1af
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/extensions/Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@ const Markdown = Extension.create({
return parser.parseSlice(dom, { preserveWhitespace: true, context: $context })
},
clipboardTextSerializer: (slice) => {
return createMarkdownSerializer(this.editor.schema).serialize(slice.content)
const traverseNodes = (slice) => {
if (slice.content.childCount > 1) {
return createMarkdownSerializer(this.editor.schema).serialize(slice.content)
} else if (slice.isLeaf) {
return slice.textContent
} else {
traverseNodes(slice.content.firstChild)
}
}

return traverseNodes(slice)
},
transformPastedHTML,
},
Expand Down

0 comments on commit 0ede1af

Please sign in to comment.