Fix highlight not drawn with same cfi note

This commit is contained in:
chrox
2024-11-11 14:44:22 +01:00
parent 4e7dd9051b
commit 7a337f17c2
3 changed files with 7 additions and 5 deletions
@@ -160,7 +160,7 @@ const FoliateViewer: React.FC<{
const initAnnotations = () => {
const { booknotes = [] } = config;
const annotations = booknotes.filter((item) => item.type === 'annotation');
const annotations = booknotes.filter((item) => item.type === 'annotation' && item.style);
try {
Promise.all(annotations.map((annotation) => view?.addAnnotation(annotation)));
} catch (e) {
@@ -14,11 +14,11 @@ interface BooknoteItemProps {
const BooknoteItem: React.FC<BooknoteItemProps> = ({ bookKey, item, editable = false }) => {
const { envConfig } = useEnv();
const { settings, getProgress, getView } = useReaderStore();
const { getConfig, saveConfig, updateBooknotes, setNotebookEditAnnotation } = useReaderStore();
const { settings, getConfig, saveConfig, getProgress, getView } = useReaderStore();
const { updateBooknotes, setNotebookEditAnnotation, setNotebookVisible } = useReaderStore();
const [isCurrent, setIsCurrent] = useState(false);
const { text, cfi } = item;
const { text, cfi, note } = item;
const progress = getProgress(bookKey);
useEffect(() => {
@@ -32,6 +32,9 @@ const BooknoteItem: React.FC<BooknoteItemProps> = ({ bookKey, item, editable = f
const handleClickItem = (event: React.MouseEvent) => {
event.preventDefault();
getView(bookKey)?.goTo(cfi);
if (note) {
setNotebookVisible(true);
}
};
const deleteNote = (note: BookNote) => {
@@ -278,7 +278,6 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
}
const config = get().booksData[id]?.config as BookConfig;
const configViewSettings = config.viewSettings!;
console.log('Initializing book view settings', configViewSettings);
set((state) => ({
viewStates: {
...state.viewStates,