2

It is a minor matter of comfort, but can I customize the Markdown editor on Ask Different?

In part of my research, I clicked my avatar at the top and then Settings > Preferences. On that page there is a Keyboard shortcuts option, but that is not what I am after.

I am very used to the key bindings that Safari provides on other sites, or even in the "Search Q&A" box and the Title on Stack Exchange sites. Some work but others do not. For example, Control-K to kill to the end of the line gets intercepted for entering preformatted text, and Control-B to move Backward one character gets intercepted for strong text. I am afraid I am an old school Emacser who prefers Control-B to left-arrow sometimes.

I have some tolerable work-arounds for this, so I guess I'm mainly interested if there is a setting I haven't found, or if it is worthwhile making a feature request to our gracious hosts.

  • 2
    What kind of experience do you have with JavaScript? A userscript might be a solution for this. I’ll have a look into how the WMD works later. – grg Mar 23 '17 at 7:35
  • 2
    I've managed to disable the WMD listening to the keyboard shortcuts, but a side effect is it breaks the toolbar buttons, which isn't acceptable. I'll probably have another look again. – grg Mar 23 '17 at 22:11
  • I am new to JavaScript, but I'd be interested to see your partial solution. – D A Vincent Mar 25 '17 at 1:30
  • 1
    I've given an answer with as far as I've got with the research. – grg Mar 25 '17 at 17:21
2

This is what I have found so far. The WMD's event listener function is anonymous, which means it can't be removed with .removeEventListener(type, listener), and jQuery's .off() doesn't seem to have any effect, but I don't have enough experience with jQuery.

To remove all event listeners, I can use $0.outerHTML = $0.outerHTML; to replace the element, however this breaks the buttons on the toolbar.

The relevant section of code from the WMD (beautified) is:

var y = "keydown";
g.isOpera && (y = "keypress"), c.addEvent(v, y, function(e) {
    if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey) {
        var t = e.charCode || e.keyCode,
            n = String.fromCharCode(t).toLowerCase();
        switch (n) {
        […]
        case "k":
            l(b.code);
            break;
        case "g":
            l(b.image);
            break;
        […]
        default:
            return
        }
        e.preventDefault && e.preventDefault(), window.event && (window.event.returnValue = !1)
    }
})

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .