UNPKG

@jirkasa/code-box

Version:

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

80 lines (79 loc) 4.33 kB
import CodeView from "../../code-view/CodeView"; import TreeNode from "../../utils/TreeNode"; import CodeBox from "../CodeBox"; import CodeBoxMemento, { CodeViewMementoEntry, FileMementoEntry } from "../CodeBoxMemento"; import FolderInfo from "./FolderInfo"; import PackageInfo from "./PackageInfo"; import ProjectCodeBox from "./ProjectCodeBox"; /** Code view entry for project code box memento. */ export type ProjectCodeBoxCodeViewMementoEntry = { /** Package name (null for default package and undefined for no package). */ package: string | null | undefined; } & CodeViewMementoEntry; /** File entry for project code box memento. */ export type ProjectCodeBoxFileMementoEntry = { /** Package name (null for default package and undefined for no package). */ package: string | null | undefined; } & FileMementoEntry; /** Represents saved state of project code box. */ declare class ProjectCodeBoxMemento extends CodeBoxMemento { /** Code view entries (code views in code box when memento was created). */ private projectCodeBoxCodeViewEntries; /** File entries (files in code box when memento was created). */ private projectCodeBoxFileEntries; /** Folder structure of code box when memento was created. */ private folderStructure; /** Packages of code box when memento was created. */ private packages; /** Project name of code box when memento was created. */ private projectName; /** Indicates whether panel was opened when memento was created. */ private isPanelOpened; /** Folder path for packages when memento was created. */ private packagesFolderPath; /** Indicates whether root folder was opened when memento was created. */ private isRootFolderOpened; /** * Creates new project 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. * @param folderStructure Folder structure. * @param packages Packages. * @param packagesFolderPath Folder path for packages. * @param projectName Project name. * @param isPanelOpened Indicates whether panel is opened. * @param isRootFolderOpened Indicates whether root folder is oepened. */ constructor(creator: ProjectCodeBox, addCodeViewToCreatorCodeBox: (identifier: string, codeView: CodeView) => void, codeViewEntries: ProjectCodeBoxCodeViewMementoEntry[], fileEntries: ProjectCodeBoxFileMementoEntry[], activeCodeView: CodeView | null, folderStructure: TreeNode<FolderInfo>[], packages: PackageInfo[], packagesFolderPath: string, projectName: string, isPanelOpened: boolean, isRootFolderOpened: boolean); apply(codeBox: CodeBox): void; /** * This method can be called after code box is prepared to inherit from its parent code box. (These things are not inherited: open/close state of panel, open/close state of folders and packages, highlights of code views. Folder path for packages is also not changed. Packages of overwritten code views and files are not changed unless new package is explicitely assigned.) * @param codeBox Code box. */ applyToInherit(codeBox: ProjectCodeBox): void; /** * Returns code view height based on passed identifier if code view is stored in memento. * @param identifier Identifier of code view. * @param minLinesCount Minimum number of lines. * @returns Height. */ getCodeViewHeightByIdentifier(identifier: string, minLinesCount: number | null): string | null; /** * Helper method to create folders in code box. * @param codeBox Code box. * @param node Node with folder info. * @param parentFolderNames Parent folder names (used internally). * @param openFolders Determines whether folders that should be open should be opened. */ private createFolders; /** * Helper method to create package in code box. * @param codeBox Code box. * @param openPackages Determines whether packages that should be open should be opened. */ private createPackages; } export default ProjectCodeBoxMemento;