Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for dataview task view #43

Open
imeed166 opened this issue Apr 4, 2022 · 9 comments
Open

support for dataview task view #43

imeed166 opened this issue Apr 4, 2022 · 9 comments

Comments

@imeed166
Copy link

imeed166 commented Apr 4, 2022

Given that the latest beta support alternate checkboxes blacksmithgu/obsidian-dataview#812, would it be possible to change their status via this plugin's right click menu ?

@ebullient
Copy link
Owner

I'll have to try it.

@ryanjamurphy
Copy link

I'm wondering about the same thing! I can put in some of the work to make this happen, I think, with some guidance...

It seems like it's not super straightforward. If I'm reading the TC code right, the plugin picks up the task to complete by reading the line that's activated by the right-click action (line 112):

const markTaskCommand: Command = {
id: "task-collector-mark",
name: "Mark item",
icon: Icons.MARK,
editorCallback: async (editor: Editor, view: MarkdownView) => {
const mark = await getMark(this.app, this.taskCollector);
if (mark) {
this.markTaskOnLines(
mark,
this.getCurrentLinesFromEditor(editor)
);
}
},
};

Dataview items, though, aren't really on "lines," are they?

And yet, when I look under the hood at the HTML in Reading mode, I can't see a difference between Dataview Tasklist-generated checkboxes and "regular" checkboxes. Why is Task Collector adding this menu to a regular checkbox....
Screen Shot 2022-04-26 at 9 21 10 AM

... but not this dataview-generated checkbox?
Screen Shot 2022-04-26 at 9 21 34 AM

@ebullient
Copy link
Owner

ebullient commented Apr 26, 2022

Dataview tasks are not added using the markdown renderer, so the markdown post-processor doesn't see them (which means I can't add the event handler to them). It creates the input boxes directly, and uses its own click handler (which TC would be in a race with, effectively).

In the end, I need some help from dataview to get this to work. I added some comments here: blacksmithgu/obsidian-dataview#812

I was able to get pretty close, but there was a bit of fighting between my handler and the dataview handler. I was also missing the dataview context, so while I could update the source correctly, the task view wasn't updated to show that...

@ryanjamurphy
Copy link

How funny that that conversation happened less than a day ago. Serendipity! I had no idea anyone else was thinking about this 'til I started poking around this morning.

It looks like @blacksmithgu might get it the rest of the way. Fingers crossed. 🤞

@ebullient
Copy link
Owner

I was playing with it yesterday. Great minds... ;)

@ebullient
Copy link
Owner

This is .. a way: blacksmithgu/obsidian-dataview#1048

@ryanjamurphy
Copy link

My hero!

@ebullient
Copy link
Owner

I think the outstanding user question is which way it should go. I have a BRAT release with a Task Collector API (so things can invoke the modal w/ complete/incomplete task completion characters defined), that's how the above PR works.

Alternately, Dataview could provide a hook so that I can override the event listener. The advantage there is that Task Collector can consolidate marking tasks (complete/reset, etc), which would make things more consistent across Dataview and elsewhere.

Not sure which is better or which makes more sense.

@blacksmithgu
Copy link

I'm adding the ability for plugins to override or extend the default dataview task hook in the next beta :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants