UNPKG

@jirkasa/code-box

Version:

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

53 lines (52 loc) 2.15 kB
import CodeViewMemento from "../code-view/CodeViewMemento"; import CodeView from "../code-view/CodeView"; import CodeBox from "./CodeBox"; /** Code view entry for code box memento. */ export type CodeViewMementoEntry = { /** Code view. */ codeView: CodeView; /** Identifier. */ identifier: string; /** Code view memento. */ codeViewMemento: CodeViewMemento; }; /** File entry for code box memento. */ export type FileMementoEntry = { /** Download link or null. */ downloadLink: string | null; /** Identifier. */ identifier: string; }; /** Represents saved state of code box. */ declare class CodeBoxMemento { /** Code box based on which memento was created. */ private creator; /** Code view entries (code views in code box when memento was created). */ private codeViewEntries; /** File entries (files in code box when memento was created). */ private fileEntries; /** Stores reference to code view that was active when memento was created. */ private activeCodeView; /** Function to add code view without making copy to code box based on which the memento was created. */ private addCodeViewToCreatorCodeBox; /** * Creates new code box memento. * @param creator Code box based on which the memento is created. * @param addCodeViewToCreatorCodeBox Function to add code view without making copy to code box based on which the memento was created. * @param codeViewEntries Code view entries. * @param fileEntries File entries. * @param activeCodeView Active code view. */ constructor(creator: CodeBox, addCodeViewToCreatorCodeBox: (identifier: string, codeView: CodeView) => void, codeViewEntries: CodeViewMementoEntry[], fileEntries: FileMementoEntry[], activeCodeView: CodeView | null); /** * Returns code box, based on which the memento was created. * @returns Code box based on which the memento was created. */ protected getCreator(): CodeBox; /** * Applies memento to code box. * @param codeBox Code box. */ apply(codeBox: CodeBox): void; } export default CodeBoxMemento;