-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acfdc68
commit 60b8be9
Showing
54 changed files
with
2,667 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import SerializedHighlight from './SerializedHighlight'; | ||
export interface IHighlightData { | ||
style?: string; | ||
id: string; | ||
content: string; | ||
} | ||
export interface IOptions { | ||
skipIDsBy?: RegExp; | ||
formatMessage: (descriptor: { | ||
id: string; | ||
}, values: { | ||
style: IHighlightData['style']; | ||
}) => string; | ||
tabbable?: boolean; | ||
} | ||
export default class Highlight { | ||
readonly id: string; | ||
readonly content: string; | ||
elements: HTMLElement[]; | ||
readonly range: Range; | ||
readonly options: IOptions; | ||
private data; | ||
private _elements; | ||
constructor(range: Range, data: Pick<IHighlightData, Exclude<keyof IHighlightData, 'id'>> & Partial<Pick<IHighlightData, 'id'>>, options: IOptions); | ||
getMessage(id: string): string; | ||
setStyle(style: string): void; | ||
getStyle(): string | undefined; | ||
removeStyle(): void; | ||
isAttached(): boolean; | ||
scrollTo(handler?: (elements: HTMLElement[]) => void): Highlight; | ||
updateStartMarker(el: Element, position: string): void; | ||
/** | ||
* Add class 'focus' to all elements of this highlight. | ||
*/ | ||
addFocusedStyles(): Highlight; | ||
/** | ||
* Move focus to the first element of this highlight. | ||
* @return boolean indicating if the action was a success. | ||
*/ | ||
focus(): boolean; | ||
intersects(range: Range): boolean; | ||
serialize(referenceElement?: HTMLElement): SerializedHighlight; | ||
private loadStyle; | ||
private checkReferenceElement; | ||
private getValidReferenceElement; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Highlight, { IHighlightData, IOptions as HighlightOptions } from './Highlight'; | ||
import SerializedHighlight from './SerializedHighlight'; | ||
export declare const ON_SELECT_DELAY = 300; | ||
interface IOptions { | ||
snapCode?: boolean; | ||
snapTableRows?: boolean; | ||
snapMathJax?: boolean; | ||
snapWords?: boolean; | ||
className?: string; | ||
skipIDsBy?: RegExp; | ||
formatMessage: (descriptor: { | ||
id: string; | ||
}, values: { | ||
style: IHighlightData['style']; | ||
}) => string; | ||
onClick?: (highlight: Highlight | undefined, event: MouseEvent) => void; | ||
onSelect?: (highlights: Highlight[], newHighlight?: Highlight) => void; | ||
onFocusIn?: (highlight: Highlight) => void; | ||
onFocusOut?: (highlight: Highlight) => void; | ||
tabbable?: boolean; | ||
} | ||
export default class Highlighter { | ||
readonly container: HTMLElement; | ||
private highlights; | ||
private options; | ||
private previousRange; | ||
private focusInHandler; | ||
private focusOutHandler; | ||
constructor(container: HTMLElement, options: IOptions); | ||
unmount(): void; | ||
eraseAll: () => void; | ||
teardown: () => void; | ||
erase: (highlight: Highlight) => void; | ||
highlight(highlight?: Highlight | SerializedHighlight): void; | ||
getHighlight(id: string): Highlight | undefined; | ||
getReferenceElement(id: string): HTMLElement | null; | ||
getHighlightFromElement(el: Element): Highlight | null | undefined; | ||
clearFocusedStyles(): void; | ||
getHighlights(): Highlight[]; | ||
getHighlightOptions(): HighlightOptions; | ||
getOrderedHighlights(): Highlight[]; | ||
getHighlightBefore(target: Highlight): Highlight | undefined; | ||
getHighlightAfter(target: Highlight): Highlight | undefined; | ||
readonly document: Document; | ||
private snapSelection; | ||
private debouncedSnapSelection; | ||
private debouncedOnSelect; | ||
private onSelectionChange; | ||
private onClickHandler; | ||
private onFocusHandler; | ||
private onClick; | ||
private onSelect; | ||
private compareRanges; | ||
} | ||
export {}; |
Oops, something went wrong.