in src/plugin/fieldViews/ProseMirrorFieldView.ts [410:424]
private setupFocusHandler() {
this.fieldViewElement.addEventListener("focusin", () => {
if (!this.innerEditorView) {
return;
}
const { tr } = this.innerEditorView.state;
tr.setSelection(this.innerEditorView.state.selection);
// Setting a text selection seems to clear out our stored marks,
// so we must add them to the transaction explicitly.
tr.setStoredMarks(this.innerEditorView.state.storedMarks ?? []);
this.dispatchTransaction(tr);
});
}