Skip to content

WidgetEditorView

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:15

_children: Component[]

Defined in: src/obsidian/augmentations/Components/Component.d.ts:13

Child Components attached to current component, will be unloaded on unloading parent component.

EmbeddedEditorView._children


_events: EventRef[]

Defined in: src/obsidian/augmentations/Components/Component.d.ts:20

Events that are attached to the current component, will be detached on unloading parent component.

EmbeddedEditorView._events


_loaded: boolean

Defined in: src/obsidian/augmentations/Components/Component.d.ts:27

Whether the component and its children are loaded.

EmbeddedEditorView._loaded


after: string

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:19

Data after reference.


app: App

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:20

Reference to the app.

EmbeddedEditorView.app


before: string

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:24

Data before reference.


containerEl: HTMLElement

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:25

Container element for the embedded view.

EmbeddedEditorView.containerEl


data: string

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:29

Full file contents.


dirty: boolean

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:30

Whether the view is currently saving.

EmbeddedEditorView.dirty


editable: boolean

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:38

Whether the editor may be edited.

EmbeddedEditorView.editable


optional editMode: IFramedMarkdownEditor

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:43

Editor component of the view.

EmbeddedEditorView.editMode


editorEl: HTMLElement

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:48

Container in which the editor is embedded.

EmbeddedEditorView.editorEl


file: null | TFile

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:53

File to which the view is attached.

EmbeddedEditorView.file


fileBeingRenamed: null | TFile

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:34

File being currently renamed.


heading: string

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:39

Current heading.


hoverPopover: null | HoverPopover

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:58

Hover element container.

EmbeddedEditorView.hoverPopover


indent: string

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:44

Indent.


inlineTitleEl: HTMLElement

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:49

Inline title element.


lastSavedData: null | string

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:54

Full inline content string.


previewEl: HTMLElement

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:63

Element containing the preview for the embedded markdown.

EmbeddedEditorView.previewEl


previewMode: MarkdownPreviewView

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:68

Preview component of the view.

EmbeddedEditorView.previewMode


saveAgain: boolean

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:59

Whether embedding should be saved twice on save.


saving: boolean

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:64

Whether the widget is currently saving.


state: unknown

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:73

Current state of the editor.

EmbeddedEditorView.state


subpath: string

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:69

Subpath reference of the path.


subpathNotFound: boolean

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:74

Whether the subpath was not found in the cache.


text: string

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:78

Text contents being embedded.

EmbeddedEditorView.text


useIframe: boolean

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:83

Whether the view renders contents using an iFrame.

EmbeddedEditorView.useIframe

get editor(): null | IFramedMarkdownEditor

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:88

Get the preview editor, if exists.

null | IFramedMarkdownEditor

EmbeddedEditorView.editor


get path(): string

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:93

Get the path to the file, if any file registered.

string

EmbeddedEditorView.path


get scroll(): unknown

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:98

Get the scroll of the file renderer component.

unknown

EmbeddedEditorView.scroll

addChild<T>(component): T

Defined in: obsidian.d.ts:911

Adds a child component, loading it if this component is loaded

T extends Component

T

T

EmbeddedEditorView.addChild

addChild<T>(component): T

Defined in: src/obsidian/augmentations/Components/Component.d.ts:41

Adds a child component, loading it if this component is loaded.

T extends Component

The type of the component to add.

T

The component to add.

T

The added component.

component.addChild(childComponent);

EmbeddedEditorView.addChild


applyScope(scope): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:79

Push/pop current scope.

Scope

void


destroyEditor(save?): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:103

Destroy edit component editor and save contents if specified.

boolean

void

EmbeddedEditorView.destroyEditor


getFoldInfo(): null | FoldInfo

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:84

Get the current folds of the editor.

null | FoldInfo


getMode(): "source" | "preview"

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:108

Gets currently active mode (editMode returns ‘source’).

"source" | "preview"

EmbeddedEditorView.getMode


load(): void

Defined in: obsidian.d.ts:889

Load this component and its children

void

EmbeddedEditorView.load

load(): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:48

Load this component and its children.

void

EmbeddedEditorView.load


loadContents(data, cache): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:89

Splice incoming data at according to subpath for correct reference, then update heading and render.

string

CachedMetadata

void


loadFile(): Promise<void>

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:94

Load file from cache based on stored path.

Promise<void>


loadFileInternal(data, cache?): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:99

Load file and check if data is different from last saved data, then loads contents.

string

CachedMetadata

void


onFileChanged(file, data, cache): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:104

Update representation on file finished updating.

TFile

string

CachedMetadata

void


onFileRename(file, oldPath): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:109

Update representation on file rename.

TAbstractFile

string

void


onload(): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:114

On loading widget, register vault change and rename events.

void

EmbeddedEditorView.onload


onMarkdownFold(): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:119

Save fold made in the editor to foldManager.

void


onMarkdownScroll(): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:118

Trigger markdown scroll on workspace.

void

EmbeddedEditorView.onMarkdownScroll


onTitleChange(element): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:124

On change of editor title element.

HTMLElement

void


onTitleKeydown(event): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:129

On keypress on editor title element.

KeyboardEvent

void


onTitlePaste(element, event): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:134

On pasting on editor title element.

HTMLElement

ClipboardEvent

void


onunload(): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:139

On unloading widget, unload component and remove scope.

void

EmbeddedEditorView.onunload


register(cb): void

Defined in: obsidian.d.ts:921

Registers a callback to be called when unloading

() => any

void

EmbeddedEditorView.register

register(cb): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:78

