UNPKG

@jirkasa/code-box

Version:

Showcase code samples on the web with a container that lets users select and display different samples.

79 lines (78 loc) 2.84 kB
import CodeView from "./CodeView"; import HighlightBoxManager from "./HighlightBoxManager"; import EventSourcePoint from "../utils/EventSourcePoint"; /** Represents highlight in code view. */ declare class HighlightBox { /** Highlight element. */ private readonly element; /** Code view to which the highlight belongs. */ private codeView; /** Event source that is used to fire event when remove method is called. */ private removeHighlightBoxEventSource; /** Start line of highlight. */ private start; /** End line of highlight. */ private end; /** Custom CSS classes applied to element of highlight box. */ private readonly customCssClasses; /** * Creates new highlight box. * @param container Element into which should be added highlight element. * @param start Start line of highlight. * @param end End line of highlight. * @param codeView Code view to which the highlight belongs. * @param removeHighlightBoxEventSource Event source to be used to fire event when remove method is called. * @param manager Manager of highlight box. */ constructor(container: HTMLElement, start: number, end: number, codeView: CodeView, removeHighlightBoxEventSource: EventSourcePoint<HighlightBox, HighlightBox>, manager: HighlightBoxManager); /** * Returns start line of highlight. * @returns Start line of highlight. */ getStart(): number; /** * Returns end line of highlight. * @returns End line of highlight. */ getEnd(): number; /** * Sets new range for highlight. * @param start Start line. * @param end End line. */ setRange(start: number, end?: number): void; /** * Adds custom CSS class to highlight element. * @param cssClass CSS class to be added to highlight element. */ addCustomCssClass(cssClass: string): void; /** * Removes custom CSS class from highlight element. * @param cssClass CSS class to be removed from highlight element. */ removeCustomCssClass(cssClass: string): void; /** * Checks if highlight element has custom CSS class. * @param cssClass CSS class to be checked. * @returns True if highlight element has custom CSS class, false otherwise. */ hasCustomCssClass(cssClass: string): boolean; /** * Returns all custom CSS classes applied to highlight element. * @returns All custom CSS classes applied to highlight element. */ getCustomCssClasses(): string[]; /** * Removes highlight. */ remove(): void; /** * Called by highlight box manager to detach highlight. */ private onDetach; /** * Called by highlight box manager to unlink code view. */ private onUnlinkCodeView; } export default HighlightBox;