diff --git a/node_modules/obsidian/.github/ISSUE_TEMPLATE/api-bug-report.md b/node_modules/obsidian/.github/ISSUE_TEMPLATE/api-bug-report.md deleted file mode 100644 index 461618f..0000000 --- a/node_modules/obsidian/.github/ISSUE_TEMPLATE/api-bug-report.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: API bug report -about: 'For reproducible bugs with the API only. If you have a question, you should - instead go to our discord server under the #plugin-dev channel to ask for help.' -title: 'Bug: ' - ---- - -**Steps to reproduce:** -- diff --git a/node_modules/obsidian/CHANGELOG.md b/node_modules/obsidian/CHANGELOG.md deleted file mode 100644 index 3c01938..0000000 --- a/node_modules/obsidian/CHANGELOG.md +++ /dev/null @@ -1,195 +0,0 @@ -# Changelog - -## v1.4.4 - -We've exposed our helper function for setting tooltips on elements (`setTooltip`) as well as added a new progress bar component. - -The `FileManager.processFrontMatter` function now also exposes the DataWriteOptions argument to be consistent with the other `process` and `write` functions. - -## v1.4.0 - -We've made some changes to `CachedMetadata` to support **Properties**. `FrontMatterCache` is now no longer a `CacheItem`—meaning that it doesn't have a position. Instead, is it a _Reference_. - -Another big change in v.1.4 is that frontmatter now supports wikilinks. If a value in the frontmatter can be interpreted as a link, it will be cached inside `CachedMetadata.frontmatterLinks`. - -## v1.1.3 - -- Updated the [Canvas spec](https://github.com/obsidianmd/obsidian-api/blob/master/canvas.d.ts) to indicate that colors can be stored in 1 or 2 formats: - - as a hex string (i.e. "#FFFFFF") - - as a number "1", "2", etc. - - If it's a number, this refers to the palette position. It can be themed via CSS variables. - - -### Theme Changes - -There are some new CSS variables related to canvas and callouts in 1.1.3+. All the extended palette colors now have an RGB variant that is used for callouts and canvas colors. The hex values are primarily used for syntax highlighting. - -```css -body { - --callout-bug: var(--color-red-rgb); - --callout-default: var(--color-blue-rgb); - --callout-error: var(--color-red-rgb); - --callout-example: var(--color-purple-rgb); - --callout-fail: var(--color-red-rgb); - --callout-important: var(--color-cyan-rgb); - --callout-info: var(--color-blue-rgb); - --callout-question: var(--color-yellow-rgb); - --callout-success: var(--color-green-rgb); - --callout-summary: var(--color-cyan-rgb); - --callout-tip: var(--color-cyan-rgb); - --callout-todo: var(--color-blue-rgb); - --callout-warning: var(--color-orange-rgb); - --callout-quote: 158, 158, 158; -} -.theme-light { - --color-red-rgb: 228, 55, 75; - --color-red: #E4374B; - - --color-orange-rgb: 217, 108, 0; - --color-orange: #d96c00; - - --color-yellow-rgb: 189, 142, 55; - --color-yellow: #BD8E37; - - --color-green-rgb: 12, 181, 79; - --color-green: #0cb54f; - - --color-cyan-rgb: 45, 183, 181; - --color-cyan: #2db7b5; - - --color-blue-rgb: 8, 109, 221; - --color-blue: #086DDD; - - --color-purple-rgb: 135, 107, 224; - --color-purple: #876be0; - - --color-pink-rgb: 195, 43, 116; - --color-pink: #C32B74; -} -.theme-dark { - --color-red-rgb: 251, 70, 76; - --color-red: #fb464c; - - --color-orange-rgb: 233, 151, 63; - --color-orange: #E9973F; - - --color-yellow-rgb: 224, 222, 113; - --color-yellow: #E0DE71; - - --color-green-rgb: 68, 207, 110; - --color-green: #44CF6E; - - --color-cyan-rgb: 83, 223, 221; - --color-cyan: #53DFDD; - - --color-blue-rgb: 2, 122, 255; - --color-blue: #027aff; - - --color-purple-rgb: 168, 130, 255; - --color-purple: #a882ff; - - --color-pink-rgb: 250, 153, 205; - --color-pink: #FA99CD; -} -``` - - -## v1.1.1 (2022-12-8 — Insider build) - -_[Changes since v1.0](https://github.com/obsidianmd/obsidian-api/compare/32fe4c3f...6161bf59)_ - -- [`file-open`](https://github.com/obsidianmd/obsidian-api/blob/ec589e9762a1d7e2faad01f894cb34c41b10ecaf/obsidian.d.ts#L4189) event is now fired when focusing a Canvas file card. -- Exposed the `activeEditor` on the Workspace. When a markdown view is active, this will point to the underlying `MarkdownEditView`. If a canvas view is active, this will be an EmbeddedEditor component. - -With these two changes, plugins should be able to adapt to the new Canvas view quite easily. Custom -views that react the the currently focused views will automatically respond to the user clicking -on file cards in the canvas. If a plugin is currently accessing the `Editor` using the following -approach: - -```ts -let view = app.workspace.getActiveViewOfType(MarkdownView); - -if (view) { - let editor = view.editor; - // or - let file = view.file; -} -``` - -Instead you can access the `editor` or `file` by looking under the `activeEditor`: -```ts -let { activeEditor } = app.workspace; -if (activeEditor) { - let editor = activeEditor.editor; - let file = activeEditor.file; -} -``` - -## v1.1.0 (2022-12-05 — Insider build) - -_[Changes since v1.0](https://github.com/obsidianmd/obsidian-api/compare/1b4f6e2...32fe4c3f)_ - -### New Metadata API - -In anticipation of bigger improvements to metadata and frontmatter in Obsidian, we have introduced a new metadata API. -It is currently defined as follows: - -```ts -interface FileManager { -/** - * Atomically read, modify, and save the frontmatter of a note. - * The frontmatter is passed in as a JS object, and should be mutated directly to achieve the desired result. - * @param file - the file to be modified. Must be a markdown file. - * @param fn - a callback function which mutates the frontMatter object synchronously. - * @public - */ - processFrontMatter(file: TFile, fn: (frontMatter: any) => void): Promise -} -``` - -To use it: - -```ts -app.fileManager.processFrontMatter(file, (frontmatter) => { - frontmatter["key1"] = value; - delete frontmatter["key2"]; -}); -``` - -All changes made within the callback block will be applied at once. - - -### Improved - -- `setTooltip` now accepts an optional tooltip position. -- The `size?: number` parameter has been removed from `setIcon`. This is now configurable via CSS. You can add override the CSS var `--icon-size` on the parent class of your element to override the sizing (e.g. `.parent-element { --icon-size: var(--icon-xs) } `) The following icon sizes are available out-of-the-box: `--icon-xs`, `--icon-s`, `--icon-m`, and `--icon-l`. -- `editorCallback` no longer passes the active `view: MarkdownView`. Instead, it now provides either the MarkdownView or a MarkdownFileInfo object. This change allows for editor commands to work within a Canvas. -- `registerHoverLinkSource` is now available in the API to register your plugin's view with the Page preview core plugin. - -### No longer broken - -- Fixed `Editor.replaceSelection` not working when run immediately after closing a modal. - -### Notable Changes - -- Added support for an optional `fundingUrl` field the plugin manifest This is a link for users that want to donate to show appreciation and support plugin development. It's displayed when your plugin is selected in the list of community plugins. -- Added macOS calendar entitlements. This allow scripts run from within Obsidian to request calendar access. - -## v1.0 (2022-10-13) - -_[Changes since v0.15.9](https://github.com/obsidianmd/obsidian-api/compare/ff121cd...1b4f6e2)_ - -### New - -- Added standard [color picker component](https://github.com/obsidianmd/obsidian-api/blob/902badd38ba907689f0917d7b193f7e33d1284fe/obsidian.d.ts#L493). - -### Improved - -- `getLeaf` can now be used to create a leaf in a new tab, a new tab group, or a new window. The preferred usage of `getLeaf` would be `getLeaf(Keymap.isModEvent(evt))` where `evt` is the user's KeyboardEvent. This allows for a consistent user experience when opening files while a modifier key is pressed. - -### Notable Changes - -- Workspace information is no longer saved to the `.obsidian/workspace` file. It is now saved to `workspace.json`. -- Added `.has-active-menu` class to file explorer item that received the right-click. -- Added `.list-bullet` class to HTML markup for unordered list items. diff --git a/node_modules/obsidian/LICENSE.md b/node_modules/obsidian/LICENSE.md deleted file mode 100644 index 2d92418..0000000 --- a/node_modules/obsidian/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2022 Dynalist Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/obsidian/README.md b/node_modules/obsidian/README.md deleted file mode 100644 index 6a000cd..0000000 --- a/node_modules/obsidian/README.md +++ /dev/null @@ -1,65 +0,0 @@ -## Obsidian API - -Type definitions for the latest [Obsidian](https://obsidian.md) API. - -### Documentation - -You can browse our Plugin API documentation at https://docs.obsidian.md/ - -For an example on how to create Obsidian plugins, use the template at https://github.com/obsidianmd/obsidian-sample-plugin - -### Plugin structure - -`manifest.json` - -- `id` the ID of your plugin. -- `name` the display name of your plugin. -- `author` the plugin author's name. -- `version` the version of your plugin. -- `minAppVersion` the minimum required Obsidian version for your plugin. -- `description` the long description of your plugin. -- `isDesktopOnly` whether your plugin uses NodeJS or Electron APIs. -- `authorUrl` (optional) a URL to your own website. -- `fundingUrl` (optional) a link for users to donation to show appreciation and support plugin development. - -`main.js` - -- This is the main entry point of your plugin. -- Import any Obsidian API using `require('obsidian')` -- Import NodeJS or Electron API using `require('fs')` or `require('electron')` -- Must export a default class which extends `Plugin` -- Must bundle all external dependencies into this file, using Rollup, Webpack, or another javascript bundler. - -### App Architecture - -##### The app is organized into a few major modules: - -- `App`, the global object that owns everything else. You can access this via `this.app` inside your plugin. The `App` interface provides accessors for the following interfaces. -- `Vault`, the interface that lets you interact with files and folders in the vault. -- `Workspace`, the interface that lets you interact with panes on the screen. -- `MetadataCache`, the interface that contains cached metadata about each markdown file, including headings, links, embeds, tags, and blocks. - -##### Additionally, by inheriting `Plugin`, you can: -- Add a ribbon icon using `this.addRibbonIcon`. -- Add a status bar (bottom) element using `this.addStatusBarItem`. -- Add a global command, optionally with a default hotkey, using `this.addCommand`. -- Add a plugin settings tab using `this.addSettingTab`. -- Register a new kind of view using `this.registerView`. -- Save and load plugin data using `this.loadData` and `this.saveData`. - -##### Registering events - -For registering events from any event interfaces, such as `App` and `Workspace`, please use `this.registerEvent`, which will automatically detach your event handler when your plugin unloads: -``` -this.registerEvent(app.on('event-name', callback)); -``` - -If you register DOM events for elements that persist on the page after your plugin unloads, such as `window` or `document` events, please use `this.registerDomEvent`: -``` -this.registerDomEvent(element, 'click', callback); -``` - -If you use `setInterval`, please use `this.registerInterval`: -``` -this.registerInterval(setInterval(callback, 1000)); -``` diff --git a/node_modules/obsidian/canvas.d.ts b/node_modules/obsidian/canvas.d.ts deleted file mode 100644 index 8369c71..0000000 --- a/node_modules/obsidian/canvas.d.ts +++ /dev/null @@ -1,97 +0,0 @@ - -/** - * A color used to encode color data for nodes and edges - * can be a number (like "1") representing one of the (currently 6) supported colors. - * or can be a custom color using the hex format "#FFFFFFF". - */ -export type CanvasColor = string; - -/** The overall canvas file's JSON */ -export interface CanvasData { - nodes: AllCanvasNodeData[]; - edges: CanvasEdgeData[]; - - /** Support arbitrary keys for forward compatibility */ - [key: string]: any; -} - -/** A node */ -export interface CanvasNodeData { - /** The unique ID for this node */ - id: string; - // The positional data - x: number; - y: number; - width: number; - height: number; - /** The color of this node */ - color?: CanvasColor; - - // Support arbitrary keys for forward compatibility - [key: string]: any; -} - -export type AllCanvasNodeData = CanvasFileData | CanvasTextData | CanvasLinkData | CanvasGroupData; - -/** A node that is a file, where the file is located somewhere in the vault. */ -export interface CanvasFileData extends CanvasNodeData { - type: 'file'; - file: string; - /** An optional subpath which links to a heading or a block. Always starts with a `#`. */ - subpath?: string; -} - -/** A node that is plaintext. */ -export interface CanvasTextData extends CanvasNodeData { - type: 'text'; - text: string; -} - -/** A node that is an external resource. */ -export interface CanvasLinkData extends CanvasNodeData { - type: 'link'; - url: string; -} - -/** The background image rendering style */ -export type BackgroundStyle = 'cover' | 'ratio' | 'repeat'; - -/** A node that represents a group. */ -export interface CanvasGroupData extends CanvasNodeData { - type: 'group'; - /** Optional label to display on top of the group. */ - label?: string; - /** Optional background image, stores the path to the image file in the vault. */ - background?: string; - /** Optional background image rendering style; defaults to 'cover'. */ - backgroundStyle?: BackgroundStyle; -} - -/** The side of the node that a connection is connected to */ -export type NodeSide = 'top' | 'right' | 'bottom' | 'left'; - -/** What to display at the end of an edge */ -export type EdgeEnd = 'none' | 'arrow'; - -/** An edge */ -export interface CanvasEdgeData { - /** The unique ID for this edge */ - id: string; - /** The node ID and side where this edge starts */ - fromNode: string; - fromSide: NodeSide; - /** The starting edge end; defaults to 'none' */ - fromEnd?: EdgeEnd; - /** The node ID and side where this edge ends */ - toNode: string; - toSide: NodeSide; - /** The ending edge end; defaults to 'arrow' */ - toEnd?: EdgeEnd; - /** The color of this edge */ - color?: CanvasColor; - /** The text label of this edge, if available */ - label?: string; - - // Support arbitrary keys for forward compatibility - [key: string]: any; -} \ No newline at end of file diff --git a/node_modules/obsidian/obsidian.d.ts b/node_modules/obsidian/obsidian.d.ts deleted file mode 100644 index 96fca39..0000000 --- a/node_modules/obsidian/obsidian.d.ts +++ /dev/null @@ -1,4962 +0,0 @@ -/** - * This file is automatically generated. - * Please do not modify or send pull requests for it. - */ - -import { Extension, StateField } from '@codemirror/state'; -import { EditorView, ViewPlugin } from '@codemirror/view'; -import * as CodeMirror from 'codemirror'; -import * as Moment from 'moment'; - -declare global { - interface ObjectConstructor { - isEmpty(object: Record): boolean; - each(object: { - [key: string]: T; - }, callback: (value: T, key?: string) => boolean | void, context?: any): boolean; - } - interface ArrayConstructor { - combine(arrays: T[][]): T[]; - } - interface Array { - first(): T | undefined; - last(): T | undefined; - contains(target: T): boolean; - remove(target: T): void; - shuffle(): this; - unique(): T[]; - findLastIndex(predicate: (value: T) => boolean): number; - } - interface Math { - clamp(value: number, min: number, max: number): number; - square(value: number): number; - } - interface StringConstructor { - isString(obj: any): obj is string; - } - interface String { - contains(target: string): boolean; - startsWith(searchString: string, position?: number): boolean; - endsWith(target: string, length?: number): boolean; - format(...args: string[]): string; - } - interface NumberConstructor { - isNumber(obj: any): obj is number; - } - interface Node { - detach(): void; - empty(): void; - insertAfter(node: T, child: Node | null): T; - indexOf(other: Node): number; - setChildrenInPlace(children: Node[]): void; - appendText(val: string): void; - /** - * Cross-window capable instanceof check, a drop-in replacement - * for instanceof checks on DOM Nodes. Remember to also check - * for nulls when necessary. - * @param type - */ - instanceOf(type: { - new (): T; - }): this is T; - /** - * The document this node belongs to, or the global document. - */ - doc: Document; - /** - * The window object this node belongs to, or the global window. - */ - win: Window; - constructorWin: Window; - } - interface Element extends Node { - getText(): string; - setText(val: string | DocumentFragment): void; - addClass(...classes: string[]): void; - addClasses(classes: string[]): void; - removeClass(...classes: string[]): void; - removeClasses(classes: string[]): void; - toggleClass(classes: string | string[], value: boolean): void; - hasClass(cls: string): boolean; - setAttr(qualifiedName: string, value: string | number | boolean | null): void; - setAttrs(obj: { - [key: string]: string | number | boolean | null; - }): void; - getAttr(qualifiedName: string): string | null; - matchParent(selector: string, lastParent?: Element): Element | null; - getCssPropertyValue(property: string, pseudoElement?: string): string; - isActiveElement(): boolean; - } - interface HTMLElement extends Element { - show(): void; - hide(): void; - toggle(show: boolean): void; - toggleVisibility(visible: boolean): void; - /** - * Returns whether this element is shown, when the element is attached to the DOM and - * none of the parent and ancestor elements are hidden with `display: none`. - * - * Exception: Does not work on `` and ``, or on elements with `position: fixed`. - */ - isShown(): boolean; - setCssStyles(styles: Partial): void; - setCssProps(props: Record): void; - /** - * Get the inner width of this element without padding. - */ - readonly innerWidth: number; - /** - * Get the inner height of this element without padding. - */ - readonly innerHeight: number; - } - interface SVGElement extends Element { - setCssStyles(styles: Partial): void; - setCssProps(props: Record): void; - } - function isBoolean(obj: any): obj is boolean; - function fish(selector: string): HTMLElement | null; - function fishAll(selector: string): HTMLElement[]; - interface Element extends Node { - find(selector: string): Element | null; - findAll(selector: string): HTMLElement[]; - findAllSelf(selector: string): HTMLElement[]; - } - interface HTMLElement extends Element { - find(selector: string): HTMLElement; - findAll(selector: string): HTMLElement[]; - findAllSelf(selector: string): HTMLElement[]; - } - interface DocumentFragment extends Node, NonElementParentNode, ParentNode { - find(selector: string): HTMLElement; - findAll(selector: string): HTMLElement[]; - } - interface DomElementInfo { - /** - * The class to be assigned. Can be a space-separated string or an array of strings. - */ - cls?: string | string[]; - /** - * The textContent to be assigned. - */ - text?: string | DocumentFragment; - /** - * HTML attributes to be added. - */ - attr?: { - [key: string]: string | number | boolean | null; - }; - /** - * HTML title (for hover tooltip). - */ - title?: string; - /** - * The parent element to be assigned to. - */ - parent?: Node; - value?: string; - type?: string; - prepend?: boolean; - placeholder?: string; - href?: string; - } - interface SvgElementInfo { - /** - * The class to be assigned. Can be a space-separated string or an array of strings. - */ - cls?: string | string[]; - /** - * HTML attributes to be added. - */ - attr?: { - [key: string]: string | number | boolean | null; - }; - /** - * The parent element to be assigned to. - */ - parent?: Node; - prepend?: boolean; - } - interface Node { - /** - * Create an element and append it to this node. - */ - createEl(tag: K, o?: DomElementInfo | string, callback?: (el: HTMLElementTagNameMap[K]) => void): HTMLElementTagNameMap[K]; - createDiv(o?: DomElementInfo | string, callback?: (el: HTMLDivElement) => void): HTMLDivElement; - createSpan(o?: DomElementInfo | string, callback?: (el: HTMLSpanElement) => void): HTMLSpanElement; - createSvg(tag: K, o?: SvgElementInfo | string, callback?: (el: SVGElementTagNameMap[K]) => void): SVGElementTagNameMap[K]; - } - function createEl(tag: K, o?: DomElementInfo | string, callback?: (el: HTMLElementTagNameMap[K]) => void): HTMLElementTagNameMap[K]; - function createDiv(o?: DomElementInfo | string, callback?: (el: HTMLDivElement) => void): HTMLDivElement; - function createSpan(o?: DomElementInfo | string, callback?: (el: HTMLSpanElement) => void): HTMLSpanElement; - function createSvg(tag: K, o?: SvgElementInfo | string, callback?: (el: SVGElementTagNameMap[K]) => void): SVGElementTagNameMap[K]; - function createFragment(callback?: (el: DocumentFragment) => void): DocumentFragment; - interface EventListenerInfo { - selector: string; - listener: Function; - options?: boolean | AddEventListenerOptions; - callback: Function; - } - interface HTMLElement extends Element { - _EVENTS?: { - [K in keyof HTMLElementEventMap]?: EventListenerInfo[]; - }; - on(this: HTMLElement, type: K, selector: string, listener: (this: HTMLElement, ev: HTMLElementEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - off(this: HTMLElement, type: K, selector: string, listener: (this: HTMLElement, ev: HTMLElementEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - onClickEvent(this: HTMLElement, listener: (this: HTMLElement, ev: MouseEvent) => any, options?: boolean | AddEventListenerOptions): void; - /** - * @param listener - the callback to call when this node is inserted into the DOM. - * @param once - if true, this will only fire once and then unhook itself. - * @returns destroy - a function to remove the event handler to avoid memory leaks. - */ - onNodeInserted(this: HTMLElement, listener: () => any, once?: boolean): () => void; - /** - * @param listener - the callback to call when this node has been migrated to another window. - * @returns destroy - a function to remove the event handler to avoid memory leaks. - */ - onWindowMigrated(this: HTMLElement, listener: (win: Window) => any): () => void; - trigger(eventType: string): void; - } - interface Document { - _EVENTS?: { - [K in keyof DocumentEventMap]?: EventListenerInfo[]; - }; - on(this: Document, type: K, selector: string, listener: (this: Document, ev: DocumentEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - off(this: Document, type: K, selector: string, listener: (this: Document, ev: DocumentEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - } - interface UIEvent extends Event { - targetNode: Node | null; - win: Window; - doc: Document; - /** - * Cross-window capable instanceof check, a drop-in replacement - * for instanceof checks on UIEvents. - * @param type - */ - instanceOf(type: { - new (...data: any[]): T; - }): this is T; - } - interface AjaxOptions { - method?: 'GET' | 'POST'; - url: string; - success?: (response: any, req: XMLHttpRequest) => any; - error?: (error: any, req: XMLHttpRequest) => any; - data?: object | string | ArrayBuffer; - headers?: Record; - withCredentials?: boolean; - req?: XMLHttpRequest; - } - function ajax(options: AjaxOptions): void; - function ajaxPromise(options: AjaxOptions): Promise; - function ready(fn: () => any): void; - function sleep(ms: number): Promise; - function nextFrame(): Promise; - /** - * The actively focused Window object. This is usually the same as `window` but - * it will be different when using popout windows. - */ - let activeWindow: Window; - /** - * The actively focused Document object. This is usually the same as `document` but - * it will be different when using popout windows. - */ - let activeDocument: Document; - interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandlers, WindowEventHandlers, WindowLocalStorage, WindowOrWorkerGlobalScope, WindowSessionStorage { - /** - * The actively focused Window object. This is usually the same as `window` but - * it will be different when using popout windows. - */ - activeWindow: Window; - /** - * The actively focused Document object. This is usually the same as `document` but - * it will be different when using popout windows. - */ - activeDocument: Document; - sleep(ms: number): Promise; - nextFrame(): Promise; - } - interface Touch { - touchType: 'stylus' | 'direct'; - } -} - -/** - * Attach to an `` element or a `
` to add type-ahead - * support. - * - * @public - */ -export abstract class AbstractInputSuggest extends PopoverSuggest { - - /** - * Limit to the number of elements rendered at once. Set to 0 to disable. Defaults to 100. - * @public - */ - limit: number; - /** - * Accepts an `` text box or a contenteditable div. - * @public - */ - constructor(app: App, textInputEl: HTMLInputElement | HTMLDivElement); - - /** - * Sets the value into the input element. - * @public - */ - setValue(value: string): void; - /** - * Gets the value from the input element. - * @public - */ - getValue(): string; - - /** @public */ - protected abstract getSuggestions(query: string): T[] | Promise; - - /** - * Registers a callback to handle when a suggestion is selected by the user. - * @public - */ - onSelect(callback: (value: T, evt: MouseEvent | KeyboardEvent) => any): this; - -} - -/** - * @public - */ -export class AbstractTextComponent extends ValueComponent { - /** - * @public - */ - inputEl: T; - - /** - * @public - */ - constructor(inputEl: T); - /** - * @public - */ - setDisabled(disabled: boolean): this; - /** - * @public - */ - getValue(): string; - /** - * @public - */ - setValue(value: string): this; - /** - * @public - */ - setPlaceholder(placeholder: string): this; - /** - * @public - */ - onChanged(): void; - /** - * @public - */ - onChange(callback: (value: string) => any): this; -} - -/** - * Adds an icon to the library. - * @param iconId - the icon ID - * @param svgContent - the content of the SVG. - * @public - */ -export function addIcon(iconId: string, svgContent: string): void; - -/** - * This is the API version of the app, which follows the release cycle of the desktop app. - * Example: "0.13.21" - * @public - */ -export let apiVersion: string; - -/** - * @public - */ -export class App { - - /** @public */ - keymap: Keymap; - /** @public */ - scope: Scope; - - /** @public */ - workspace: Workspace; - - /** @public */ - vault: Vault; - /** @public */ - metadataCache: MetadataCache; - - /** @public */ - fileManager: FileManager; - - /** - * The last known user interaction event, to help commands find out what modifier keys are pressed. - * @public - */ - lastEvent: UserEvent | null; - -} - -/** @public */ -export function arrayBufferToBase64(buffer: ArrayBuffer): string; - -/** @public */ -export function arrayBufferToHex(data: ArrayBuffer): string; - -/** @public */ -export function base64ToArrayBuffer(base64: string): ArrayBuffer; - -/** - * @public - */ -export abstract class BaseComponent { - /** @public */ - disabled: boolean; - /** - * Facilitates chaining - * @public - */ - then(cb: (component: this) => any): this; - /** - * @public - */ - setDisabled(disabled: boolean): this; -} - -/** - * @public - */ -export interface BlockCache extends CacheItem { - /** @public */ - id: string; -} - -/** - * @public - */ -export interface BlockSubpathResult extends SubpathResult { - /** - * @public - */ - type: 'block'; - /** - * @public - */ - block: BlockCache; - /** - * @public - */ - list?: ListItemCache; -} - -/** - * @public - */ -export class ButtonComponent extends BaseComponent { - /** - * @public - */ - buttonEl: HTMLButtonElement; - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - setDisabled(disabled: boolean): this; - /** - * @public - */ - setCta(): this; - /** - * @public - */ - removeCta(): this; - /** - * @public - */ - setWarning(): this; - /** - * @public - */ - setTooltip(tooltip: string, options?: TooltipOptions): this; - /** - * @public - */ - setButtonText(name: string): this; - /** - * @public - */ - setIcon(icon: IconName): this; - /** - * @public - */ - setClass(cls: string): this; - /** - * @public - */ - onClick(callback: (evt: MouseEvent) => any): this; -} - -/** - * @public - */ -export interface CachedMetadata { - /** - * @public - */ - links?: LinkCache[]; - /** - * @public - */ - embeds?: EmbedCache[]; - /** - * @public - */ - tags?: TagCache[]; - /** - * @public - */ - headings?: HeadingCache[]; - /** - * Sections are root level markdown blocks, which can be used to divide the document up. - * @public - */ - sections?: SectionCache[]; - /** - * @public - */ - listItems?: ListItemCache[]; - /** - * @public - */ - frontmatter?: FrontMatterCache; - /** - * @public - */ - frontmatterPosition?: Pos; - - /** - * @public - */ - frontmatterLinks?: FrontmatterLinkCache[]; - /** - * @public - */ - blocks?: Record; -} - -/** - * @public - */ -export interface CacheItem { - /** - * @public - */ - position: Pos; - -} - -/** @public */ -export interface CloseableComponent { - /** @public */ - close(): any; -} - -/** - * Color picker component. Values are by default 6-digit hash-prefixed hex strings like `#000000`. - * @public - */ -export class ColorComponent extends ValueComponent { - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - setDisabled(disabled: boolean): this; - /** - * @public - */ - getValue(): HexString; - /** - * @public - */ - getValueRgb(): RGB; - /** - * @public - */ - getValueHsl(): HSL; - - /** - * @public - */ - setValue(value: HexString): this; - /** - * @public - */ - setValueRgb(rgb: RGB): this; - /** - * @public - */ - setValueHsl(hsl: HSL): this; - - /** - * @public - */ - onChange(callback: (value: string) => any): this; -} - -/** - * @public - */ -export interface Command { - /** - * Globally unique ID to identify this command. - * @public - */ - id: string; - /** - * Human friendly name for searching. - * @public - */ - name: string; - /** - * Icon ID to be used in the toolbar. - * See {@link https://docs.obsidian.md/Plugins/User+interface/Icons} for available icons and how to add your own. - * @public - */ - icon?: IconName; - /** @public */ - mobileOnly?: boolean; - /** - * Whether holding the hotkey should repeatedly trigger this command. - * @defaultValue false - * @public - */ - repeatable?: boolean; - /** - * Simple callback, triggered globally. - * @example - * ```ts - * this.addCommand({ - * id: "print-greeting-to-console", - * name: "Print greeting to console", - * callback: () => { - * console.log("Hey, you!"); - * }, - * }); - * ``` - * @public - */ - callback?: () => any; - /** - * Complex callback, overrides the simple callback. - * Used to "check" whether your command can be performed in the current circumstances. - * For example, if your command requires the active focused pane to be a MarkdownView, then - * you should only return true if the condition is satisfied. Returning false or undefined causes - * the command to be hidden from the command palette. - * - * @param checking - Whether the command palette is just "checking" if your command should show right now. - * If checking is true, then this function should not perform any action. - * If checking is false, then this function should perform the action. - * @returns Whether this command can be executed at the moment. - * - * @example - * ```ts - * this.addCommand({ - * id: 'example-command', - * name: 'Example command', - * checkCallback: (checking: boolean) => { - * const value = getRequiredValue(); - * - * if (value) { - * if (!checking) { - * doCommand(value); - * } - * return true; - * } - * - * return false; - * } - * }); - * ``` - * - * @public - */ - checkCallback?: (checking: boolean) => boolean | void; - - /** - * A command callback that is only triggered when the user is in an editor. - * Overrides `callback` and `checkCallback` - * @example - * ```ts - * this.addCommand({ - * id: 'example-command', - * name: 'Example command', - * editorCallback: (editor: Editor, view: MarkdownView) => { - * const sel = editor.getSelection(); - * - * console.log(`You have selected: ${sel}`); - * } - * }); - * ``` - * @public - */ - editorCallback?: (editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any; - /** - * A command callback that is only triggered when the user is in an editor. - * Overrides `editorCallback`, `callback` and `checkCallback` - * @example - * ```ts - * this.addCommand({ - * id: 'example-command', - * name: 'Example command', - * editorCheckCallback: (checking: boolean, editor: Editor, view: MarkdownView) => { - * const value = getRequiredValue(); - * - * if (value) { - * if (!checking) { - * doCommand(value); - * } - * - * return true; - * } - * - * return false; - * } - * }); - * ``` - * @public - */ - editorCheckCallback?: (checking: boolean, editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => boolean | void; - /** - * Sets the default hotkey. It is recommended for plugins to avoid setting default hotkeys if possible, - * to avoid conflicting hotkeys with one that's set by the user, even though customized hotkeys have higher priority. - * @public - */ - hotkeys?: Hotkey[]; - -} - -/** - * @public - */ -export class Component { - - /** - * Load this component and its children - * @public - */ - load(): void; - /** - * Override this to load your component - * @public - * @virtual - */ - onload(): void; - /** - * Unload this component and its children - * @public - */ - unload(): void; - /** - * Override this to unload your component - * @public - * @virtual - */ - onunload(): void; - /** - * Adds a child component, loading it if this component is loaded - * @public - */ - addChild(component: T): T; - /** - * Removes a child component, unloading it - * @public - */ - removeChild(component: T): T; - /** - * Registers a callback to be called when unloading - * @public - */ - register(cb: () => any): void; - /** - * Registers an event to be detached when unloading - * @public - */ - registerEvent(eventRef: EventRef): void; - /** - * Registers an DOM event to be detached when unloading - * @public - */ - registerDomEvent(el: Window, type: K, callback: (this: HTMLElement, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - /** - * Registers an DOM event to be detached when unloading - * @public - */ - registerDomEvent(el: Document, type: K, callback: (this: HTMLElement, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - /** - * Registers an DOM event to be detached when unloading - * @public - */ - registerDomEvent(el: HTMLElement, type: K, callback: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - - /** - * Registers an interval (from setInterval) to be cancelled when unloading - * Use {@link window.setInterval} instead of {@link setInterval} to avoid TypeScript confusing between NodeJS vs Browser API - * @public - */ - registerInterval(id: number): number; -} - -/** @public */ -export type Constructor = abstract new (...args: any[]) => T; - -/** - * Work directly with files and folders inside a vault. - * If possible prefer using the {@link Vault} API over this. - * @public - */ -export interface DataAdapter { - - /** - * @public - */ - getName(): string; - - /** - * Check if something exists at the given path. - * @param normalizedPath - path to file/folder, use {@link normalizePath} to normalize beforehand. - * @param sensitive - Some file systems/operating systems are case-insensitive, set to true to force a case-sensitivity check. - * @public - */ - exists(normalizedPath: string, sensitive?: boolean): Promise; - /** - * Retrieve metadata about the given file/folder. - * @param normalizedPath - path to file/folder, use {@link normalizePath} to normalize beforehand. - * @public - */ - stat(normalizedPath: string): Promise; - /** - * Retrieve a list of all files and folders inside the given folder, non-recursive. - * @param normalizedPath - path to folder, use {@link normalizePath} to normalize beforehand. - * @public - */ - list(normalizedPath: string): Promise; - /** - * @param normalizedPath - path to file, use {@link normalizePath} to normalize beforehand. - * @public - */ - read(normalizedPath: string): Promise; - /** - * @param normalizedPath - path to file, use {@link normalizePath} to normalize beforehand. - * @public - */ - readBinary(normalizedPath: string): Promise; - /** - * Write to a plaintext file. - * If the file exists its content will be overwritten, otherwise the file will be created. - * @param normalizedPath - path to file, use {@link normalizePath} to normalize beforehand. - * @param data - new file content - * @param options - (Optional) - * @public - */ - write(normalizedPath: string, data: string, options?: DataWriteOptions): Promise; - /** - * Write to a binary file. - * If the file exists its content will be overwritten, otherwise the file will be created. - * @param normalizedPath - path to file, use {@link normalizePath} to normalize beforehand. - * @param data - the new file content - * @param options - (Optional) - * @public - */ - writeBinary(normalizedPath: string, data: ArrayBuffer, options?: DataWriteOptions): Promise; - /** - * Add text to the end of a plaintext file. - * @param normalizedPath - path to file, use {@link normalizePath} to normalize beforehand. - * @param data - the text to append. - * @param options - (Optional) - * @public - */ - append(normalizedPath: string, data: string, options?: DataWriteOptions): Promise; - /** - * Atomically read, modify, and save the contents of a plaintext file. - * @param normalizedPath - path to file/folder, use {@link normalizePath} to normalize beforehand. - * @param fn - a callback function which returns the new content of the file synchronously. - * @param options - write options. - * @returns string - the text value of the file that was written. - * @public - */ - process(normalizedPath: string, fn: (data: string) => string, options?: DataWriteOptions): Promise; - /** - * Returns an URI for the browser engine to use, for example to embed an image. - * @param normalizedPath - path to file/folder, use {@link normalizePath} to normalize beforehand. - * @public - */ - getResourcePath(normalizedPath: string): string; - /** - * Create a directory. - * @param normalizedPath - path to use for new folder, use {@link normalizePath} to normalize beforehand. - * @public - */ - mkdir(normalizedPath: string): Promise; - /** - * Try moving to system trash. - * @param normalizedPath - path to file/folder, use {@link normalizePath} to normalize beforehand. - * @returns Returns true if succeeded. This can fail due to system trash being disabled. - * @public - */ - trashSystem(normalizedPath: string): Promise; - /** - * Move to local trash. - * Files will be moved into the `.trash` folder at the root of the vault. - * @param normalizedPath - path to file/folder, use {@link normalizePath} to normalize beforehand. - * @public - */ - trashLocal(normalizedPath: string): Promise; - /** - * Remove a directory. - * @param normalizedPath - path to folder, use {@link normalizePath} to normalize beforehand. - * @param recursive - If `true`, delete folders under this folder recursively, if `false` the folder needs to be empty. - * @public - */ - rmdir(normalizedPath: string, recursive: boolean): Promise; - /** - * Delete a file. - * @param normalizedPath - path to file, use {@link normalizePath} to normalize beforehand. - * @public - */ - remove(normalizedPath: string): Promise; - - /** - * Rename a file or folder. - * @param normalizedPath - current path to file/folder, use {@link normalizePath} to normalize beforehand. - * @param normalizedNewPath - new path to file/folder, use {@link normalizePath} to normalize beforehand. - * @public - */ - rename(normalizedPath: string, normalizedNewPath: string): Promise; - /** - * Create a copy of a file. - * This will fail if there is already a file at `normalizedNewPath`. - * @param normalizedPath - path to file, use {@link normalizePath} to normalize beforehand. - * @param normalizedNewPath - path to file, use {@link normalizePath} to normalize beforehand. - * @public - */ - copy(normalizedPath: string, normalizedNewPath: string): Promise; -} - -/** - * @public - */ -export interface DataWriteOptions { - /** - * Time of creation, represented as a unix timestamp, in milliseconds. - * Omit this if you want to keep the default behaviour. - * @public - * */ - ctime?: number; - /** - * Time of last modification, represented as a unix timestamp, in milliseconds. - * Omit this if you want to keep the default behaviour. - * @public - */ - mtime?: number; - -} - -/** - * A standard debounce function. - * Use this to have a time-delayed function only be called once in a given timeframe. - * - * @param cb - The function to call. - * @param timeout - The timeout to wait, in milliseconds - * @param resetTimer - Whether to reset the timeout when the debouncer is called again. - * @returns a debounced function that takes the same parameter as the original function. - * @example - * ```ts - * const debounced = debounce((text: string) => { - * console.log(text); - * }, 1000, true); - * debounced("Hello world"); // this will not be printed - * await sleep(500); - * debounced("World, hello"); // this will be printed to the console. - * ``` - * @public - */ -export function debounce(cb: (...args: [...T]) => V, timeout?: number, resetTimer?: boolean): Debouncer; - -/** @public */ -export interface Debouncer { - /** @public */ - (...args: [...T]): this; - /** @public */ - cancel(): this; - /** @public */ - run(): V | void; -} - -/** - * @public - */ -export class DropdownComponent extends ValueComponent { - /** - * @public - */ - selectEl: HTMLSelectElement; - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - setDisabled(disabled: boolean): this; - /** - * @public - */ - addOption(value: string, display: string): this; - /** - * @public - */ - addOptions(options: Record): this; - /** - * @public - */ - getValue(): string; - /** - * @public - */ - setValue(value: string): this; - /** - * @public - */ - onChange(callback: (value: string) => any): this; -} - -/** - * @public - */ -export abstract class EditableFileView extends FileView { - -} - -/** - * A common interface that bridges the gap between CodeMirror 5 and CodeMirror 6. - * @public - */ -export abstract class Editor { - - /** @public */ - getDoc(): this; - /** @public */ - abstract refresh(): void; - /** @public */ - abstract getValue(): string; - /** @public */ - abstract setValue(content: string): void; - /** - * Get the text at line (0-indexed) - * @public - */ - abstract getLine(line: number): string; - /** @public */ - setLine(n: number, text: string): void; - /** - * Gets the number of lines in the document - * @public - */ - abstract lineCount(): number; - /** @public */ - abstract lastLine(): number; - /** @public */ - abstract getSelection(): string; - /** @public */ - somethingSelected(): boolean; - /** @public */ - abstract getRange(from: EditorPosition, to: EditorPosition): string; - /** @public */ - abstract replaceSelection(replacement: string, origin?: string): void; - /** @public */ - abstract replaceRange(replacement: string, from: EditorPosition, to?: EditorPosition, origin?: string): void; - /** @public */ - abstract getCursor(string?: 'from' | 'to' | 'head' | 'anchor'): EditorPosition; - /** @public */ - abstract listSelections(): EditorSelection[]; - /** @public */ - setCursor(pos: EditorPosition | number, ch?: number): void; - /** @public */ - abstract setSelection(anchor: EditorPosition, head?: EditorPosition): void; - /** @public */ - abstract setSelections(ranges: EditorSelectionOrCaret[], main?: number): void; - /** @public */ - abstract focus(): void; - /** @public */ - abstract blur(): void; - /** @public */ - abstract hasFocus(): boolean; - /** @public */ - abstract getScrollInfo(): { - /** @public */ - top: number; - /** @public */ - left: number; - }; - /** @public */ - abstract scrollTo(x?: number | null, y?: number | null): void; - /** @public */ - abstract scrollIntoView(range: EditorRange, center?: boolean): void; - /** @public */ - abstract undo(): void; - /** @public */ - abstract redo(): void; - /** @public */ - abstract exec(command: EditorCommandName): void; - /** @public */ - abstract transaction(tx: EditorTransaction, origin?: string): void; - /** @public */ - abstract wordAt(pos: EditorPosition): EditorRange | null; - /** @public */ - abstract posToOffset(pos: EditorPosition): number; - /** @public */ - abstract offsetToPos(offset: number): EditorPosition; - - /** @public */ - processLines(read: (line: number, lineText: string) => T | null, write: (line: number, lineText: string, value: T | null) => EditorChange | void, ignoreEmpty?: boolean): void; - -} - -/** @public */ -export interface EditorChange extends EditorRangeOrCaret { - /** @public */ - text: string; -} - -/** @public */ -export type EditorCommandName = 'goUp' | 'goDown' | 'goLeft' | 'goRight' | 'goStart' | 'goEnd' | 'goWordLeft' | 'goWordRight' | 'indentMore' | 'indentLess' | 'newlineAndIndent' | 'swapLineUp' | 'swapLineDown' | 'deleteLine' | 'toggleFold' | 'foldAll' | 'unfoldAll'; - -/** - * Use this StateField to get a reference to the EditorView - * @public - */ -export const editorEditorField: StateField; - -/** - * Use this StateField to get information about this markdown editor, such as the associated file, or the Editor. - * @public - */ -export const editorInfoField: StateField; - -/** - * Use this StateField to check whether Live Preview is active - * @public - */ -export const editorLivePreviewField: StateField; - -/** @public */ -export interface EditorPosition { - /** @public */ - line: number; - /** @public */ - ch: number; -} - -/** @public */ -export interface EditorRange { - /** @public */ - from: EditorPosition; - /** @public */ - to: EditorPosition; -} - -/** @public */ -export interface EditorRangeOrCaret { - /** @public */ - from: EditorPosition; - /** @public */ - to?: EditorPosition; -} - -/** @public */ -export interface EditorScrollInfo { - /** @public */ - left: number; - /** @public */ - top: number; - /** @public */ - width: number; - /** @public */ - height: number; - /** @public */ - clientWidth: number; - /** @public */ - clientHeight: number; -} - -/** @public */ -export interface EditorSelection { - /** @public */ - anchor: EditorPosition; - /** @public */ - head: EditorPosition; -} - -/** @public */ -export interface EditorSelectionOrCaret { - /** @public */ - anchor: EditorPosition; - /** @public */ - head?: EditorPosition; -} - -/** @public */ -export abstract class EditorSuggest extends PopoverSuggest { - /** - * Current suggestion context, containing the result of `onTrigger`. - * This will be null any time the EditorSuggest is not supposed to run. - * @public - */ - context: EditorSuggestContext | null; - /** - * Override this to use a different limit for suggestion items - * @public - */ - limit: number; - /** @public */ - constructor(app: App); - /** - * @public - */ - setInstructions(instructions: Instruction[]): void; - - /** - * Based on the editor line and cursor position, determine if this EditorSuggest should be triggered at this moment. - * Typically, you would run a regular expression on the current line text before the cursor. - * Return null to indicate that this editor suggest is not supposed to be triggered. - * - * Please be mindful of performance when implementing this function, as it will be triggered very often (on each keypress). - * Keep it simple, and return null as early as possible if you determine that it is not the right time. - * @public - */ - abstract onTrigger(cursor: EditorPosition, editor: Editor, file: TFile | null): EditorSuggestTriggerInfo | null; - /** - * Generate suggestion items based on this context. Can be async, but preferably sync. - * When generating async suggestions, you should pass the context along. - * @public - */ - abstract getSuggestions(context: EditorSuggestContext): T[] | Promise; - -} - -/** @public */ -export interface EditorSuggestContext extends EditorSuggestTriggerInfo { - /** @public */ - editor: Editor; - /** @public */ - file: TFile; -} - -/** @public */ -export interface EditorSuggestTriggerInfo { - /** - * The start position of the triggering text. This is used to position the popover. - * @public - */ - start: EditorPosition; - /** - * The end position of the triggering text. This is used to position the popover. - * @public - */ - end: EditorPosition; - /** - * They query string (usually the text between start and end) that will be used to generate the suggestion content. - * @public - */ - query: string; -} - -/** @public */ -export interface EditorTransaction { - /** @public */ - replaceSelection?: string; - /** @public */ - changes?: EditorChange[]; - /** - * Multiple selections, overrides `selection`. - * @public - */ - selections?: EditorRangeOrCaret[]; - /** @public */ - selection?: EditorRangeOrCaret; -} - -/** - * This is now deprecated - it is now mapped directly to `editorInfoField`, which return a MarkdownFileInfo, which may be a MarkdownView but not necessarily. - * @public - * @deprecated use {@link editorInfoField} instead. - */ -export const editorViewField: StateField; - -/** - * @public - */ -export interface EmbedCache extends ReferenceCache { -} - -/** - * @public - */ -export interface EventRef { - -} - -/** - * @public - */ -export class Events { - - /** - * @public - */ - on(name: string, callback: (...data: any) => any, ctx?: any): EventRef; - /** - * @public - */ - off(name: string, callback: (...data: any) => any): void; - /** - * @public - */ - offref(ref: EventRef): void; - /** - * @public - */ - trigger(name: string, ...data: any[]): void; - /** - * @public - */ - tryTrigger(evt: EventRef, args: any[]): void; -} - -/** - * @public - */ -export class ExtraButtonComponent extends BaseComponent { - /** - * @public - */ - extraSettingsEl: HTMLElement; - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - setDisabled(disabled: boolean): this; - /** - * @public - */ - setTooltip(tooltip: string, options?: TooltipOptions): this; - /** - * @param icon - ID of the icon, can use any icon loaded with {@link addIcon} or from the inbuilt library. - * @see The Obsidian icon library includes the {@link https://lucide.dev/ Lucide icon library}, any icon name from their site will work here. - * @public - */ - setIcon(icon: IconName): this; - /** - * @public - */ - onClick(callback: () => any): this; -} - -/** - * Manage the creation, deletion and renaming of files from the UI. - * @public - */ -export class FileManager { - - /** - * Gets the folder that new files should be saved to, given the user's preferences. - * @param sourcePath - The path to the current open/focused file, - * used when the user wants new files to be created "in the same folder". - * Use an empty string if there is no active file. - * @param newFilePath - The path to the file that will be newly created, - * used to infer what settings to use based on the path's extension. - * @public - */ - getNewFileParent(sourcePath: string, newFilePath?: string): TFolder; - - /** - * Rename or move a file safely, and update all links to it depending on the user's preferences. - * @param file - the file to rename - * @param newPath - the new path for the file - * @public - */ - renameFile(file: TAbstractFile, newPath: string): Promise; - - /** - * Generate a markdown link based on the user's preferences. - * @param file - the file to link to. - * @param sourcePath - where the link is stored in, used to compute relative links. - * @param subpath - A subpath, starting with `#`, used for linking to headings or blocks. - * @param alias - The display text if it's to be different than the file name. Pass empty string to use file name. - * @public - */ - generateMarkdownLink(file: TFile, sourcePath: string, subpath?: string, alias?: string): string; - - /** - * Atomically read, modify, and save the frontmatter of a note. - * The frontmatter is passed in as a JS object, and should be mutated directly to achieve the desired result. - * - * Remember to handle errors thrown by this method. - * - * @param file - the file to be modified. Must be a markdown file. - * @param fn - a callback function which mutates the frontmatter object synchronously. - * @param options - write options. - * @throws YAMLParseError if the YAML parsing fails - * @throws any errors that your callback function throws - * @public - */ - processFrontMatter(file: TFile, fn: (frontmatter: any) => void, options?: DataWriteOptions): Promise; - - /** - * Resolves a unique path for the attachment file being saved. - * Ensures that the parent directory exists and dedupes the - * filename if the destination filename already exists. - * - * @param filename Name of the attachment being saved - * @param sourcePath The path to the note associated with this attachment, defaults to the workspace's active file. - * @returns Full path for where the attachment should be saved, according to the user's settings - * @public - */ - getAvailablePathForAttachment(filename: string, sourcePath?: string): Promise; -} - -/** - * @public - */ -export interface FileStats { - /** - * Time of creation, represented as a unix timestamp, in milliseconds. - * @public - */ - ctime: number; - /** - * Time of last modification, represented as a unix timestamp, in milliseconds. - * @public - */ - mtime: number; - /** - * Size on disk, as bytes. - * @public - */ - size: number; -} - -/** - * @public - */ -export class FileSystemAdapter implements DataAdapter { - - /** - * @public - */ - getName(): string; - /** - * @public - */ - getBasePath(): string; - - /** - * @public - */ - mkdir(normalizedPath: string): Promise; - /** - * @public - */ - trashSystem(normalizedPath: string): Promise; - /** - * @public - */ - trashLocal(normalizedPath: string): Promise; - /** - * @public - */ - rmdir(normalizedPath: string, recursive: boolean): Promise; - /** - * @public - */ - read(normalizedPath: string): Promise; - /** - * @public - */ - readBinary(normalizedPath: string): Promise; - /** - * @public - */ - write(normalizedPath: string, data: string, options?: DataWriteOptions): Promise; - /** - * @public - */ - writeBinary(normalizedPath: string, data: ArrayBuffer, options?: DataWriteOptions): Promise; - /** - * @public - */ - append(normalizedPath: string, data: string, options?: DataWriteOptions): Promise; - /** - * @public - */ - process(normalizedPath: string, fn: (data: string) => string, options?: DataWriteOptions): Promise; - - /** - * @public - */ - getResourcePath(normalizedPath: string): string; - /** - * Returns the file:// path of this file - * @public - */ - getFilePath(normalizedPath: string): string; - /** - * @public - */ - remove(normalizedPath: string): Promise; - - /** - * @public - */ - rename(normalizedPath: string, normalizedNewPath: string): Promise; - /** - * @public - */ - copy(normalizedPath: string, normalizedNewPath: string): Promise; - /** - * @public - */ - exists(normalizedPath: string, sensitive?: boolean): Promise; - - /** - * @public - */ - stat(normalizedPath: string): Promise; - /** - * @public - */ - list(normalizedPath: string): Promise; - - /** - * @public - */ - getFullPath(normalizedPath: string): string; - - /** - * @public - */ - static readLocalFile(path: string): Promise; - /** - * @public - */ - static mkdir(path: string): Promise; -} - -/** - * @public - */ -export abstract class FileView extends ItemView { - /** - * @public - */ - allowNoFile: boolean; - /** - * @public - */ - file: TFile | null; - /** - * File views can be navigated by default. - * @inheritDoc - * @public - */ - navigation: boolean; - /** - * @public - */ - constructor(leaf: WorkspaceLeaf); - - /** - * @public - */ - getDisplayText(): string; - /** - * @public - */ - onload(): void; - /** - * @public - */ - getState(): any; - - /** - * @public - */ - setState(state: any, result: ViewStateResult): Promise; - - /** - * @public - */ - onLoadFile(file: TFile): Promise; - /** - * @public - */ - onUnloadFile(file: TFile): Promise; - /** - * @public - */ - onRename(file: TFile): Promise; - - /** - * @public - */ - canAcceptExtension(extension: string): boolean; -} - -/** - * Flush the MathJax stylesheet. - * @public - */ -export function finishRenderMath(): Promise; - -/** - * @public - */ -export interface FrontMatterCache { - /** - * @public - */ - [key: string]: any; -} - -/** @public */ -export interface FrontMatterInfo { - /** @public Whether this file has a frontmatter block */ - exists: boolean; - /** @public String representation of the frontmatter */ - frontmatter: string; - /** @public Start of the frontmatter contents (excluding the ---) */ - from: number; - /** @public End of the frontmatter contents (excluding the ---) */ - to: number; - /** @public Offset where the frontmatter block ends (including the ---) */ - contentStart: number; -} - -/** - * @public - */ -export interface FrontmatterLinkCache extends Reference { - /** - * @public - */ - key: string; -} - -/** - * @public - */ -export interface FuzzyMatch { - /** @public */ - item: T; - /** @public */ - match: SearchResult; -} - -/** - * @public - */ -export function fuzzySearch(q: PreparedQuery, text: string): SearchResult | null; - -/** - * @public - */ -export abstract class FuzzySuggestModal extends SuggestModal> { - /** - * @public - */ - getSuggestions(query: string): FuzzyMatch[]; - /** - * @public - */ - renderSuggestion(item: FuzzyMatch, el: HTMLElement): void; - /** - * @public - */ - onChooseSuggestion(item: FuzzyMatch, evt: MouseEvent | KeyboardEvent): void; - /** - * @public - */ - abstract getItems(): T[]; - /** - * @public - */ - abstract getItemText(item: T): string; - /** - * @public - */ - abstract onChooseItem(item: T, evt: MouseEvent | KeyboardEvent): void; -} - -/** - * @public - */ -export function getAllTags(cache: CachedMetadata): string[] | null; - -/** @public */ -export function getBlobArrayBuffer(blob: Blob): Promise; - -/** - * Given the contents of a file, get information about the frontmatter of the file, including - * whether there is a frontmatter block, the offsets of where it starts and ends, and the frontmatter text. - * - * @public - */ -export function getFrontMatterInfo(content: string): FrontMatterInfo; - -/** - * Create an SVG from an iconId. Returns null if no icon associated with the iconId. - * @param iconId - the icon ID - * @public - */ -export function getIcon(iconId: string): SVGSVGElement | null; - -/** - * Get the list of registered icons. - * @public - */ -export function getIconIds(): IconName[]; - -/** - * @public - */ -export function getLinkpath(linktext: string): string; - -/** - * @public - */ -export interface HeadingCache extends CacheItem { - /** - * @public - */ - heading: string; - /** - * @public - */ - level: number; -} - -/** - * @public - */ -export interface HeadingSubpathResult extends SubpathResult { - /** - * @public - */ - type: 'heading'; - /** - * @public - */ - current: HeadingCache; - /** - * @public - */ - next: HeadingCache; -} - -/** - * Hex strings are 6-digit hash-prefixed rgb strings in lowercase form. - * Example: #ffffff - * @public - */ -export type HexString = string; - -/** @public */ -export function hexToArrayBuffer(hex: string): ArrayBuffer; - -/** - * @public - */ -export interface Hotkey { - /** @public */ - modifiers: Modifier[]; - /** @public */ - key: string; - -} - -/** - * @public - */ -export interface HoverLinkSource { - /** - * The string that will be displayed in the 'Page preview' plugin settings. It should match your plugin's display name. - * @public - */ - display: string; - /** - * Whether or not the `hover-link` event requires the 'Mod' key to be pressed to trigger. - * @public - */ - defaultMod: boolean; -} - -/** - * @public - */ -export interface HoverParent { - /** @public */ - hoverPopover: HoverPopover | null; -} - -/** - * @public - */ -export class HoverPopover extends Component { - - /** - * @public - */ - hoverEl: HTMLElement; - /** - * @public - */ - state: PopoverState; - - /** - * @public - */ - constructor(parent: HoverParent, targetEl: HTMLElement | null, waitTime?: number); - -} - -/** - * @public - */ -export interface HSL { - /** - * Hue integer value between 0 and 360 - * @public - */ - h: number; - /** - * Saturation integer value between 0 and 100 - * @public - */ - s: number; - /** - * Lightness integer value between 0 and 100 - * @public - */ - l: number; -} - -/** - * Converts HTML to Markdown using Turndown Service. - * @public - */ -export function htmlToMarkdown(html: string | HTMLElement | Document | DocumentFragment): string; - -/** - * @public - */ -export interface Instruction { - /** @public */ - command: string; - /** @public */ - purpose: string; -} - -/** - * @public - */ -export interface ISuggestOwner { - /** - * Render the suggestion item into DOM. - * @public - */ - renderSuggestion(value: T, el: HTMLElement): void; - /** - * Called when the user makes a selection. - * @public - */ - selectSuggestion(value: T, evt: MouseEvent | KeyboardEvent): void; - -} - -/** - * @public - */ -export abstract class ItemView extends View { - - /** @public */ - contentEl: HTMLElement; - - /** - * @public - */ - constructor(leaf: WorkspaceLeaf); - - /** - * @public - */ - addAction(icon: IconName, title: string, callback: (evt: MouseEvent) => any): HTMLElement; - -} - -/** - * Iterate links and embeds. If callback returns true, the iteration process will be interrupted. - * @returns true if callback ever returns true, false otherwise. - * @public - * @deprecated - */ -export function iterateCacheRefs(cache: CachedMetadata, cb: (ref: ReferenceCache) => boolean | void): boolean; - -/** - * @returns true if callback ever returns true, false otherwise. - * @public - */ -export function iterateRefs(refs: Reference[], cb: (ref: Reference) => boolean | void): boolean; - -/** - * Manages keymap lifecycle for different {@link Scope}s. - * - * @public - */ -export class Keymap { - - /** - * Push a scope onto the scope stack, setting it as the active scope to handle all key events. - * @public - */ - pushScope(scope: Scope): void; - /** - * Remove a scope from the scope stack. - * If the given scope is active, the next scope in the stack will be made active. - * @public - */ - popScope(scope: Scope): void; - - /** - * Checks whether the modifier key is pressed during this event. - * @public - */ - static isModifier(evt: MouseEvent | TouchEvent | KeyboardEvent, modifier: Modifier): boolean; - - /** - * Translates an event into the type of pane that should open. - * Returns 'tab' if the modifier key Cmd/Ctrl is pressed OR if this is a middle-click MouseEvent. - * Returns 'split' if Cmd/Ctrl+Alt is pressed. - * Returns 'window' if Cmd/Ctrl+Alt+Shift is pressed. - * @public - * */ - static isModEvent(evt?: UserEvent | null): PaneType | boolean; -} - -/** - * @public - */ -export interface KeymapContext extends KeymapInfo { - /** - * Interpreted virtual key. - * @public - */ - vkey: string; -} - -/** - * @public - */ -export interface KeymapEventHandler extends KeymapInfo { - /** @public */ - scope: Scope; - -} - -/** - * Return `false` to automatically preventDefault - * @public - */ -export type KeymapEventListener = (evt: KeyboardEvent, ctx: KeymapContext) => false | any; - -/** - * @public - */ -export interface KeymapInfo { - /** @public */ - modifiers: string | null; - /** @public */ - key: string | null; -} - -/** - * @public - */ -export interface LinkCache extends ReferenceCache { -} - -/** - * @public - */ -export interface ListedFiles { - /** @public */ - files: string[]; - /** @public */ - folders: string[]; -} - -/** - * @public - */ -export interface ListItemCache extends CacheItem { - /** - * The block ID of this list item, if defined. - * @public - */ - id?: string | undefined; - /** - * A single character indicating the checked status of a task. - * The space character `' '` is interpreted as an incomplete task. - * An other character is interpreted as completed task. - * `undefined` if this item isn't a task. - * @public - */ - task?: string | undefined; - /** - * Line number of the parent list item (position.start.line). - * If this item has no parent (e.g. it's a root level list), - * then this value is the negative of the line number of the first list item (start of the list). - * - * Can be used to deduce which list items belongs to the same group (item1.parent === item2.parent). - * Can be used to reconstruct hierarchy information (parentItem.position.start.line === childItem.parent). - * @public - */ - parent: number; -} - -/** - * @public - */ -export interface LivePreviewState { - /** - * True if the left mouse is currently held down in the editor - * (for example, when drag-to-select text). - * @public - */ - mousedown: boolean; -} - -/** - * @public - */ -export const livePreviewState: ViewPlugin; - -/** - * Load MathJax. - * @see {@link https://www.mathjax.org/ Official MathJax documentation} - * @public - */ -export function loadMathJax(): Promise; - -/** - * Load Mermaid and return a promise to the global mermaid object. - * Can also use `mermaid` after this promise resolves to get the same reference. - * @see {@link https://mermaid.js.org/ Official Mermaid documentation} - * @public - */ -export function loadMermaid(): Promise; - -/** - * Load PDF.js and return a promise to the global pdfjsLib object. - * Can also use `window.pdfjsLib` after this promise resolves to get the same reference. - * @see {@link https://mozilla.github.io/pdf.js/ Official PDF.js documentation} - * @public - */ -export function loadPdfJs(): Promise; - -/** - * Load Prism.js and return a promise to the global Prism object. - * Can also use `Prism` after this promise resolves to get the same reference. - * @see {@link https://prismjs.com/ Official Prism documentation} - * @public - */ -export function loadPrism(): Promise; - -/** - * @public - */ -export interface Loc { - /** - * @public - */ - line: number; - /** - * @public - */ - col: number; - /** - * @public - */ - offset: number; -} - -/** - * This is the editor for Obsidian Mobile as well as the upcoming WYSIWYG editor. - * @public - */ -export class MarkdownEditView implements MarkdownSubView, HoverParent, MarkdownFileInfo { - - /** @public */ - app: App; - - /** @public */ - hoverPopover: HoverPopover; - - /** - * @public - */ - constructor(view: MarkdownView); - - /** - * @public - */ - clear(): void; - /** - * @public - */ - get(): string; - /** - * @public - */ - set(data: string, clear: boolean): void; - - /** @public */ - get file(): TFile; - - /** - * @public - */ - getSelection(): string; - - /** - * @public - */ - getScroll(): number; - /** - * @public - */ - applyScroll(scroll: number): void; - -} - -/** - * @public - */ -export interface MarkdownFileInfo extends HoverParent { - /** - * @public - */ - app: App; - /** - * @public - */ - get file(): TFile | null; - - /** - * @public - */ - editor?: Editor; -} - -/** - * A post processor receives an element which is a section of the preview. - * - * Post processors can mutate the DOM to render various things, such as mermaid graphs, latex equations, or custom controls. - * - * If your post processor requires lifecycle management, for example, to clear an interval, kill a subprocess, etc when this element is - * removed from the app, look into {@link MarkdownPostProcessorContext#addChild} - * @public - */ -export interface MarkdownPostProcessor { - /** - * The processor function itself. - * @public - */ - (el: HTMLElement, ctx: MarkdownPostProcessorContext): Promise | void; - /** - * An optional integer sort order. Defaults to 0. Lower number runs before higher numbers. - * @public - */ - sortOrder?: number; -} - -/** - * @public - */ -export interface MarkdownPostProcessorContext { - /** - * @public - */ - docId: string; - /** @public */ - sourcePath: string; - /** @public */ - frontmatter: any | null | undefined; - - /** - * Adds a child component that will have its lifecycle managed by the renderer. - * - * Use this to add a dependent child to the renderer such that if the containerEl - * of the child is ever removed, the component's unload will be called. - * @public - */ - addChild(child: MarkdownRenderChild): void; - /** - * Gets the section information of this element at this point in time. - * Only call this function right before you need this information to get the most up-to-date version. - * This function may also return null in many circumstances; if you use it, you must be prepared to deal with nulls. - * @public - */ - getSectionInfo(el: HTMLElement): MarkdownSectionInformation | null; - -} - -/** @public **/ -export interface MarkdownPreviewEvents extends Component { - -} - -/** - * @public - */ -export class MarkdownPreviewRenderer { - - /** - * @public - */ - static registerPostProcessor(postProcessor: MarkdownPostProcessor, sortOrder?: number): void; - /** - * @public - */ - static unregisterPostProcessor(postProcessor: MarkdownPostProcessor): void; - - /** - * @public - */ - static createCodeBlockPostProcessor(language: string, handler: (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => Promise | void): (el: HTMLElement, ctx: MarkdownPostProcessorContext) => void; - -} - -/** - * @public - */ -export class MarkdownPreviewView extends MarkdownRenderer implements MarkdownSubView, MarkdownPreviewEvents { - - /** - * @public - */ - containerEl: HTMLElement; - - /** - * @public - */ - get file(): TFile; - - /** - * @public - */ - get(): string; - /** - * @public - */ - set(data: string, clear: boolean): void; - /** - * @public - */ - clear(): void; - - /** - * @public - */ - rerender(full?: boolean): void; - - /** - * @public - */ - getScroll(): number; - /** - * @public - */ - applyScroll(scroll: number): void; - -} - -/** - * @public - */ -export class MarkdownRenderChild extends Component { - /** @public */ - containerEl: HTMLElement; - /** - * @param containerEl - This HTMLElement will be used to test whether this component is still alive. - * It should be a child of the markdown preview sections, and when it's no longer attached - * (for example, when it is replaced with a new version because the user edited the markdown source code), - * this component will be unloaded. - * @public - */ - constructor(containerEl: HTMLElement); -} - -/** - * @public - */ -export abstract class MarkdownRenderer extends MarkdownRenderChild implements MarkdownPreviewEvents, HoverParent { - /** @public */ - app: App; - - /** @public */ - hoverPopover: HoverPopover; - - /** @public */ - abstract get file(): TFile; - - /** - * Renders markdown string to an HTML element. - * @public - * @deprecated - use {@link MarkdownRenderer.render} - */ - static renderMarkdown(markdown: string, el: HTMLElement, sourcePath: string, component: Component): Promise; - /** - * Renders markdown string to an HTML element. - * @param app - A reference to the app object - * @param markdown - The markdown source code - * @param el - The element to append to - * @param sourcePath - The normalized path of this markdown file, used to resolve relative internal links - * @param component - A parent component to manage the lifecycle of the rendered child components. - * @public - */ - static render(app: App, markdown: string, el: HTMLElement, sourcePath: string, component: Component): Promise; -} - -/** @public */ -export interface MarkdownSectionInformation { - /** @public */ - text: string; - /** @public */ - lineStart: number; - /** @public */ - lineEnd: number; -} - -/** - * @public - */ -export interface MarkdownSubView { - - /** - * @public - */ - getScroll(): number; - /** - * @public - */ - applyScroll(scroll: number): void; - - /** - * @public - */ - get(): string; - /** - * @public - */ - set(data: string, clear: boolean): void; - -} - -/** - * @public - */ -export class MarkdownView extends TextFileView implements MarkdownFileInfo { - - /** @public */ - editor: Editor; - - /** @public */ - previewMode: MarkdownPreviewView; - - /** @public */ - currentMode: MarkdownSubView; - - /** @public */ - hoverPopover: HoverPopover | null; - /** - * @public - */ - constructor(leaf: WorkspaceLeaf); - - /** - * @public - */ - getViewType(): string; - - /** - * @public - */ - getMode(): MarkdownViewModeType; - - /** - * @public - */ - getViewData(): string; - /** - * @public - */ - clear(): void; - - /** - * @public - */ - setViewData(data: string, clear: boolean): void; - - /** - * @public - */ - showSearch(replace?: boolean): void; - -} - -/** - * @public - */ -export type MarkdownViewModeType = 'source' | 'preview'; - -/** - * @public - */ -export class Menu extends Component implements CloseableComponent { - - /** - * @public - */ - constructor(); - - /** - * @public - */ - setNoIcon(): this; - /** - * Force this menu to use native or DOM. - * (Only works on the desktop app) - * @public - */ - setUseNativeMenu(useNativeMenu: boolean): this; - /** - * Adds a menu item. Only works when menu is not shown yet. - * @public - */ - addItem(cb: (item: MenuItem) => any): this; - /** - * Adds a separator. Only works when menu is not shown yet. - * @public - */ - addSeparator(): this; - - /** - * @public - */ - showAtMouseEvent(evt: MouseEvent): this; - /** - * @public - */ - showAtPosition(position: MenuPositionDef, doc?: Document): this; - /** - * @public - */ - hide(): this; - /** @public */ - close(): void; - /** - * @public - */ - onHide(callback: () => any): void; - -} - -/** - * @public - */ -export class MenuItem { - - /** - * Private constructor. Use {@link Menu.addItem} instead. - * @public - */ - private constructor(); - /** - * @public - */ - setTitle(title: string | DocumentFragment): this; - /** - * @param icon - ID of the icon, can use any icon loaded with {@link addIcon} or from the built-in lucide library. - * @see The Obsidian icon library includes the {@link https://lucide.dev/ Lucide icon library}, any icon name from their site will work here. - * @public - */ - setIcon(icon: IconName | null): this; - - /** - * @public - */ - setChecked(checked: boolean | null): this; - /** - * @public - */ - setDisabled(disabled: boolean): this; - - /** - * @public - */ - setIsLabel(isLabel: boolean): this; - - /** - * @public - */ - onClick(callback: (evt: MouseEvent | KeyboardEvent) => any): this; - - /** - * Sets the section this menu item should belong in. - * To find the section IDs of an existing menu, inspect the DOM elements - * to see their `data-section` attribute. - * @public - */ - setSection(section: string): this; - -} - -/** @public */ -export interface MenuPositionDef { - /** @public */ - x: number; - /** @public */ - y: number; - /** @public */ - width?: number; - /** @public */ - overlap?: boolean; - /** @public */ - left?: boolean; -} - -/** - * @public - */ -export class MenuSeparator { - -} - -/** - * - * Linktext is any internal link that is composed of a path and a subpath, such as "My note#Heading" - * Linkpath (or path) is the path part of a linktext - * Subpath is the heading/block ID part of a linktext. - * - * @public - */ -export class MetadataCache extends Events { - - /** - * Get the best match for a linkpath. - * @public - */ - getFirstLinkpathDest(linkpath: string, sourcePath: string): TFile | null; - - /** - * @public - */ - getFileCache(file: TFile): CachedMetadata | null; - /** - * @public - */ - getCache(path: string): CachedMetadata | null; - - /** - * Generates a linktext for a file. - * - * If file name is unique, use the filename. - * If not unique, use full path. - * @public - */ - fileToLinktext(file: TFile, sourcePath: string, omitMdExtension?: boolean): string; - - /** - * Contains all resolved links. This object maps each source file's path to an object of destination file paths with the link count. - * Source and destination paths are all vault absolute paths that comes from `TFile.path` and can be used with `Vault.getAbstractFileByPath(path)`. - * @public - */ - resolvedLinks: Record>; - /** - * Contains all unresolved links. This object maps each source file to an object of unknown destinations with count. - * Source paths are all vault absolute paths, similar to `resolvedLinks`. - * @public - */ - unresolvedLinks: Record>; - - /** - * Called when a file has been indexed, and its (updated) cache is now available. - * - * Note: This is not called when a file is renamed for performance reasons. - * You must hook the vault rename event for those. - * (Details: https://github.com/obsidianmd/obsidian-api/issues/77) - * @public - */ - on(name: 'changed', callback: (file: TFile, data: string, cache: CachedMetadata) => any, ctx?: any): EventRef; - /** - * Called when a file has been deleted. A best-effort previous version of the cached metadata is presented, - * but it could be null in case the file was not successfully cached previously. - * @public - */ - on(name: 'deleted', callback: (file: TFile, prevCache: CachedMetadata | null) => any, ctx?: any): EventRef; - - /** - * Called when a file has been resolved for `resolvedLinks` and `unresolvedLinks`. - * This happens sometimes after a file has been indexed. - * @public - */ - on(name: 'resolve', callback: (file: TFile) => any, ctx?: any): EventRef; - /** - * Called when all files has been resolved. This will be fired each time files get modified after the initial load. - * @public - */ - on(name: 'resolved', callback: () => any, ctx?: any): EventRef; -} - -/** - * @public - */ -export class Modal implements CloseableComponent { - /** - * @public - */ - app: App; - /** - * @public - */ - scope: Scope; - /** - * @public - */ - containerEl: HTMLElement; - /** - * @public - */ - modalEl: HTMLElement; - /** - * @public - */ - titleEl: HTMLElement; - /** - * @public - */ - contentEl: HTMLElement; - - /** - * @public - */ - shouldRestoreSelection: boolean; - - /** - * @public - */ - constructor(app: App); - /** - * @public - */ - open(): void; - /** - * @public - */ - close(): void; - /** - * @public - */ - onOpen(): void; - /** - * @public - */ - onClose(): void; - - /** - * @public - */ - setTitle(title: string): this; - /** - * @public - */ - setContent(content: string | DocumentFragment): this; - -} - -/** - * Mod = Cmd on MacOS and Ctrl on other OS - * Ctrl = Ctrl key for every OS - * Meta = Cmd on MacOS and Win key on other OS - * @public - */ -export type Modifier = 'Mod' | 'Ctrl' | 'Meta' | 'Shift' | 'Alt'; - -/** @public */ -export const moment: typeof Moment; - - -/** - * @public - */ -export class MomentFormatComponent extends TextComponent { - /** - * @public - */ - sampleEl: HTMLElement; - - /** - * Sets the default format when input is cleared. Also used for placeholder. - * @public - */ - setDefaultFormat(defaultFormat: string): this; - /** - * @public - */ - setSampleEl(sampleEl: HTMLElement): this; - /** - * @public - */ - setValue(value: string): this; - /** - * @public - */ - onChanged(): void; - /** - * @public - */ - updateSample(): void; -} - -/** - * @public - */ -export function normalizePath(path: string): string; - -/** - * Notification component. Use to present timely, high-value information. - * @public - */ -export class Notice { - /** - * @public - */ - noticeEl: HTMLElement; - /** - * @param message - The message to be displayed, can either be a simple string or a {@link DocumentFragment} - * @param duration - Time in milliseconds to show the notice for. If this is 0, the - * Notice will stay visible until the user manually dismisses it. - * @public - */ - constructor(message: string | DocumentFragment, duration?: number); - /** - * Change the message of this notice. - * @public - */ - setMessage(message: string | DocumentFragment): this; - /** - * @public - */ - hide(): void; -} - -/** - * @public - */ -export interface ObsidianProtocolData { - /** @public */ - action: string; - /** @public */ - [key: string]: string; -} - -/** - * @public - */ -export type ObsidianProtocolHandler = (params: ObsidianProtocolData) => any; - -/** - * @public - */ -export interface OpenViewState { - /** @public */ - state?: any; - /** @public */ - eState?: any; - /** @public */ - active?: boolean; - /** @public */ - group?: WorkspaceLeaf; -} - -/** - * @public - */ -export type PaneType = 'tab' | 'split' | 'window'; - -/** - * @public - */ -export function parseFrontMatterAliases(frontmatter: any | null): string[] | null; - -/** - * @public - */ -export function parseFrontMatterEntry(frontmatter: any | null, key: string | RegExp): any | null; - -/** - * @public - */ -export function parseFrontMatterStringArray(frontmatter: any | null, key: string | RegExp, nospaces?: boolean): string[] | null; - -/** - * @public - */ -export function parseFrontMatterTags(frontmatter: any | null): string[] | null; - -/** - * @public - */ -export function parseLinktext(linktext: string): { - /** - * @public - */ - path: string; - /** - * @public - */ - subpath: string; -}; - -/** @public */ -export function parseYaml(yaml: string): any; - -/** @public */ -export const Platform: { - /** - * The UI is in desktop mode. - * @public - */ - isDesktop: boolean; - /** - * The UI is in mobile mode. - * @public - */ - isMobile: boolean; - /** - * We're running the electron-based desktop app. - * @public - */ - isDesktopApp: boolean; - /** - * We're running the capacitor-js mobile app. - * @public - */ - isMobileApp: boolean; - /** - * We're running the iOS app. - * @public - */ - isIosApp: boolean; - /** - * We're running the Android app. - * @public - */ - isAndroidApp: boolean; - /** - * We're in a mobile app that has very limited screen space. - * @public - */ - isPhone: boolean; - /** - * We're in a mobile app that has sufficiently large screen space. - * @public - */ - isTablet: boolean; - /** - * We're on a macOS device, or a device that pretends to be one (like iPhones and iPads). - * Typically used to detect whether to use command-based hotkeys vs ctrl-based hotkeys. - * @public - */ - isMacOS: boolean; - /** - * We're on a Windows device. - * @public - */ - isWin: boolean; - /** - * We're on a Linux device. - * @public - */ - isLinux: boolean; - /** - * We're running in Safari. - * Typically used to provide workarounds for Safari bugs. - * @public - */ - isSafari: boolean; - /** - * The path prefix for resolving local files on this platform. - * This returns: - * - `file:///` on mobile - * - `app://random-id/` on desktop (Replaces the old format of `app://local/`) - * @public - */ - resourcePathPrefix: string; - -}; - -/** - * @public - */ -export abstract class Plugin extends Component { - - /** - * @public - */ - app: App; - /** - * @public - */ - manifest: PluginManifest; - /** - * @public - */ - constructor(app: App, manifest: PluginManifest); - /** - * Adds a ribbon icon to the left bar. - * @param icon - The icon name to be used. See {@link addIcon} - * @param title - The title to be displayed in the tooltip. - * @param callback - The `click` callback. - * @public - */ - addRibbonIcon(icon: IconName, title: string, callback: (evt: MouseEvent) => any): HTMLElement; - /** - * Adds a status bar item to the bottom of the app. - * Not available on mobile. - * @see {@link https://docs.obsidian.md/Plugins/User+interface/Status+bar} - * @return HTMLElement - element to modify. - * @public - */ - addStatusBarItem(): HTMLElement; - /** - * Register a command globally. - * Registered commands will be available from the @{link https://help.obsidian.md/Plugins/Command+palette Command pallete}. - * The command id and name will be automatically prefixed with this plugin's id and name. - * @public - */ - addCommand(command: Command): Command; - /** - * Register a settings tab, which allows users to change settings. - * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings#Register+a+settings+tab} - * @public - */ - addSettingTab(settingTab: PluginSettingTab): void; - /** - * @public - */ - registerView(type: string, viewCreator: ViewCreator): void; - /** - * Registers a view with the 'Page preview' core plugin as an emitter of the 'hover-link' on the event. - * @public - */ - registerHoverLinkSource(id: string, info: HoverLinkSource): void; - /** - * @public - */ - registerExtensions(extensions: string[], viewType: string): void; - /** - * Registers a post processor, to change how the document looks in reading mode. - * @see {@link https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing} - * @public - */ - registerMarkdownPostProcessor(postProcessor: MarkdownPostProcessor, sortOrder?: number): MarkdownPostProcessor; - /** - * Register a special post processor that handles fenced code given a language and a handler. - * This special post processor takes care of removing the
 and create a 
