tokenshift / obsidian-progress-clocks

Progress clocks and other useful widgets for https://obsidian.md/.
MIT License
2 stars 2 forks source link

Progress clock states not saved when the clocks are in a table #5

Open Pibemanden opened 5 months ago

Pibemanden commented 5 months ago

As the title indicates, I am having trouble with putting the progress clocks into tables. When the progress clocks are outside the table they will keep the state I left them in between opening and closing Obsidian. But no matter if I save or not I cannot keep the state of the progress clock if I have it embedded inside a table (just the default no fancy plugin).

schicks commented 3 months ago

I'm happy to pick this up if you're good with PRs. Some quick code diving makes it seem like the problem is probably here; I'm suspicious that when we dispatch this event back to obsidian it doesn't end up going to the right place (or getting through at all) in the context of a table.

tokenshift commented 3 months ago

PRs are more than welcome. I haven't had a chance to dig into this yet, but I suspect you're right about the cause. CounterWidget likely has the same problem.

schicks commented 3 months ago

Some actual debugging with console logs suggests that when the inline text is in a table, we render the Clock from here rather than using ClockWidget at all. Trying to understand a little better; given that we have the inline plugin, what is the code in handleMarkdownPostProcessor trying to accomplish? Is that supposed to be doing something for the non inline clocks?

tokenshift commented 3 months ago

Oh, interesting. handleMarkdownPostProcessor is what's used when you're in View mode rather than Edit mode; it looks like in table cells, Obsidian is using handleMarkdownPostProcessor to render cell contents (even when it's in edit mode), rather than the widgets it normally uses in edit mode.

The Clock object in handleMarkdownPostProcessor will still emit the update event, the problem will be getting a handle to the editable source for it. The widget gives you the built in nodeFrom and nodeTo; I don't know if there's a way to get that context information from handleMarkdownPostProcessor.

schicks commented 3 months ago

Draft PR here but still having some issues. More to discuss on the PR thread.