Skip to content

Commit

Permalink
3.1.2
Browse files Browse the repository at this point in the history
- Fixed issue related to multiple checkboxes in admonitions (#9)
  • Loading branch information
valentine195 committed Apr 19, 2021
1 parent 5b7d0f5 commit c236997
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ An icon without a title will have this CSS:

# Version History

## 3.1.0
- Fixed issue where checkboxes in admonitions were not toggleable
## 3.0.0

- Added ability to create custom admonitions via Settings
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-admonition",
"name": "Admonition",
"version": "3.1.1",
"version": "3.1.2",
"minAppVersion": "0.11.0",
"description": "Admonition block-styled content for Obsidian.md",
"author": "Jeremy Valentine",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-admonition",
"version": "3.1.1",
"version": "3.1.2",
"description": "Admonition block-styled content for Obsidian.md",
"main": "main.js",
"scripts": {
Expand Down
22 changes: 14 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +247,29 @@ export default class ObsidianAdmonition
i
].querySelectorAll(".task-list-item");
if (!tasks.length) continue;
for (let j = 0, task = tasks[j]; j < tasks.length; j++) {
for (let j = 0; j < tasks.length; j++) {
let task = tasks[j];
if (!task.children.length) continue;
const inputs = task.querySelectorAll(
"input[type='checkbox']"
) as NodeListOf<HTMLInputElement>;
if (!inputs.length) continue;
const input = inputs[0];

let innerText = task.getText().replace(/\n/g, "");
if (
!input.nextSibling ||
input.nextSibling.nodeName != "#text"
)
continue;
const innerText = input.nextSibling.textContent;

const search = new RegExp(
`\\[\\s?[xX]?\\s?\\]\\s*${innerText}`
);

const line = splitContent.find((l) => search.test(l));

let inputs = task.getElementsByTagName("input");
if (!inputs.length) continue;

inputs[0].dataset["line"] = `${
splitContent.indexOf(line) + 1
}`;
input.dataset["line"] = `${splitContent.indexOf(line) + 1}`;
}
}

Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"0.2.3": "0.11.0",
"1.0.1": "0.11.0",
"2.0.1": "0.11.0",
"3.1.1": "0.11.0"
"3.1.2": "0.11.0"
}

0 comments on commit c236997

Please sign in to comment.