Emacs shortcut keys in text box

Is there a way to disable markdown shortcuts in the text box and enable emacs shortcuts like Crtl-a, Ctrl-k like it works in a terminal?

1 Like

Iā€™ve added some shortcuts, so I think you should be able to change them as well. As I recall the function to call to add a shortcut was documented fairly well in the source.

sorry Iā€™m not familiar with Ruby, can you point me to the code?

Also, just so we are on same page - we are using a CDCK hosted version and Iā€™m looking for a setting that a user can toggle for themselves.

Iā€™m afraid there isnā€™t a way to disable markdown, though keyboard shortcuts should be working. :+1: Are there any that youā€™re having issues with?

I donā€™t want to disable markdown, just the shortcuts, itā€™s annoying when I type Ctrl+K to kill a line and discourse opens a ā€œinsert hyperlink dialogueā€

2 Likes

Ah, I see. Sorry for my confusion. :slight_smile:

I think a lot of the shortcuts work as youā€™d expect (like select-all, bold, copy, and paste etc), though the hyperlink one does open the modal. I donā€™t believe there is a way in the settings to disable that, though Iā€™ll check to make sure.

There is a quick ā€˜insert linkā€™ that may be of some use. If you copy a link from somewhere and then highlight the text in your composer youā€™d like to make a hyperlink, you can then paste your link in and it will automatically format it as a markdown hyperlink with the highlighted text as the display text.

Thereā€™s also the inline onebox approach too, which can be quite useful, where just pasting in the link into the composer mid-sentence will add a title where it can. eg Plugin directory | Discourse - Civilized Discussion .


Turns out I did not have a handle on this topic at allā€¦ :derp: :slight_smile:

1 Like

No. They work as you expect, but @manojm321 uses the One True Editor, which has different bindings. Control-K should kill to the end of the line. Control-y should yank text out of the kill buffer and on and on.

@manojm321, itā€™s not ruby you need but javascript and ember. You can do it in a component, I think. Oh, the shortcuts I added were not to the composer but to the main interface. I still think itā€™s possible, but I donā€™t know that I know where an example is.

You can look for theme components that add to the composer and/or search the source for, maybe, paste.

2 Likes

We do have a plugin API to add keyboard shortcuts:

But we donā€™t yet have one for removing the shortcut.

The library we are using is a fork of ItsATrap, with documentation here. I expect it should not take too long to add one that removes the shortcut binding itself, and just a bit more work to remove it from shift + ?:


That said, we donā€™t yet have many requests to do this, so itā€™ll likely not be prioritised until we get more requests. Iā€™m gonna add a pr-welcome as well.

4 Likes

Ah. Thereā€™s the rub. I thought there might be a different api in the composer than in other contexts.

Iā€™ve just adjusted to being multilingual, using emacs, vscode, and vim in various circumstances and with different goals.

2 Likes

Hmmmā€¦ I think I pulled a ā€œdidnā€™t understand the topicā€ here as well. The request here is specific to the composer.

:facepalm:

@pfaffman you are right. Composer specific shortcuts are not handled by ItsATrap, but here instead:

@manojm321, can I suggest to reach out to our @team if youā€™d like to explore this feature for your community?

3 Likes

I said emacs, but I really mean readline: readline(3) - Linux manual page

these shortcuts(good chunk, if not all atleast moving the cursor) universally works across lot of text boxes.

sure

1 Like

This looks like something I would love to have for myself, but I have no idea if the Nanowrimo site where I use Discourse would provide it for one oddball user from the antediluvian past.

As a touch typist since 1984, and an emacs user since the mid 90ā€™s, Iā€™ve got the keyboard motion commands wired in, and there is an effort involved that slows me down when I have to stop my reflexive attempts to do the emacs thing in a Discourse edit box.

But, as I noted, Iā€™m an oddball.

1 Like