From a04577628731ced61b04e40d82afa86dd1c51c79 Mon Sep 17 00:00:00 2001 From: Jeremy Valentine <38669521+valentine195@users.noreply.github.com> Date: Wed, 22 May 2024 20:09:43 -0400 Subject: [PATCH] fix: Improves lifetime of Admonition rendered content --- src/main.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index cd39c26..c748ec8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,6 @@ import { addIcon, Component, editorLivePreviewField, - livePreviewState, MarkdownPostProcessor, MarkdownPostProcessorContext, MarkdownPreviewRenderer, @@ -81,6 +80,9 @@ declare module "obsidian" { dispatch: (tr: TransactionSpec) => void; }; } + interface Workspace { + iterateCodeMirrors(callback: (cm: CodeMirror.Editor) => void): void; + } } import AdmonitionSetting from "./settings"; @@ -90,6 +92,7 @@ import { IconName } from "@fortawesome/fontawesome-svg-core"; import CalloutManager from "./callout/manager"; import { AdmonitionSuggest } from "./suggest/suggest"; import { EditorState, TransactionSpec } from "@codemirror/state"; +import CodeMirror from "codemirror"; const DEFAULT_APP_SETTINGS: AdmonitionSettings = { userAdmonitions: {}, @@ -461,11 +464,12 @@ ${editor.getDoc().getSelection()} const titleInnerEl = titleEl.createDiv( "callout-title-inner admonition-title-content" ); - MarkdownRenderer.renderMarkdown( + MarkdownRenderer.render( + this.app, title, titleInnerEl, source ?? "", - new Component() + this ); if ( titleInnerEl.firstElementChild &&