UNPKG

word-marker

Version:

The library used to tag web page text, which can store tag information.

49 lines (48 loc) 1.32 kB
export type MarkData = { id: string; startEle?: Text; startEleId?: string; startOffset: number; startText: string; startBrother: string; startParentText?: string; endEle?: Text; endEleId?: string; endOffset: number; endText: string; endBrother: string; endParentText?: string; text: string; single: boolean; message: string; }; type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; export type MarkOptions = { scrollBy?: HTMLElement | Document; lazy?: boolean; attribute?: string; color?: string; globalAlpha?: number; zIndex?: number; data?: MarkData[]; tag?: (node: HTMLElement) => void; ignoreNode?: (node: ChildNode) => boolean; callback?: (data?: MarkData, range?: Range & { range: Range[]; }) => void; mark?: (ctx: CanvasRenderingContext2D, range: Range) => void; highlight?: (ctx: CanvasRenderingContext2D, range: Range) => void; }; export type Range = { x: number; y: number; width: number; height: number; }; export type Message = { id: string; range: Range[]; message: string; }; export type WordMarkOptions = RequiredBy<MarkOptions, 'scrollBy' | 'color' | 'globalAlpha' | 'data'>; export {};