views:

60

answers:

1

if you create an unordered list in tinymce and hit the tab key the code created looks like this:

<ul>
<li><span style="white-space: pre;"> </span>list item 1</li>
</ul>

however, if you click on the indent button in the editor's toolbar (instead of the tab key), the following code is created:

<ul>
<li>list item 1
<ul>
<li>list item 1.1</li>
</ul>
</li>
</ul>

i would like that same thing to happen when i press the tab key. i want nested lists instead of just a white space. is there a way to achieve this? thanks!

A: 

Yes, there is. All you need to do is to add a handler for one of the following events: onKey(Down or Pressed). It should look more or less like this:

ed.onKeyUp.add(function(ed, evt) {

// keyCode == 9 means TAB
if (evt.keyCode == 9 && !evt.ctrlKey && !evt.shiftKey && !evt.altKey) {

  // this is how you get the actual node in your editor's iframe
  actual_node_in_dom = ed.selection.getNode();

  // here you need some js-code to manipulate the dom according to your wishes

}
Thariama