Skip to content

Commit

Permalink
fix(core): dont use selection for setContent replacement (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch authored Jul 6, 2022
1 parent 8bc3986 commit 134a4bd
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/core/src/commands/setContent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ParseOptions } from 'prosemirror-model'
import { TextSelection } from 'prosemirror-state'

import { createDocument } from '../helpers/createDocument'
import { Content, RawCommands } from '../types'
Expand All @@ -22,11 +21,9 @@ declare module '@tiptap/core' {
export const setContent: RawCommands['setContent'] = (content, emitUpdate = false, parseOptions = {}) => ({ tr, editor, dispatch }) => {
const { doc } = tr
const document = createDocument(content, editor.schema, parseOptions)
const selection = TextSelection.create(doc, 0, doc.content.size)

if (dispatch) {
tr.setSelection(selection)
.replaceSelectionWith(document, false)
tr.replaceWith(0, doc.content.size, document)
.setMeta('preventUpdate', !emitUpdate)
}

Expand Down

0 comments on commit 134a4bd

Please sign in to comment.