Skip to content

Comments

Fix: scroll to heading (and scroll to top) in rich text editor, Fixes #114#115

Open
bwat47 wants to merge 7 commits intocqroot:mainfrom
bwat47:rte_scroll_fix
Open

Fix: scroll to heading (and scroll to top) in rich text editor, Fixes #114#115
bwat47 wants to merge 7 commits intocqroot:mainfrom
bwat47:rte_scroll_fix

Conversation

@bwat47
Copy link

@bwat47 bwat47 commented Jan 27, 2026

Note

This change was done with LLM assistance

refs:

https://discourse.joplinapp.org/t/a-markdown-outline-sidebar-plugin-for-joplin/13364/143?u=bwat47

#114

Issue:

Scrolling when clicking on headings (or the title of the outline panel) in the rich text editor isn't working in recent joplin versions. Instead of scrolling to the heading, it scrolls to the current cursor position in the editor.

  1. Switch to rich text editor
  2. Scroll down a bit and left click somewhere in document to place the cursor
  3. Scroll up to the top of the document
  4. Click a heading (that would be at a different position than your cursor position from step 2)
  5. It will then scroll to wherever you placed the cursor in step 2 (not to the clicked heading)

Fix:

Prevent race conditions or conflicts from multiple scroll commands being called back to back:

  • Only trigger scrollToLine if the markdown editor is active, otherwise use scrollToHash (which works with both markdown viewer and rich text editor), this fixes the scroll to heading behavior.

  • When clicking the outline panel title in the rich text editor, map 'rendered-md' to 'tinymce' (this is needed for scroll to top to work in the rich text editor)

Note

If the user has a heading titled just "rendered-md", clicking that heading in the rich text editor will scroll to the top. However, this is partially a pre-existing issue (and this is a really fringe scenario).

In the current version of the plugin, clicking a heading called "rendered-md" in the markdown viewer will scroll to the top, and in the rich text editor clicking a heading called "tinymce" will scroll to the top. The only difference with this change is that now "rendered-md" will also scroll to the top in the rich text editor.

Testing performed (desktop)

Tested scrolling to headings (and scroll to top by clicking the panel title):

  • With markdown editor only view
  • With markdown viewer only view
  • With markdown editor split view
  • With rich text editor

Note

On mobile there's a pre-existing issue where tapping a heading from the panel doesn't do anything: #98. These changes do not change the mobile behavior.

- Check if markdown editor and/or viewer is active and only trigger scrollToLine if the editor is active, so scrollToHash is only used when viewer or rich text editor is active, this fixes the scroll to heading.

- When clicking the outline panel title in the rich text editor, map 'rendered-md' to 'tinymce' (this is needed for scroll to top to work in the rich text editor)
don't run both commands when split view is active, just scroll editor which automatically scrolls viewer
noteVisiblePanes should always return an array
…tor path since they are the same command and the hash const already handles the only difference (rendered-md vs tinymce)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant