开发者

TinyMCE: Nested lists if tab key is pressed

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!


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

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