Skip to content

Commit e937e17

Browse files
committed
highlight transient annotations, closes #29
1 parent 1480fb7 commit e937e17

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/seed-text-view.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { seedTextViewContext } from "./seed-context";
1010
import { addAppListener, SeedState } from "./redux/seed-store";
1111
import { initText, setText, TextState } from "./redux/textsSlice";
1212
import { initTextView, setText as setTextViewText, scrolledTo, fetchAnnotationsPerSegment } from "./redux/textViewsSlice";
13-
import { annotationSelected } from './redux/annotationsSlice';
13+
import { annotationSelected, annotationsPassedBy } from './redux/annotationsSlice';
1414
import { selectAnnotationsAtSegmentThunk, passByAnnotationsAtSegmentThunk } from "./redux/selectAnnotations";
1515
import { CSSDefinition } from './redux/cssTypes';
1616
import { scrolled, syncOthers } from './redux/synopsisSlice';
@@ -121,16 +121,34 @@ export class SeedTextView extends windowMixin(storeConsumerMixin(LitElement)) {
121121
this.store?.dispatch(addAppListener({
122122
actionCreator: annotationSelected,
123123
effect: (_action, listenerApi): void => {
124-
// reset highlightning of priviously selected annotation
124+
// reset highlighting of previously selected annotation
125125
if (this.annotationSelected) {
126126
this.colorizeAnnotation(listenerApi.getState(), this.annotationSelected, { "border": "none"});
127127
}
128128
// highlight currently selected annotation
129129
this.annotationSelected = listenerApi.getState().annotations.annotationSelected ?? "unknown";
130+
// TODO: make CSS configurable
130131
this.colorizeAnnotation(listenerApi.getState(), this.annotationSelected, { "border": "1px solid red"});
131132
}
132133
}));
133134

135+
this.store?.dispatch(addAppListener({
136+
actionCreator: annotationsPassedBy,
137+
effect: (_action, listenerApi): void => {
138+
// reset highlighting of previously transient annotations:
139+
// general annotation highlighting and transient
140+
// highlighting are bound to the same visual category,
141+
// so we can use the general highlighting for a reset
142+
this.colorizeText(listenerApi.getState().textViews[this.id].cssPerSegment);
143+
// highlight transient annotations
144+
const annotIds: Array<string> = listenerApi.getState().annotations.annotationsTransient;
145+
annotIds.forEach(annotId => {
146+
// TODO: make CSS configurable
147+
this.colorizeAnnotation(listenerApi.getState(), annotId, { "background-color": "silver"});
148+
});
149+
}
150+
}));
151+
134152
// this.storeUnsubscribeListeners.push(subsc);
135153
}
136154

0 commit comments

Comments
 (0)