sleemanj / xinha

WYSIWYG HTML Editor Component (turns <textarea> into HTML editors)
http://trac.xinha.org/
Other
13 stars 2 forks source link

Catch tab keypress events and prevent default (Trac #1618) #1618

Closed sleemanj closed 3 years ago

sleemanj commented 10 years ago

Browsers behave inconsistently when the tab key is pressed in a contenteditable window. I think none of the browsers' behaviors are desired:

When the cursor is within certain contexts (lists, tables) I think the tab key should be caught and some context-specific behavior should occur (#1614, #1617). But when no relevant context is found, I think Xinha should still catch the keypress event and prevent the default behavior.

Possibly there should be a framework here that:

But those options are technically already available at a lower level using event subscribers, so a minimal patch that just catches and stops the event is probably sufficient.

Reported by ejucovy, migrated from http://trac.xinha.org/ticket/1618

sleemanj commented 10 years ago

ejucovy commented:

Related thread: http://lists.w3.org/Archives/Public/public-webapps/2012JanMar/0047.html

sleemanj commented 10 years ago

1378 Does this for both Gecko and WebKit. Configurable by tabSpanClass and tabSpanContents options, inserts (or removes for shift-tab) as the name suggests, spans. It works surprisingly well.