Skip to content

Commit

Permalink
fix: Improves lifetime of Admonition rendered content
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed May 23, 2024
1 parent e36a4a8 commit a045776
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
addIcon,
Component,
editorLivePreviewField,
livePreviewState,
MarkdownPostProcessor,
MarkdownPostProcessorContext,
MarkdownPreviewRenderer,
Expand Down Expand Up @@ -81,6 +80,9 @@ declare module "obsidian" {
dispatch: (tr: TransactionSpec) => void;
};
}
interface Workspace {
iterateCodeMirrors(callback: (cm: CodeMirror.Editor) => void): void;
}
}

import AdmonitionSetting from "./settings";
Expand All @@ -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: {},
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit a045776

Please sign in to comment.