From f3fe7283f80749072b5d374fc167a0e2ce52b3ee Mon Sep 17 00:00:00 2001 From: Hemachandar <132386067+hmacr@users.noreply.github.com> Date: Thu, 11 Sep 2025 02:18:29 +0530 Subject: [PATCH] fix: Allow pasting simple lists (#10150) --- app/editor/extensions/PasteHandler.tsx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/editor/extensions/PasteHandler.tsx b/app/editor/extensions/PasteHandler.tsx index be4ae63893..82f0f2d3d7 100644 --- a/app/editor/extensions/PasteHandler.tsx +++ b/app/editor/extensions/PasteHandler.tsx @@ -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 = () =>