fix(kosync): use 1-based indices in xpointer, closes #1968 (#1973)

This commit is contained in:
Huang Xin
2025-09-06 13:40:32 +08:00
committed by GitHub
parent d0264de3eb
commit dfe68988aa
4 changed files with 31 additions and 31 deletions
@@ -96,12 +96,8 @@ export const useKOSync = (bookKey: string) => {
if (!remote.progress?.startsWith('/body')) return;
try {
const content = view?.renderer.getContents()[0];
const cfi = await getCFIFromXPointer(
remote.progress!,
content?.doc,
content?.index,
bookDoc,
);
const koProgress = normalizeProgressXPointer(remote.progress);
const cfi = await getCFIFromXPointer(koProgress, content?.doc, content?.index, bookDoc);
view?.goTo(cfi);
} catch (error) {
console.error('Failed to convert XPointer to CFI', error);
@@ -242,6 +238,7 @@ export const useKOSync = (bookKey: string) => {
const handlePushProgress = (event: CustomEvent) => {
if (event.detail.bookKey !== bookKey) return;
pushProgress();
pushProgress.flush();
};
const handleFlush = (event: CustomEvent) => {
if (event.detail.bookKey !== bookKey) return;