Skip to content

MarkdownView

Extends

Implements

Constructors

new MarkdownView()

new MarkdownView(leaf): MarkdownView

Parameters

leaf: WorkspaceLeaf

Returns

MarkdownView

Overrides

TextFileView.constructor

Properties

_children

_children: Component[]

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

Inherited from

TextFileView._children


_events

_events: EventRef[]

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

Inherited from

TextFileView._events


_loaded

_loaded: boolean

Whether the component and its children are loaded

Inherited from

TextFileView._loaded


actionsEl

actionsEl: HTMLElement

Container of actions for the view

Inherited from

TextFileView.actionsEl


allowNoFile

allowNoFile: boolean

Inherited from

TextFileView.allowNoFile


app

app: App

Implementation of

MarkdownFileInfo.app

Inherited from

TextFileView.app


backButtonEl

backButtonEl: HTMLButtonElement

Back button element for changing view history

Inherited from

TextFileView.backButtonEl


backlinks: unknown

Backlinks component


backlinksEl

backlinksEl: HTMLElement

The embedded backlinks element for the current file


canDropAnywhere

canDropAnywhere: boolean

Whether the view may be dropped anywhere in workspace

Inherited from

TextFileView.canDropAnywhere


closeable

closeable: boolean

Whether the leaf may close the view

Inherited from

TextFileView.closeable


containerEl

containerEl: HTMLElement

Inherited from

TextFileView.containerEl


contentEl

contentEl: HTMLElement

Inherited from

TextFileView.contentEl


currentMode

currentMode: MarkdownSubView


data

data: string

In memory data

Inherited from

TextFileView.data


dirty

dirty: boolean

Whether current file is dirty (different from saved contents)

Inherited from

TextFileView.dirty


editMode

editMode: MarkdownEditView

Editor component of the view


editor

editor: Editor

Implementation of

MarkdownFileInfo.editor


file

file: null | TFile

Implementation of

MarkdownFileInfo.file

Inherited from

TextFileView.file


fileBeingRenamed

fileBeingRenamed: null | TFile

The file that is currently being renamed

Inherited from

TextFileView.fileBeingRenamed


forwardButtonEl

forwardButtonEl: HTMLButtonElement

Forward button element for changing view history

Inherited from

TextFileView.forwardButtonEl


headerEl

headerEl: HTMLElement

Header bar container of view

Inherited from

TextFileView.headerEl


hoverPopover

hoverPopover: null | HoverPopover

Implementation of

MarkdownFileInfo.hoverPopover


icon

icon: string

Inherited from

TextFileView.icon


iconEl

iconEl: HTMLElement

Icon element for the view (for dragging)

Inherited from

TextFileView.iconEl


inlineTitleEl

inlineTitleEl: HTMLElement

Editable title element of the view


isPlaintext

isPlaintext: boolean

Whether editor should be rendered as plaintext

Inherited from

TextFileView.isPlaintext


lastSavedData

lastSavedData: null | string

The data that was last saved

Inherited from

TextFileView.lastSavedData


leaf

leaf: WorkspaceLeaf

Inherited from

TextFileView.leaf


metadataEditor

metadataEditor: MetadataEditor

Frontmatter editor of the editor

Implementation of

MarkdownFileInfo.metadataEditor


modeButtonEl

modeButtonEl: HTMLAnchorElement

Button for switching between different modes of the view


modes

modes: object

The registered modes of the view

preview

preview: MarkdownPreviewView

source

source: MarkdownEditView


moreOptionsButtonEl

moreOptionsButtonEl: HTMLAnchorElement

Anchor button for revealing more view actions

Inherited from

TextFileView.moreOptionsButtonEl


navigation: boolean

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.)

Inherited from

TextFileView.navigation


previewMode

previewMode: MarkdownPreviewView


rawFrontmatter

rawFrontmatter: string

File frontmatter as a raw string


requestSave()

requestSave: () => void

Debounced save in 2 seconds from now

Returns

void

Inherited from

TextFileView.requestSave


saveAgain

saveAgain: boolean

Whether on saving, the file should be saved again (for dirtiness checks)

Inherited from

