From 134a4bd1fbbd7f56faa1fc70c97d3b58554fc3f1 Mon Sep 17 00:00:00 2001 From: Dominik <6538827+bdbch@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:59:16 +0200 Subject: [PATCH] fix(core): dont use selection for setContent replacement (#2934) --- packages/core/src/commands/setContent.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/core/src/commands/setContent.ts b/packages/core/src/commands/setContent.ts index d21574777d4..2ee8bc8d997 100644 --- a/packages/core/src/commands/setContent.ts +++ b/packages/core/src/commands/setContent.ts @@ -1,5 +1,4 @@ import { ParseOptions } from 'prosemirror-model' -import { TextSelection } from 'prosemirror-state' import { createDocument } from '../helpers/createDocument' import { Content, RawCommands } from '../types' @@ -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) }