diff --git a/src/component/embed.ts b/src/component/embed.ts index 110cf3e..132c38c 100644 --- a/src/component/embed.ts +++ b/src/component/embed.ts @@ -33,7 +33,7 @@ export class CodeLinkEmbedPreview extends Component { } async setCode(file: TFile, node?: TagTreeNode | null): Promise { - this._codeEl.replaceChildren(); + this._codeEl.empty(); const langName = getLang(file.path); const text = node @@ -44,7 +44,7 @@ export class CodeLinkEmbedPreview extends Component { } setText(file: TFile, targetNode?: TagTreeNode | null) { - this._textEl.replaceChildren(); + this._textEl.empty(); if (!this._plugin.settings.showPathInEmbed) { return; diff --git a/src/processor/hover.ts b/src/processor/hover.ts index 2f38641..cf13c5f 100644 --- a/src/processor/hover.ts +++ b/src/processor/hover.ts @@ -32,7 +32,7 @@ export class CodeLinkHoverPreviewObserver { return; } - el.replaceChildren(); + el.empty(); el.addClass("code-link-hover-preview-popover"); const code = await this.hovering.content(); @@ -59,7 +59,6 @@ export class CodeLinkHoverPreviewPostProcessor extends PostProcessor { } process: MarkdownPostProcessor = (el, { sourcePath }) => { - // FIXME post processor won't be called again if plugin is disabled after file is opened this._observer.sourcePath = sourcePath; const internalLinkEls = Array.from( @@ -75,11 +74,17 @@ export class CodeLinkHoverPreviewPostProcessor extends PostProcessor { "data-href" ); - const item = - link && - CodeLinkItem.fromInner(this._plugin, sourcePath, link); + if (!link) { + return; + } + + const item = CodeLinkItem.fromInner( + this._plugin, + sourcePath, + link + ); - if (item && item.lang) { + if (item?.lang) { this._observer.hovering = item; } }