TextFileView.saveAgain


saving

saving: boolean

Whether the file is currently saving

Inherited from

TextFileView.saving


scope

scope: null | Scope

Assign an optional scope to your view to register hotkeys for when the view is in focus.

Example

this.scope = new Scope(this.app.scope);

Default

null
@public

Inherited from

TextFileView.scope


scroll

scroll: null | number

Current scroll position of the editor


showBacklinks: boolean

Whether to show backlinks in the editor


sourceMode

sourceMode: object

cmEditor

cmEditor: any


titleContainerEl

titleContainerEl: HTMLElement

Container for the title of the view

Inherited from

TextFileView.titleContainerEl


titleEl

titleEl: HTMLElement

Title element for the view

Inherited from

TextFileView.titleEl


titleParentEl

titleParentEl: HTMLElement

Title of the parent

Inherited from

TextFileView.titleParentEl

Methods

addAction()

addAction(icon, title, callback)

addAction(icon, title, callback): HTMLElement

Parameters

icon: string

title: string

callback

Returns

HTMLElement

Inherited from

TextFileView.addAction

addAction(icon, title, callback)

addAction(icon, title, callback): HTMLElement

Adds an action button to the header of the view

Parameters

icon: string

The icon for the action

title: string

The title for the action

callback

Callback to execute on click

Returns

HTMLElement

Inherited from

TextFileView.addAction


addChild()

addChild<T>(component): T

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

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

TextFileView.addChild


addProperty()

addProperty(unused): void

Add property to inline metadata editor or properties plugin

Parameters

unused: undefined

Returns

void


canAcceptExtension()

canAcceptExtension(extension)

canAcceptExtension(extension): boolean

Parameters

extension: string

Returns

boolean

Inherited from

TextFileView.canAcceptExtension

canAcceptExtension(extension)

canAcceptExtension(extension): boolean

Determines whether the specified file extension can be opened in this view.

Parameters

extension: string

The file extension to be evaluated

Returns

boolean

Inherited from

TextFileView.canAcceptExtension


canShowProperties()

canShowProperties(): boolean

Whether the editor can render properties according to the current mode and config

Returns

boolean


canToggleBacklinks(): boolean

Whether the editor can toggle backlinks according to current mode

Returns

boolean


clear()

clear(): void

Returns

void

Overrides

TextFileView.clear


close()

close(): Promise<void>

Closes the view

Returns

Promise<void>

Inherited from

TextFileView.close


collapseProperties()

collapseProperties(collapse): void

Collapse the properties editor

Parameters

collapse: boolean

Returns

void


editProperty()

editProperty(unused): void

Edit the focused property in the metadata editor

Parameters

unused: undefined

Returns

void


focusMetadata()

focusMetadata(focus?): void

Focus on the metadata editor given property information

Parameters

focus?

focus.focusHeading?: boolean

focus.propertyIdx?: number

focus.propertyKey?: string

Returns

void


getDisplayText()

getDisplayText(): string

Returns

string

Inherited from

TextFileView.getDisplayText


getEphemeralState()

getEphemeralState(): any

Gets the ephemeral (non-persistent) state of the editor

Returns

any

Inherited from

TextFileView.getEphemeralState


getFile()

getFile(): null | TFile

Get the file attached to the view

Returns

null | TFile


getIcon()

getIcon()

getIcon(): string

Returns

string

Inherited from

TextFileView.getIcon

getIcon()

getIcon(): string

Returns the icon name

Returns

string

Inherited from

TextFileView.getIcon


getMode()

getMode()

getMode(): MarkdownViewModeType

Returns

MarkdownViewModeType

getMode()

getMode(): MarkdownViewModeType

Get the current mode of the editor

Returns

MarkdownViewModeType


getSelection()

getSelection(): string

Get selection of current mode

Returns

string


getSideTooltipPlacement()

getSideTooltipPlacement(): undefined | "left" | "right"

Returns the placement of the tooltip

Returns

undefined | "left" | "right"

Inherited from

TextFileView.getSideTooltipPlacement


getState()

getState(): Record<string, unknown>

Returns

Record<string, unknown>

Inherited from

