Fixes #100 implements a custom Markdown renderer

This commit is contained in:
Zef Hemel
2022-11-01 15:01:28 +01:00
parent b8e27b216e
commit 3d671e8195
20 changed files with 652 additions and 37 deletions
+9
View File
@@ -88,6 +88,14 @@ export function taskToggle(event: ClickEvent) {
return taskToggleAtPos(event.pos);
}
export function previewTaskToggle(eventString: string) {
const [eventName, pos] = JSON.parse(eventString);
if (eventName === "task") {
console.log("Gotta toggle a task at", pos);
return taskToggleAtPos(+pos);
}
}
async function toggleTaskMarker(node: ParseTree, moveToPos: number) {
let changeTo = "[x]";
if (node.children![0].text === "[x]" || node.children![0].text === "[X]") {
@@ -139,6 +147,7 @@ export async function taskToggleAtPos(pos: number) {
addParentPointers(mdTree);
const node = nodeAtPos(mdTree, pos);
// console.log("Got this node", node?.type);
if (node && node.type === "TaskMarker") {
await toggleTaskMarker(node, pos);
}
+5
View File
@@ -47,3 +47,8 @@ functions:
key: Alt-+
contexts:
- DeadlineDate
previewTaskToggle:
env: client
path: ./task.ts:previewTaskToggle
events:
- preview:click