Skip to content

Commit

Permalink
refactor: Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
observerw committed Jul 1, 2024
1 parent 68a2962 commit fc93479
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/component/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class CodeLinkEmbedPreview extends Component {
}

async setCode(file: TFile, node?: TagTreeNode | null): Promise<void> {
this._codeEl.replaceChildren();
this._codeEl.empty();

const langName = getLang(file.path);
const text = node
Expand All @@ -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;
Expand Down
17 changes: 11 additions & 6 deletions src/processor/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand All @@ -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;
}
}
Expand Down

0 comments on commit fc93479

Please sign in to comment.