View Single Post
Old 12-10-2024, 01:10 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,789
Karma: 6000000
Join Date: Nov 2009
Device: many
How syncing works in general ... Take a character starting position in an html file, you can reverse walk back up the dom tree recording parent tag and child number in that parent tag (typically not counting text nodes) and generate what Sigil calls a WebPath or TagPath

This is a simplification of the epub CFI spec approach, just single file based not reliant on the OPF.

Then in you can give Preview that WebPath and run a javascript to scroll to that location.

You can of course run the process in reverse, by generating the WebPath in Preview using javascript and pass it to the editor to move to that location.

For the CodeView side of syncing see the routines starting here:

https://github.com/Sigil-Ebook/Sigil...itor.cpp#L2704



For the Preview side of things see the javascripts here:

https://github.com/Sigil-Ebook/Sigil...les/javascript



and the code to use them starting with this routine:

https://github.com/Sigil-Ebook/Sigil...eview.cpp#L419



and higher level support code starting here (see routine names with Caret in them):

https://github.com/Sigil-Ebook/Sigil...indow.cpp#L445

Last edited by KevinH; 12-10-2024 at 01:26 PM.
KevinH is online now   Reply With Quote