Skip to content

MarkdownBaseView

Unofficial

Base interface for markdown editor views, providing CodeMirror integration and editing capabilities.

Import:

import type { MarkdownBaseView } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface MarkdownBaseView extends Component

Extends: Component

Constructor

new MarkdownBaseView()

Constructor.

To extract the constructor type, use ExtractConstructor<Component>.

Properties

PropertyTypeDescription
_childrenComponent[]Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from Component)
_eventsEventRef[]Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from Component)
_loadedbooleanWhether the component and its children are loaded.
(Inherited from Component)
appAppReference to the app.
cleanupLivePreview(() => void) | nullCallback to clear all elements.
clipboardManagerClipboardManagerManager that handles pasting text, html and images into the editor.
cmEditorViewCodemirror editor instance.
cmInitbooleanWhether CodeMirror is initialized.
containerElHTMLElementContainer element of the editor view.
cursorPopupElHTMLElement | nullPopup element for internal link.
editor?EditorObsidian editor instance.
editorElHTMLElementElement in which the CodeMirror editor resides.
editorSuggestEditorSuggestsEditor suggester for autocompleting files, links, aliases, etc.
livePreviewPluginExtension[]The CodeMirror plugins that handle the rendering of, and interaction with Obsidian's Markdown.
localExtensionsExtension[]Local (always active) extensions for the editor.
ownerMarkdownFileInfoController of the editor view.
sourceModebooleanWhether live preview rendering is disabled.
tableCellnull | TableCellEditorReference to editor attached to table cell, if any.

Methods

MethodReturnsDescription
addChild(component)TAdds a child component, loading it if this component is loaded.
(Inherited from Component)
applyFoldInfo(info)voidApply fold history to editor.
buildLocalExtensions()Extension[]Constructs local (always active) extensions for the editor.
clear()voidCleanup live preview, remove and then re-add all editor extensions.
destroy()voidClean up live preview, remove all extensions, destroy editor.
destroyTableCell(cell?)voidRemoves specified tablecell.
editTableCell(cell, newCell)TableCellEditorEdit a specified table cell, creating a table cell editor.
get()stringGet the current editor document as a string.
getDynamicExtensions()Extension[]Constructs extensions for the editor based on user settings.
getFoldInfo()FoldInfo | nullGet the current folds of the editor.
getLocalExtensions()unknownBuilds all local extensions and assigns to this.localExtensions.
load()voidLoad this component and its children.
(Inherited from Component)
onContextMenu(event, x)Promise<void>Creates menu on right mouse click.
onEditorClick(event, element?)voidExecute click functionality on token on mouse click.
onEditorDragStart(event)voidExecute drag functionality on drag start.
onEditorLinkMouseover(event, target)voidExecute hover functionality on mouse over event.
onload()voidOverride this to load your component.
(Inherited from Component)
onMenu(event)voidExecute context menu functionality on right mouse click.
onResize()voidReposition suggest and scroll position on resize.
onunload()voidOverride this to unload your component
(Inherited from Component)
onUpdate(update, changed)voidExecute functionality on CM editor state update.
register(cb)voidRegisters a callback to be called when unloading.
(Inherited from Component)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading.
(Inherited from Component)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from Component)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from Component)
registerEvent(eventRef)voidRegisters an event to be detached when unloading.
(Inherited from Component)
registerInterval(id)numberRegisters an interval (from setInterval) to be cancelled when unloading. Use window.setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API
(Inherited from Component)
registerScopeEvent(keymapEventHandler)voidRegister a scope keymap event handler to be removed on unload.
(Inherited from Component)
reinit()voidReinitialize the editor inside new container.
removeChild(component)TRemoves a child component, unloading it.
(Inherited from Component)
reparent(newContainer)voidMove the editor into the new container.
resetSyntaxHighlighting()voidBodge to reset the syntax highlighting.
saveHistory()voidSave history of file and data (for caching, for faster reopening of same file in editor).
set(data, clear)voidSet the state of the editor.
toggleFoldFrontmatter()voidEnables/disables frontmatter folding.
toggleSource()voidToggle source mode for editor and dispatch effect.
triggerClickableToken(token, newLeaf)voidExecute functionality of token (open external link, open internal link in leaf, ...).
unload()voidOverride this to unload your component.
(Inherited from Component)
updateEvent()(update: ViewUpdate) => voidCallback for onUpdate functionality added as an extension.
updateLinkPopup()voidIn mobile, creates a popover link on clickable token, if exists.
updateOptions()voidReconfigure/re-add all the dynamic extensions.

Links to this page: