From 770f546a38d7ec827bff55fd0dd64b873a112180 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 2 Nov 2022 13:06:48 -0400 Subject: fro --- src/client/views/nodes/formattedText/FormattedTextBox.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index ee97e5e62..e9f59f17d 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -1399,11 +1399,13 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent selectOnLoad && this._editorView!.focus(), 0); - else selectOnLoad && this._editorView!.focus(); - FormattedTextBox.DontSelectInitialText = false; + selectOnLoad && this._editorView!.focus(); // add user mark for any first character that was typed since the user mark that gets set in KeyPress won't have been called yet. if (this._editorView) { + const tr = this._editorView.state.tr; + const { from, to } = tr.selection; + // for some reason, the selection is sometimes lost in the sidebar view when prosemirror syncs the seledtion with the dom, so reset the selectoin after the document has ben fully instantiated. + if (FormattedTextBox.DontSelectInitialText) setTimeout(() => this._editorView?.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(from), tr.doc.resolve(to)))), 250); this._editorView.state.storedMarks = [ ...(this._editorView.state.storedMarks ?? []), ...(!this._editorView.state.storedMarks?.some(mark => mark.type === schema.marks.user_mark) ? [schema.marks.user_mark.create({ userid: Doc.CurrentUserEmail, modified: Math.floor(Date.now() / 1000) })] : []), @@ -1415,6 +1417,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent