Skip to content

MarkdownEditView

This is the editor for Obsidian Mobile as well as the upcoming WYSIWYG editor.

Extends

Implements

Constructors

new MarkdownEditView()

new MarkdownEditView(view): MarkdownEditView

Parameters

view: MarkdownView

Returns

MarkdownEditView

Properties

_children

_children: Component[]

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

Inherited from

MarkdownScrollableEditView._children


_events

_events: EventRef[]

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

Inherited from

MarkdownScrollableEditView._events


_loaded

_loaded: boolean

Whether the component and its children are loaded

Inherited from

MarkdownScrollableEditView._loaded


app

app: App

Implementation of

MarkdownFileInfo.app

Inherited from

MarkdownScrollableEditView.app


cleanupLivePreview

cleanupLivePreview: null | () => void

Callback to clear all elements

Inherited from

MarkdownScrollableEditView.cleanupLivePreview


clipboardManager

clipboardManager: ClipBoardManager

Manager that handles pasting text, html and images into the editor

Inherited from

MarkdownScrollableEditView.clipboardManager


cm

cm: EditorView

Codemirror editor instance

Inherited from

MarkdownScrollableEditView.cm


cmInit

cmInit: boolean

Whether CodeMirror is initialized

Inherited from

MarkdownScrollableEditView.cmInit


containerEl

containerEl: HTMLElement

Container element of the editor view

Inherited from

MarkdownScrollableEditView.containerEl


cssClasses

cssClasses: []

List of CSS classes applied to the editor

Inherited from

MarkdownScrollableEditView.cssClasses


cursorPopupEl

cursorPopupEl: null | HTMLElement

Popup element for internal link

Inherited from

MarkdownScrollableEditView.cursorPopupEl


editor?

optional editor: Editor

Implementation of

MarkdownFileInfo.editor

Inherited from

MarkdownScrollableEditView.editor


editorEl

editorEl: HTMLElement

Element in which the CodeMirror editor resides

Inherited from

MarkdownScrollableEditView.editorEl


editorSuggest

editorSuggest: EditorSuggests

Editor suggester for autocompleting files, links, aliases, etc.

Inherited from

MarkdownScrollableEditView.editorSuggest


hoverPopover

hoverPopover: HoverPopover

Implementation of

MarkdownFileInfo.hoverPopover

Inherited from

MarkdownFileInfo.hoverPopover


isScrolling

isScrolling: boolean

Whether the editor is currently scrolling

Inherited from

MarkdownScrollableEditView.isScrolling


livePreviewPlugin

livePreviewPlugin: Extension[]

The CodeMirror plugins that handle the rendering of, and interaction with Obsidian’s Markdown

Inherited from

MarkdownScrollableEditView.livePreviewPlugin


localExtensions

localExtensions: Extension[]

Local (always active) extensions for the editor

Inherited from

MarkdownScrollableEditView.localExtensions


metadataEditor?

optional metadataEditor: MetadataEditor

Implementation of

MarkdownFileInfo.metadataEditor

Inherited from

MarkdownFileInfo.metadataEditor


owner

owner: MarkdownFileInfo

Controller of the editor view

Inherited from

MarkdownScrollableEditView.owner


propertiesExtension

propertiesExtension: Extension[]

Frontmatter editor extension for the editor


scope

scope: undefined | Scope

Scope for the search component, if exists

Inherited from

MarkdownScrollableEditView.scope


search: EditorSearchComponent

Search component for the editor, provides highlight and search functionality

Inherited from

MarkdownScrollableEditView.search


sizerEl

sizerEl: HTMLElement

Container for the editor, handles editor size

Inherited from

MarkdownScrollableEditView.sizerEl


sourceMode

sourceMode: boolean

Whether live preview rendering is disabled

Inherited from

MarkdownScrollableEditView.sourceMode


tableCell

tableCell: null | TableCellEditor

Reference to editor attached to table cell, if any

Inherited from

MarkdownScrollableEditView.tableCell


type

type: "source"

Editing mode of the editor


view

view: MarkdownView

View the source view editor is attached to

Accessors

activeCM

get activeCM(): EditorView

Currently active CM instance (table cell CM or main CM)

Returns

EditorView

Inherited from

MarkdownScrollableEditView.activeCM


file

get file(): TFile

Returns

TFile

Implementation of

MarkdownFileInfo.file

Inherited from

MarkdownScrollableEditView.file


path

get path(): string

Returns path of the attached file

Returns

string

Inherited from

MarkdownScrollableEditView.path

Methods

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

MarkdownScrollableEditView.addChild


applyFoldInfo()

applyFoldInfo(info): void

Apply fold history to editor

Parameters

info: FoldInfo

Returns

void

Inherited from

MarkdownScrollableEditView.applyFoldInfo


