gingko / client

Gingko Writer. Tree-based writing software, written in Elm.
https://gingkowriter.com
MIT License
361 stars 49 forks source link

enable link insertion shortcut #241

Closed wowthedoge closed 1 month ago

wowthedoge commented 2 months ago

Made it so that Ctrl+B adds the needed asterisks and places the cursor between them, so no need to highlight text before bolding them. Same for italics.

Tests: I have only tested locally, without Cypress (I have not set up the testing yet).

wowthedoge commented 2 months ago

Just a small change I wanted to do to test the waters as my first contribution to open source 😅. This was my own idea, please don't hesitate to let me know if this isn't the intended behavior.

AdrianoFerrari commented 2 months ago

Hi. Thanks for the submission!

I think that similar to this change, but more immediately useful, would be to add a "turn selected text into Markdown link" feature.

Basically, doing almost exactly what this Github comment window does. Here's how I imagine it would work:

  1. User selects some text and presses "Ctrl+Shift+K" (instead of "Ctrl+K", which is taken for "Split card down").
  2. selected text gets wrapped in square brackets, followed by (url), like this: [selected text here](url)

(Bonus: if the selected text is a URL, then use it in the (url) section, so user would end up with : [link text](https://the.url.they.selected))

What do you think?

wowthedoge commented 2 months ago

Yeah, sounds good! I'll try my hand at that.

wowthedoge commented 2 months ago

Hey, here's the feature suggested. I noticed ctrl+shift+k wass already taken for 'merge card up', like an undo for ctrl+k. This can also be done with ctrl+shift+up so I've went ahead and replaced ctrl+shift+k with the insert markdown link functionality you mentioned. For consistency, I've also removed ctrl+shift+j as an undo for ctrl+j. What do you think?

AdrianoFerrari commented 2 months ago

This works great, thank you!

Sorry for the delayed responses.

I just have a few change requests. You can either do these yourself (so you can get the satisfaction of having developed this feature 100% yourself :grin: ), or tell me and I can implement them.

  1. Use "mod+alt+k" as the shortcut for the link insertion (sorry, should have thought of it sooner). Note that you'll also have to add that shortcut to the override list here.
  2. Restore "mod+shift+j/k" shortcuts. Even though they have equivalents with the arrow keys, the "j/k" variants exist so that people can keep their hands on the home row and access them quickly without moving their hands down to the less-used arrow keys.

Once it's live, I'll add this to the keyboard shortcut modals and help screen, so people can find it and start using it :+1: .

wowthedoge commented 1 month ago

Ok! Here it is, "mod+shift+j/k" restored and the insert link changed to be using "mod+alt+k".

AdrianoFerrari commented 1 month ago

Merged, and added to the "Shortcut" menus.

Thanks for implementing this!

wowthedoge commented 1 month ago

That's great! Thank you for the opportunity. If there's any other features you need help with, I'll be glad to contribute!