gsantner / markor

Text editor - Notes & ToDo (for Android) - Markdown, todo.txt, plaintext, math, ..
https://github.com/gsantner/markor/discussions/2269
Other
3.68k stars 358 forks source link

Markdown scroll sync between preview and src #2373

Open guanglinn opened 1 month ago

guanglinn commented 1 month ago

⚠️ This issue respects the following points: ⚠️

Description

This is a feature request.
Hope Markor supports scroll synchronization between markdown preview in view-mode and its source code in edit-mode.

Information

Android version: Android 12 Device: Huawei Nova 8 App Version: 2.12.5 (code 154)

Source

GitHub Releases

Format / File type

Markdown

Additional info / Log

-
gsantner commented 1 month ago

2189 #679 #1070

guanglinn commented 1 month ago

I am sorry for not noticing those closed issues.

guanglinn commented 1 month ago

This is an advanced feature for Markor, but I noticed that Visual Studio Code does well in Markdown scroll sync, the code of this feature is here vscode/extensions/markdown-language-features/preview-src/scroll-sync.ts, and the related issue from VSCode Support to scroll markdown preview with source scrolling.

It may be a very valuable reference for us to analyze its principle and implementation. @gsantner @harshad1

https://github.com/user-attachments/assets/0303b233-d950-497d-a9e9-fbce537cdfe9/

harshad1 commented 1 month ago

To this end every node in the markdown html now has a line=# attribute. This should be sufficient to jump when going back and forth if handled well, I think

gsantner commented 1 month ago

Unfortunatley it's though markdown specific and next up people cry out when it is ""broken/unavailable/not works"" for other formats. It's not generic solveable in easy way

guanglinn commented 1 month ago

I think it is feasible on Markor to a certain extent, maybe we can try to implement it on Markdown first.

If we master the implementation of the feature principle in code and it works well, then it could be easily implemented for other formats.