From c51081f34e1f03d20d43765144cafe6ed398d193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 16 Feb 2021 22:36:28 +0100 Subject: [PATCH] fix storedMarks when using focus first, fix #94 --- packages/core/src/commands/focus.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/src/commands/focus.ts b/packages/core/src/commands/focus.ts index 00c412f07..f1094729c 100644 --- a/packages/core/src/commands/focus.ts +++ b/packages/core/src/commands/focus.ts @@ -58,13 +58,19 @@ export const focus: RawCommands['focus'] = (position = null) => ({ } const { from, to } = resolveSelection(editor.state, position) || editor.state.selection - const { doc } = tr + const { doc, storedMarks } = tr const resolvedFrom = minMax(from, 0, doc.content.size) const resolvedEnd = minMax(to, 0, doc.content.size) const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd) + const isSameSelection = editor.state.selection.eq(selection) if (dispatch) { tr.setSelection(selection) + + if (isSameSelection && storedMarks) { + tr.setStoredMarks(storedMarks) + } + view.focus() }