Skip to content

Instantly share code, notes, and snippets.

@laszlokorte
Created December 30, 2010 20:18
Show Gist options
  • Save laszlokorte/760242 to your computer and use it in GitHub Desktop.
Save laszlokorte/760242 to your computer and use it in GitHub Desktop.
TinyMCE fix for leaving definition-lists with the enter key
setup : function(ed) {
ed.onKeyPress.addToTop(function(ed, e) {
if(e.keyIdentifier =='Enter' && ed.selection)
{
var element = ed.selection.getNode(),
tagname = element.tagName.toLowerCase(),
contentLength = element.textContent.length;
if( contentLength==0 && (tagname=='dt' || tagname=='dd'))
{
ed.execCommand("formatBlock",false, 'p');
e.stopPropagation();
e.preventDefault();
return false;
}
}
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment