Skip to content

Commit f505688

Browse files
committed
0.2.3
- Explicitly create "details"/"summary" if collapse parameter is set
1 parent 0fbaffc commit f505688

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-admonition",
33
"name": "Admonition",
4-
"version": "0.2.2",
4+
"version": "0.2.3",
55
"minAppVersion": "0.11.0",
66
"description": "Admonition block-styled content for Obsidian.md",
77
"author": "Jeremy Valentine",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-admonition",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Admonition block-styled content for Obsidian.md",
55
"main": "main.js",
66
"scripts": {

src/main.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,29 +182,36 @@ export default class ObsidianAdmonition extends Plugin {
182182
title: string,
183183
collapse?: string
184184
): HTMLElement {
185-
let attrs,
186-
els: Array<keyof HTMLElementTagNameMap> = ["div", "div"];
185+
let admonition;
187186
if (collapse) {
188-
els = ["details", "summary"];
187+
let attrs;
189188
if (collapse === "open") {
190189
attrs = { open: "open" };
191190
} else {
192191
attrs = {};
193192
}
194-
/* attrs = {
195-
[collapse]: true
196-
}; */
193+
admonition = createEl("details", {
194+
cls: `admonition admonition-${type}`,
195+
attr: attrs
196+
});
197+
admonition.createEl("summary", {
198+
cls: `admonition-title ${
199+
!title.trim().length ? "no-title" : ""
200+
}`,
201+
text: title
202+
});
203+
} else {
204+
admonition = createDiv({
205+
cls: `admonition admonition-${type}`
206+
});
207+
admonition.createDiv({
208+
cls: `admonition-title ${
209+
!title.trim().length ? "no-title" : ""
210+
}`,
211+
text: title
212+
});
197213
}
198214

199-
let admonition = createEl(els[0], {
200-
cls: `admonition admonition-${type}`,
201-
attr: attrs
202-
});
203-
admonition.createEl(els[1], {
204-
cls: `admonition-title ${!title.trim().length ? "no-title" : ""}`,
205-
text: title
206-
});
207-
208215
return admonition;
209216
}
210217
onunload() {

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"0.2.2": "0.11.0"
2+
"0.2.3": "0.11.0"
33
}

0 commit comments

Comments
 (0)