fix clipboardTextSerializer for single lines

This commit is contained in:
Philipinho
2026-03-28 23:59:46 +00:00
parent cda7cc9a57
commit 8b4cc82e5a
@@ -20,6 +20,20 @@ export const MarkdownClipboard = Extension.create({
key: new PluginKey("markdownClipboard"), key: new PluginKey("markdownClipboard"),
props: { props: {
clipboardTextSerializer: (slice) => { clipboardTextSerializer: (slice) => {
const listTypes = ["bulletList", "orderedList", "taskList"];
let topLevelCount = 0;
let hasList = false;
slice.content.forEach((node) => {
if (listTypes.includes(node.type.name)) {
hasList = true;
topLevelCount += node.childCount;
} else {
topLevelCount++;
}
});
if (!hasList || topLevelCount < 2) return null;
const div = document.createElement("div"); const div = document.createElement("div");
const serializer = DOMSerializer.fromSchema(this.editor.schema); const serializer = DOMSerializer.fromSchema(this.editor.schema);
const fragment = serializer.serializeFragment(slice.content); const fragment = serializer.serializeFragment(slice.content);