diff --git a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx index 66f4092f5..45e824d5a 100644 --- a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx +++ b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx @@ -13,6 +13,7 @@ import { getLocaleById } from "../../../services/i18n"; import { getMermaidConfig } from "../../../services/mermaid"; import { loadIncludedNote, refreshIncludedNote } from "./utils"; import { renderMathInElement } from "../../../services/math"; +import link from "../../../services/link"; export default function ReadOnlyText({ note }: TypeWidgetProps) { const blob = useNoteBlob(note); @@ -27,6 +28,7 @@ export default function ReadOnlyText({ note }: TypeWidgetProps) { applyInlineMermaid(container); applyIncludedNotes(container); applyMath(container); + applyReferenceLinks(container); }, [ blob ]); // React to included note changes. @@ -80,11 +82,11 @@ async function applyInlineMermaid(container: HTMLDivElement) { } function applyIncludedNotes(container: HTMLDivElement) { - const includedNotes = container.querySelectorAll("section.include-note"); + const includedNotes = container.querySelectorAll("section.include-note"); for (const includedNote of includedNotes) { - const noteId = (includedNote as HTMLElement).dataset.noteId; + const noteId = includedNote.dataset.noteId; if (!noteId) continue; - loadIncludedNote(noteId, $(includedNote as HTMLElement)); + loadIncludedNote(noteId, $(includedNote)); } } @@ -94,3 +96,10 @@ function applyMath(container: HTMLDivElement) { renderMathInElement(equation, { trust: true }); } } + +function applyReferenceLinks(container: HTMLDivElement) { + const referenceLinks = container.querySelectorAll("a.reference-link"); + for (const referenceLink of referenceLinks) { + link.loadReferenceLinkTitle($(referenceLink)); + } +} diff --git a/apps/client/src/widgets/type_widgets_old/read_only_text.ts b/apps/client/src/widgets/type_widgets_old/read_only_text.ts index 2738186c5..5a4724f22 100644 --- a/apps/client/src/widgets/type_widgets_old/read_only_text.ts +++ b/apps/client/src/widgets/type_widgets_old/read_only_text.ts @@ -3,8 +3,6 @@ import { formatCodeBlocks } from "../../services/syntax_highlight.js"; import type FNote from "../../entities/fnote.js"; import type { CommandListenerData, EventData } from "../../components/app_context.js"; import appContext from "../../components/app_context.js"; -import { getMermaidConfig } from "../../services/mermaid.js"; -import { renderMathInElement } from "../../services/math.js"; export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget { @@ -27,16 +25,6 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget { } async doRefresh(note: FNote) { - this.onLanguageChanged(); - - const blob = await note.getBlob(); - - this.$content.html(blob?.content ?? ""); - - this.$content.find("a.reference-link").each((_, el) => { - this.loadReferenceLinkTitle($(el)); - }); - await formatCodeBlocks(this.$content); }