seanosullivanuk / nova-markdownclips

Basic and Extended Markdown Syntax Clips for Nova
7 stars 0 forks source link

Format selection with keyboard shortcuts #1

Closed patrickvuarnoz closed 3 years ago

patrickvuarnoz commented 3 years ago

First I have to say that this is a very cool idea for a Nova extension!

As I jumped right in I was immediately tempted to press CMD+B on a selected text and was wondering if it would format the selected text as bold, ie. adding ** around it (as it does here in the text editor in GITHUB or in JIRA). It would be very handy if it did instead of replacing the selection.

Don't know how difficult that is. So this is just a feature proposal.

seanosullivanuk commented 3 years ago

Thank you for your kind words and the suggestion. Its a good one. I'll take a look into it. 👍🏻

seanosullivanuk commented 3 years ago

I have released v1.1 with support for Bold and Italic as commands. You can bind these to keyboard shortcuts if you wish, or use the options in the Editor menu. Thank you for your suggestion. I hope you enjoy it.

patrickvuarnoz commented 3 years ago

Hi Sean, many thanks for having a look into it so quickly. Unfortunately it's not fully what I meant. Your clips already support CMD-B and CMD-I without having to register global keyboard shortcuts for them. You did register that in your Clips.json:

image

I was wondering if the insertion of one of these clips could preserve the pre-selected text. From the documentation at Nova I can see that this is theoretically possible:

https://docs.nova.app/extensions/snippets/#variables

I tried to create a clip that follows that documentation but I didn't get it to work as desired. I think SELECTED_TEXT is always defined but may be empty, so a default will never be applied:

    {
      "content" : "**${SELECTED_TEXT:bold}**",
      "name" : "My Test",
      "scope" : "editor",
      "shortcut" : "alt-b",
      "syntax" : "markdown"
    },

Maybe you have a clever idea how it can be achieved with the given possibilities of the clips. Or maybe the only way to do this would be to have two different clips: one for bol-> which inserts **${1:bold}** and one for CMD-B which inserts **$SELECTED_TEXT**.

seanosullivanuk commented 3 years ago

This appears to do what you're talking about. Could you try this and let me know?

 {
      "content" : "**$0$SELECTED_TEXT**",
      "name" : "Bold Test",
      "scope" : "editor",
      "shortcut" : "cmd-shift-b"
    }

Thanks, Sean

patrickvuarnoz commented 3 years ago

That's interesting. It seems to work. If no text was selected it does not add that nice blue placeholder thing when hitting cmd-shift-b but it places the cursor between the **** so you can still type right away. When there has been text selected it does exactly what I was looking for.

Maybe that's the maximum that's currently possible with what Nova offers. Thanks!

seanosullivanuk commented 3 years ago

You’re very welcome. I don’t think we can get the behaviour of SELECTED_TEXT within one of the variable bubbles in the current version of Nova. I’ll look at getting this wrapped up with italic as well, into an update this evening.

Sean


From: patrickvuarnoz @.> Sent: Monday, May 17, 2021 12:44:21 PM To: seanosullivanuk/nova-markdownclips @.> Cc: Sean O'Sullivan @.>; State change @.> Subject: Re: [seanosullivanuk/nova-markdownclips] Format selection with keyboard shortcuts (#1)

That's interesting. It seems to work. If no text was selected it does not add that nice blue placeholder thing when hitting cmd-shift-b but it places the cursor between the **** so you can still type right away. When there has been text selected it does exactly what I was looking for.

Maybe that's the maximum that's currently possible with what Nova offers. Thanks!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/seanosullivanuk/nova-markdownclips/issues/1#issuecomment-842256861, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKOCTSMVGLFHLKQ64ZY6J63TOD6RLANCNFSM44Y55VNQ.

seanosullivanuk commented 3 years ago

This is now wrapped up in v1.2. https://github.com/seanosullivanuk/nova-markdownclips/releases/tag/1.2