Skip to content

Commit 5b7d0f5

Browse files
committed
3.1.1
- Fixed issue where checkboxes in admonitions were not updating when clicked (closes #9) - Fixed issue where some checked checkboxes in admonitions would not show crossed out
1 parent 51198cd commit 5b7d0f5

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
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": "3.0.1",
4+
"version": "3.1.1",
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": "3.0.1",
3+
"version": "3.1.1",
44
"description": "Admonition block-styled content for Obsidian.md",
55
"main": "main.js",
66
"scripts": {

src/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,7 @@ input.is-invalid {
108108
font-size: 0.875em;
109109
color: #dc3545;
110110
}
111+
112+
.admonition li.task-list-item.is-checked p {
113+
text-decoration: line-through;
114+
}

src/main.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ export default class ObsidianAdmonition
222222
let admonitionContent = admonitionElement.createDiv({
223223
cls: "admonition-content"
224224
});
225-
let markdownRenderChild = new MarkdownRenderChild();
225+
let markdownRenderChild = new MarkdownRenderChild(
226+
admonitionElement
227+
);
226228
markdownRenderChild.containerEl = admonitionElement;
227229

228230
/**
@@ -235,6 +237,36 @@ export default class ObsidianAdmonition
235237
markdownRenderChild
236238
);
237239

240+
const taskLists = admonitionContent.querySelectorAll(
241+
".contains-task-list"
242+
);
243+
const splitContent = content.split("\n");
244+
245+
for (let i = 0; i < taskLists.length; i++) {
246+
let tasks: NodeListOf<HTMLLIElement> = taskLists[
247+
i
248+
].querySelectorAll(".task-list-item");
249+
if (!tasks.length) continue;
250+
for (let j = 0, task = tasks[j]; j < tasks.length; j++) {
251+
if (!task.children.length) continue;
252+
253+
let innerText = task.getText().replace(/\n/g, "");
254+
255+
const search = new RegExp(
256+
`\\[\\s?[xX]?\\s?\\]\\s*${innerText}`
257+
);
258+
259+
const line = splitContent.find((l) => search.test(l));
260+
261+
let inputs = task.getElementsByTagName("input");
262+
if (!inputs.length) continue;
263+
264+
inputs[0].dataset["line"] = `${
265+
splitContent.indexOf(line) + 1
266+
}`;
267+
}
268+
}
269+
238270
/**
239271
* Replace the <pre> tag with the new admonition.
240272
*/

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"0.2.3": "0.11.0",
33
"1.0.1": "0.11.0",
44
"2.0.1": "0.11.0",
5-
"3.0.1": "0.11.0"
5+
"3.1.1": "0.11.0"
66
}

0 commit comments

Comments
 (0)