UNPKG

@jirkasa/code-box

Version:

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

60 lines (59 loc) 2.18 kB
import CodeBox from "./CodeBox"; import CodeBoxFileManager from "./CodeBoxFileManager"; /** Represents file of code box. */ declare class CodeBoxFile<T extends CodeBox = CodeBox> { /** Identifier of file. */ protected identifier: string; /** Download link or null if file is not downloadable. */ protected downloadLink: string | null; /** Code box to which file belongs. */ protected codeBox: T | null; /** * Creates new code box file. * @param identifier Identifier. * @param downloadLink Download link or null if file should not be downloadable. * @param codeBox Code box to which file belongs. * @param manager Manager of code box file. */ constructor(identifier: string, downloadLink: string | null, codeBox: T, manager: CodeBoxFileManager); /** * Returns identifier of file. * @returns Identifier. */ getIdentifier(): string | null; /** * Changes identifier of file. * @param newIdentifier New identifier. * @returns Indicates whether change has been successfully completed (if passed new identifier already belongs to some other file in code box, it returns false). */ changeIdentifier(newIdentifier: string): boolean; /** * Removes file from code box. */ remove(): void; /** * Returns download link of file. * @returns Download link or null if file is not downloadable. */ getDownloadLink(): string | null; /** * Changes download link of file or sets it as non-downloadable. * @param downloadLink Download link (or null if file should not be downloadable). */ setDownloadLink(downloadLink: string | null): void; /** * Called by file manager when identifier should be changed. * @param newIdentifier New identifier. */ private onIdentifierChange; /** * Called by file manager when download link should be changed. * @param newDownloadLink New download link or null. */ private onDownloadLinkChange; /** * Called by file manager when file should be unlinked from code box. */ private onUnlinkCodeBox; } export default CodeBoxFile;