TextFileView.getState


getSyncViewState()

getSyncViewState(): any

Get view state for sync plugin

Returns

any

Inherited from

TextFileView.getSyncViewState


getViewData()

getViewData(): string

Returns

string

Overrides

TextFileView.getViewData


getViewType()

getViewType()

getViewType(): string

Returns

string

Inherited from

TextFileView.getViewType

getViewType()

getViewType(): "markdown"

Get the current view type

Returns

"markdown"

Inherited from

TextFileView.getViewType


handleCopy()

handleCopy(event): void

Handle copy event on metadata editor and serialize properties

Parameters

event: ClipboardEvent

Returns

void

Inherited from

TextFileView.handleCopy


handleCut()

handleCut(event): void

Handle cut event on metadata editor and serialize and remove properties

Parameters

event: ClipboardEvent

Returns

void

Inherited from

TextFileView.handleCut


handleDrop()

handleDrop(event, t, n): unknown

Parameters

event: DragEvent

t: unknown

n: unknown

Returns

unknown

Inherited from

TextFileView.handleDrop


handlePaste()

handlePaste(event): void

Handle paste event of properties on metadata editor

Parameters

event: ClipboardEvent

Returns

void

Inherited from

TextFileView.handlePaste


load()

load(): void

Load this component and its children

Returns

void

Inherited from

TextFileView.load


loadFile()

loadFile(file): Promise<unknown>

Loads the file with the onLoadFile function

Parameters

file: TFile

The File to load

Returns

Promise<unknown>

Inherited from

TextFileView.loadFile


loadFileInternal()

loadFileInternal(file, clear): Promise<unknown>

Parameters

file: TFile

clear: boolean

Returns

Promise<unknown>

Inherited from

TextFileView.loadFileInternal


loadFrontmatter()

loadFrontmatter(data): void

Validate correctness of frontmatter and update metadata editor

Parameters

data: string

Returns

void


metadataHasFocus()

metadataHasFocus(): boolean

Whether the metadata editor has focus

Returns

boolean


onClose()

onClose(): Promise<void>

Returns

Promise<void>

Inherited from

TextFileView.onClose


onCssChange()

onCssChange(): void

On app css change, update source mode editor

Returns

void


onDelete()

onDelete(file): Promise<void>

Updates the view if it contains the deleted file

Parameters

file: TFile

The file that is deleted

Returns

Promise<void>

Inherited from

TextFileView.onDelete


onExternalDataChange()

onExternalDataChange(file, data): void

Update editor on external data change (from sync plugin)

Parameters

file: TFile

data: string

Returns

void


onGroupChange()

onGroupChange(): void

Returns

void

Inherited from

TextFileView.onGroupChange


onHeaderMenu()

onHeaderMenu(e): void

Parameters

e: unknown

Returns

void

Inherited from

TextFileView.onHeaderMenu


onInlineTitleBlur()

onInlineTitleBlur(): Promise<void>

On blur of inline title, save new filename

Returns

Promise<void>


onInternalDataChange()

onInternalDataChange(): void

On data change of editor, update internal data and metadata editor

Returns

void


onload()

onload(): void

On loading markdown view, register resize, css-change and quick-preview events

Returns

void

Inherited from

TextFileView.onload


onLoadFile()

onLoadFile(file): Promise<void>

Parameters

file: TFile

Returns

Promise<void>

Inherited from

TextFileView.onLoadFile


onMarkdownFold()

onMarkdownFold(): void

On fold of markdown in source editor, save fold info to fold manager

Returns

void


onMarkdownScroll()

onMarkdownScroll(): void

On markdown scroll in editors, update scroll, sync state and trigger markdown scroll event

Returns

void


onModify()

onModify(file): void

Is called when the vault has a ‘modify’ event. Reloads the file if the view is currently not saving the file and the modified file is the file in this view.

Parameters

file: TFile

The modified file

Returns

void

Inherited from

TextFileView.onModify


onMoreOptions()

onMoreOptions(event): void

Parameters

event: Event

Returns

void

Inherited from

TextFileView.onMoreOptions


onMoreOptionsMenu()

onMoreOptionsMenu(e): void

