mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-25 04:19:02 +08:00
use tr.replaceRangeWith instead of tr.insert for insertContent command
This commit is contained in:
parent
e2756aab5f
commit
12b6f0e4f7
@ -20,15 +20,11 @@ declare module '@tiptap/core' {
|
||||
|
||||
export const insertContentAt: RawCommands['insertContentAt'] = (range, value) => ({ tr, dispatch, editor }) => {
|
||||
if (dispatch) {
|
||||
if (range.from !== range.to) {
|
||||
tr.deleteRange(range.from, range.to)
|
||||
}
|
||||
|
||||
const content = createNodeFromContent(value, editor.schema)
|
||||
|
||||
tr.insert(range.from, content)
|
||||
selectionToInsertionEnd(tr, tr.steps.length - 1, -1)
|
||||
tr.scrollIntoView()
|
||||
// @ts-ignore
|
||||
tr.replaceRangeWith(range.from, range.to, content)
|
||||
selectionToInsertionEnd(tr, tr.steps.length - 1, 1)
|
||||
}
|
||||
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user