mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 23:15:15 +08:00
fix storedMarks when using focus first, fix #94
This commit is contained in:
parent
71d8fbbcb1
commit
c51081f34e
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user