Skip to content

Commit 2e9a2fc

Browse files
committed
Improve clarity and linting
1 parent 4f2fe35 commit 2e9a2fc

6 files changed

Lines changed: 12 additions & 22 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "embed-metadata",
33
"name": "Embed Metadata",
44
"version": "0.5.2",
5-
"minAppVersion": "0.15.0",
5+
"minAppVersion": "1.0.0",
66
"description": "Render frontmatter metadata (Properties) inside your notes with a lightweight inline syntax.",
77
"author": "Schemen",
88
"authorUrl": "https://github.com/schemen",

src/editor-metadata.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ function shouldRebuildForChanges(update: ViewUpdate, plugin: EmbedMetadataPlugin
506506
const nextFrontmatter = getFrontmatterRange(nextDoc);
507507
let needsRebuild = false;
508508

509-
update.changes.iterChanges((fromA, toA, fromB, toB, inserted) => {
509+
update.changes.iterChanges((fromA, toA, fromB, toB, _inserted) => {
510510
if (needsRebuild) {
511511
return;
512512
}
@@ -668,31 +668,23 @@ class MetadataWidget extends WidgetType {
668668

669669
// Render the replacement widget node for a single syntax marker.
670670
toDOM(): HTMLElement {
671-
const span = document.createElement("span");
671+
const span = window.activeDocument.createElement("span");
672672
applyValueStyles(span, this.plugin.settings);
673673
let container = span;
674674
if (this.markdownStyle.highlight) {
675-
const mark = document.createElement("mark");
676-
mark.classList.add("cm-highlight");
677-
container.appendChild(mark);
675+
const mark = container.createEl("mark", {cls: "cm-highlight"});
678676
container = mark;
679677
}
680678
if (this.markdownStyle.strike) {
681-
const del = document.createElement("del");
682-
del.classList.add("cm-strikethrough");
683-
container.appendChild(del);
679+
const del = container.createEl("del", {cls: "cm-strikethrough"});
684680
container = del;
685681
}
686682
if (this.markdownStyle.bold) {
687-
const strong = document.createElement("strong");
688-
strong.classList.add("cm-strong");
689-
container.appendChild(strong);
683+
const strong = container.createEl("strong", {cls: "cm-strong"});
690684
container = strong;
691685
}
692686
if (this.markdownStyle.italic) {
693-
const em = document.createElement("em");
694-
em.classList.add("cm-em");
695-
container.appendChild(em);
687+
const em = container.createEl("em", {cls: "cm-em"});
696688
container = em;
697689
}
698690
renderInlineMarkdown(this.plugin.app, this.sourcePath, container, this.value, this.plugin);

src/markdown-render.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export function renderInlineMarkdown(
1818

1919
el.textContent = "";
2020

21-
const temp = document.createElement("span");
22-
el.appendChild(temp);
21+
const temp = el.createSpan();
2322

2423
void MarkdownRenderer.render(app, value, temp, sourcePath, component).then(() => {
2524
if (!temp.parentElement) {
@@ -57,8 +56,7 @@ export function renderInlineMarkdownText(
5756
}
5857

5958
el.textContent = "";
60-
const temp = document.createElement("span");
61-
el.appendChild(temp);
59+
const temp = el.createSpan();
6260

6361
void MarkdownRenderer.render(app, value, temp, sourcePath, component).then(() => {
6462
if (!temp.parentElement) {

src/metadata-suggest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class MetadataSuggest extends EditorSuggest<string> {
6262
}
6363

6464
// Insert the selected key and close the syntax marker if needed.
65-
selectSuggestion(value: string, evt: MouseEvent | KeyboardEvent): void {
65+
selectSuggestion(value: string, _evt: MouseEvent | KeyboardEvent): void {
6666
if (!this.context) {
6767
return;
6868
}

src/migration-modal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class MigrationModal extends Modal {
9898
entry.selected = checkbox.checked;
9999
});
100100

101-
row.createEl("span", {
101+
row.createSpan({
102102
text: `${entry.file.path} (${entry.count})`,
103103
});
104104
}

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"0.4.1": "0.15.0",
88
"0.5.0": "0.15.0",
99
"0.5.1": "0.15.0",
10-
"0.5.2": "0.15.0"
10+
"0.5.2": "1.0.0"
1111
}

0 commit comments

Comments
 (0)