Skip to content

MarkdownPreviewView

Official

The markdown preview view.

Import:

import { MarkdownPreviewView } from 'obsidian';

Signature:

export class MarkdownPreviewView extends MarkdownRenderer implements MarkdownSubView, MarkdownPreviewEvents

Extends: MarkdownRenderer

Implements: MarkdownSubView, MarkdownPreviewEvents

Constructor

new MarkdownPreviewView(markdownView: MarkdownView)

Constructor.

To get the constructor instance, use getMarkdownPreviewViewConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
_childrenComponent[]Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from MarkdownPreviewEvents)
_eventsEventRef[]Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from MarkdownPreviewEvents)
_loadedbooleanWhether the component and its children are loaded.
(Inherited from MarkdownPreviewEvents)
appAppThe Obsidian app instance.
(Inherited from MarkdownRenderer)
containerElHTMLElementThe container element of the markdown preview view.
docIdstringUnique identifier for the rendered element.
hoverPopoverHoverPopover | nullThe hover popover of the markdown renderer.
(Inherited from MarkdownRenderer)
rendererReadViewRendererHTML renderer for the Markdown.
searchnull | unknownSearch instance for in-document search, or null if inactive.
type'preview' | stringThe subview type identifier (e.g. 'preview').
viewMarkdownViewThe parent obsidian#MarkdownView containing this preview.

Methods

MethodReturnsDescription
addChild(component)TAdds a child component, loading it if this component is loaded.
(Inherited from MarkdownPreviewEvents)
applyFoldInfo(e)unknownApply fold information to the preview.
applyScroll(scroll)voidApply the scroll position to the markdown preview view.
beforeUnload()unknownPerform cleanup before the preview is unloaded.
clear()voidClear the markdown content of the markdown preview view.
edit(e)unknownSwitch to edit mode for the given element or selection.
foldAll()unknownFold all foldable sections in the preview.
get()stringGet the markdown content of the markdown preview view.
getEphemeralState(e)unknownGet the ephemeral state of the preview (e.g. scroll position).
getFoldInfo()unknownGet the current fold state information.
getScroll()numberGet the scroll position of the markdown preview view.
getSelection()unknownGet the current text selection in the preview.
hide()voidHide the preview view.
load()voidLoad this component and its children.
(Inherited from MarkdownPreviewEvents)
onCheckboxClick(e, n, i)unknownHandle a checkbox click event in the rendered markdown.
(Inherited from MarkdownRenderer)
onConfigChanged(configKey)voidHandles an app config change relevant to the preview, dispatching to the matching update method.
onFileChange(e)unknownHandle a file change event for the rendered file.
(Inherited from MarkdownRenderer)
onFoldChange()unknownHandle a fold state change in the preview.
onload()voidCalled when the preview view is loaded.
onRenderComplete()unknownCalled when the markdown rendering is complete.
(Inherited from MarkdownRenderer)
onResize()unknownHandle a resize event on the preview view.
onScroll()unknownHandle a scroll event on the preview view.
onunload()voidOverride this to unload your component
(Inherited from MarkdownPreviewEvents)
postProcess(e, t, n)unknownApply post-processing to the rendered markdown output.
(Inherited from MarkdownRenderer)
register(cb)voidRegisters a callback to be called when unloading.
(Inherited from MarkdownPreviewEvents)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading.
(Inherited from MarkdownPreviewEvents)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from MarkdownPreviewEvents)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from MarkdownPreviewEvents)
registerEvent(eventRef)voidRegisters an event to be detached when unloading.
(Inherited from MarkdownPreviewEvents)
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 MarkdownPreviewEvents)
registerScopeEvent(keymapEventHandler)voidRegister a scope keymap event handler to be removed on unload.
(Inherited from MarkdownPreviewEvents)
removeChild(component)TRemoves a child component, unloading it.
(Inherited from MarkdownPreviewEvents)
render(app, markdown, el, sourcePath, component)Promise<void>Renders Markdown string to an HTML element.
(Inherited from MarkdownRenderer)
renderMarkdown(markdown, el, sourcePath, component)Promise<void>Renders Markdown string to an HTML element.
(Inherited from MarkdownRenderer)
requestUpdateLinks()unknownRequest an update of rendered links in the preview.
rerender(full?)voidForce the markdown preview view to rerender.
resolveLinks(e)unknownResolve internal links in the rendered markdown.
(Inherited from MarkdownRenderer)
set(data, clear)voidSet the markdown content of the markdown preview view.
setEphemeralState(e)unknownSet the ephemeral state of the preview (e.g. scroll position).
show()voidShow the preview view.
showSearch()unknownShow the in-document search bar.
unfoldAll()unknownUnfold all folded sections in the preview.
unload()voidOverride this to unload your component.
(Inherited from MarkdownPreviewEvents)
updateFoldHeading()voidUpdates whether headings can be folded in the preview.
updateFoldIndent()voidUpdates whether lists can be folded in the preview.
updateIndentGuide()voidUpdates the indentation-guide display in the preview.
updateOptions()unknownUpdate the rendering options of the preview.
updatePropertiesInDocument()voidUpdates whether properties are shown inline in the document.
updateReadableLineLength()voidUpdates the readable-line-length display in the preview.
updateRTL()voidUpdates the right-to-left text direction of the preview.
updateStrictLineBreaks()voidUpdates strict-line-break handling and re-renders the preview.

Links to this page: