Ellpeck / ObsidianSimpleTimeTracker

Multi-purpose time trackers for your notes!
MIT License
132 stars 19 forks source link

feat: add tag display to Segment #43

Closed graf-Gopher closed 5 months ago

graf-Gopher commented 5 months ago

A little background: At the moment, I am developing Homepage/Dashboard and of course there was a need for time tracking. Your plugin has come in handy, but based on our needs, need to somehow synchronize the data in the tracker with other analytics and tasks. The easiest way was to use tags. Adding them to Segment was not a problem, but visually it was terrible.

This PR is aimed precisely at adding a visual display of tags in the Segment field (since we work with code block, there are some implementation nuances). I tried to minimally interfere with the standard functionality of the plugin, so the code turned out to be practically independent.

I doubt that the functionality is very interesting, but maybe it will be useful to someone, and for the development of the plugin.

Ellpeck commented 5 months ago

Hi, thanks for your pull request!!

Are these tags you speak of just regular Obsidian tags, ie #some/tag? If so, doesn't that just make this pull request a part-implementation of #25?

graf-Gopher commented 5 months ago

Yes, everything is correct. This PR adds a visual part just for regular Obsidian tags. If there is a need and you like my implementation, I can add the link formatting as requested in #25.

Ellpeck commented 5 months ago

Yes, also supporting links in the segment display would be lovely!

Does this implementation also support having multiple tags in a segment name, or having a segment name that consists of text and a tag together?

graf-Gopher commented 5 months ago

Unfortunately, I did not even think about this functionality. Currently, the tag is checked only at the beginning of Segment and only in the amount of one.

In this case, I suggest closing this PR. I will add all the necessary functionality and let you know.

List of functionality:

  1. Obsidian hashtag - #tag
  2. Link - [link](link)
  3. Multiple hashtag and links in Segment field
  4. Combining text and link/tag = #tag1 text1 #tag2 [link1](link) text2

Did I forget anything?

graf-Gopher commented 5 months ago

In addition, if I find a way, I will add support for Markdown in general

Ellpeck commented 5 months ago

Yes, I think those features would be necessary for me to be comfortable merging this PR, as otherwise, a lot of users might be confused as to why their tags only work sometimes - I think in a case like this, it's better not to have this feature at all, than to have it only work some of the time.

The list you sent sounds great, and it's pretty much what I had in mind for #25.

I also think it would be nice if the tags were discoverable through search, and through the tag list core plugin thing, but I think that's automatically taken care of due to the fact that the tag will be displayed #withTagSyntax in the underlying JSON data, as well. I'm not sure if tags in code blocks get picked up, though.

In addition, if I find a way, I will add support for Markdown in general

I was thinking that it might just be possible to enable CodeMirror support and/or use a special CodeMirror box for the segment name, but I've yet to check if Obsidian's API has builtin functionality for that (something like a "CodeMirrorTextBox", or whatever).

Thanks so much for your work on this pull request! If you're interested in implementing the feature list you mentioned, feel free to do it as a part of this pull request and just convert it to a draft in the meantime :)

graf-Gopher commented 5 months ago

After reading a lot of documentation and code of other plugins, the solution turned out to be quite simple - to add to Segment column a work with all the possibilities of Obsidian markdown (but only those that work on one line). Also added a test file with Markdown formatting.

The only nuance that I noticed (regarding tags), when clicking on a tag inside the tracker, there is a transition to the search, and there it does not find this tag in our tracker codeblock, only those outside it (outside codenlock). Of course this is treated by replacing tag:#tag with #tag in search input. From what I learned, this is most likely the specifics of work in codenlock. I still don't know how to fix it...

Ellpeck commented 5 months ago

I think I'm okay with the codeblock thing for now, this is still a very useful addition to the project. Given tags didn't work at all before, this is a good compromise, I think! Thanks so much for your hard work on this :)

Ellpeck commented 5 months ago

Thanks so much again for implementing this feature!! 🥰