fix: Allow pasting simple lists (#10150)

This commit is contained in:
Hemachandar
2025-09-11 02:18:29 +05:30
committed by GitHub
parent 839bf5cb91
commit f3fe7283f8
+15 -10
View File
@@ -459,6 +459,7 @@ export default class PasteHandler extends Extension {
const { view, schema } = this.editor;
const { state } = view;
const { from } = state.selection;
let tr = state.tr;
const links: string[] = [];
let allLinks = true;
@@ -480,22 +481,26 @@ export default class PasteHandler extends Extension {
return false;
});
if (!allLinks || !links.length) {
return;
}
const showPasteMenu = allLinks && links.length;
const placeholderId = links[0];
const to = from + listNode.nodeSize;
// it's possible that the links can be converted to mentions
if (showPasteMenu) {
const placeholderId = links[0];
const to = from + listNode.nodeSize;
const transaction = state.tr
.replaceSelectionWith(listNode)
.setMeta(this.key, {
tr = state.tr.replaceSelectionWith(listNode).setMeta(this.key, {
add: { from, to, id: placeholderId },
});
} else {
// Paste as simple list
tr = tr.replaceSelectionWith(listNode, this.shiftKey);
}
view.dispatch(transaction);
view.dispatch(tr);
this.showPasteMenu(links);
if (showPasteMenu) {
this.showPasteMenu(links);
}
}
private placeholderId = () =>