MarkdownPreviewRenderer
Official
The renderer of the markdown preview.
Import:
import { MarkdownPreviewRenderer } from 'obsidian';Signature:
export class MarkdownPreviewRendererConstructor
new MarkdownPreviewRenderer(owner: unknown, containerEl: HTMLElement, parentEl: HTMLElement, workerPath: unknown, observeInsertion?: boolean | undefined)Constructor.
To get the constructor instance, use getMarkdownPreviewRendererConstructor from obsidian-typings/implementations.
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addFooter() | void | Adds a footer section to the rendered preview. | |
| addHeader() | void | Adds a header section to the rendered preview. | |
| applyFoldInfo(foldInfo) | void | Applies fold information to the preview. | |
| applyScroll(scroll, options?) | boolean | Scrolls the preview to a position. | |
| applyScrollDelayed(scroll, options?, callback?) | void | Scrolls the preview to a position once rendering has completed. | |
| applyScrollSection(section) | boolean | undefined | Scrolls the preview so the given section is at the top. | |
| belongsToMe(el) | boolean | Checks whether an element belongs to this renderer. | |
| cleanupParentComponents() | void | Removes child components whose elements no longer belong to this renderer. | |
| clear() | void | Clears the rendered sections. | |
| createCodeBlockPostProcessor(language, handler) | (el: HTMLElement, ctx: MarkdownPostProcessorContext) => void | ||
| foldAllHeadings() | void | Folds all headings in the preview. | |
| foldAllLists() | void | Folds all lists in the preview. | |
| getFoldInfo() | FoldInfo | Gets the current fold information. | |
| getInternalLinkHref(el) | null | string | Gets the internal-link href for an element, if it belongs to this renderer. | |
| getScroll() | null | number | Gets the current scroll position. | |
| getSectionContainer(el) | unknown | Gets the section whose element contains the given element. | |
| getSectionForElement(el) | unknown | Gets the section whose element contains the given element. | |
| getSectionInfo(el) | MarkdownSectionInformation | null | Gets section information for an element. | |
| getSectionTop(section) | number | Gets the scroll-top offset of a section. | |
| handleDetached(el) | boolean | Checks whether an element belongs to one of this renderer's sections. | |
| highlightEl(el) | void | Briefly highlights an element. | |
| measureSection(section) | void | Measures the rendered height of a section. | |
| onCheckboxClick(evt, el) | void | Handles a checkbox click within the preview. | |
| onFootnoteLinkClick(evt, el) | void | Handles a footnote-link click within the preview. | |
| onHeadingCollapseClick(evt, el) | void | Handles a heading-collapse-indicator click within the preview. | |
| onListCollapseClick(evt, el) | void | Handles a list-collapse-indicator click within the preview. | |
| onRender() | void | Renders the queued sections. | |
| onRendered(callback) | void | Registers a callback to run after the next render, or immediately if already rendered. | |
| onResize() | void | Handles a resize of the preview container. | |
| onScroll() | void | Handles a scroll of the preview container. | |
| parseAsync() | void | Parses the current text asynchronously. | |
| parseFinish(text, parseResult) | void | Finalizes a parse result into sections. | |
| parseSync() | void | Parses the current text synchronously. | |
| queueRender() | void | Queues a render of the preview. | |
| registerPostProcessor(postProcessor, sortOrder?) | void | ||
| removeFooter() | void | Removes the footer section from the preview. | |
| removeHeader() | void | Removes the header section from the preview. | |
| renderHighlights(startSection, endSection) | void | Renders search highlights across a range of sections. | |
| rerender(full?) | void | Re-renders the preview. | |
| selectRange(range) | void | Selects a range within the preview, scrolling its section into view. | |
| set(text) | void | Sets the preview text and queues a render. | |
| setListCollapse(el, collapsed) | void | Collapses or expands the lists within an element. | |
| showSection(section) | void | Ensures a section is shown, updating the virtual display. | |
| unfoldAllHeadings() | void | Unfolds all headings in the preview. | |
| unfoldAllLists() | void | Unfolds all lists in the preview. | |
| unregisterPostProcessor(postProcessor) | void | ||
| updateFooter() | void | Re-measures the footer section. | |
| updateHeader() | void | Re-measures the header section. | |
| updateShownSections() | void | Recomputes which sections should be shown based on heading-fold levels. | |
| updateVirtualDisplay(scrollTop?) | void | Updates the virtually-rendered sections for the current scroll position. | |
| static registerDomEvents(el, handlers, childElFn) | void | Registers the DOM events. | |
| static unregisterCodeBlockPostProcessor(language) | void | Remove the code block post processor currently registered with the given language. |
Links to this page: