/** ** About the various text fields of textElements ** rawText vs. text vs. original text text: The displyed text. This will have linebreaks if wrapped & will be the parsed text or the original-markup depending on Obsidian view mode originalText: this is the text without added linebreaks for wrapping. This will be parsed or markup depending on view mode rawText: text with original markdown markup and without the added linebreaks for wrapping */ import { App, TFile } from "obsidian"; import ExcalidrawPlugin from "./main"; import { TextMode } from "./ExcalidrawView"; import { LinkParts } from "./utils/Utils"; import { ExcalidrawElement, FileId } from "@zsviczian/excalidraw/types/element/types"; import { DataURL } from "@zsviczian/excalidraw/types/types"; import { EmbeddedFile, MimeType } from "./EmbeddedFileLoader"; declare module "obsidian" { interface MetadataCache { blockCache: { getForFile(x: any, f: TAbstractFile): any; }; } } export declare enum AutoexportPreference { none = 0, both = 1, png = 2, svg = 3, inherit = 4 } export declare const REGEX_LINK: { EXPR: RegExp; getResList: (text: string) => IteratorResult[]; getRes: (text: string) => IterableIterator; isTransclusion: (parts: IteratorResult) => boolean; getLink: (parts: IteratorResult) => string; isWikiLink: (parts: IteratorResult) => boolean; getAliasOrLink: (parts: IteratorResult) => string; getWrapLength: (parts: IteratorResult, defaultWrap: number) => number; }; export declare const REG_LINKINDEX_HYPERLINK: RegExp; export declare const changeThemeOfExcalidrawMD: (data: string) => string; export declare function getJSON(data: string): { scene: string; pos: number; }; export declare function getMarkdownDrawingSection(jsonString: string, compressed: boolean): string; export declare class ExcalidrawData { private plugin; textElements: Map; elementLinks: Map; scene: any; deletedElements: ExcalidrawElement[]; file: TFile; private app; private showLinkBrackets; private linkPrefix; embeddableTheme: "light" | "dark" | "auto" | "default"; private urlPrefix; autoexportPreference: AutoexportPreference; private textMode; loaded: boolean; files: Map; private equations; private compatibilityMode; selectedElementIds: { [key: string]: boolean; }; constructor(plugin: ExcalidrawPlugin); /** * 1.5.4: for backward compatibility following the release of container bound text elements and the depreciation boundElementIds field */ private initializeNonInitializedFields; /** * Loads a new drawing * @param {TFile} file - the MD file containing the Excalidraw drawing * @returns {boolean} - true if file was loaded, false if there was an error */ loadData(data: string, file: TFile, textMode: TextMode): Promise; loadLegacyData(data: string, file: TFile): Promise; setTextMode(textMode: TextMode, forceupdate?: boolean): Promise; updateTextElement(sceneTextElement: any, newText: string, newOriginalText: string, forceUpdate?: boolean, containerType?: string): void; /** * Updates the TextElements in the Excalidraw scene based on textElements MAP in ExcalidrawData * Depending on textMode, TextElements will receive their raw or parsed values * @param forceupdate : will update text elements even if text contents has not changed, this will * correct sizing issues */ private updateSceneTextElements; private getText; private findNewElementLinksInScene; /** * check for textElements in Scene missing from textElements Map * @returns {boolean} - true if there were changes */ private findNewTextElementsInScene; private updateElementLinksFromScene; /** * update text element map by deleting entries that are no long in the scene * and updating the textElement map based on the text updated in the scene */ private updateTextElementsFromScene; private parseasync; private parseLinks; /** * * @param text * @returns [string,number] - the transcluded text, and the line number for the location of the text */ getTransclusion(link: string): Promise<{ contents: string; lineNum: number; }>; /** * Process aliases and block embeds * @param text * @returns */ private parse; private parseCheckbox; /** * Does a quick parse of the raw text. Returns the parsed string if raw text does not include a transclusion. * Return null if raw text includes a transclusion. * This is implemented in a separate function, because by nature resolving a transclusion is an asynchronious * activity. Quick parse gets the job done synchronously if possible. * @param text */ private quickParse; /** * Generate markdown file representation of excalidraw drawing * @returns markdown string */ disableCompression: boolean; generateMD(deletedElements?: ExcalidrawElement[]): string; saveDataURLtoVault(dataURL: DataURL, mimeType: MimeType, key: FileId): Promise; /** * deletes fileIds from Excalidraw data for files no longer in the scene * @returns */ private syncFiles; syncElements(newScene: any, selectedElementIds?: { [key: string]: boolean; }): Promise; updateScene(newScene: any): Promise; getRawText(id: string): string; /** * returns parsed text with the correct line length * @param id * @returns */ getParsedText(id: string): [parseResultWrapped: string, parseResultOriginal: string, link: string]; /** * Attempts to quickparse (sycnhronously) the raw text. * * If successful: * - it will set the textElements cache with the parsed result, and * - return the parsed result as an array of 3 values: [parsedTextWrapped, parsedText, link] * * If the text contains a transclusion: * - it will initiate the async parse, and * - it will return [null,null,null]. * @param elementID * @param rawText * @param rawOriginalText * @param updateSceneCallback * @returns [parseResultWrapped: string, parseResultOriginal: string, link: string] */ setTextElement(elementID: string, rawText: string, rawOriginalText: string, updateSceneCallback: Function): [parseResultWrapped: string, parseResultOriginal: string, link: string]; addTextElement(elementID: string, rawText: string, rawOriginalText: string): Promise<[string, string, string]>; deleteTextElement(id: string): void; getOpenMode(): { viewModeEnabled: boolean; zenModeEnabled: boolean; }; getLinkOpacity(): number; getOnLoadScript(): string; private setLinkPrefix; private setUrlPrefix; private setAutoexportPreferences; private setembeddableThemePreference; private setShowLinkBrackets; /** Files and equations copy/paste support This is not a complete solution, it assumes the source document is opened first at that time the fileId is stored in the master files/equations map when pasted the map is checked if the file already exists This will not work if pasting from one vault to another, but for the most common usecase of copying an image or equation from one drawing to another within the same vault this is going to do the job */ setFile(fileId: FileId, data: EmbeddedFile): void; getFiles(): EmbeddedFile[]; getFile(fileId: FileId): EmbeddedFile; getFileEntries(): IterableIterator<[FileId, EmbeddedFile]>; deleteFile(fileId: FileId): void; hasFile(fileId: FileId): boolean; setEquation(fileId: FileId, data: { latex: string; isLoaded: boolean; }): void; getEquation(fileId: FileId): { latex: string; isLoaded: boolean; }; getEquationEntries(): IterableIterator<[FileId, { latex: string; isLoaded: boolean; }]>; deleteEquation(fileId: FileId): void; hasEquation(fileId: FileId): boolean; } export declare const getTransclusion: (linkParts: LinkParts, app: App, file: TFile, charCountLimit?: number) => Promise<{ contents: string; lineNum: number; leadingHashes?: string; }>;