From 7b189a493ac78b31f6ea2f8747977b151eca2284 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 9 Aug 2024 19:55:54 +0200 Subject: [PATCH] fixed arrows not being displayed for markdown content --- src/main.ts | 2 +- src/tracker.ts | 12 ++++++------ test-vault/test-markdown.md | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index 014c7aa..329b37a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,7 +21,7 @@ export default class SimpleTimeTrackerPlugin extends Plugin { this.addSettingTab(new SimpleTimeTrackerSettingsTab(this.app, this)); - this.registerMarkdownCodeBlockProcessor("simple-time-tracker", async (s, e, i) => { + this.registerMarkdownCodeBlockProcessor("simple-time-tracker", (s, e, i) => { e.empty(); let component = new MarkdownRenderChild(e); let tracker = loadTracker(s); diff --git a/src/tracker.ts b/src/tracker.ts index 233c951..48476a1 100644 --- a/src/tracker.ts +++ b/src/tracker.ts @@ -349,7 +349,7 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle row.createEl("td", { text: entry.endTime || entry.subEntries ? formatDuration(getDuration(entry), settings) : "" }); - void renderNameAsMarkdown(nameField.label, getFile, component); + renderNameAsMarkdown(nameField.label, getFile, component); let expandButton = new ButtonComponent(nameField.label) .setClass("clickable-icon") @@ -394,7 +394,7 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle await saveTracker(tracker, getFile(), getSectionInfo()); editButton.setIcon("lucide-pencil"); - void renderNameAsMarkdown(nameField.label, getFile, component); + renderNameAsMarkdown(nameField.label, getFile, component); } else { nameField.beginEdit(entry.name); expandButton.buttonEl.style.display = "none"; @@ -438,10 +438,10 @@ function showConfirm(message: string): Promise { } function renderNameAsMarkdown(label: HTMLSpanElement, getFile: GetFile, component: Component): void { - MarkdownRenderer.renderMarkdown(label.innerHTML, label, getFile(), component).then(() => { - // rendering wraps it in a paragraph - label.innerHTML = label.querySelector("p").innerHTML; - }); + // we don't have to wait here since async code only occurs when a file needs to be loaded (like a linked image) + void MarkdownRenderer.renderMarkdown(label.innerHTML, label, getFile(), component); + // rendering wraps it in a paragraph + label.innerHTML = label.querySelector("p").innerHTML; } diff --git a/test-vault/test-markdown.md b/test-vault/test-markdown.md index 663c1e7..cca48ec 100644 --- a/test-vault/test-markdown.md +++ b/test-vault/test-markdown.md @@ -1,5 +1,5 @@ Tested for #tag, *italic*, [link](test2), etc: ```simple-time-tracker -{"entries":[{"name":"`Segment 1`","startTime":"2022-09-27T19:51:18.000Z","endTime":"2022-09-27T19:51:24.000Z"},{"name":"Segment 2","startTime":"2022-09-27T19:51:25.000Z","endTime":"2022-09-27T19:51:26.000Z"},{"name":"#tag Seqment 3 *add* #tag1 text","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tagp1","startTime":"2024-03-17T11:16:00.382Z","endTime":"2024-03-17T11:16:15.966Z","subEntries":null},{"name":"Part 3","startTime":"2024-03-17T11:17:08.000Z","endTime":"2024-03-17T11:17:24.000Z","subEntries":null}],"collapsed":true},{"name":"#tag3 Segment 4","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tag4","startTime":"2024-03-17T12:22:04.000Z","endTime":"2024-03-17T12:22:16.000Z","subEntries":null},{"name":"#tag5 Part 2 *italic*","startTime":"2024-03-17T12:22:20.000Z","endTime":"2024-03-17T12:22:24.000Z","subEntries":null}],"collapsed":true},{"name":"*italic* Segment 5 #tag6 [test2](test2)","startTime":"2024-03-17T12:40:37.000Z","endTime":"2024-03-17T12:40:45.000Z","subEntries":null},{"name":"Segment 6","startTime":"2024-03-27T13:20:56.000Z","endTime":"2024-08-09T16:27:18.029Z","subEntries":null}]} +{"entries":[{"name":"`Segment 1`","startTime":"2022-09-27T19:51:18.000Z","endTime":"2022-09-27T19:51:24.000Z"},{"name":"Segment 2","startTime":"2022-09-27T19:51:25.000Z","endTime":"2022-09-27T19:51:26.000Z"},{"name":"#tag Seqment 3 *add* #tag1 text","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tagp1","startTime":"2024-03-17T11:16:00.382Z","endTime":"2024-03-17T11:16:15.966Z"},{"name":"Part 3","startTime":"2024-03-17T11:17:08.000Z","endTime":"2024-03-17T11:17:24.000Z"}]},{"name":"#tag3 Segment 4","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tag4","startTime":"2024-03-17T12:22:04.000Z","endTime":"2024-03-17T12:22:16.000Z"},{"name":"#tag5 Part 2 *italic*","startTime":"2024-03-17T12:22:20.000Z","endTime":"2024-03-17T12:22:24.000Z"}]},{"name":"*italic* Segment 5 #tag6 [test2](test2)","startTime":"2024-03-17T12:40:37.000Z","endTime":"2024-03-17T12:40:45.000Z"},{"name":"Segment 6","startTime":"2024-03-27T13:20:56.000Z","endTime":"2024-08-09T16:27:18.029Z"}]} ```