diff --git a/packages/core/src/commands/cut.ts b/packages/core/src/commands/cut.ts index 2ee34fb67..e07247b64 100644 --- a/packages/core/src/commands/cut.ts +++ b/packages/core/src/commands/cut.ts @@ -19,7 +19,9 @@ export const cut: RawCommands['cut'] = (originRange, targetPos) => ({ editor }) return editor .chain() .deleteRange(originRange) - .insertContentAt(targetPos, contentSlice.content.toJSON()) + .command(({ commands, tr }) => { + return commands.insertContentAt(tr.mapping.map(targetPos), contentSlice.content.toJSON()) + }) .focus() .run() } diff --git a/packages/core/src/commands/insertContentAt.ts b/packages/core/src/commands/insertContentAt.ts index ba30035fc..68589c5a2 100644 --- a/packages/core/src/commands/insertContentAt.ts +++ b/packages/core/src/commands/insertContentAt.ts @@ -46,7 +46,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value, return true } - let { from, to } = typeof position === 'number' ? { from: tr.mapping.map(position), to: tr.mapping.map(position) } : { from: tr.mapping.map(position.from), to: tr.mapping.map(position.to) } + let { from, to } = typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to } let isOnlyTextContent = true let isOnlyBlockContent = true