Parameters

e: unknown

Returns

void

Inherited from

TextFileView.onMoreOptionsMenu


onOpen()

onOpen(): Promise<void>

Returns

Promise<void>

Inherited from

TextFileView.onOpen


onPaneMenu()

onPaneMenu(menu, source): void

Populates the pane menu.

(Replaces the previously removed onHeaderMenu and onMoreOptionsMenu)

Parameters

menu: Menu

source: string

Returns

void

Inherited from

TextFileView.onPaneMenu


onRename()

onRename(file)

onRename(file): Promise<void>

Parameters

file: TFile

Returns

Promise<void>

Inherited from

TextFileView.onRename

onRename(file)

onRename(file): Promise<void>

Updates the view information based on the new file name

Parameters

file: TFile

The file that is renamed

Returns

Promise<void>

Inherited from

TextFileView.onRename


onResize()

onResize(): void

Called when the size of this view is changed.

Returns

void

Inherited from

TextFileView.onResize


onSwitchView()

onSwitchView(event): Promise<void>

On mod click, opens editor of opposite mode in split view to right

Parameters

event: MouseEvent | KeyboardEvent

Returns

Promise<void>


onTabMenu()

onTabMenu(menu): void

Adds the menu items to the menu

Parameters

menu: Menu

the menu to fill

Returns

void

Inherited from

TextFileView.onTabMenu


onTitleBlur()

onTitleBlur(): Promise<void>

Is called when the titleEl looses focus Event type: ‘blur’

Returns

Promise<void>

Inherited from

TextFileView.onTitleBlur


onTitleChange()

onTitleChange(titleEl): void

Is called when the titleEl is changed Event type: ‘input’

Parameters

titleEl: HTMLElement

The titleEl of the view

Returns

void

Inherited from

TextFileView.onTitleChange


onTitleFocus()

onTitleFocus(): void

Is called when the titleEl gains focus Event type: ‘focus’

Returns

void

Inherited from

TextFileView.onTitleFocus


onTitleKeydown()

onTitleKeydown(event): void

Is called when the titleEl is focused and a keydown is triggered Event type: ‘keydown’

Parameters

event: KeyboardEvent

The KeyboardEvent which triggered this function

Returns

void

Inherited from

TextFileView.onTitleKeydown


onTitlePaste()

onTitlePaste(titleEl, event): void

Is called when the titleEl is focused and a paste event is triggered Event type: ‘paste’

Parameters

titleEl: HTMLElement

The titleEl of the view

event: ClipboardEvent

The ClipboardEvent which triggered this function

Returns

void

Inherited from

TextFileView.onTitlePaste


onunload()

onunload(): void

Override this to unload your component

Returns

void

Inherited from

TextFileView.onunload


onUnloadFile()

onUnloadFile(file): Promise<void>

Parameters

file: TFile

Returns

Promise<void>

Inherited from

TextFileView.onUnloadFile


open()

open(parentEl): Promise<void>

Opens the view

Parameters

parentEl: Node

The node the view get attached to

Returns

Promise<void>

Inherited from

TextFileView.open


printToPdf()

printToPdf(): void

Opens PDF modal for exporting PDF of the current file

Returns

void


redo()

redo(): void

Redo action of source mode editor

Returns

void


register()

register(cb): void

Registers a callback to be called when unloading

Parameters

cb

Returns

void

Inherited from

TextFileView.register


registerDomEvent()

registerDomEvent(el, type, callback, options)

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

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof WindowEventMap

Parameters

el: Window

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

TextFileView.registerDomEvent

registerDomEvent(el, type, callback, options)

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

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof DocumentEventMap

Parameters

el: Document

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

TextFileView.registerDomEvent

registerDomEvent(el, type, callback, options)

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

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof HTMLElementEventMap

Parameters

el: HTMLElement

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

TextFileView.registerDomEvent


registerEvent()

registerEvent(eventRef): void

Registers an event to be detached when unloading

Parameters

eventRef: EventRef

Returns

void

Inherited from

TextFileView.registerEvent


registerInterval()

registerInterval(id): number

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

Parameters

id: number

Returns

