Zachatoo / obsidian-css-editor

Edit CSS snippets in Obsidian.
MIT License
57 stars 2 forks source link

feature: enable/disable snippets from the switcher? #21

Closed holroy closed 6 months ago

holroy commented 6 months ago

I'm liking the development of this plugin, and I do understand you wanting to keep it simple, but I also thought about another idea during the night if we had the one command approach: How hard would it be to indicate whether the snippet was active within the quick switcher, and potentially have a key to toggle the enabled/disabled status from the switcher?

Just taking a quick glance it seems like this might take some work, since if I'm correct it only maps the file names directly with the base file name in the first line and the folder in the second line. And to do such a thing like I'm suggesting we would need some indicator maybe on the right to indicate the status. Maybe even a checkbox?

This might need access to parts of the dialog which we don't have. If you don't see/know any way to handle this, don't sweat it, but I just wanted to mention this idea as that would make CSS handling of snippets so much better from my perspective where I change them a lot when answering on the forum, so I'm getting kind of bored enabling/disabling them.

Zachatoo commented 6 months ago

I think this is a good idea and within the scope of this plugin.

I'm more inclined to add another "instruction" for toggling the enabled status of a CSS snippet as opposed to a checkbox, to keep the UI similar to the quick switcher.

I definitely like having the enabled status somewhere in the suggestion, probably on the right side as you suggested. I would suggest "Enabled" and "Disabled" as the words to use if we don't use checkboxes.

A quick win might be to add a command that toggles the enabled status of the CSS snippet you're currently editing, similar to the command that deletes the CSS snippet you're currently editing.

holroy commented 6 months ago

How to toggle doesn't matter that much to me, but I would like some visual indication as to whether it was enabled or not, but I'm not sure how to get that outside of hacks like modifying the file name before presentation or stuff like that...

holroy commented 6 months ago

Ideally I would like for something to appear in the right margin, but I reckon it's a whole lot easier to actually prefix the file name with either ☑︎ if enabled, or if disabled. This could then easily be removed when handling the chosen item.

I'm also not sure how to disable/enable a snippet from Typescript. (a few minutes later) Then again you do already enable newly created snippets, so you've got the code for setting that at least. Where did you get that code piece from? Is there also a getEnabled() call?

holroy commented 6 months ago

I'm not totally sure on whether my logic is sound regarding extending the chooser in obsidian.d.ts, but it do seem to work, so please do review the code thoroughly, Zachatoo

holroy commented 6 months ago

If I must say it myself, I think this plugin looks better every day that goes by!

Zachatoo commented 6 months ago

Thanks for working on this! Released in 1.1.0!