ReadViewRenderer
Unofficial
Renderer for the reading/preview view, managing section-based markdown rendering.
Import:
import type { ReadViewRenderer } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface ReadViewRendererProperties
| Property | Type | Description | |
|---|---|---|---|
| addBottomPadding | boolean | Whether to add bottom padding to the preview. | |
| asyncSections | unknown[] | Sections that are being rendered asynchronously. | |
| footer | null | RendererSection | The .mod-footer.mod-ui section rendered after the content, or null when the renderer has none. | |
| header | null | RendererSection | The .mod-header.mod-ui section rendered before the content, or null when the renderer has none. | |
| lastRender | number | Timestamp of the last render operation. | |
| lastScroll | number | Last recorded scroll position. | |
| lastText | null | string | Text content from the last render, or null when the next render must not reuse it. | |
| previewEl | HTMLElement | Container element for the rendered preview. | |
| pusherEl | HTMLElement | Element used to push content for scroll height calculation. | |
| recycledSections | unknown[] | Pool of recycled section elements for reuse. | |
| rendered | (() => void)[] | null | Callbacks waiting for the pending render to complete, or null when no render is pending. | |
| sections | RendererSection[] | All sections in the rendered document. | |
| sizerEl | HTMLElement | The .markdown-preview-sizer element that holds the rendered sections. | |
| text | string | Current text content being rendered. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addFooter() | void | Add the footer section, if the renderer has none yet. | |
| addHeader() | void | Add the header section, if the renderer has none yet. | |
| clear() | void | Clear all rendered sections and reset the renderer. | |
| onRendered(callback) | void | Run a callback after the pending render completes, or immediately when no render is pending. | |
| parseAsync() | void | Parse the text content asynchronously into sections. | |
| parseSync() | void | Parse the text content synchronously into sections. | |
| queueRender() | void | Queue a render update for the next animation frame. | |
| removeFooter() | void | Remove the footer section, if the renderer has one. | |
| removeHeader() | void | Remove the header section, if the renderer has one. | |
| rerender(full?) | void | Render the text again. | |
| set(text) | void | Set the text content and trigger a re-render. | |
| updateFooter() | void | Re-measure the footer section and queue a render. Call it after changing the footer's content. | |
| updateHeader() | void | Re-measure the header section and queue a render. Call it after changing the header's content. |
Links to this page: