UNPKG

@launchmenu/applet-notes

Version:
163 lines 5.75 kB
import { File, FileAutoReloader, FileAutoSaver } from "@launchmenu/core"; import { DataCacher, IDataHook, IDataRetriever } from "model-react"; import { NoteCategory } from "./NoteCategory"; import { NotesSource } from "./NotesSource"; import { INoteMetadata } from "./_types/INoteMetadata"; import { IInherit } from "./_types/IInherit"; import { IHighlightLanguage } from "./_types/IHighlightLanguage"; export declare class Note { readonly ID: string; protected dataSource: IDataRetriever<INoteMetadata>; protected update: (ID: string, data?: INoteMetadata) => void; protected notesSource: NotesSource; protected file: DataCacher<{ file: File; fileSaver: FileAutoSaver; fileReloader: FileAutoReloader; } | undefined>; /** * Creates a new note instance * @param ID The ID of the note * @param dataSource The data source of the note * @param update A function to update the note's data * @param categoriesSource All categories in the system, including ones not assigned to this note */ constructor(ID: string, dataSource: IDataRetriever<INoteMetadata>, update: (ID: string, data?: INoteMetadata) => void, notesSource: NotesSource); /** * Properly disposes this note */ destroy(): void; /** * Retrieves the name of the note * @param hook The hook to subscribe to changes * @returns The note's name */ getName(hook?: IDataHook): string; /** * Retrieves the notes source that this note belongs to * @returns The notes source */ getSource(): NotesSource; /** The cached category */ protected category: DataCacher<NoteCategory | undefined>; /** * Retrieves the note's category * @param hook The hook to subscribe to changes * @returns The note's category */ getCategory(hook?: IDataHook): NoteCategory | undefined; /** * Retrieves the path of the note's file * @param hook The hook to subscribe to changes * @returns The note's file path */ getFilePath(hook?: IDataHook): string; /** * Retrieves the text of the note * @param hook The hook to subscribe to changes * @returns The note's contents */ getText(hook?: IDataHook): string; /** * Retrieves the last update time * @param hook The hook to subscribe to changes * @returns The timestamp of the last update */ getModifiedAt(hook?: IDataHook): number; /** * Retrieves all the notes metadata at once * @param hook The hook to subscribe to changes * @returns The notes metadata */ getData(hook?: IDataHook): INoteMetadata; /** * Retrieves the color of this note * @param hook The hook to subscribe to changes * @returns The color of the note */ getColor(hook?: IDataHook): string; /** * Retrieves the font size for the note * @param hook The hook to subscribe to changes * @returns The font size of the note */ getFontSize(hook?: IDataHook): number; /** * Retrieves the syntax mode for the note * @param hook The hook to subscribe to changes * @returns The syntax mode of the note */ getSyntaxMode(hook?: IDataHook): IHighlightLanguage; /** * Retrieves the value of whether to show rich content * @param hook The hook to subscribe to changes * @returns Whether to show rich content */ getShowRichContent(hook?: IDataHook): boolean; /** * Retrieves the default value of whether to search the content for notes in this category * @param hook The hook to subscribe to changes * @returns Whether to search content */ getSearchContent(hook?: IDataHook): boolean; /** * Updates the note's name * @param name The new name of the node */ setName(name: string): void; /** * Updates the note's category * @param category The new category of the note */ setCategory(category: NoteCategory | undefined | null): void; /** * Updates the note category's ID * @param categoryID The new category ID of the note */ setCategoryID(categoryID: string | undefined | null): void; /** * Sets the file path * @param path The path to the note's file */ setFilePath(path: string): void; /** * Sets the text of the note's file * @param text The text to be set */ setText(text: string): void; /** * Sets the last update time * @param time The time to set */ setModifiedAt(time: number): void; /** * Deletes the note */ delete(): void; /** * Sets the color of the note * @param color The new color of the note */ setColor(color: string | IInherit): void; /** * Sets the font size of the note * @param fontSize The new font size of the category */ setFontSize(fontSize: number | IInherit): void; /** * Sets the syntax mode of the note * @param mode The new syntax mode of the note */ setSyntaxMode(mode: IHighlightLanguage | IInherit): void; /** * Sets whether to show rich content of the note * @param showRichContent Whether to show rich content */ setShowRichContent(showRichContent: boolean | IInherit): void; /** * Sets the default for whether to search content for notes in this category * @param searchContent Whether to search content for this category */ setSearchContent(searchContent: boolean | IInherit): void; } //# sourceMappingURL=Note.d.ts.map