mgsloan / todoist-shortcuts

Browser extension which adds comprehensive keyboard shortcuts to Todoist, beyond what is offered by Todoist itself
MIT License
313 stars 23 forks source link

Adds ability to create a project above currently selected one via shift+p #240

Closed kory-smith closed 1 year ago

kory-smith commented 1 year ago

Been a while! I'm finally ready to start actually contributing to this extension. Been a long time coming. I have a lot of plans, but first, I'll just implement something I've wanted to a while: the ability to create a new project with a shortcut.

mgsloan commented 1 year ago

Awesome, thank you!!

mgsloan commented 1 year ago

I've made some changes for robustness. I know it looks like a rewrite, but your addition was very helpful

mgsloan commented 1 year ago

I've also changed the binding to alt+p, and added alt+shift+p for adding project above. I'd have preferred to make this ctrl+p, but unfortunately there is no way to disable the browser print action.

The reason for this change is in analogy to o (add task below) vs shift-o (add task above)

kory-smith commented 1 year ago

Thank you for the enhancements! I probably should have said this earlier, but my master plan was to suggest changing the current sort behavior to free up some keybindings.

I'd love it if s opened the sort menu and made hints just like the g does. Here's a mockup of how it would look: image

Then, p and shift+p would be free for project above and project below. That's actually why I went with shift+p to add a project above in the first place.

I'd also like to add a few more keybindings for working with projects (like one to delete a project, one to archive a project, etc). And I'm probably also going to try my hand at a more robust options page.

mgsloan commented 1 year ago

That makes sense! I released version 175 with this, but then upon checking it looks like my approach already broke when it comes to selecting the menu item, not sure what is up with that.

However! I noticed that the menu item is focused with a box around it. Turns out that pressing enter with the menu open will also open the 'add project above', and tab changes which item is selected. So, I think it's more versatile to just support opening the menu. I also added w for opening the top right "more actions" menu. Those changes were released in version 176

I do really like your idea for the changes to sorting.

kory-smith commented 1 year ago

That makes sense! I released version 175 with this, but then upon checking it looks like my approach already broke when it comes to selecting the menu item, not sure what is up with that.

I just looked into this, and I think it's happening because in this line, selectUnique throws an error because it can't find an a tag (which I know you expect).

However! I noticed that the menu item is focused with a box around it. Turns out that pressing enter with the menu open will also open the 'add project above', and tab changes which item is selected. So, I think it's more versatile to just support opening the menu. I also added w for opening the top right "more actions" menu. Those changes were released in version 176

I do really like your idea for the changes to sorting.

It sounds like you aren't interested in actually clicking the button with p or alt+p, but I also found that your ADD_ABOVE_SVG_PATH is different from mine. Mine is M9 6.74L6.35 9.4a.5.5 0 01-.7-.7l3.53-3.54a.5.5 0 01.7 0l3.55 3.53a.5.5 0 01-.71.7L10 6.69V18.5a.5.5 0 11-1 0V6.74zM17 15h2.5a.5.5 0 110 1H17v2.5a.5.5 0 11-1 0V16h-2.5a.5.5 0 110-1H16v-2.5a.5.5 0 111 0V15z. No clue what accounts for the difference, but I wanted to let you know. I personally would really like the button to be clicked, but that might just have to be a setting or something I hard-code into my own instance of the extension.