Skip to content

MarkdownPreviewView

Extends

Implements

Constructors

new MarkdownPreviewView()

new MarkdownPreviewView(containerEl): MarkdownPreviewView

Parameters

containerEl: HTMLElement

This HTMLElement will be used to test whether this component is still alive. It should be a child of the Markdown preview sections, and when it’s no longer attached (for example, when it is replaced with a new version because the user edited the Markdown source code), this component will be unloaded.

Returns

MarkdownPreviewView

Inherited from

MarkdownRenderer.constructor

Properties

_children

_children: Component[]

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

Implementation of

MarkdownPreviewEvents._children

Inherited from

MarkdownPreviewEvents._children


_events

_events: EventRef[]

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

Implementation of

MarkdownPreviewEvents._events

Inherited from

MarkdownPreviewEvents._events


_loaded

_loaded: boolean

Whether the component and its children are loaded

Implementation of

MarkdownPreviewEvents._loaded

Inherited from

MarkdownPreviewEvents._loaded


app

app: App

Inherited from

MarkdownRenderer.app


containerEl

containerEl: HTMLElement

Overrides

MarkdownRenderer.containerEl


docId

docId: string

Unique identifier for the rendered element


hoverPopover

hoverPopover: HoverPopover

Inherited from

MarkdownRenderer.hoverPopover


renderer

renderer: ReadViewRenderer

HTML renderer for the Markdown


search: unknown


type

type: string


view

view: MarkdownView

Accessors

file

get file(): TFile

Returns

TFile

Overrides

MarkdownRenderer.file


path

get path(): unknown

Returns

unknown

Inherited from

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

Implementation of

MarkdownPreviewEvents.addChild

Inherited from

MarkdownPreviewEvents.addChild


applyFoldInfo()

applyFoldInfo(e): unknown

Parameters

e: unknown

Returns

unknown


applyScroll()

applyScroll(scroll): void

Parameters

scroll: number

Returns

void

Implementation of

MarkdownSubView.applyScroll

Inherited from

MarkdownSubView.applyScroll


beforeUnload()

beforeUnload(): unknown

Returns

unknown


clear()

clear()

clear(): void

Returns

void

clear()

clear(): unknown

Clears the rendered preview

Returns

unknown


edit()

edit(e): unknown

Parameters

e: unknown

Returns

unknown


foldAll()

foldAll(): unknown

Returns

unknown


get()

get()

get(): string

Returns

string

Implementation of

MarkdownSubView.get

Inherited from

MarkdownSubView.get

get()

get(): string

Returns the renderer text

Returns

string

Implementation of

MarkdownSubView.get


getEphemeralState()

getEphemeralState(e): unknown

Parameters

e: unknown

Returns

unknown


getFoldInfo()

getFoldInfo(): unknown

Returns

unknown


getScroll()

getScroll(): number

Returns

number

Implementation of

MarkdownSubView.getScroll

Inherited from

MarkdownSubView.getScroll


getSelection()

getSelection(): unknown

Returns

unknown


hide()

hide(): void

Returns

void


load()

load(): void

Load this component and its children

Returns

void

Implementation of

MarkdownPreviewEvents.load

Inherited from

MarkdownPreviewEvents.load


onCheckboxClick()

onCheckboxClick(e, n, i): unknown

Parameters

e: unknown

n: unknown

i: unknown

Returns

unknown

Inherited from

MarkdownRenderer.onCheckboxClick


onFileChange()

onFileChange(e): unknown

Parameters

e: unknown

Returns

unknown

Inherited from

MarkdownRenderer.onFileChange


onFoldChange()

onFoldChange(): unknown

Returns

unknown

Inherited from

MarkdownRenderer.onFoldChange


onload()

onload(): void

Override this to load your component

Returns

void

Implementation of

MarkdownPreviewEvents.onload

Inherited from

MarkdownPreviewEvents.onload


onRenderComplete()

