Zachatoo / obsidian-css-editor

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

Feature: Just one command with multiple action #20

Closed holroy closed 6 months ago

holroy commented 6 months ago

When playing around with #19 , I discovered that you've added an open in new tab command from the edit dialog, and when looking at the Obsidian Quick Switcher I see the following instructions at the bottom:

image

This got me thinking, wouldn't it be nice to have just one command to do edit, create and delete? In other word add instructions to the one fuzzy dialog like this:

image

In other words to just just Enter to edit, or combine with ⌘/command/ctrl to open in new tab, ⇧/shift to create a new snippet, and ⌥/opt/alt to delete a snippet.

Zachatoo commented 6 months ago

I think that would be really cool! I love anything that will make this plugin feel more native.

I think I'd like to more closely match the verbiage of the quick switcher, for example using "to navigate" instead of "Select CSS snippet", "to delete" instead of "Delete snippet", etc.

I also think I'd also prefer to have something like CmdDelete for deleting. Though that may be harder to represent with an icon. I just want it to be less likely to be accidental, unless there was some sort of confirmation to avoid the pain you've described elsewhere with accidentally deleting a CSS snippet.

Those are my two criticisms, I love the idea. Were you planning on implementing this or would you like me to look into it?

Zachatoo commented 6 months ago

I've decided to take this on as I'm particularly excited about this idea!

Zachatoo commented 6 months ago

This has been released in version 1.0.0!

holroy commented 6 months ago

Those are my two criticisms, I love the idea. Were you planning on implementing this or would you like me to look into it?

I was ready to implement it, but I wanted to know if you liked the idea or not, so posted the issue before I went to bed last night, and then I wake up seeing that you've implemented it already! :-D

I was also presenting an idea, and I actually thought a little bit about how to avoid accidentally deleting a snippet, but I didn't think about using another key like the delete key. I neither have any issues on you choosing another wording, since English is not my native language and in general I feel like I could always write stuff better.

A little comment related to keyboard handling

I've not looked a whole lot at your code, but when I implemented the suggestions/instructions I used this block:

this.setInstructions([
    {command: "↑↓", purpose: "Select CSS snippet"},
    {command: "⏎", purpose:"Edit snippet"},
    {command: Platform.isMacOS ? "⌘ ⏎" : "shift", purpose: "Edit in new tab"},
    {command: Platform.isMacOS ? "⇧ ⏎" : "shift", purpose: "Create snippet"},
    {command: Platform.isMacOS ? "⌥ ⏎" : "alt ⏎", purpose: "Delete snippet"},
]);

This was included into the constructor of the fuzzy suggest dialog, so in other words, there is already a command to build the instructions with your better wording.

Zachatoo commented 6 months ago

there is already a command to build the instructions

That API looks way cleaner than what I was doing, we should definitely switch to that!