interface InstanceConfig$1 { /** * Whether or not the toolbar + code embed should be wrapped *together* in wrapper, or just have toolbar and code elem be sibling * @default true */ wrapCombo: boolean; /** * The style of icon to use for the toolbar. * For choices other than `emoji` or `plaintext`, you must have the font pack installed. * @default 'emoji' */ iconStyle: 'emoji' | 'plaintext' | 'material' | 'fontawesome'; /** * Use if you have code blocks that are not getting picked up by the Prism highlighter, because they don't adhere to the standard. * - For example, `autoFix` can turn Pandoc output of `
` into the correct standard of `
`, and then re-highlight it with Prism. * @default false */ autoFix: boolean; /** * Use CSS animations * @default true */ animate: boolean; /** * Use linewrap - e.g. white-space: pre-wrap */ lineWrap: boolean; /** * If set to a URL string that returns text, it will be loaded into the embed * @default false */ remoteSrc: boolean | string; } interface GlobalConfig$1 extends InstanceConfig$1 { /** * CSS selector used to find code elements to inject toolbar into. * - Used for .autoInit() * @default 'pre > code[class*="language-"]' */ selector?: string; /** * Alternative to `selector` (and overrides it) */ targetElements?: NodeListOf | HTMLElement; /** * Extra logging * @default false */ debug: boolean; } interface ToolbarInstance$1 { container: HTMLElement; codeElem: HTMLPreElement | HTMLElement; toolbarElem: HTMLDivElement; collapsed: boolean; copyButton: HTMLElement | HTMLDivElement | HTMLButtonElement; clipboardInitialized: boolean; ClipboardJSInstance?: ClipboardJS; eventsAttached: boolean; config: InstanceConfig$1; isMaximized: boolean; fullscreenWrapper?: HTMLDivElement; /** * Internal use - unique ID */ id: string; } declare class ClipboardJS { constructor(input: string | HTMLElement | NodeListOf, config?: { container?: HTMLElement; }); on(eventType: 'success' | 'error', callback: (event: Event) => void): void; destroy(): void; } declare global { interface Window { PrismToolbar: typeof PrismToolbar; } } declare namespace IconMap { export namespace _break { const emoji: string; const material: string; const fa: string; } export { _break as break }; export namespace copy { const emoji_1: string; export { emoji_1 as emoji }; const material_1: string; export { material_1 as material }; const fa_1: string; export { fa_1 as fa }; } export namespace max { const emoji_2: string; export { emoji_2 as emoji }; const material_2: string; export { material_2 as material }; const fa_2: string; export { fa_2 as fa }; } } /** * @typedef {import('./types').InstanceConfig} Config * @typedef {keyof typeof IconMap} ButtonType */ declare class JPrismToolbarUI { /** * @param {Config} config */ constructor(config: Config); config: InstanceConfig$1; /** * If neither Material or FontAwesome is to be used, * fallback to a plain button type * @param {ButtonType} buttonType * @param {Config} [config] */ getFallbackButtonCode(buttonType: ButtonType, config?: InstanceConfig$1 | undefined): string; /** * @param {ButtonType} buttonType * @param {Config} [config] */ getButtonCode(buttonType: ButtonType, config?: InstanceConfig$1 | undefined): string; /** * @param {ButtonType} buttonType * @param {boolean} isMaterial */ getThirdPartyIconCode(buttonType: ButtonType, isMaterial: boolean): string; /** * Main function to get entire injectable toolbar HTML * @param {Config} [config] */ getToolbarHtml(config?: InstanceConfig$1 | undefined): string; getToolbarCss(): string; } type Config = InstanceConfig$1; type ButtonType = keyof typeof IconMap; declare class PrismToolbar { /** @param {Partial | string} [inputSettings] */ constructor(inputSettings?: string | Partial | undefined); /** * Public Members */ debug: boolean; /** @type {ToolbarInstance[]} */ domInstances: ToolbarInstance[]; /** @type {HTMLElement[]} */ targetElementsArr: HTMLElement[]; /** @type {string | undefined} */ selector: string | undefined; /** @type {GlobalConfig} */ settings: GlobalConfig; uiController: JPrismToolbarUI; getNewInstanceId(): string; /** * Main initialization function * - Uses inputs from constructor arguments / settings */ init(): Promise; /** * Attempts to run initialization for elements matching selector * @param {string} [OPT_autoSelector] */ autoInit(OPT_autoSelector?: string | undefined): Promise; /** * Tries to auto init all code blocks, based on element types */ autoInitAll(): Promise; /** * @param {HTMLElement} elem */ initOnElem(elem: HTMLElement): Promise; initClipboardJS(): void; /** * Force jPrismToolbar to evaluate inputs to determine which elements to target for adding the toolbar to */ populateListOfTargets(): void; /** * * @param {HTMLElement} element * @returns {InstanceConfig} */ getPerInstanceConfig(element: HTMLElement): InstanceConfig; /** * Fix code blocks that are not properly setup to be formatted by Prism * @param {HTMLElement} elem */ autoFix(elem: HTMLElement): boolean; /** * @param {ToolbarInstance} instance */ toggleCollapsed(instance: ToolbarInstance): void; /** * * @param {ToolbarInstance} instance * @param {MouseEvent} evt */ copyCode(instance: ToolbarInstance, evt: MouseEvent): void; getHasClipboardJS(): boolean; /** * * @param {ToolbarInstance} instance */ toggleMaximize(instance: ToolbarInstance): void; /** * @param {ToolbarInstance} instance */ toggleLineWrap(instance: ToolbarInstance): void; /** * @param {HTMLButtonElement | HTMLElement} buttonElement */ animateButtonClick: (buttonElement: HTMLButtonElement | HTMLElement) => void; /** * Attaches event listeners to all instances that need them set up. */ attachEventListeners(): void; /** * Iterates over all PrismToolbar "Instances" and passes an object representation of the instance to the callback * @param {(instance: ToolbarInstance) => void} callback - the function that will receive the instance */ iterator(callback: (instance: ToolbarInstance) => void): void; /** * Flash a temporary message in the toolbar UI * @param {ToolbarInstance} instance * @param {string} message * @param {number} [OPT_delay] */ showMessage(instance: ToolbarInstance, message: string, OPT_delay?: number | undefined): void; /** * Parse a remote code URL and load, if possible * @param {ToolbarInstance} instance * @param {string} src */ loadRemoteCode(instance: ToolbarInstance, src: string): Promise; /** * Fetch a URL that returns raw code, and display the code in an instance * @param {ToolbarInstance} instance * @param {string} codeSrc Where the raw code text can be fetched from * @param {string} [userLink] Where the user should be taken to if they want to view the original source code in Github / VC */ fetchAndLoadIntoInstance(instance: ToolbarInstance, codeSrc: string, userLink?: string | undefined): Promise<{ success: boolean; response: Response | null; rawRemoteCode: string; }>; /** * Display a remote code URL notice in the toolbar * - Set url to null to hide * @param {ToolbarInstance} instance * @param {string | null} url * @param {string} [linkText] */ setRemoteSrcDisplay(instance: ToolbarInstance, url: string | null, linkText?: string | undefined): void; /** * * @param {ToolbarInstance} instance * @param {string} content * @param {boolean} [OPT_reHighlight] * @param {boolean} [OPT_forceIntoCodeEleme] */ setInnerContent(instance: ToolbarInstance, content: string, OPT_reHighlight?: boolean | undefined, OPT_forceIntoCodeEleme?: boolean | undefined): void; /** * Attempt to highlight (or re-highlight) code syntax with Prism * @param {ToolbarInstance | HTMLElement | Element} instanceOrElem */ highlight(instanceOrElem: ToolbarInstance | HTMLElement | Element): void; #private; } type InstanceConfig = InstanceConfig$1; type GlobalConfig = GlobalConfig$1; type ToolbarInstance = ToolbarInstance$1; export default PrismToolbar; export { GlobalConfig, InstanceConfig, PrismToolbar, ToolbarInstance };