Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<a href="https://www.buymeacoffee.com/yuexunjiang"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=yuexunjiang&button_colour=FFDD00&font_colour=000000&font_family=Comic&outline_colour=000000&coffee_colour=ffffff" /></a>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you delete this.
This is my plugin, you have no right to remove the sponsor button in the README after adding these codes.


### 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).
Expand Down
13 changes: 11 additions & 2 deletions src/models/TaskEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: <[^>]+>/, '');
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion src/state/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}),
);

Expand Down