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