Skip to content

Commit

Permalink
fix: Fixes issue with post processors map not getting reinitialized p…
Browse files Browse the repository at this point in the history
…roperly
  • Loading branch information
valentine195 committed Mar 29, 2022
1 parent 23804d3 commit a7752d9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.ts
Expand Up @@ -68,7 +68,9 @@ declare module "obsidian" {
}
interface MarkdownPreviewRenderer {
onCheckboxClick: (evt: MouseEvent, el: HTMLInputElement) => void;
unregisterCodeBlockPostProcessor(lang: string): void;
}
namespace MarkdownPreviewRenderer {
function unregisterCodeBlockPostProcessor(lang: string): void;
}
}

Expand Down Expand Up @@ -129,6 +131,8 @@ export default class ObsidianAdmonition extends Plugin {
async onload(): Promise<void> {
console.log("Obsidian Admonition loaded");

this.postprocessors = new Map();

await this.loadSettings();
await this.iconManager.load();
this.app.workspace.onLayoutReady(async () => {
Expand Down Expand Up @@ -574,7 +578,6 @@ ${editor.getDoc().getSelection()}

/** Register an admonition code-block post processor for legacy support. */
if (this.postprocessors.has(type)) {
//@ts-expect-error
MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(
`ad-${type}`
);
Expand Down Expand Up @@ -696,7 +699,6 @@ ${editor.getDoc().getSelection()}
MarkdownPreviewRenderer.unregisterPostProcessor(
this.postprocessors.get(admonition.type)
);
//@ts-expect-error
MarkdownPreviewRenderer.unregisterCodeBlockPostProcessor(
`ad-${admonition.type}`
);
Expand Down

0 comments on commit a7752d9

Please sign in to comment.