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

Property Type Description
_children Component[] Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from MarkdownPreviewEvents)
_events EventRef[] Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from MarkdownPreviewEvents)
_loaded boolean Whether the component and its children are loaded.
(Inherited from MarkdownPreviewEvents)
app App The Obsidian app instance.
(Inherited from MarkdownRenderer)
containerEl HTMLElement The container element of the markdown preview view.
docId string Unique identifier for the rendered element.
hoverPopover HoverPopover | null The hover popover of the markdown renderer.
(Inherited from MarkdownRenderer)
renderer ReadViewRenderer HTML renderer for the Markdown.
search null | unknown Search instance for in-document search, or null if inactive.
type 'preview' | string The subview type identifier (e.g. 'preview').
view MarkdownView The parent obsidian#MarkdownView containing this preview.

Methods

Method Returns Description
addChild(component) T Adds a child component, loading it if this component is loaded.
(Inherited from MarkdownPreviewEvents)
applyFoldInfo(e) unknown Apply fold information to the preview.
applyScroll(scroll) void Apply the scroll position to the markdown preview view.
beforeUnload() unknown Perform cleanup before the preview is unloaded.
clear() void Clear the markdown content of the markdown preview view.
edit(e) unknown Switch to edit mode for the given element or selection.
foldAll() unknown Fold all foldable sections in the preview.
get() string Get the markdown content of the markdown preview view.
getEphemeralState(e) unknown Get the ephemeral state of the preview (e.g. scroll position).
getFoldInfo() unknown Get the current fold state information.
getScroll() number Get the scroll position of the markdown preview view.
getSelection() unknown Get the current text selection in the preview.
hide() void Hide the preview view.
load() void Load this component and its children.
(Inherited from MarkdownPreviewEvents)
onCheckboxClick(e, n, i) unknown Handle a checkbox click event in the rendered markdown.
(Inherited from MarkdownRenderer)
onConfigChanged(configKey) void Handles an app config change relevant to the preview, dispatching to the matching update method.
onFileChange(e) unknown Handle a file change event for the rendered file.
(Inherited from MarkdownRenderer)
onFoldChange() unknown Handle a fold state change in the preview.
onload() void Called when the preview view is loaded.
onRenderComplete() unknown Called when the markdown rendering is complete.
(Inherited from MarkdownRenderer)
onResize() unknown Handle a resize event on the preview view.
onScroll() unknown Handle a scroll event on the preview view.
onunload() void Override this to unload your component
(Inherited from MarkdownPreviewEvents)
postProcess(e, t, n) unknown Apply post-processing to the rendered markdown output.
(Inherited from MarkdownRenderer)
register(cb) void Registers a callback to be called when unloading.
(Inherited from MarkdownPreviewEvents)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading.
(Inherited from MarkdownPreviewEvents)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from MarkdownPreviewEvents)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from MarkdownPreviewEvents)
registerEvent(eventRef) void Registers an event to be detached when unloading.
(Inherited from MarkdownPreviewEvents)
registerInterval(id) number Registers 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) void Register a scope keymap event handler to be removed on unload.
(Inherited from MarkdownPreviewEvents)
removeChild(component) T Removes 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() unknown Request an update of rendered links in the preview.
rerender(full?) void Force the markdown preview view to rerender.
resolveLinks(e) unknown Resolve internal links in the rendered markdown.
(Inherited from MarkdownRenderer)
set(data, clear) void Set the markdown content of the markdown preview view.
setEphemeralState(e) unknown Set the ephemeral state of the preview (e.g. scroll position).
show() void Show the preview view.
showSearch() unknown Show the in-document search bar.
unfoldAll() unknown Unfold all folded sections in the preview.
unload() void Override this to unload your component.
(Inherited from MarkdownPreviewEvents)
updateFoldHeading() void Updates whether headings can be folded in the preview.
updateFoldIndent() void Updates whether lists can be folded in the preview.
updateIndentGuide() void Updates the indentation-guide display in the preview.
updateOptions() unknown Update the rendering options of the preview.
updatePropertiesInDocument() void Updates whether properties are shown inline in the document.
updateReadableLineLength() void Updates the readable-line-length display in the preview.
updateRTL() void Updates the right-to-left text direction of the preview.
updateStrictLineBreaks() void Updates strict-line-break handling and re-renders the preview.

Links to this page: