Skip to content

Commit

Permalink
Update highlightManager.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed May 6, 2024
1 parent 3ca8b34 commit 4a249fd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/app/content/components/Page/highlightManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import * as select from '../../selectors';
import { expandClosestSolution } from '../../utils/domUtils';
import attachHighlight from '../utils/attachHighlight';
import { erase, highlightData, insertPendingCardInOrder, isUnknownHighlightData, updateStyle } from './highlightUtils';
import { addToast } from '../../../notifications/actions';

export interface HighlightManagerServices {
getProp: () => HighlightProp;
setPendingHighlight: (highlight: Highlight) => void;
clearPendingHighlight: () => void;
highlighter: Highlighter;
container: HTMLElement;
}
Expand Down Expand Up @@ -94,6 +94,11 @@ const onSelectHighlight = (
highlight: Highlight | undefined
) => defer(async() => {
if (highlights.length > 0 || !highlight) {
appServices.dispatch(
addToast('overlapping highlights are not supported', {
destination: 'page',
})
);
return;
}

Expand All @@ -107,7 +112,7 @@ const onSelectHighlight = (
});

const createHighlighter = (
highlightManagerServices: Omit<HighlightManagerServices, 'highlighter' | 'intl'>,
highlightManagerServices: Omit<HighlightManagerServices, 'highlighter'>,
appServices: AppServices & MiddlewareAPI,
intl: IntlShape
) => {
Expand Down Expand Up @@ -152,7 +157,6 @@ export interface UpdateOptions {

// tslint:disable-next-line: max-line-length
export default (container: HTMLElement, getProp: () => HighlightProp, appServices: AppServices & MiddlewareAPI, intl: IntlShape) => {
let highlighter: Highlighter;
let pendingHighlight: Highlight | undefined;
let scrollTargetHighlightIdThatWasHandled: string;
let setListHighlighter = (_highlighter: Highlighter): void => undefined;
Expand Down Expand Up @@ -209,13 +213,12 @@ export default (container: HTMLElement, getProp: () => HighlightProp, appService
};

const highlightManagerServices = {
clearPendingHighlight,
container,
getProp,
setPendingHighlight,
};

highlighter = createHighlighter(highlightManagerServices, appServices, intl);
const highlighter = createHighlighter(highlightManagerServices, appServices, intl);
setListHighlighter(highlighter);

return {
Expand Down

0 comments on commit 4a249fd

Please sign in to comment.