/** * LightCode is a minimal wrapper around Prism for displaying code highlighting * * @customElement * @tagname light-code * * @csspart base - The base wrapping element * @csspart pre - The
element wrapping the source code
* @csspart code - The element wrapping the source code
* @csspart gutter - The gutter for line numbers. This is only for the overlay for when the lines dont correspond to size of the code.
* @csspart gutter-cell - The element that holds line numbers.
* @slot default - The code to use for highlighting
*/
export default class LightCode extends BaseElement {
/**
* @override
*/
static override styles: import("lit").CSSResult[];
/**
* @override
*/
static override properties: {
disableHighlight: {
type: BooleanConstructor;
attribute: string;
};
preserveWhitespace: {
type: BooleanConstructor;
attribute: string;
};
highlightLines: {
attribute: string;
};
insertedLines: {
attribute: string;
};
deletedLines: {
attribute: string;
};
disableLineNumbers: {
type: BooleanConstructor;
reflect: boolean;
attribute: string;
};
lineNumberStart: {
type: NumberConstructor;
attribute: string;
};
wrap: {
reflect: boolean;
attribute: string;
};
language: {};
code: {};
highlighter: {
attribute: boolean;
state: boolean;
};
__highlightedCode__: {
attribute: boolean;
state: boolean;
};
};
/**
* The language to highlight for.
* @type {string}
*/
language: string;
/**
* If disabled, its on you to provide `
`
* @type {boolean}
*/
disableHighlight: boolean;
/**
* We will take the code, wrap it in `
` and run it through
* PrismJS.
* If the element has `disableHighlight`, we will not touch their code. Instead they must pass in escapedHTML.
* @type {string}
*/
code: string;
/**
* @internal
* @type {MutationObserverInit}
*/
__mutationObserverConfig: MutationObserverInit;
/**
* @internal
* @type {() => void}
*/
codeDebounce: () => void;
/**
* @property
* @type {"soft" | "hard"}
* If `wrap="soft"`, lines will wrap when they reach the edge of their container. If `wrap="hard"`, lines will not wrap instead all the user to scroll horizontally to see more code.
*/
wrap: "soft" | "hard";
/**
* @property
* @type {Boolean}
* Whether or not to preserve white spaces from templates and attempt to dedent and chomp new lines.
*/
preserveWhitespace: boolean;
/**
* @type {string} - A string of possible lines to highlight. Example: "{1-9, 16, 18}"
*/
highlightLines: string;
/**
* @type {string} - A string of lines that are inserted for diffs. Example: "{1-9, 16, 18}"
*/
insertedLines: string;
/**
* @type {string} - A string of lines that are deleted for diffs. Example: "{1-9, 16, 18}"
*/
deletedLines: string;
/**
* @type {boolean} whether or not to disable line numbers
*/
disableLineNumbers: boolean;
/**
* Where to start counting from indexes. Note, this is only for display purposes in the gutter.
* @type {number}
*/
lineNumberStart: number;
/**
* Highlighter to use for highlighting code. Default is Prism.
*/
highlighter: import("prism-esm").Prism;
__resizeObserver: ResizeObserver;
newLineRegex: RegExp;
__highlightedCode__: string;
/**
* @override
* @param {import("lit").PropertyValues} changedProperties
*/
override willUpdate(changedProperties: import("lit").PropertyValues): void;
/**
* @override
* @param {import("lit").PropertyValues} changedProperties
*/
override updated(changedProperties: import("lit").PropertyValues): void;
/**
* @internal
* @param {"preview-code" | "code"} variable
*/
handleMutation(variable: "preview-code" | "code"): void;
/**
* @internal
* @param {string} name
* @returns {HTMLSlotElement | null | undefined}
*/
findSlot(name: string): HTMLSlotElement | null | undefined;
/**
* @internal
* @param {Event | { target?: undefined | null | HTMLSlotElement }} e
*/
handleTemplate(e: Event | {
target?: undefined | null | HTMLSlotElement;
}): void;
/**
* Only used to unescape things like `</script>` from slotted content.
* @internal
* @param {string} text
*/
unescapeTags(text: string): string;
/**
* @public
* Override this function to use your own highlight function
*/
public highlight(code?: string): string;
/**
* @internal
*/
__setGutterMeasurements(): void;
/**
* @override
*/
override render(): import("lit").TemplateResult<1>;
}
import { BaseElement } from "../../../internal/base-element.js";