onRenderComplete(): unknown

Returns

unknown

Inherited from

MarkdownRenderer.onRenderComplete


onResize()

onResize(): unknown

Returns

unknown


onScroll()

onScroll(): unknown

Returns

unknown

Inherited from

MarkdownRenderer.onScroll


onunload()

onunload(): void

Override this to unload your component

Returns

void

Implementation of

MarkdownPreviewEvents.onunload

Inherited from

MarkdownPreviewEvents.onunload


postProcess()

postProcess(e, t, n): unknown

Parameters

e: unknown

t: unknown

n: unknown

Returns

unknown

Inherited from

MarkdownRenderer.postProcess


register()

register(cb): void

Registers a callback to be called when unloading

Parameters

cb

Returns

void

Implementation of

MarkdownPreviewEvents.register

Inherited from

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

Implementation of

MarkdownPreviewEvents.registerDomEvent

Inherited from

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

Implementation of

MarkdownPreviewEvents.registerDomEvent

Inherited from

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

Implementation of

MarkdownPreviewEvents.registerDomEvent

Inherited from

MarkdownPreviewEvents.registerDomEvent


registerEvent()

registerEvent(eventRef): void

Registers an event to be detached when unloading

Parameters

eventRef: EventRef

Returns

void

Implementation of

MarkdownPreviewEvents.registerEvent

Inherited from

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

Implementation of

MarkdownPreviewEvents.registerInterval

Inherited from

MarkdownPreviewEvents.registerInterval


registerScopeEvent()

registerScopeEvent(keymapEventHandler): void

Parameters

keymapEventHandler: KeymapEventHandler

Returns

void

Implementation of

MarkdownPreviewEvents.registerScopeEvent

Inherited from

MarkdownPreviewEvents.registerScopeEvent


removeChild()

removeChild<T>(component): T

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Implementation of

MarkdownPreviewEvents.removeChild

Inherited from

MarkdownPreviewEvents.removeChild


requestUpdateLinks(): unknown

Returns

unknown


rerender()

rerender(full?): void

Parameters

full?: boolean

Returns

void


resolveLinks(e): unknown

Parameters

e: unknown

Returns

unknown

Inherited from

MarkdownRenderer.resolveLinks


set()

set(data, clear)

set(data, clear): void

Parameters

data: string

clear: boolean

Returns

void

Implementation of

MarkdownSubView.set

Inherited from

MarkdownSubView.set

set(data, clear)

set(data, clear): void

Set the Preview to new data

Parameters

data: string

The data to set the renderer to

clear: boolean

If the preview should be cleared

Returns

void

Implementation of

MarkdownSubView.set


setEphemeralState()

setEphemeralState(e): unknown

Parameters

e: unknown

Returns

unknown


show()

show(): void

Returns

void


showSearch()

showSearch(): unknown

Returns

unknown


unfoldAll()

unfoldAll(): unknown

Returns

unknown


unload()

unload(): void

Unload this component and its children

Returns

void

Implementation of

MarkdownPreviewEvents.unload

Inherited from

MarkdownPreviewEvents.unload


updateOptions()

updateOptions(): unknown

Returns

unknown


render()

static render(app, markdown, el, sourcePath, component): Promise<void>

Renders Markdown string to an HTML element.

Parameters

app: App

A reference to the app object

markdown: string

The Markdown source code

el: HTMLElement

The element to append to

sourcePath: string

The normalized path of this Markdown file, used to resolve relative internal links

component: Component

A parent component to manage the lifecycle of the rendered child components.

Returns

Promise<void>

Inherited from

MarkdownRenderer.render


renderMarkdown()

static renderMarkdown(markdown, el, sourcePath, component): Promise<void>

Renders Markdown string to an HTML element.

Parameters

markdown: string

el: HTMLElement

sourcePath: string

component: Component

Returns

Promise<void>

Inherited from

MarkdownRenderer.renderMarkdown