Repository navigation
Conversation
The Document node sets `allowGapCursor: true` so that the gap cursor works between blocks, because its content match lists `footnotes` as the default type after the first block. The override also allowed a gap cursor at the top level after `comments` and `footnotes`, for example below the last footnote, where no paragraph can be inserted. Move such a gap cursor to the nearest text position. Prefer the direction the cursor was moving in, so arrow keys still move between comments and footnotes. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
|
/backport to stable35 |
| @@ -13,6 +13,8 @@ import { ListItem } from '@tiptap/extension-list' | |||
| import Placeholder from '@tiptap/extension-placeholder' | |||
| import Text from '@tiptap/extension-text' | |||
| import { CharacterCount, Dropcursor, Gapcursor } from '@tiptap/extensions' | |||
| import { GapCursor } from '@tiptap/pm/gapcursor' | |||
There was a problem hiding this comment.
Holy moly. Gapcursor is loaded in the line before. Does the capital c make all the difference? 😅
There was a problem hiding this comment.
Hehe, yes. One is the ProseMirror plugin GapCursor (tiptap/pm is a repackaged version of ProseMirror) and one is the Tiptap extension Gapcursor which builds on top of the ProseMirror plugin.
| const dir = selection.head < oldState.selection.head ? -1 : 1 | ||
| return newState.tr.setSelection(Selection.near(selection.$head, dir)) |
There was a problem hiding this comment.
With dir = -1 this moves the selection into comments, but the editor always renders that section hidden (section[data-type="comments"] { display: none; } in src/css/prosemirror.scss), and CommentReference.insertComment explicitly moves the cursor out of "the hidden comments container" for that reason. The new test is skipped between comments and footnotes asserts the selection lands in Comment.
Checked in Chrome with this change on stable35 (document: one paragraph with a comment and a footnote reference, one comment, one footnote; caret at the start of the footnote):
- ArrowLeft or ArrowUp →
TextSelectionindoc > comments > comment > commentItem > paragraph, no visible caret. Without this change the gap cursor between the sections is shown. - then Backspace → the whole comment thread is removed and the footnote text is merged into the body paragraph. Saved file:
Text with a comment[^comment-1] and a footnote[^1].Footnote bodyfollowed by an empty[^1]:. Without this change, ArrowLeft + Backspace only node-selects the hidden comments section. - then Enter instead → an empty paragraph is added inside the hidden comment.
Suggestion: never target comments; when the neighbour in direction dir is comments, continue before it (e.g. Selection.near(doc.resolve(<position before the comments node>), -1)) and adapt the test.
The Document node sets
allowGapCursor: trueso that the gap cursor works between blocks, because its content match listsfootnotesas the default type after the first block. The override also allowed a gap cursor at the top level aftercommentsandfootnotes, for example below the last footnote, where no paragraph can be inserted.Move such a gap cursor to the nearest text position. Prefer the direction the cursor was moving in, so arrow keys still move between comments and footnotes.
Assisted-by: ClaudeCode:claude-opus-5-5
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)🤖 AI (if applicable)