fix storedMarks when using focus first, fix #94
This commit is contained in:
@@ -58,13 +58,19 @@ export const focus: RawCommands['focus'] = (position = null) => ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { from, to } = resolveSelection(editor.state, position) || editor.state.selection
|
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 resolvedFrom = minMax(from, 0, doc.content.size)
|
||||||
const resolvedEnd = minMax(to, 0, doc.content.size)
|
const resolvedEnd = minMax(to, 0, doc.content.size)
|
||||||
const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
||||||
|
const isSameSelection = editor.state.selection.eq(selection)
|
||||||
|
|
||||||
if (dispatch) {
|
if (dispatch) {
|
||||||
tr.setSelection(selection)
|
tr.setSelection(selection)
|
||||||
|
|
||||||
|
if (isSameSelection && storedMarks) {
|
||||||
|
tr.setStoredMarks(storedMarks)
|
||||||
|
}
|
||||||
|
|
||||||
view.focus()
|
view.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user