mirror of
https://github.com/lutu-gl/Obsidian-Minimal-Quiz.git
synced 2026-07-22 05:42:37 +00:00
Pass to MarkdownRenderer.render the correct sourcePath
This commit is contained in:
parent
33083b451d
commit
a619aca53a
1 changed files with 8 additions and 4 deletions
12
main.ts
12
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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue