neutronX / django-markdownx

Comprehensive Markdown plugin built for Django
https://neutronx.github.io/django-markdownx/
Other
863 stars 153 forks source link

Make markdown editor not eat TAB for scrolling elements #66

Open MythicManiac opened 7 years ago

MythicManiac commented 7 years ago

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.

xenatisch commented 7 years ago

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

D4r1 commented 7 years ago

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

jaywink commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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.