number

Inherited from

TextFileView.registerInterval


registerMode()

registerMode(component): void

Register editor mode component to view

Parameters

component: MarkdownSubView

Returns

void


registerScopeEvent()

registerScopeEvent(keymapEventHandler): void

Parameters

keymapEventHandler: KeymapEventHandler

Returns

void

Inherited from

TextFileView.registerScopeEvent


removeChild()

removeChild<T>(component): T

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

TextFileView.removeChild


renderBreadcrumbs()

renderBreadcrumbs(): void

Returns

void

Inherited from

TextFileView.renderBreadcrumbs


save()

save(clear)

save(clear?): Promise<void>

Parameters

clear?: boolean

Returns

Promise<void>

Inherited from

TextFileView.save

save(clear)

save(clear?): Promise<void>

Saves the opened file

Parameters

clear?: boolean

If set clears the editor under certain conditions

Returns

Promise<void>

Inherited from

TextFileView.save


saveFrontmatter()

saveFrontmatter(properties): void

Save the frontmatter of the file

Parameters

properties: Record<string, any>

Returns

void


saveImmediately()

saveImmediately(): void

If any changes(dirty = true) in the file forces the file to save

Returns

void

Inherited from

TextFileView.saveImmediately


saveTitle()

saveTitle(titleEl): Promise<void>

Updates the file to match the updated title

Parameters

titleEl: HTMLElement

The current titleEl

Returns

Promise<void>

Inherited from

TextFileView.saveTitle


setData()

setData(data, clear): void

Set the data to the editor. This is used to load the file contents.

Parameters

data: string

The new data

clear: boolean

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.

Returns

void

Inherited from

TextFileView.setData


setEphemeralState()

setEphemeralState(state)

setEphemeralState(state): void

Parameters

state: unknown

Returns

void

Inherited from

TextFileView.setEphemeralState

setEphemeralState(state)

setEphemeralState(state): void

Set the ephemeral (non-persistent) state of the editor

Parameters

state: any

Returns

void

Inherited from

TextFileView.setEphemeralState


setMode()

setMode(component): Promise<void>

Set the mode of the editor

Parameters

component: MarkdownSubView

Returns

Promise<void>


setState()

setState(state, result): Promise<void>

Parameters

state: any

result: ViewStateResult

Returns

Promise<void>

Inherited from

TextFileView.setState


setViewData()

setViewData(data, clear): void

Parameters

data: string

clear: boolean

Returns

void

Overrides

TextFileView.setViewData


shiftFocusAfter()

shiftFocusAfter(): void

Shift focus to first line of editor

Returns

void


shiftFocusBefore()

shiftFocusBefore(): void

Shift focus to inline title

Returns

void


showSearch()

showSearch(replace?): void

Parameters

replace?: boolean

Returns

void


syncState()

syncState(e): Promise<unknown>

Parameters

e: boolean

Returns

Promise<unknown>

Inherited from

TextFileView.syncState


toggleBacklinks(): Promise<void>

Toggle backlinks on editor

Returns

Promise<void>


toggleCollapseProperties()

toggleCollapseProperties(): void

Toggle collapse status of properties editor if allowed

Returns

void


toggleMode()

toggleMode(): void

Toggle between source and preview mode

Returns

void


triggerClickableToken()

triggerClickableToken(token, new_leaf): void

Execute functionality of token (open external link, open internal link in leaf, …)

Parameters

token: Token

new_leaf: boolean

Returns

void


undo()

undo(): void

Undo action of source mode editor

Returns

void


unload()

unload(): void

Unload this component and its children

Returns

void

Inherited from

TextFileView.unload


updateBacklinks(): void

Update the backlinks component for new file

Returns

void


updateButtons()

updateButtons(): void

Update reading/source view action buttons of modeButtonEl with current mode

Returns

void


updateNavButtons()

updateNavButtons(): void

Updates the navigation buttons depending on the history

Returns

void

Inherited from

TextFileView.updateNavButtons


updateOptions()

updateOptions(): void

Update options of the editors from settings

Returns

void


updateShowBacklinks(): void

Hide/render backlinks component

Returns

void