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.

1 Like

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