Fix: scroll to heading (and scroll to top) in rich text editor, Fixes #114#115
Open
bwat47 wants to merge 7 commits intocqroot:mainfrom
Open
Fix: scroll to heading (and scroll to top) in rich text editor, Fixes #114#115bwat47 wants to merge 7 commits intocqroot:mainfrom
bwat47 wants to merge 7 commits intocqroot:mainfrom
Conversation
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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):
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.