0

如果您在 tinymce 中创建一个无序列表并按 Tab 键,则创建的代码如下所示:

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

但是,如果您单击编辑器工具栏中的缩进按钮(而不是 Tab 键),则会创建以下代码:

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

当我按下 Tab 键时,我希望同样的事情发生。我想要嵌套列表而不仅仅是一个空格。有没有办法做到这一点?谢谢!

4

1 回答 1

1

就在这里。您需要做的就是为以下事件之一添加一个处理程序:onKey(Down 或 Pressed)。它应该或多或少像这样:

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

}
于 2010-08-23T06:36:34.193 回答