feat(pdf): support TTS and annotation on PDFs, closes #2149 & #3462 (#3493)

* chore: bump jsdom to the latest version

* feat(pdf): support TTS and annotation on PDFs, closes #2149 & closes #3462
This commit is contained in:
Huang Xin
2026-03-09 17:28:19 +08:00
committed by GitHub
parent 93b96d64eb
commit 8850e6c00f
34 changed files with 841 additions and 252 deletions
@@ -27,7 +27,7 @@ export const useAnnotationEditor = ({
const { envConfig } = useEnv();
const { settings } = useSettingsStore();
const { getConfig, saveConfig, updateBooknotes } = useBookDataStore();
const { getView, getViewsById } = useReaderStore();
const { getView, getProgress, getViewsById } = useReaderStore();
const view = getView(bookKey);
const editingAnnotationRef = useRef(annotation);
@@ -144,14 +144,16 @@ export const useAnnotationEditor = ({
if (newCfi && newText) {
const config = getConfig(bookKey)!;
const progress = getProgress(bookKey)!;
const { booknotes: annotations = [] } = config;
const existingIndex = annotations.findIndex(
(a) => a.id === editingAnnotationRef.current.id && !a.deletedAt,
);
if (existingIndex !== -1) {
const existingAnnotation = annotations[existingIndex]!;
const updatedAnnotation: BookNote = {
...annotations[existingIndex]!,
...existingAnnotation,
cfi: newCfi,
text: newText,
updatedAt: Date.now(),
@@ -174,8 +176,9 @@ export const useAnnotationEditor = ({
annotated: true,
text: newText,
cfi: newCfi,
range: newRange,
index: targetIndex,
range: newRange,
page: existingAnnotation.page || progress.page,
});
}
}