fix storedMarks when using focus first, fix #94

This commit is contained in:
Philipp Kühn 2021-02-16 22:36:28 +01:00
parent 71d8fbbcb1
commit c51081f34e

View File

@ -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()
}