code-medium icon indicating copy to clipboard operation
code-medium copied to clipboard

[Suggestion] Keyboard Shortcut?

Open ibehnam opened this issue 2 years ago • 9 comments

This extension is exactly what I was looking for! Thanks for doing this. I was wondering if we can assign shortcut keys to insert Github Gists using this extension? Medium already has some for text (e.g., CMD+OPTION+1 => Heading 1). It'd be nice to have something like CMD+OPT+0 => Insert Gist.

ibehnam avatar Jul 20 '22 18:07 ibehnam

This does indeed looks nice to have. I think the user should be able to customize the shortcut, maybe even keeping "CMD/CTRL + OPTION" and just changing "1" with other keys.

The customization could be done in the extension button popup.

The user should also know that they can use the shortcut, so the info should be added somewhere, in the list of features but also potentially in the gist editor as a tip.

Maluen avatar Jul 20 '22 23:07 Maluen

Yes, that all sounds good!

If it's not possible to do, there's always the option of assigning shortcuts in the browser (e.g., in Brave you can assign shortcuts to extensions, but the extension has to provide the list of its functionalities, see the Dark Reader example).

For example, the following doesn't work: image

But this one works: image

ibehnam avatar Jul 22 '22 15:07 ibehnam

Added shortcut with default "CTRL/CMD + SHIFT + 0".

I didn't use "CTRL/CMD + ALT/OPT + 0" since chrome allows either "CTRL" or "ALT". See https://developer.chrome.com/docs/extensions/reference/commands/#key-combinations

If another extension is already using the same combination, the shortcut will be unset and must be manually changed. This can be confusing for an end user. For this chrome docs suggest notifying the user on installation, example: https://developer.chrome.com/docs/extensions/reference/commands/#verify-commands-registered

For now no notification is being shown.

Maluen avatar Jul 23 '22 00:07 Maluen

I've changed the default to "ALT + SHIFT + 0" as the old one triggered zoom in Firefox, also other "CTRL + SHIFT" combinations are bound to firefox's own shortcuts.

Maluen avatar Jul 23 '22 11:07 Maluen

Also the shortcut will only work when the Medium Editor toolbar is active, that is when the cursor is on a new line (most of the time this also means the "+" is visible):

image

Otherwise it wouldn't add the gist anyway after typing it.

Maluen avatar Jul 23 '22 11:07 Maluen

Thanks @Maluen for this! I haven't got the chance to download the files to update the extension yet, and the one on the Chrome store (and the release page here) is outdated. I'll give it a shot first chance I get and will let you know how it is.

ibehnam avatar Jul 24 '22 03:07 ibehnam

@ibehnam I didn't release yet, but you can build from source to test latest commits. See https://github.com/Maluen/code-medium#building-manually the generated folder can be loaded as an "unpacked extension" in chrome/firefox.

Maluen avatar Jul 24 '22 10:07 Maluen

Thanks! I missed the part about building. Had tried just importing the SRC folder in Chrome but got the “manifest is corrupted” error. Will try again.

On Sun, Jul 24, 2022 at 6:00 AM Maluen @.***> wrote:

@ibehnam https://github.com/ibehnam I didn't release yet, but you can build from source to test latest commits. See https://github.com/Maluen/code-medium#building-manually the generated folder can be loaded as an "unpacked extension" in chrome/firefox.

— Reply to this email directly, view it on GitHub https://github.com/Maluen/code-medium/issues/13#issuecomment-1193285135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN7H2GVUR7HDK5QN3GXC2ULVVUH5FANCNFSM54EW2QYQ . You are receiving this because you were mentioned.Message ID: @.***>

ibehnam avatar Jul 24 '22 14:07 ibehnam

@ibehnam the folder to load is dist/chrome (in Chrome) or dist/firefox (in Firefox), which is generated by following https://github.com/Maluen/code-medium#building-manually

Maluen avatar Jul 24 '22 15:07 Maluen

Done, included in v0.6.0

Maluen avatar Apr 16 '24 20:04 Maluen