Hello! This is my first time posting here, so I’d like to express my gratitude to Marijn for the excellent work!
In my editor, I plan to include the text of a book synchronized with the playing audio. I’m seeking a method to mark each paragraph with {start, stop} positions on the audio track (outside of the editor). This will enable me to highlight the text segment corresponding to the current track position during audio playback.
Therefore, I have the following requirements:
- I need a way to mark text pieces in the editor. I’m considering using Marks for that purpose. Since I’m using Tiptap on top of Prosemirror, I tried this extension as example, and it works fine and seems adaptable for my case. However, there may be gaps (non-marked text) between marked text, which seems acceptable for my logic.
- I need a way to find and scroll to the marked position. For example, if I have a track position of 85 seconds, I should be able to search for a marked node with this position in its interval (for example, {start: 82.4, stop: 96.1}).
Now, my questions are:
- Is using marks the only and best way to achieve this?
- Is there a way to quickly find these marks? I assume I might need to preprocess the document into some data structure to obtain the necessary nodes faster?
Sorry, my questions may seem obvious, but it’s mostly for my ideas validation (maybe there are better ways). Please let me know if you have any suggestions or ideas to enhance this approach.
p.s. I’m using Tiptap