diff --git a/readme.md b/readme.md index 37b34c0..cc530a4 100644 --- a/readme.md +++ b/readme.md @@ -4,8 +4,6 @@ A simple to-do list plugin for logseq > This plugin relies solely on the Logseq Plugin API to access local data, and does not store it externally. - - ### Features - Quickly add new to-do items to today's journal page. - View all of today's to-do items (include scheduled & today's journal page). diff --git a/src/models/TaskEntity.ts b/src/models/TaskEntity.ts index faa0c8f..aeba45b 100644 --- a/src/models/TaskEntity.ts +++ b/src/models/TaskEntity.ts @@ -45,18 +45,19 @@ export interface TaskEntityObject { class TaskEntity { private block: BlockEntity; private page: PageEntity; + private content: string; constructor(block: BlockEntity, page: PageEntity) { this.block = block; this.page = page; + this.content = this.rawContent; } public get uuid(): string { return getBlockUUID(this.block); } - public get content(): string { - let content = this.rawContent; + public trimContent(content: string): string { content = content.replace(this.block.marker, ''); content = content.replace(`[#${this.block.priority}]`, ''); content = content.replace(/SCHEDULED: <[^>]+>/, ''); @@ -96,6 +97,14 @@ class TaskEntity { return this.page.properties?.[key]; } + public getContent() { + return this.trimContent(this.content); + } + + public setContent(value: string) { + this.content = value; + } + public toObject(): TaskEntityObject { return { uuid: this.uuid, diff --git a/src/state/tasks.ts b/src/state/tasks.ts index 36cb8ff..d28565d 100644 --- a/src/state/tasks.ts +++ b/src/state/tasks.ts @@ -21,7 +21,18 @@ async function getTaskEntitiesByQuery(query: string) { const page = await window.logseq.Editor.getPage( (block?.page as PageEntity).name, ); - return new TaskEntity(block!, page!); + let task = new TaskEntity(block!, page!); + try { + task.setContent(task.getContent().replace('((', '').replace('))','')); + const in_block = await window.logseq.Editor.getBlock(task.getContent(), { + includeChildren: false, + }); + if (in_block != null) { + task.setContent(task.trimContent(in_block.content)); + } + } catch { + } + return task; }), );