fix: preserve note id when changing style and preserve style when changing color, closes #252 (#436)

This commit is contained in:
Huang Xin
2025-02-23 15:32:57 +01:00
committed by GitHub
parent a9aa2fe7a4
commit 1d5b189185
2 changed files with 3 additions and 2 deletions
@@ -357,6 +357,7 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
if (existingIndex !== -1) {
views.forEach((view) => view?.addAnnotation(annotation, true));
if (update) {
annotation.id = annotations[existingIndex]!.id;
annotations[existingIndex] = annotation;
views.forEach((view) => view?.addAnnotation(annotation));
} else {
@@ -37,8 +37,8 @@ const HighlightOptions: React.FC<HighlightOptionsProps> = ({
onHandleHighlight(true);
};
const handleSelectColor = (color: HighlightColor) => {
const style = globalReadSettings.highlightStyle;
globalReadSettings.highlightStyles[style] = color;
globalReadSettings.highlightStyle = selectedStyle;
globalReadSettings.highlightStyles[selectedStyle] = color;
setSettings(settings);
setSelectedColor(color);
onHandleHighlight(true);