forked from akai/readest
* chore: bump jsdom to the latest version * feat(pdf): support TTS and annotation on PDFs, closes #2149 & closes #3462
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user