Skip to content

fix(gapcursor): don't offer gap cursor after comments and footnotes - #9626

Open
mejo- wants to merge 1 commit into
mainfrom
fix/footnote_gap_cursor
Open

mejo- wants to merge 1 commit into
mainfrom
fix/footnote_gap_cursor

Conversation

@mejo-

@mejo- mejo- commented Nov 16, 2026

Copy link
Copy Markdown
Member

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.

Assisted-by: ClaudeCode:claude-opus-5-5

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

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
@mejo- mejo- self-assigned this Nov 16, 2026
@mejo- mejo- added bug Something isn't working 3. to review labels Nov 16, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity team Nov 16, 2026
@mejo- mejo- moved this from 🧭 Planning evaluation (don't pick) to 👀 In review in 📝 Productivity team Nov 16, 2026
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Nov 16, 2026
@mejo-

mejo- commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

/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'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy moly. Gapcursor is loaded in the line before. Does the capital c make all the difference? 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@samin-z
samin-z requested review from samin-z and removed request for samin-z November 17, 2026 08:59
Comment on lines +119 to +120
const dir = selection.head < oldState.selection.head ? -1 : 1
return newState.tr.setSelection(Selection.near(selection.$head, dir))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 → TextSelection in doc > 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 body followed 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits backport-request bug Something isn't working

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

4 participants