declare class Editor {
container: HTMLElement;
editable: boolean;
onInput: () => void;
textareas: Record;
lines: Record;
panel: HTMLDivElement;
instanceId: number;
static nextId: number;
constructor(container: HTMLElement, editable: boolean, onInput: () => void);
_build(): void;
updateLines(textarea: HTMLTextAreaElement, lines: HTMLElement): void;
getCode(): {
html: string;
css: string;
js: string;
};
setCode(code: {
html?: string;
css?: string;
js?: string;
}): void;
show(lang: string): void;
}
declare class Preview {
container: HTMLElement;
zoomLevel: number;
panel: HTMLDivElement;
iframe: HTMLIFrameElement;
instanceId: number;
static nextId: number;
network: boolean;
dialogs: boolean;
constructor(container: HTMLElement, network?: boolean, dialogs?: boolean);
_build(): void;
renderStatic(html: string, css: string): void;
private _buildCSP;
execCode({ html, css, js }: {
html: string;
css: string;
js: string;
}): void;
setZoom(level: number): void;
}
declare class Tabs {
container: HTMLElement;
editor: Editor;
preview: Preview;
onTabChange: (tab: string) => void;
bar: HTMLDivElement;
constructor(container: HTMLElement, editor: Editor, preview: Preview, onTabChange: (tab: string) => void);
_build(): void;
_switch(tab: string): void;
}
interface ToolbarOptions {
clickToLoad: boolean;
onRun: () => void;
onRerun: () => void;
onZoom: (level: number) => void;
}
declare class Toolbar {
container: HTMLElement;
clickToLoad: boolean;
onRun: () => void;
onRerun: () => void;
onZoom: (level: number) => void;
wrapper: HTMLDivElement | null;
footer: HTMLDivElement;
constructor(container: HTMLElement, { clickToLoad, onRun, onRerun, onZoom }: ToolbarOptions);
_build(): void;
setZoom(level: number): void;
_setZoom(scale: string): void;
}
type EditorTab = 'html' | 'css' | 'js';
interface DefaultTabConfig {
editor?: EditorTab | null;
preview?: boolean;
}
interface ExtractSourceItem {
selector: string | string[];
target?: string;
position?: 'replace' | 'before' | 'after' | 'prepend' | 'append';
}
interface ExtractSource {
html?: ExtractSourceItem[];
css?: ExtractSourceItem[];
js?: ExtractSourceItem[];
}
interface ExtractConfig {
source: ExtractSource;
}
interface PreviewConfig {
live?: boolean;
debounce?: number;
zoom?: number;
}
interface SecurityConfig {
network?: boolean;
dialogs?: boolean;
}
interface RunCodeOptions {
element?: string | HTMLElement;
theme?: string;
clickToLoad?: boolean;
editable?: boolean;
security?: SecurityConfig;
defaultTab?: string | DefaultTabConfig;
preview?: PreviewConfig;
code?: {
html?: string;
css?: string;
js?: string;
};
extract?: ExtractConfig;
}
declare class RunCode {
options: RunCodeOptions;
container: HTMLElement | null;
root: HTMLElement;
editor: Editor | null;
preview: Preview | null;
tabs: Tabs | null;
toolbar: Toolbar | null;
static instances: WeakMap;
static defineTheme(name: string, colors: Record, base?: string): void;
constructor(options?: RunCodeOptions);
init(): this;
_build(): void;
_execute(): void;
runCode(): void;
setCode(code: {
html?: string;
css?: string;
js?: string;
}): void;
private _readContent;
private _assembleItems;
private _runExtract;
_switchToTab(tab: string | DefaultTabConfig): void;
destroy(): void;
setTheme(theme: string): void;
}
export { RunCode as default };