that - * will be passed to the handler, and is expected to be filled with custom elements. - * @see {@link https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing#Post-process+Markdown+code+blocks} - * @public - */ - registerMarkdownCodeBlockProcessor(language: string, handler: (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => Promise | void, sortOrder?: number): MarkdownPostProcessor; - - /** - * Registers a CodeMirror 6 extension. - * To reconfigure cm6 extensions for a plugin on the fly, an array should be passed in, and modified dynamically. - * Once this array is modified, calling {@link Workspace.updateOptions} will apply the changes. - * @param extension - must be a CodeMirror 6 `Extension`, or an array of Extensions. - * @public - */ - registerEditorExtension(extension: Extension): void; - /** - * Register a handler for obsidian:// URLs. - * @param action - the action string. For example, "open" corresponds to `obsidian://open`. - * @param handler - the callback to trigger. A key-value pair that is decoded from the query will be passed in. - * For example, `obsidian://open?key=value` would generate `{"action": "open", "key": "value"}`. - * @public - */ - registerObsidianProtocolHandler(action: string, handler: ObsidianProtocolHandler): void; - /** - * Register an EditorSuggest which can provide live suggestions while the user is typing. - * @public - */ - registerEditorSuggest(editorSuggest: EditorSuggest): void; - /** - * Load settings data from disk. - * Data is stored in `data.json` in the plugin folder. - * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings} - * @public - */ - loadData(): Promise; - /** - * Write settings data to disk. - * Data is stored in `data.json` in the plugin folder. - * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings} - * @public - */ - saveData(data: any): Promise; - - /** - * Called when the `data.json` file is modified on disk externally from Obsidian. - * This usually means that a Sync service or external program has modified - * the plugin settings. - * - * Implement this method to reload plugin settings when they have changed externally. - * - * @public - */ - onExternalSettingsChange?(): any; -} - - -/** - * Metadata about a Community plugin. - * @see {@link https://docs.obsidian.md/Reference/Manifest} - * @public - */ -export interface PluginManifest { - /** - * Vault path to the plugin folder in the config directory. - * @public - */ - dir?: string; - /** - * The plugin ID. - * @public - */ - id: string; - /** - * The display name. - * @public - */ - name: string; - /** - * The author's name. - * @public - */ - author: string; - /** - * The current version, using {@link https://semver.org/ Semantic Versioning}. - * @public - */ - version: string; - /** - * The minimum required Obsidian version to run this plugin. - * @public - */ - minAppVersion: string; - /** - * A description of the plugin. - * @public - */ - description: string; - /** - * A URL to the author's website. - * @public - */ - authorUrl?: string; - - /** - * Whether the plugin can be used only on desktop. - * @public - */ - isDesktopOnly?: boolean; -} - -/** - * Provides a unified interface for users to configure the plugin. - * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings#Register+a+settings+tab} - * @public - */ -export abstract class PluginSettingTab extends SettingTab { - - /** - * @public - */ - constructor(app: App, plugin: Plugin); -} - -/** - * @public - */ -export interface Point { - /** - * @public - */ - x: number; - /** - * @public - */ - y: number; -} - -/** - * @public - */ -export enum PopoverState { - -} - -/** - * Base class for adding a type-ahead popover. - * @public - */ -export abstract class PopoverSuggest implements ISuggestOwner, CloseableComponent { - /** @public */ - app: App; - /** @public */ - scope: Scope; - - /** @public */ - constructor(app: App, scope?: Scope); - /** @public */ - open(): void; - /** @public */ - close(): void; - - /** - * @inheritDoc - * @public - */ - abstract renderSuggestion(value: T, el: HTMLElement): void; - /** - * @inheritDoc - * @public - */ - abstract selectSuggestion(value: T, evt: MouseEvent | KeyboardEvent): void; -} - -/** - * @public - */ -export interface Pos { - /** - * @public - */ - start: Loc; - /** - * @public - */ - end: Loc; -} - -/** - * @public - */ -export interface PreparedQuery { - /** @public */ - query: string; - /** @public */ - tokens: string[]; - /** @public */ - fuzzy: string[]; -} - -/** - * Construct a fuzzy search callback that runs on a target string. - * Performance may be an issue if you are running the search for more than a few thousand times. - * If performance is a problem, consider using `prepareSimpleSearch` instead. - * @param query - the fuzzy query. - * @return fn - the callback function to apply the search on. - * @public - */ -export function prepareFuzzySearch(query: string): (text: string) => SearchResult | null; - -/** - * @public - */ -export function prepareQuery(query: string): PreparedQuery; - -/** - * Construct a simple search callback that runs on a target string. - * @param query - the space-separated words - * @return fn - the callback function to apply the search on - * @public - */ -export function prepareSimpleSearch(query: string): (text: string) => SearchResult | null; - -/** - * @public - */ -export class ProgressBarComponent extends ValueComponent { - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - getValue(): number; - /** - * @param value - The progress amount, a value between 0-100. - * @public - */ - setValue(value: number): this; - -} - -/** - * @public - */ -export interface Reference { - /** - * @public - */ - link: string; - /** - * @public - */ - original: string; - /** - * if title is different than link text, in the case of [[page name|display name]] - * @public - */ - displayText?: string; -} - -/** - * @public - */ -export interface ReferenceCache extends Reference, CacheItem { -} - -/** - * Remove a custom icon from the library. - * @param iconId - the icon ID - * @public - */ -export function removeIcon(iconId: string): void; - -/** - * @public - */ -export function renderMatches(el: HTMLElement | DocumentFragment, text: string, matches: SearchMatches | null, offset?: number): void; - -/** - * Render some LaTeX math using the MathJax engine. Returns an HTMLElement. - * Requires calling `finishRenderMath` when rendering is all done to flush the MathJax stylesheet. - * @public - */ -export function renderMath(source: string, display: boolean): HTMLElement; - -/** - * @public - */ -export function renderResults(el: HTMLElement, text: string, result: SearchResult, offset?: number): void; - -/** - * Similar to `fetch()`, request a URL using HTTP/HTTPS, without any CORS restrictions. - * Returns the text value of the response. - * @public - */ -export function request(request: RequestUrlParam | string): Promise; - -/** - * Similar to `fetch()`, request a URL using HTTP/HTTPS, without any CORS restrictions. - * @public - */ -export function requestUrl(request: RequestUrlParam | string): RequestUrlResponsePromise; - -/** @public */ -export interface RequestUrlParam { - /** @public */ - url: string; - /** @public */ - method?: string; - /** @public */ - contentType?: string; - /** @public */ - body?: string | ArrayBuffer; - /** @public */ - headers?: Record; - /** - * Whether to throw an error when the status code is 400+ - * Defaults to true - * @public - */ - throw?: boolean; -} - -/** @public */ -export interface RequestUrlResponse { - /** @public */ - status: number; - /** @public */ - headers: Record; - /** @public */ - arrayBuffer: ArrayBuffer; - /** @public */ - json: any; - /** @public */ - text: string; -} - -/** @public */ -export interface RequestUrlResponsePromise extends Promise { - /** @public */ - arrayBuffer: Promise; - /** @public */ - json: Promise; - /** @public */ - text: Promise; -} - -/** - * Returns true if the API version is equal or higher than the requested version. - * Use this to limit functionality that require specific API versions to avoid - * crashing on older Obsidian builds. - * @public - */ -export function requireApiVersion(version: string): boolean; - -/** - * @public - */ -export function resolveSubpath(cache: CachedMetadata, subpath: string): HeadingSubpathResult | BlockSubpathResult | null; - -/** - * @public - */ -export interface RGB { - /** - * Red integer value between 0 and 255 - * @public - */ - r: number; - /** - * Green integer value between 0 and 255 - * @public - */ - g: number; - /** - * Blue integer value between 0 and 255 - * @public - */ - b: number; -} - -/** @public */ -export function sanitizeHTMLToDom(html: string): DocumentFragment; - -/** - * A scope receives keyboard events and binds callbacks to given hotkeys. - * Only one scope is active at a time, but scopes may define parent scopes (in the constructor) and inherit their hotkeys. - * @public - */ -export class Scope { - - /** - * @public - */ - constructor(parent?: Scope); - /** - * Add a keymap event handler to this scope. - * @param modifiers - `Mod`, `Ctrl`, `Meta`, `Shift`, or `Alt`. `Mod` translates to `Meta` on macOS and `Ctrl` otherwise. - * @param key - Keycode from https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key%5FValues - * @param func - the callback that will be called when a user triggers the keybind. - * @public - */ - register(modifiers: Modifier[], key: string | null, func: KeymapEventListener): KeymapEventHandler; - /** - * Remove an existing keymap event handler. - * @public - */ - unregister(handler: KeymapEventHandler): void; - -} - -/** - * @public - */ -export class SearchComponent extends AbstractTextComponent { - /** - * @public - */ - clearButtonEl: HTMLElement; - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - onChanged(): void; - -} - -/** - * @public - */ -export type SearchMatches = SearchMatchPart[]; - -/** - * Text position offsets within text file. Represents - * a text range [from offset, to offset]. - * - * @public - */ -export type SearchMatchPart = [number, number]; - -/** - * @public - */ -export interface SearchResult { - /** @public */ - score: number; - /** @public */ - matches: SearchMatches; -} - -/** - * @public - */ -export interface SearchResultContainer { - /** @public */ - match: SearchResult; -} - -/** - * @public - */ -export interface SectionCache extends CacheItem { - /** - * The block ID of this section, if defined. - * @public - */ - id?: string | undefined; - /** - * The type string generated by the parser. - * @public - */ - type: string; -} - -/** - * Insert an SVG into the element from an iconId. Does nothing if no icon associated with the iconId. - * @param parent - the HTML element to insert the icon - * @param iconId - the icon ID - * @see The Obsidian icon library includes the {@link https://lucide.dev/ Lucide icon library}, any icon name from their site will work here. - * @public - */ -export function setIcon(parent: HTMLElement, iconId: IconName): void; - -/** - * @public - */ -export class Setting { - /** @public */ - settingEl: HTMLElement; - /** @public */ - infoEl: HTMLElement; - /** @public */ - nameEl: HTMLElement; - /** @public */ - descEl: HTMLElement; - /** @public */ - controlEl: HTMLElement; - /** @public */ - components: BaseComponent[]; - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - setName(name: string | DocumentFragment): this; - /** - * @public - */ - setDesc(desc: string | DocumentFragment): this; - /** - * @public - */ - setClass(cls: string): this; - /** - * @public - */ - setTooltip(tooltip: string, options?: TooltipOptions): this; - /** - * @public - */ - setHeading(): this; - /** - * @public - */ - setDisabled(disabled: boolean): this; - - /** - * @public - */ - addButton(cb: (component: ButtonComponent) => any): this; - /** - * @public - */ - addExtraButton(cb: (component: ExtraButtonComponent) => any): this; - /** - * @public - */ - addToggle(cb: (component: ToggleComponent) => any): this; - /** - * @public - */ - addText(cb: (component: TextComponent) => any): this; - /** - * @public - */ - addSearch(cb: (component: SearchComponent) => any): this; - /** - * @public - */ - addTextArea(cb: (component: TextAreaComponent) => any): this; - /** - * @public - */ - addMomentFormat(cb: (component: MomentFormatComponent) => any): this; - /** - * @public - */ - addDropdown(cb: (component: DropdownComponent) => any): this; - /** - * @public - */ - addColorPicker(cb: (component: ColorComponent) => any): this; - /** - * @public - */ - addProgressBar(cb: (component: ProgressBarComponent) => any): this; - /** - * @public - */ - addSlider(cb: (component: SliderComponent) => any): this; - /** - * Facilitates chaining - * @public - */ - then(cb: (setting: this) => any): this; - /** - * @public - */ - clear(): this; - -} - -/** - * @public - * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings#Register+a+settings+tab} - */ -export abstract class SettingTab { - - /** - * Reference to the app instance. - * @public - */ - app: App; - - /** - * Outermost HTML element on the setting tab. - * @public - */ - containerEl: HTMLElement; - - /** - * Called when the settings tab should be rendered. - * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings#Register+a+settings+tab} - * @public - */ - abstract display(): any; - /** - * Hides the contents of the setting tab. - * Any registered components should be unloaded when the view is hidden. - * Override this if you need to perform additional cleanup. - * @public - */ - hide(): any; -} - -/** - * @param el - The element to show the tooltip on - * @param tooltip - The tooltip text to show - * @param options - * @public - */ -export function setTooltip(el: HTMLElement, tooltip: string, options?: TooltipOptions): void; - -/** - * @public - */ -export class SliderComponent extends ValueComponent { - /** - * @public - */ - sliderEl: HTMLInputElement; - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - setDisabled(disabled: boolean): this; - /** - * @public - */ - setLimits(min: number, max: number, step: number | 'any'): this; - /** - * @public - */ - getValue(): number; - /** - * @public - */ - setValue(value: number): this; - /** - * @public - */ - getValuePretty(): string; - /** - * @public - */ - setDynamicTooltip(): this; - /** - * @public - */ - showTooltip(): void; - /** - * @public - */ - onChange(callback: (value: number) => any): this; -} - -/** - * @public - */ -export function sortSearchResults(results: SearchResultContainer[]): void; - -/** - * @public - */ -export type SplitDirection = 'vertical' | 'horizontal'; - -/** @public */ -export interface Stat { - /** @public */ - type: 'file' | 'folder'; - /** - * Time of creation, represented as a unix timestamp. - * @public - * */ - ctime: number; - /** - * Time of last modification, represented as a unix timestamp. - * @public - */ - mtime: number; - /** - * Size on disk, as bytes. - * @public - */ - size: number; -} - -/** @public */ -export function stringifyYaml(obj: any): string; - -/** - * This function normalizes headings for link matching by stripping out special characters and shrinking consecutive spaces. - * @public - */ -export function stripHeading(heading: string): string; - -/** - * This function prepares headings for linking. It strips out some bad combinations of special characters that could break links. - * @public - */ -export function stripHeadingForLink(heading: string): string; - -/** - * @public - */ -export interface SubpathResult { - /** - * @public - */ - start: Loc; - /** - * @public - */ - end: Loc | null; -} - -/** - * @public - */ -export abstract class SuggestModal extends Modal implements ISuggestOwner { - /** - * @public - */ - limit: number; - /** - * @public - */ - emptyStateText: string; - - /** - * @public - */ - inputEl: HTMLInputElement; - - /** - * @public - */ - resultContainerEl: HTMLElement; - /** - * @public - */ - constructor(app: App); - /** - * @public - */ - setPlaceholder(placeholder: string): void; - /** - * @public - */ - setInstructions(instructions: Instruction[]): void; - - /** - * @public - */ - onNoSuggestion(): void; - /** - * @public - */ - selectSuggestion(value: T, evt: MouseEvent | KeyboardEvent): void; - /** - * @public - */ - abstract getSuggestions(query: string): T[] | Promise; - /** - * @public - */ - abstract renderSuggestion(value: T, el: HTMLElement): any; - /** - * @public - */ - abstract onChooseSuggestion(item: T, evt: MouseEvent | KeyboardEvent): any; -} - -/** - * This can be either a `TFile` or a `TFolder`. - * @public - */ -export abstract class TAbstractFile { - /** - * @public - */ - vault: Vault; - /** - * @public - */ - path: string; - /** - * @public - */ - name: string; - /** - * @public - */ - parent: TFolder | null; - -} - -/** - * @public - */ -export interface TagCache extends CacheItem { - /** - * @public - */ - tag: string; -} - -/** - * @public - */ -export class Tasks { - - /** - * @public - */ - add(callback: () => Promise): void; - /** - * @public - */ - addPromise(promise: Promise): void; - /** - * @public - */ - isEmpty(): boolean; - /** - * @public - */ - promise(): Promise; -} - -/** - * @public - */ -export class TextAreaComponent extends AbstractTextComponent { - /** - * @public - */ - constructor(containerEl: HTMLElement); -} - -/** - * @public - */ -export class TextComponent extends AbstractTextComponent { - /** - * @public - */ - constructor(containerEl: HTMLElement); -} - -/** - * This class implements a plaintext-based editable file view, which can be loaded and saved given an editor. - * - * Note that by default, this view only saves when it's closing. To implement auto-save, your editor should - * call `this.requestSave()` when the content is changed. - * @public - */ -export abstract class TextFileView extends EditableFileView { - - /** - * In memory data - * @public - */ - data: string; - /** - * Debounced save in 2 seconds from now - * @public - */ - requestSave: () => void; - - /** - * @public - */ - constructor(leaf: WorkspaceLeaf); - - /** - * @public - */ - onUnloadFile(file: TFile): Promise; - /** - * @public - */ - onLoadFile(file: TFile): Promise; - - /** - * @public - */ - save(clear?: boolean): Promise; - - /** - * Gets the data from the editor. This will be called to save the editor contents to the file. - * @public - */ - abstract getViewData(): string; - /** - * Set the data to the editor. This is used to load the file contents. - * - * If clear is set, then it means we're opening a completely different file. - * In that case, you should call clear(), or implement a slightly more efficient - * clearing mechanism given the new data to be set. - * @public - */ - abstract setViewData(data: string, clear: boolean): void; - /** - * Clear the editor. This is usually called when we're about to open a completely - * different file, so it's best to clear any editor states like undo-redo history, - * and any caches/indexes associated with the previous file contents. - * @public - */ - abstract clear(): void; -} - -/** - * @public - */ -export class TFile extends TAbstractFile { - /** - * @public - */ - stat: FileStats; - /** - * @public - */ - basename: string; - /** - * @public - */ - extension: string; - -} - -/** - * @public - */ -export class TFolder extends TAbstractFile { - /** - * @public - */ - children: TAbstractFile[]; - - /** - * @public - */ - isRoot(): boolean; - -} - -/** - * @public - */ -export class ToggleComponent extends ValueComponent { - /** - * @public - */ - toggleEl: HTMLElement; - - /** - * @public - */ - constructor(containerEl: HTMLElement); - /** - * @public - */ - setDisabled(disabled: boolean): this; - /** - * @public - */ - getValue(): boolean; - /** - * @public - */ - setValue(on: boolean): this; - - /** - * @public - */ - setTooltip(tooltip: string, options?: TooltipOptions): this; - /** - * @public - */ - onClick(): void; - /** - * @public - */ - onChange(callback: (value: boolean) => any): this; -} - -/** @public */ -export interface TooltipOptions { - /** @public */ - placement?: TooltipPlacement; - - /** @public */ - delay?: number; -} - -/** @public */ -export type TooltipPlacement = 'bottom' | 'right' | 'left' | 'top'; - -/** @public */ -export type UserEvent = MouseEvent | KeyboardEvent | TouchEvent | PointerEvent; - -/** - * @public - */ -export abstract class ValueComponent extends BaseComponent { - /** - * @public - */ - registerOptionListener(listeners: Record T>, key: string): this; - /** - * @public - */ - abstract getValue(): T; - /** - * @public - */ - abstract setValue(value: T): this; -} - -/** - * Work with files and folders stored inside a vault. - * @see {@link https://docs.obsidian.md/Plugins/Vault} - * @public - */ -export class Vault extends Events { - /** - * @public - */ - adapter: DataAdapter; - - /** - * Gets the path to the config folder. - * This value is typically `.obsidian` but it could be different. - * @public - */ - configDir: string; - - /** - * Gets the name of the vault. - * @public - */ - getName(): string; - - /** - * Get a file inside the vault at the given path. - * Returns `null` if the file does not exist. - * - * @param path - * @public - */ - getFileByPath(path: string): TFile | null; - /** - * Get a folder inside the vault at the given path. - * Returns `null` if the folder does not exist. - * - * @param path - * @public - */ - getFolderByPath(path: string): TFolder | null; - /** - * Get a file or folder inside the vault at the given path. To check if the return type is - * a file, use `instanceof TFile`. To check if it is a folder, use `instanceof TFolder`. - * @param path - vault absolute path to the folder or file, with extension, case sensitive. - * @returns the abstract file, if it's found. - * @public - */ - getAbstractFileByPath(path: string): TAbstractFile | null; - - /** - * Get the root folder of the current vault. - * @public - */ - getRoot(): TFolder; - - /** - * Create a new plaintext file inside the vault. - * @param path - Vault absolute path for the new file, with extension. - * @param data - text content for the new file. - * @param options - (Optional) - * @public - */ - create(path: string, data: string, options?: DataWriteOptions): Promise; - /** - * Create a new binary file inside the vault. - * @param path - Vault absolute path for the new file, with extension. - * @param data - content for the new file. - * @param options - (Optional) - * @throws Error if file already exists - * @public - */ - createBinary(path: string, data: ArrayBuffer, options?: DataWriteOptions): Promise; - /** - * Create a new folder inside the vault. - * @param path - Vault absolute path for the new folder. - * @throws Error if folder already exists - * @public - */ - createFolder(path: string): Promise; - /** - * Read a plaintext file that is stored inside the vault, directly from disk. - * Use this if you intend to modify the file content afterwards. - * Use {@link Vault.cachedRead} otherwise for better performance. - * @public - */ - read(file: TFile): Promise; - /** - * Read the content of a plaintext file stored inside the vault - * Use this if you only want to display the content to the user. - * If you want to modify the file content afterward use {@link Vault.read} - * @public - */ - cachedRead(file: TFile): Promise; - /** - * Read the content of a binary file stored inside the vault. - * @public - */ - readBinary(file: TFile): Promise; - - /** - * Returns an URI for the browser engine to use, for example to embed an image. - * @public - */ - getResourcePath(file: TFile): string; - /** - * Deletes the file completely. - * @param file - The file or folder to be deleted - * @param force - Should attempt to delete folder even if it has hidden children - * @public - */ - delete(file: TAbstractFile, force?: boolean): Promise; - /** - * Tries to move to system trash. If that isn't successful/allowed, use local trash - * @param file - The file or folder to be deleted - * @param system - Set to `false` to use local trash by default. - * @public - */ - trash(file: TAbstractFile, system: boolean): Promise; - /** - * Rename or move a file. - * @param file - the file to rename/move - * @param newPath - vault absolute path to move file to. - * @public - */ - rename(file: TAbstractFile, newPath: string): Promise; - /** - * Modify the contents of a plaintext file. - * @param file - The file - * @param data - The new file content - * @param options - (Optional) - * @public - */ - modify(file: TFile, data: string, options?: DataWriteOptions): Promise; - /** - * Modify the contents of a binary file. - * @param file - The file - * @param data - The new file content - * @param options - (Optional) - * @public - */ - modifyBinary(file: TFile, data: ArrayBuffer, options?: DataWriteOptions): Promise; - /** - * Add text to the end of a plaintext file inside the vault. - * @param file - The file - * @param data - the text to add - * @param options - (Optional) - * @public - */ - append(file: TFile, data: string, options?: DataWriteOptions): Promise; - /** - * Atomically read, modify, and save the contents of a note. - * @param file - the file to be read and modified. - * @param fn - a callback function which returns the new content of the note synchronously. - * @param options - write options. - * @returns string - the text value of the note that was written. - * @public - */ - process(file: TFile, fn: (data: string) => string, options?: DataWriteOptions): Promise; - /** - * Create a copy of the selected file. - * @param file - The file - * @param newPath - Vault absolute path for the new copy. - * @public - */ - copy(file: TFile, newPath: string): Promise; - /** - * Get all files and folders in the vault. - * @public - */ - getAllLoadedFiles(): TAbstractFile[]; - - /** - * @public - */ - static recurseChildren(root: TFolder, cb: (file: TAbstractFile) => any): void; - /** - * Get all markdown files in the vault. - * @public - */ - getMarkdownFiles(): TFile[]; - /** - * Get all files in the vault. - * @public - */ - getFiles(): TFile[]; - - /** - * Called when a file is created. - * This is also called when the vault is first loaded for each existing file - * If you do not wish to receive create events on vault load, register your event handler inside {@link Workspace.onLayoutReady}. - * @public - */ - on(name: 'create', callback: (file: TAbstractFile) => any, ctx?: any): EventRef; - /** - * Called when a file is modified. - * @public - */ - on(name: 'modify', callback: (file: TAbstractFile) => any, ctx?: any): EventRef; - /** - * Called when a file is deleted. - * @public - */ - on(name: 'delete', callback: (file: TAbstractFile) => any, ctx?: any): EventRef; - /** - * Called when a file is renamed. - * @public - */ - on(name: 'rename', callback: (file: TAbstractFile, oldPath: string) => any, ctx?: any): EventRef; - -} - -/** - * @public - */ -export abstract class View extends Component { - /** - * @public - */ - app: App; - /** - * @public - */ - icon: IconName; - /** - * Whether or not the view is intended for navigation. - * If your view is a static view that is not intended to be navigated away, set this to false. - * (For example: File explorer, calendar, etc.) - * If your view opens a file or can be otherwise navigated, set this to true. - * (For example: Markdown editor view, Kanban view, PDF view, etc.) - * - * @public - */ - navigation: boolean; - - /** - * @public - */ - leaf: WorkspaceLeaf; - /** - * @public - */ - containerEl: HTMLElement; - /** - * Assign an optional scope to your view to register hotkeys for when the view - * is in focus. - * - * @example - * ```ts - * this.scope = new Scope(this.app.scope); - * ``` - * @default null - * @public - */ - scope: Scope | null; - /** - * @public - */ - constructor(leaf: WorkspaceLeaf); - - /** - * @public - */ - protected onOpen(): Promise; - /** - * @public - */ - protected onClose(): Promise; - /** - * @public - */ - abstract getViewType(): string; - /** - * @public - */ - getState(): any; - /** - * @public - */ - setState(state: any, result: ViewStateResult): Promise; - /** - * @public - */ - getEphemeralState(): any; - /** - * @public - */ - setEphemeralState(state: any): void; - /** - * @public - */ - getIcon(): IconName; - /** - * Called when the size of this view is changed. - * @public - */ - onResize(): void; - /** - * @public - */ - abstract getDisplayText(): string; - /** - * Populates the pane menu. - * - * (Replaces the previously removed `onHeaderMenu` and `onMoreOptionsMenu`) - * @public - */ - onPaneMenu(menu: Menu, source: 'more-options' | 'tab-header' | string): void; - -} - -/** - * @public - */ -export type ViewCreator = (leaf: WorkspaceLeaf) => View; - -/** - * @public - */ -export interface ViewState { - - /** - * @public - */ - type: string; - /** - * @public - */ - state?: any; - /** - * @public - */ - active?: boolean; - /** - * @public - */ - pinned?: boolean; - /** - * @public - */ - group?: WorkspaceLeaf; -} - -/** - * @public - */ -export interface ViewStateResult { - /** - * Set this to true to indicate that there is a state change which should be recorded in the navigation history. - * @public - */ - history: boolean; - -} - -/** - * @public - */ -export class Workspace extends Events { - - /** - * @public - */ - leftSplit: WorkspaceSidedock | WorkspaceMobileDrawer; - /** - * @public - */ - rightSplit: WorkspaceSidedock | WorkspaceMobileDrawer; - /** - * @public - */ - leftRibbon: WorkspaceRibbon; - /** - * @public - */ - rightRibbon: WorkspaceRibbon; - /** - * @public - */ - rootSplit: WorkspaceRoot; - - /** - * Indicates the currently focused leaf, if one exists. - * - * Please avoid using `activeLeaf` directly, especially without checking whether - * `activeLeaf` is null. - * - * The recommended alternatives are: - * - If you need information about the current view, use {@link Workspace.getActiveViewOfType}. - * - If you need to open a new file or navigate a view, use {@link Workspace.getLeaf}. - * - * @public - * @deprecated - The use of this field is discouraged. - */ - activeLeaf: WorkspaceLeaf | null; - - /** - * @public - */ - containerEl: HTMLElement; - /** - * @public - */ - layoutReady: boolean; - /** - * @public - */ - requestSaveLayout: Debouncer<[], Promise>; - - /** - * A component managing the current editor. This can be null - * if the active view has no editor. - * @public - */ - activeEditor: MarkdownFileInfo | null; - - /** - * Runs the callback function right away if layout is already ready, - * or push it to a queue to be called later when layout is ready. - * @public - * */ - onLayoutReady(callback: () => any): void; - /** - * @public - */ - changeLayout(workspace: any): Promise; - - /** - * @public - */ - getLayout(): any; - - /** - * @public - */ - createLeafInParent(parent: WorkspaceSplit, index: number): WorkspaceLeaf; - - /** - * @public - */ - createLeafBySplit(leaf: WorkspaceLeaf, direction?: SplitDirection, before?: boolean): WorkspaceLeaf; - /** - * @public - * @deprecated - You should use {@link Workspace.getLeaf|getLeaf(true)} instead which does the same thing. - */ - splitActiveLeaf(direction?: SplitDirection): WorkspaceLeaf; - - /** - * @public - * @deprecated - Use the new form of this method instead - */ - duplicateLeaf(leaf: WorkspaceLeaf, direction?: SplitDirection): Promise; - /** - * @public - */ - duplicateLeaf(leaf: WorkspaceLeaf, leafType: PaneType | boolean, direction?: SplitDirection): Promise; - /** - * @public - * @deprecated - You should use {@link Workspace.getLeaf|getLeaf(false)} instead which does the same thing. - */ - getUnpinnedLeaf(): WorkspaceLeaf; - /** - * Creates a new leaf in a leaf adjacent to the currently active leaf. - * If direction is `'vertical'`, the leaf will appear to the right. - * If direction is `'horizontal'`, the leaf will appear below the current leaf. - * - * @public - */ - getLeaf(newLeaf?: 'split', direction?: SplitDirection): WorkspaceLeaf; - /** - * If newLeaf is false (or not set) then an existing leaf which can be navigated - * is returned, or a new leaf will be created if there was no leaf available. - * - * If newLeaf is `'tab'` or `true` then a new leaf will be created in the preferred - * location within the root split and returned. - * - * If newLeaf is `'split'` then a new leaf will be created adjacent to the currently active leaf. - * - * If newLeaf is `'window'` then a popout window will be created with a new leaf inside. - * - * @public - */ - getLeaf(newLeaf?: PaneType | boolean): WorkspaceLeaf; - - /** - * Migrates this leaf to a new popout window. - * Only works on the desktop app. - * @public - */ - moveLeafToPopout(leaf: WorkspaceLeaf, data?: WorkspaceWindowInitData): WorkspaceWindow; - - /** - * Open a new popout window with a single new leaf and return that leaf. - * Only works on the desktop app. - * @public - */ - openPopoutLeaf(data?: WorkspaceWindowInitData): WorkspaceLeaf; - /** - * @public - */ - openLinkText(linktext: string, sourcePath: string, newLeaf?: PaneType | boolean, openViewState?: OpenViewState): Promise; - /** - * Sets the active leaf - * @param leaf - The new active leaf - * @param params - Parameter object of whether to set the focus. - * @public - */ - setActiveLeaf(leaf: WorkspaceLeaf, params?: { - /** @public */ - focus?: boolean; - }): void; - /** - * @deprecated - function signature changed. Use other form instead - * @public - */ - setActiveLeaf(leaf: WorkspaceLeaf, pushHistory: boolean, focus: boolean): void; - - /** - * @public - */ - getLeafById(id: string): WorkspaceLeaf | null; - /** - * @public - */ - getGroupLeaves(group: string): WorkspaceLeaf[]; - - /** - * @public - */ - getMostRecentLeaf(root?: WorkspaceParent): WorkspaceLeaf | null; - /** - * @public - */ - getLeftLeaf(split: boolean): WorkspaceLeaf | null; - /** - * @public - */ - getRightLeaf(split: boolean): WorkspaceLeaf | null; - - /** - * @public - */ - getActiveViewOfType(type: Constructor): T | null; - - /** - * Returns the file for the current view if it's a FileView. - * - * Otherwise, it will recent the most recently active file. - * - * @public - */ - getActiveFile(): TFile | null; - - /** - * Iterate through all leaves in the main area of the workspace. - * @public - */ - iterateRootLeaves(callback: (leaf: WorkspaceLeaf) => any): void; - /** - * Iterate through all leaves, including main area leaves, floating leaves, and sidebar leaves. - * @public - */ - iterateAllLeaves(callback: (leaf: WorkspaceLeaf) => any): void; - /** - * @public - */ - getLeavesOfType(viewType: string): WorkspaceLeaf[]; - /** - * @public - */ - detachLeavesOfType(viewType: string): void; - - /** - * @public - */ - revealLeaf(leaf: WorkspaceLeaf): void; - /** - * @public - */ - getLastOpenFiles(): string[]; - - /** - * Calling this function will update/reconfigure the options of all markdown panes. - * It is fairly expensive, so it should not be called frequently. - * @public - */ - updateOptions(): void; - - /** - * @public - */ - on(name: 'quick-preview', callback: (file: TFile, data: string) => any, ctx?: any): EventRef; - /** - * @public - */ - on(name: 'resize', callback: () => any, ctx?: any): EventRef; - /** - * @public - */ - on(name: 'active-leaf-change', callback: (leaf: WorkspaceLeaf | null) => any, ctx?: any): EventRef; - /** - * @public - */ - on(name: 'file-open', callback: (file: TFile | null) => any, ctx?: any): EventRef; - - /** - * @public - */ - on(name: 'layout-change', callback: () => any, ctx?: any): EventRef; - /** - * @public - */ - on(name: 'window-open', callback: (win: WorkspaceWindow, window: Window) => any, ctx?: any): EventRef; - /** - * @public - */ - on(name: 'window-close', callback: (win: WorkspaceWindow, window: Window) => any, ctx?: any): EventRef; - /** - * Triggered when the CSS of the app has changed. - * @public - */ - on(name: 'css-change', callback: () => any, ctx?: any): EventRef; - /** - * Triggered when the user opens the context menu on a file. - * @public - */ - on(name: 'file-menu', callback: (menu: Menu, file: TAbstractFile, source: string, leaf?: WorkspaceLeaf) => any, ctx?: any): EventRef; - /** - * Triggered when the user opens the context menu with multiple files selected in the File Explorer. - * @public - */ - on(name: 'files-menu', callback: (menu: Menu, files: TAbstractFile[], source: string, leaf?: WorkspaceLeaf) => any, ctx?: any): EventRef; - - /** - * Triggered when the user opens the context menu on an external URL. - * @public - */ - on(name: 'url-menu', callback: (menu: Menu, url: string) => any, ctx?: any): EventRef; - /** - * Triggered when the user opens the context menu on an editor. - * @public - */ - on(name: 'editor-menu', callback: (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef; - /** - * Triggered when changes to an editor has been applied, either programmatically or from a user event. - * @public - */ - on(name: 'editor-change', callback: (editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef; - - /** - * Triggered when the editor receives a paste event. - * Check for `evt.defaultPrevented` before attempting to handle this event, and return if it has been already handled. - * Use `evt.preventDefault()` to indicate that you've handled the event. - * @public - */ - on(name: 'editor-paste', callback: (evt: ClipboardEvent, editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef; - /** - * Triggered when the editor receives a drop event. - * Check for `evt.defaultPrevented` before attempting to handle this event, and return if it has been already handled. - * Use `evt.preventDefault()` to indicate that you've handled the event. - * @public - */ - on(name: 'editor-drop', callback: (evt: DragEvent, editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef; - - /** - * Triggered when the app is about to quit. Not guaranteed to actually run. - * Perform some best effort cleanup here. - * @public - */ - on(name: 'quit', callback: (tasks: Tasks) => any, ctx?: any): EventRef; - -} - -/** - * @public - */ -export abstract class WorkspaceContainer extends WorkspaceSplit { - - /** @public */ - abstract win: Window; - /** @public */ - abstract doc: Document; - -} - -/** - * @public - */ -export class WorkspaceFloating extends WorkspaceParent { - -} - -/** - * @public - */ -export abstract class WorkspaceItem extends Events { - - /** - * @public - */ - getRoot(): WorkspaceItem; - /** - * Get the root container parent item, which can be one of: - * - {@link WorkspaceRoot} - * - {@link WorkspaceWindow} - * @public - */ - getContainer(): WorkspaceContainer; - -} - -/** - * @public - */ -export class WorkspaceLeaf extends WorkspaceItem { - - /** - * @public - */ - view: View; - - /** - * By default, `openFile` will also make the leaf active. - * Pass in `{ active: false }` to override. - * - * @public - */ - openFile(file: TFile, openState?: OpenViewState): Promise; - - /** - * @public - */ - open(view: View): Promise; - - /** - * @public - */ - getViewState(): ViewState; - /** - * @public - */ - setViewState(viewState: ViewState, eState?: any): Promise; - - /** - * @public - */ - getEphemeralState(): any; - /** - * @public - */ - setEphemeralState(state: any): void; - /** - * @public - */ - togglePinned(): void; - /** - * @public - */ - setPinned(pinned: boolean): void; - /** - * @public - */ - setGroupMember(other: WorkspaceLeaf): void; - /** - * @public - */ - setGroup(group: string): void; - /** - * @public - */ - detach(): void; - - /** - * @public - */ - getIcon(): IconName; - /** - * @public - */ - getDisplayText(): string; - - /** - * @public - */ - onResize(): void; - - /** - * @public - */ - on(name: 'pinned-change', callback: (pinned: boolean) => any, ctx?: any): EventRef; - /** - * @public - */ - on(name: 'group-change', callback: (group: string) => any, ctx?: any): EventRef; - -} - -/** - * @public - */ -export class WorkspaceMobileDrawer extends WorkspaceParent { - - /** @public */ - collapsed: boolean; - - /** @public */ - expand(): void; - - /** @public */ - collapse(): void; - - /** @public */ - toggle(): void; - -} - -/** - * @public - */ -export abstract class WorkspaceParent extends WorkspaceItem { - -} - -/** - * @public - */ -export class WorkspaceRibbon { - -} - -/** - * @public - */ -export class WorkspaceRoot extends WorkspaceContainer { - /** @public */ - win: Window; - /** @public */ - doc: Document; -} - -/** - * @public - */ -export class WorkspaceSidedock extends WorkspaceSplit { - - /** @public */ - collapsed: boolean; - - /** @public */ - toggle(): void; - /** @public */ - collapse(): void; - /** @public */ - expand(): void; - -} - -/** - * @public - */ -export class WorkspaceSplit extends WorkspaceParent { - -} - -/** - * @public - */ -export class WorkspaceTabs extends WorkspaceParent { - -} - -/** - * @public - */ -export class WorkspaceWindow extends WorkspaceContainer { - - /** @public */ - win: Window; - /** @public */ - doc: Document; - -} - -/** - * @public - */ -export interface WorkspaceWindowInitData { - - /** - * The suggested size - * @public - */ - size?: { - /** @public */ - width: number; - /** @public */ - height: number; - }; -} - -export { } - -/** @public */ -declare global { - /** - * Global reference to the app. - * @public - * @deprecated - Prefer not to use this value directly. - */ - var app: App; -} - -/** @public */ -export type IconName = string; - diff --git a/node_modules/obsidian/package.json b/node_modules/obsidian/package.json deleted file mode 100644 index a377685..0000000 --- a/node_modules/obsidian/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "obsidian", - "version": "1.5.7-1", - "description": "Type definitions for the latest Obsidian API (https://obsidian.md)", - "keywords": ["obsdmd"], - "homepage": "https://obsidian.md", - "repository": { - "type": "git", - "url": "https://github.com/obsidianmd/obsidian-api.git" - }, - "license": "MIT", - "main": "", - "types": "obsidian.d.ts", - "dependencies": { - "@types/codemirror": "5.60.8", - "moment": "2.29.4" - }, - "peerDependencies": { - "@codemirror/state": "^6.0.0", - "@codemirror/view": "^6.0.0" - } -} diff --git a/node_modules/obsidian/publish.d.ts b/node_modules/obsidian/publish.d.ts deleted file mode 100644 index 68cf85f..0000000 --- a/node_modules/obsidian/publish.d.ts +++ /dev/null @@ -1,510 +0,0 @@ - -declare global { - interface ObjectConstructor { - isEmpty(object: Record): boolean; - each(object: { - [key: string]: T; - }, callback: (value: T, key?: string) => boolean | void, context?: any): boolean; - } - interface ArrayConstructor { - combine(arrays: T[][]): T[]; - } - interface Array { - first(): T | undefined; - last(): T | undefined; - contains(target: T): boolean; - remove(target: T): void; - shuffle(): this; - unique(): T[]; - } - interface Math { - clamp(value: number, min: number, max: number): number; - square(value: number): number; - } - interface StringConstructor { - isString(obj: any): obj is string; - } - interface String { - contains(target: string): boolean; - startsWith(searchString: string, position?: number): boolean; - endsWith(target: string, length?: number): boolean; - format(...args: string[]): string; - } - interface NumberConstructor { - isNumber(obj: any): obj is number; - } - interface Node { - detach(): void; - empty(): void; - insertAfter(node: T, child: Node | null): T; - indexOf(other: Node): number; - setChildrenInPlace(children: Node[]): void; - appendText(val: string): void; - /** - * Cross-window capable instanceof check, a drop-in replacement - * for instanceof checks on DOM Nodes. Remember to also check - * for nulls when necessary. - * @param type - */ - instanceOf(type: { - new (): T; - }): this is T; - /** - * The document this node belongs to, or the global document. - */ - doc: Document; - /** - * The window object this node belongs to, or the global window. - */ - win: Window; - constructorWin: Window; - } - interface Element extends Node { - getText(): string; - setText(val: string | DocumentFragment): void; - addClass(...classes: string[]): void; - addClasses(classes: string[]): void; - removeClass(...classes: string[]): void; - removeClasses(classes: string[]): void; - toggleClass(classes: string | string[], value: boolean): void; - hasClass(cls: string): boolean; - setAttr(qualifiedName: string, value: string | number | boolean | null): void; - setAttrs(obj: { - [key: string]: string | number | boolean | null; - }): void; - getAttr(qualifiedName: string): string | null; - matchParent(selector: string, lastParent?: Element): Element | null; - getCssPropertyValue(property: string, pseudoElement?: string): string; - isActiveElement(): boolean; - } - interface HTMLElement extends Element { - show(): void; - hide(): void; - toggle(show: boolean): void; - toggleVisibility(visible: boolean): void; - /** - * Returns whether this element is shown, when the element is attached to the DOM and - * none of the parent and ancestor elements are hidden with `display: none`. - * - * Exception: Does not work on and , or on elements with `position: fixed`. - */ - isShown(): boolean; - setCssStyles(styles: Partial): void; - setCssProps(props: Record): void; - /** - * Get the inner width of this element without padding. - */ - readonly innerWidth: number; - /** - * Get the inner height of this element without padding. - */ - readonly innerHeight: number; - } - interface SVGElement extends Element { - setCssStyles(styles: Partial): void; - setCssProps(props: Record): void; - } - function isBoolean(obj: any): obj is boolean; - function fish(selector: string): HTMLElement | null; - function fishAll(selector: string): HTMLElement[]; - interface Element extends Node { - find(selector: string): Element | null; - findAll(selector: string): HTMLElement[]; - findAllSelf(selector: string): HTMLElement[]; - } - interface HTMLElement extends Element { - find(selector: string): HTMLElement; - findAll(selector: string): HTMLElement[]; - findAllSelf(selector: string): HTMLElement[]; - } - interface DocumentFragment extends Node, NonElementParentNode, ParentNode { - find(selector: string): HTMLElement; - findAll(selector: string): HTMLElement[]; - } - interface DomElementInfo { - /** - * The class to be assigned. Can be a space-separated string or an array of strings. - */ - cls?: string | string[]; - /** - * The textContent to be assigned. - */ - text?: string | DocumentFragment; - /** - * HTML attributes to be added. - */ - attr?: { - [key: string]: string | number | boolean | null; - }; - /** - * HTML title (for hover tooltip). - */ - title?: string; - /** - * The parent element to be assigned to. - */ - parent?: Node; - value?: string; - type?: string; - prepend?: boolean; - placeholder?: string; - href?: string; - } - interface SvgElementInfo { - /** - * The class to be assigned. Can be a space-separated string or an array of strings. - */ - cls?: string | string[]; - /** - * HTML attributes to be added. - */ - attr?: { - [key: string]: string | number | boolean | null; - }; - /** - * The parent element to be assigned to. - */ - parent?: Node; - prepend?: boolean; - } - interface Node { - /** - * Create an element and append it to this node. - */ - createEl(tag: K, o?: DomElementInfo | string, callback?: (el: HTMLElementTagNameMap[K]) => void): HTMLElementTagNameMap[K]; - createDiv(o?: DomElementInfo | string, callback?: (el: HTMLDivElement) => void): HTMLDivElement; - createSpan(o?: DomElementInfo | string, callback?: (el: HTMLSpanElement) => void): HTMLSpanElement; - createSvg(tag: K, o?: SvgElementInfo | string, callback?: (el: SVGElementTagNameMap[K]) => void): SVGElementTagNameMap[K]; - } - function createEl(tag: K, o?: DomElementInfo | string, callback?: (el: HTMLElementTagNameMap[K]) => void): HTMLElementTagNameMap[K]; - function createDiv(o?: DomElementInfo | string, callback?: (el: HTMLDivElement) => void): HTMLDivElement; - function createSpan(o?: DomElementInfo | string, callback?: (el: HTMLSpanElement) => void): HTMLSpanElement; - function createSvg(tag: K, o?: SvgElementInfo | string, callback?: (el: SVGElementTagNameMap[K]) => void): SVGElementTagNameMap[K]; - function createFragment(callback?: (el: DocumentFragment) => void): DocumentFragment; - interface EventListenerInfo { - selector: string; - listener: Function; - options?: boolean | AddEventListenerOptions; - callback: Function; - } - interface HTMLElement extends Element { - _EVENTS?: { - [K in keyof HTMLElementEventMap]?: EventListenerInfo[]; - }; - on(this: HTMLElement, type: K, selector: string, listener: (this: HTMLElement, ev: HTMLElementEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - off(this: HTMLElement, type: K, selector: string, listener: (this: HTMLElement, ev: HTMLElementEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - onClickEvent(this: HTMLElement, listener: (this: HTMLElement, ev: MouseEvent) => any, options?: boolean | AddEventListenerOptions): void; - /** - * @param listener - the callback to call when this node is inserted into the DOM. - * @param once - if true, this will only fire once and then unhook itself. - * @returns destroy - a function to remove the event handler to avoid memory leaks. - */ - onNodeInserted(this: HTMLElement, listener: () => any, once?: boolean): () => void; - /** - * @param listener - the callback to call when this node has been migrated to another window. - * @returns destroy - a function to remove the event handler to avoid memory leaks. - */ - onWindowMigrated(this: HTMLElement, listener: (win: Window) => any): () => void; - trigger(eventType: string): void; - } - interface Document { - _EVENTS?: { - [K in keyof DocumentEventMap]?: EventListenerInfo[]; - }; - on(this: Document, type: K, selector: string, listener: (this: Document, ev: DocumentEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - off(this: Document, type: K, selector: string, listener: (this: Document, ev: DocumentEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void; - } - interface UIEvent extends Event { - targetNode: Node | null; - win: Window; - doc: Document; - /** - * Cross-window capable instanceof check, a drop-in replacement - * for instanceof checks on UIEvents. - * @param type - */ - instanceOf(type: { - new (...data: any[]): T; - }): this is T; - } - interface AjaxOptions { - method?: 'GET' | 'POST'; - url: string; - success?: (response: any, req: XMLHttpRequest) => any; - error?: (error: any, req: XMLHttpRequest) => any; - data?: object | string | ArrayBuffer; - headers?: Record; - withCredentials?: boolean; - req?: XMLHttpRequest; - } - function ajax(options: AjaxOptions): void; - function ajaxPromise(options: AjaxOptions): Promise; - function ready(fn: () => any): void; - function sleep(ms: number): Promise; - function nextFrame(): Promise; - /** - * The actively focused Window object. This is usually the same as `window` but - * it will be different when using popout windows. - */ - let activeWindow: Window; - /** - * The actively focused Document object. This is usually the same as `document` but - * it will be different when using popout windows. - */ - let activeDocument: Document; - interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandlers, WindowEventHandlers, WindowLocalStorage, WindowOrWorkerGlobalScope, WindowSessionStorage { - /** - * The actively focused Window object. This is usually the same as `window` but - * it will be different when using popout windows. - */ - activeWindow: Window; - /** - * The actively focused Document object. This is usually the same as `document` but - * it will be different when using popout windows. - */ - activeDocument: Document; - sleep(ms: number): Promise; - nextFrame(): Promise; - } - interface Touch { - touchType: 'stylus' | 'direct'; - } -} - -/** - * @public - */ -export class Component { - - /** - * Load this component and its children - * @public - */ - load(): void; - /** - * Override this to load your component - * @public - * @virtual - */ - onload(): void; - /** - * Unload this component and its children - * @public - */ - unload(): void; - /** - * Override this to unload your component - * @public - * @virtual - */ - onunload(): void; - /** - * Adds a child component, loading it if this component is loaded - * @public - */ - addChild(component: T): T; - /** - * Removes a child component, unloading it - * @public - */ - removeChild(component: T): T; - /** - * Registers a callback to be called when unloading - * @public - */ - register(cb: () => any): void; - /** - * Registers an event to be detached when unloading - * @public - */ - registerEvent(eventRef: EventRef): void; - /** - * Registers an DOM event to be detached when unloading - * @public - */ - registerDomEvent(el: Window, type: K, callback: (this: HTMLElement, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - /** - * Registers an DOM event to be detached when unloading - * @public - */ - registerDomEvent(el: Document, type: K, callback: (this: HTMLElement, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - /** - * Registers an DOM event to be detached when unloading - * @public - */ - registerDomEvent(el: HTMLElement, type: K, callback: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - - /** - * Registers an interval (from setInterval) to be cancelled when unloading - * Use {@link window.setInterval} instead of {@link setInterval} to avoid TypeScript confusing between NodeJS vs Browser API - * @public - */ - registerInterval(id: number): number; -} - -/** - * @public - */ -export interface EventRef { - -} - -/** - * @public - */ -export class Events { - - /** - * @public - */ - on(name: string, callback: (...data: any) => any, ctx?: any): EventRef; - /** - * @public - */ - off(name: string, callback: (...data: any) => any): void; - /** - * @public - */ - offref(ref: EventRef): void; - /** - * @public - */ - trigger(name: string, ...data: any[]): void; - /** - * @public - */ - tryTrigger(evt: EventRef, args: any[]): void; -} - -/** - * A post processor receives an element which is a section of the preview. - * - * Post processors can mutate the DOM to render various things, such as mermaid graphs, latex equations, or custom controls. - * - * If your post processor requires lifecycle management, for example, to clear an interval, kill a subprocess, etc when this element is - * removed from the app, look into {@link MarkdownPostProcessorContext#addChild} - * @public - */ -export interface MarkdownPostProcessor { - /** - * The processor function itself. - * @public - */ - (el: HTMLElement, ctx: MarkdownPostProcessorContext): Promise | void; - /** - * An optional integer sort order. Defaults to 0. Lower number runs before higher numbers. - * @public - */ - sortOrder?: number; -} - -/** - * @public - */ -export interface MarkdownPostProcessorContext { - /** - * @public - */ - docId: string; - /** @public */ - sourcePath: string; - /** @public */ - frontmatter: any | null | undefined; - - /** - * Adds a child component that will have its lifecycle managed by the renderer. - * - * Use this to add a dependent child to the renderer such that if the containerEl - * of the child is ever removed, the component's unload will be called. - * @public - */ - addChild(child: MarkdownRenderChild): void; - /** - * Gets the section information of this element at this point in time. - * Only call this function right before you need this information to get the most up-to-date version. - * This function may also return null in many circumstances; if you use it, you must be prepared to deal with nulls. - * @public - */ - getSectionInfo(el: HTMLElement): MarkdownSectionInformation | null; - -} - -/** - * @public - */ -export class MarkdownPreviewRenderer { - - /** - * @public - */ - static registerPostProcessor(postProcessor: MarkdownPostProcessor, sortOrder?: number): void; - /** - * @public - */ - static unregisterPostProcessor(postProcessor: MarkdownPostProcessor): void; - - /** - * @public - */ - static createCodeBlockPostProcessor(language: string, handler: (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => Promise | void): (el: HTMLElement, ctx: MarkdownPostProcessorContext) => void; - -} - -/** - * @public - */ -export class MarkdownRenderChild extends Component { - /** @public */ - containerEl: HTMLElement; - /** - * @param containerEl - This HTMLElement will be used to test whether this component is still alive. - * It should be a child of the markdown preview sections, and when it's no longer attached - * (for example, when it is replaced with a new version because the user edited the markdown source code), - * this component will be unloaded. - * @public - */ - constructor(containerEl: HTMLElement); -} - -/** @public */ -export interface MarkdownSectionInformation { - /** @public */ - text: string; - /** @public */ - lineStart: number; - /** @public */ - lineEnd: number; -} - -/** @public */ -export class Publish extends Events { - - /** @public */ - get currentFilepath(): string; - /** - * @public - */ - registerMarkdownPostProcessor(postProcessor: MarkdownPostProcessor, sortOrder?: number): MarkdownPostProcessor; - /** - * Register a special post processor that handles fenced code given a language and a handler. - * This special post processor takes care of removing the
 and create a 
that - * will be passed to your handler, and is expected to be filled with your custom elements. - * @public - */ - registerMarkdownCodeBlockProcessor(language: string, handler: (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => Promise | void, sortOrder?: number): MarkdownPostProcessor; - - /** @public */ - on(name: 'navigated', callback: () => any, ctx?: any): EventRef; -} - -export { } - -/** @public */ -declare global { - /** - * Global reference to the publish instance. - * @public - */ - var publish: Publish; -} -