Registers a callback to be called when unloading.

() => any

The callback to be called when unloading.

void

component.register(() => {
console.log('MyComponent unloaded');
});

EmbeddedEditorView.register


registerDomEvent<K>(el, type, callback, options?): void

Defined in: obsidian.d.ts:931

Registers an DOM event to be detached when unloading

K extends keyof WindowEventMap

Window

K

(this, ev) => any

boolean | AddEventListenerOptions

void

EmbeddedEditorView.registerDomEvent

registerDomEvent<K>(el, type, callback, options?): void

Defined in: obsidian.d.ts:936

Registers an DOM event to be detached when unloading

K extends keyof DocumentEventMap

Document

K

(this, ev) => any

boolean | AddEventListenerOptions

void

EmbeddedEditorView.registerDomEvent

registerDomEvent<K>(el, type, callback, options?): void

Defined in: obsidian.d.ts:941

Registers an DOM event to be detached when unloading

K extends keyof HTMLElementEventMap

HTMLElement

K

(this, ev) => any

boolean | AddEventListenerOptions

void

EmbeddedEditorView.registerDomEvent

registerDomEvent<K>(el, type, callback, options?): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:96

Registers an DOM event to be detached when unloading.

K extends keyof DocumentEventMap

The type of the event to register.

Document

The element to register the event on.

K

The type of the event to register.

(this, ev) => any

The callback to be called when the event is triggered.

The options for the event.

boolean | AddEventListenerOptions

void

component.registerDomEvent(document, 'click', () => {
console.log('Document clicked');
});

EmbeddedEditorView.registerDomEvent

registerDomEvent<K>(el, type, callback, options?): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:119

Registers an DOM event to be detached when unloading.

K extends keyof HTMLElementEventMap

The type of the event to register.

HTMLElement

The element to register the event on.

K

The type of the event to register.

(this, ev) => any

The callback to be called when the event is triggered.

The options for the event.

boolean | AddEventListenerOptions

void

component.registerDomEvent(document.body, 'click', () => {
console.log('Body clicked');
});

EmbeddedEditorView.registerDomEvent

registerDomEvent<K>(el, type, callback, options?): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:142

Registers an DOM event to be detached when unloading.

K extends keyof WindowEventMap

The type of the event to register.

Window

The element to register the event on.

K

The type of the event to register.

(this, ev) => any

The callback to be called when the event is triggered.

The options for the event.

boolean | AddEventListenerOptions

void

component.registerDomEvent(window, 'click', () => {
console.log('Window clicked');
});

EmbeddedEditorView.registerDomEvent


registerEvent(eventRef): void

Defined in: obsidian.d.ts:926

Registers an event to be detached when unloading

EventRef

void

EmbeddedEditorView.registerEvent

registerEvent(eventRef): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:159

Registers an event to be detached when unloading.

EventRef

The event to be registered.

void

component.registerEvent(eventRef);

EmbeddedEditorView.registerEvent


registerInterval(id): number

Defined in: obsidian.d.ts:948

Registers an interval (from setInterval) to be cancelled when unloading Use setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API

number

number

EmbeddedEditorView.registerInterval

registerInterval(id): number

Defined in: src/obsidian/augmentations/Components/Component.d.ts:175

Registers an interval (from setInterval) to be cancelled when unloading. Use setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API

number

The id of the interval to register.

number

The id of the interval.

component.registerInterval(window.setInterval(() => {
console.log('Interval');
}, 1000));

EmbeddedEditorView.registerInterval


registerScopeEvent(keymapEventHandler): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:181

KeymapEventHandler

void

EmbeddedEditorView.registerScopeEvent


removeChild<T>(component): T

Defined in: obsidian.d.ts:916

Removes a child component, unloading it

T extends Component

T

T

EmbeddedEditorView.removeChild

removeChild<T>(component): T

Defined in: src/obsidian/augmentations/Components/Component.d.ts:195

Removes a child component, unloading it.

T extends Component

The type of the component to remove.

T

The component to remove.

T

The removed component.

component.removeChild(childComponent);

EmbeddedEditorView.removeChild


requestSave(): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:128

Debounced save of contents.

void

EmbeddedEditorView.requestSave


requestSaveFolds(): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:133

Debounced save of editor folds.

void

EmbeddedEditorView.requestSaveFolds


save(data, delayed?): Promise<void>

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:144

Save changes made in editable widget.

string

boolean

Promise<void>

EmbeddedEditorView.save


saveTitle(element): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:149

On blur widget, save title.

HTMLElement

void


set(data, clear): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:143

Set the state of the editor.

string

boolean

void

EmbeddedEditorView.set


showEditor(): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:148

Reveal the editor if editable widget and applies saved state.

void

EmbeddedEditorView.showEditor


showPreview(show?): void

Defined in: src/obsidian/internals/WidgetEditorView.d.ts:154

Show preview of widget.

boolean

void

EmbeddedEditorView.showPreview


showSearch(replace?): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:158

Reveal search component in file renderer component.

boolean

void

EmbeddedEditorView.showSearch


toggleMode(): void

Defined in: src/obsidian/internals/EmbeddedEditorView.d.ts:163

Toggle between edit and preview mode.

void

EmbeddedEditorView.toggleMode


unload(): void

Defined in: obsidian.d.ts:900

Unload this component and its children

void

EmbeddedEditorView.unload

unload(): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:211

Override this to unload your component.

void

class MyComponent extends Component {
public override onunload(): void {
console.log('MyComponent unloaded');
}
}

EmbeddedEditorView.unload