Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1350,11 +1350,15 @@ export function LoadedRichMarkdownEditor({
// load-bearing and runs on every settle even when the body is unchanged — setContent maps a
// pre-existing selection onto the new doc, so a prior select-all survives as "select everything",
// permanently painting every divider/image with the rich-leaf-in-selection decoration (keymap.ts)
// until the user clicks away. setTextSelection (not .focus()) never steals DOM focus.
// until the user clicks away. setTextSelection (not .focus()) never steals DOM focus. A caret is
// already collapsed: moving it to the end would only take away where the reader just clicked,
// since an editable editor can take a click before its first settle lands.
runOffRender(() => {
syncEditorContent(content)
pendingCollapseRef.current = false
editor.commands.setTextSelection(editor.state.doc.content.size)
if (!editor.state.selection.empty) {
editor.commands.setTextSelection(editor.state.doc.content.size)
}
editor.setEditable(effectiveCanEdit && settledVerdict && collabReady)
if (shouldFocus) editor.commands.focus('end')
})
Expand All @@ -1366,7 +1370,9 @@ export function LoadedRichMarkdownEditor({
// run bumped the token), so a post-stream select-all can't keep the leaf-in-selection decoration.
if (pendingCollapseRef.current) {
pendingCollapseRef.current = false
editor.commands.setTextSelection(editor.state.doc.content.size)
if (!editor.state.selection.empty) {
editor.commands.setTextSelection(editor.state.doc.content.size)
}
}
if (settled) editor.setEditable(effectiveCanEdit && settled.verdict && collabReady)
})
Expand Down
Loading