applyScroll()

applyScroll(scroll): void

Parameters

scroll: number

Returns

void

Implementation of

MarkdownSubView.applyScroll

Inherited from

MarkdownScrollableEditView.applyScroll


beforeUnload()

beforeUnload(): void

Save functionality to execute before editor view unload

Returns

void


buildLocalExtensions()

buildLocalExtensions(): Extension[]

Constructs local (always active) extensions for the editor

Returns

Extension[]

Inherited from

MarkdownScrollableEditView.buildLocalExtensions


clear()

clear()

clear(): void

Returns

void

Inherited from

MarkdownScrollableEditView.clear

clear()

clear(): void

Clear the editor view

Returns

void


destroy()

destroy(): void

Destroy/Detach the editor view

Returns

void

Inherited from

MarkdownScrollableEditView.destroy


destroyTableCell()

destroyTableCell(cell?): void

Removes specified tablecell

Parameters

cell?: TableCellEditor

Returns

void

Inherited from

MarkdownScrollableEditView.destroyTableCell


editTableCell()

editTableCell(cell, new_cell): TableCellEditor

Edit a specified table cell, creating a table cell editor

Parameters

cell: TableEditor

new_cell: TableCell

Returns

TableCellEditor

Inherited from

MarkdownScrollableEditView.editTableCell


focus()

focus(): void

Focus the editor (and for mobile: render keyboard)

Returns

void

Inherited from

MarkdownScrollableEditView.focus


get()

get(): string

Returns

string

Implementation of

MarkdownSubView.get

Inherited from

MarkdownScrollableEditView.get


getDynamicExtensions()

getDynamicExtensions(): Extension[]

Constructs extensions for the editor based on user settings

Returns

Extension[]

Inherited from

MarkdownScrollableEditView.getDynamicExtensions


getEphemeralState()

getEphemeralState(state): object

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

Parameters

state: unknown

Returns

object

cursor

cursor: EditorRange


getFoldInfo()

getFoldInfo(): null | FoldInfo

Get the current folds of the editor

Returns

null | FoldInfo

Inherited from

MarkdownScrollableEditView.getFoldInfo


getLocalExtensions()

getLocalExtensions(): unknown

Builds all local extensions and assigns to this.localExtensions

Returns

unknown

Inherited from

MarkdownScrollableEditView.getLocalExtensions


getScroll()

getScroll(): number

Returns

number

Implementation of

MarkdownSubView.getScroll

Inherited from

MarkdownScrollableEditView.getScroll


getSelection()

getSelection()

getSelection(): string

Returns

string

getSelection()

getSelection(): string

Get the main selected range as string

Returns

string


handleScroll()

handleScroll(): void

Invokes onMarkdownScroll on scroll

Returns

void

Inherited from

MarkdownScrollableEditView.handleScroll


hide()

hide(): void

Hides the editor (sets display: none)

Returns

void

Inherited from

MarkdownScrollableEditView.hide


highlightSearchMatches()

highlightSearchMatches(ranges, style?, remove_previous?, range?): void

Add highlights for specified ranges

Parameters

ranges: EditorRange[]

style?: "is-flashing" | "obsidian-search-match-highlight"

remove_previous?: boolean

range?: EditorSelection

Returns

void


load()

load(): void

Load this component and its children

Returns

void

Inherited from

MarkdownScrollableEditView.load


onContextMenu()

onContextMenu(event, x): Promise<void>

Creates menu on right mouse click

Parameters

event: PointerEvent

x: boolean

Returns

Promise<void>

Inherited from

MarkdownScrollableEditView.onContextMenu


onCssChange()

onCssChange(): void

Clear editor cache and refreshes editor on app css change

Returns

void

Inherited from

MarkdownScrollableEditView.onCssChange


onEditorClick()

onEditorClick(event, element?): void

Execute click functionality on token on mouse click

Parameters

event: MouseEvent

element?: HTMLElement

Returns

void

Inherited from

MarkdownScrollableEditView.onEditorClick


onEditorDragStart()

onEditorDragStart(event): void

Execute drag functionality on drag start

Parameters

event: DragEvent

Returns

void

Inherited from

MarkdownScrollableEditView.onEditorDragStart


onEditorLinkMouseover()

onEditorLinkMouseover(event, target): void

Execute hover functionality on mouse over event

Parameters

event: MouseEvent

target: HTMLElement

Returns

void

Inherited from

MarkdownScrollableEditView.onEditorLinkMouseover


onload()

onload(): void

Override this to load your component

Returns

void

Inherited from

MarkdownScrollableEditView.onload


onMenu()

onMenu(event): void

Execute context menu functionality on right mouse click

Parameters

event: MouseEvent

Returns

void

Inherited from

MarkdownScrollableEditView.onMenu


onResize()

