Skip to content

Commit bf0da83

Browse files
committed
Refactor to follow Obsidian style guide
1 parent e33257e commit bf0da83

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/frontmatterImageEditorExtension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export interface FrontmatterImageStateFieldValue {
1919
}
2020

2121
export const renderFrontmatterImage = (src: string): HTMLElement => {
22-
const img = document.createElement("img");
23-
img.src = src;
24-
img.style.display = "block";
25-
return img;
22+
const img = document.createElement("img");
23+
img.src = src;
24+
img.classList.add("frontmatter-image");
25+
return img;
2626
}
2727

2828
export const frontmatterImageEditorExtension = (

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ export default class FrontmatterImagePlugin extends Plugin {
4343
const div = document.createElement("div");
4444
const img = renderFrontmatterImage(currentImageValue);
4545
div.appendChild(img);
46-
div.insertAdjacentHTML("beforeend", "<br/>");
47-
element.insertAdjacentElement("beforeend", div);
46+
const br = document.createElement("br");
47+
div.appendChild(br);
48+
element.appendChild(div);
4849
},
4950
);
5051
}

styles.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
img.frontmatter-image {
2+
display: block;
3+
}

0 commit comments

Comments
 (0)