From a619aca53a51880b3a381a3c437001c2aeb501ec Mon Sep 17 00:00:00 2001 From: Lutu-gl <74654393+Lutu-gl@users.noreply.github.com> Date: Sun, 30 Mar 2025 00:37:32 +0100 Subject: [PATCH] Pass to MarkdownRenderer.render the correct sourcePath --- main.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.ts b/main.ts index 6a6dd78..403161e 100644 --- a/main.ts +++ b/main.ts @@ -42,7 +42,9 @@ export default class MinimalQuizPlugin extends Plugin { const qaMap = this.extractQuestionsAndAnswers(content); const entries = Array.from(qaMap.entries()); if (entries.length > 0) { - new QuestionsModal(this.app, entries, this.settings).open(); + const filePath = this.app.workspace.getActiveFile()?.path ?? 'unknown'; + + new QuestionsModal(this.app, entries, this.settings, filePath).open(); } else { new Notice('No questions found.'); } @@ -79,12 +81,14 @@ class QuestionsModal extends Modal { currentIndex = 0; settings: MinimalQuizSettings; component: Component; + sourcePath: string; - constructor(app: App, questions: [string, string][], settings: MinimalQuizSettings) { + constructor(app: App, questions: [string, string][], settings: MinimalQuizSettings, sourcePath: string) { super(app); this.entries = questions; this.settings = settings; this.component = new Component(); + this.sourcePath = sourcePath; } onOpen() { @@ -161,12 +165,12 @@ class QuestionsModal extends Modal { } renderQuestion(question: string, questionContainer: HTMLElement) { this.component.load(); - MarkdownRenderer.render(this.app, question, questionContainer, '', this.component); + MarkdownRenderer.render(this.app, question, questionContainer, this.sourcePath, this.component); } renderAnswer(answer: string, answerContainer: HTMLElement){ this.component.load(); - MarkdownRenderer.render(this.app, answer, answerContainer, '', this.component); + MarkdownRenderer.render(this.app, answer, answerContainer, this.sourcePath, this.component); } toggleAnswer() {