django-markdownx icon indicating copy to clipboard operation
django-markdownx copied to clipboard

Make markdown editor not eat TAB for scrolling elements

Open MythicManiac opened this issue 8 years ago • 5 comments

Currently the markdown editor widget eats the tab keypress in a way that prevents element focus change. This seems to be intended behaviour as a tab character is inserted.

There should be a way to opt-out of this behaviour and instead use tab for changing the focused element like normally. Right now the only way to opt-out seems to be by overriding the entire javascript file with a modified version of it.

MythicManiac avatar May 05 '17 08:05 MythicManiac

Ok, I'll consider implementing an option for this in the next minor release, that is v2.1.

xenatisch avatar May 05 '17 17:05 xenatisch

To add to the discussion, using [ and ] for indentation prevents typing in links.

D4r1 avatar Aug 23 '17 12:08 D4r1

Thanks for the awesome library! I was just about to ask how to easiest do this when I found this. Having tabs appear when switching browser tabs on the keyboard is highly frustrating, so a big 👍 for this.

jaywink avatar Sep 02 '17 15:09 jaywink

OK I decided to hack something for myself, if it's a suitable patch I could add tests and make a PR out of it: https://github.com/jaywink/django-markdownx/commit/8b84886d3cbb768410110ae81958ad6018f7a0fe

The weird thing though, when I set MARKDOWNX_DISABLE_KEYS = True in my settings, I only get data-markdownx-disable-keys="" in the HTML element attrs. I would have investigated more, but since I copied the implementation from editor resize, I tried that and the same result. If I set MARKDOWNX_DISABLE_KEYS = "true" things work. What am I doing wrong or is something broken on master?

Let me know if this patch is acceptable, otherwise I'll keep it for myself until the feature lands here later 👍

jaywink avatar Sep 02 '17 21:09 jaywink

I realized after doing the above that I can just check whether CTRL is pressed at the same time and always ignore TAB in that case. This fixes everything I have against the hotkeys for me. PR #85 filed for consideration.

Can still clean the "disable keys" commit if that is seen as a good addition, though personally I wont be using it after all.

jaywink avatar Sep 03 '17 13:09 jaywink