onResize(): void

Update editor size and bottom padding on resize

Returns

void

Inherited from

MarkdownScrollableEditView.onResize


onScroll()

onScroll(): void

Update editor suggest position and invokes handleScroll on scroll

Returns

void

Inherited from

MarkdownScrollableEditView.onScroll


onunload()

onunload(): void

Override this to unload your component

Returns

void

Inherited from

MarkdownScrollableEditView.onunload


onUpdate()

onUpdate(update, changed): void

Execute functionality on CM editor state update

Parameters

update: ViewUpdate

changed: boolean

Returns

void

Inherited from

MarkdownScrollableEditView.onUpdate


onViewClick()

onViewClick(event?): void

Close editor suggest and removes highlights on click

Parameters

event?: MouseEvent

Returns

void

Inherited from

MarkdownScrollableEditView.onViewClick


register()

register(cb): void

Registers a callback to be called when unloading

Parameters

cb

Returns

void

Inherited from

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

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

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

MarkdownScrollableEditView.registerDomEvent


registerEvent()

registerEvent(eventRef): void

Registers an event to be detached when unloading

Parameters

eventRef: EventRef

Returns

void

Inherited from

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

MarkdownScrollableEditView.registerInterval


registerScopeEvent()

registerScopeEvent(keymapEventHandler): void

Parameters

keymapEventHandler: KeymapEventHandler

Returns

void

Inherited from

MarkdownScrollableEditView.registerScopeEvent


reinit()

reinit(): void

Reinitialize the editor inside new container

Returns

void

Inherited from

MarkdownScrollableEditView.reinit


removeChild()

removeChild<T>(component): T

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

MarkdownScrollableEditView.removeChild


reparent()

reparent(new_container): void

Move the editor into the new container

Parameters

new_container: HTMLElement

Returns

void

Inherited from

MarkdownScrollableEditView.reparent


requestOnInternalDataChange()

requestOnInternalDataChange(): void

Debounced onInternalDataChange of view

Returns

void


requestSaveFolds()

requestSaveFolds(): unknown

Debounced onMarkdownFold of view

Returns

unknown


resetSyntaxHighlighting()

resetSyntaxHighlighting(): void

Bodge to reset the syntax highlighting

Returns

void

Inherited from

MarkdownScrollableEditView.resetSyntaxHighlighting


set()

set(data, clear)

set(data, clear): void

Parameters

data: string

clear: boolean

Returns

void

Implementation of

MarkdownSubView.set

Inherited from

MarkdownScrollableEditView.set

set(data, clear)

set(data, clear): void

Set the state of the editor

Parameters

data: string

clear: boolean

Returns

void

Implementation of

MarkdownSubView.set


setCssClass()

setCssClass(classes): void

Add classes to the editor, functions as a toggle

Parameters

classes: string[]

Returns

void

Inherited from

MarkdownScrollableEditView.setCssClass


setEphemeralState()

setEphemeralState(state): void

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

Parameters

state: unknown

Returns

void


setHighlight()

setHighlight(match): void

Set highlight of any search match

Parameters

match

match.endLoc?: number

match.focus: boolean

match.line?: number

match.match?: unknown

match.startLoc?: number

Returns

void


setState()

setState(state): void

Set the state of the editor (applies selections, scrolls, …)

Parameters

state: unknown

Returns

void


show()

show(): void

Render the editor and the metadata-editor element

Returns

void

Inherited from

MarkdownScrollableEditView.show


showSearch()

showSearch(replace): void

Reveal the search (and replace) component

Parameters

replace: boolean

Returns

void

Inherited from

MarkdownScrollableEditView.showSearch


toggleFoldFrontmatter()

toggleFoldFrontmatter(): void

Enables/disables frontmatter folding

Returns

void

Inherited from

MarkdownScrollableEditView.toggleFoldFrontmatter


toggleSource()

toggleSource(): void

Toggle source mode for editor and dispatch effect

Returns

void

Inherited from

MarkdownScrollableEditView.toggleSource


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

Inherited from

MarkdownScrollableEditView.triggerClickableToken


unload()

unload(): void

Unload this component and its children

Returns

void

Inherited from

MarkdownScrollableEditView.unload


updateBottomPadding()

updateBottomPadding(height): void

Update the bottom padding of the CodeMirror contentdom (based on backlinksEl)

Parameters

height: number

Returns

void

Inherited from

MarkdownScrollableEditView.updateBottomPadding


updateLinkPopup()

updateLinkPopup(): void

In mobile, creates a popover link on clickable token, if exists

Returns

void

Inherited from

MarkdownScrollableEditView.updateLinkPopup


updateOptions()

updateOptions(): void

Update options of the editor from settings

Returns

void

Inherited from

MarkdownScrollableEditView.updateOptions