Skip to content

Commit

Permalink
fix(core): fix cut and insertContentAt functions (#4187)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch committed Jul 7, 2023
1 parent c1d1854 commit 6b65af8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/commands/cut.ts
Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion packages/core/src/commands/insertContentAt.ts
Expand Up @@ -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
Expand Down

0 comments on commit 6b65af8

Please sign in to comment.