如何在CKEditor中使用制表符空间?

时间:2014-02-22 02:23:34

标签: javascript jquery ckeditor

是否可以让CKEditor将tab识别为编辑器中的一个功能,尤其是在源代码模式下?现在,当我点击Tab键时,光标将转到页面上的下一个字段。

我想让tab字符工作,所以CKEditor可以更像代码编辑器,我可以用标签空格格式化我的标记。

我真的很感激我能得到的任何帮助。

我正在使用CKEDitor 4.0.1

或者,或许在较新版本的CKEditor中支持此功能?

4 个答案:

答案 0 :(得分:13)

此链接可能有所帮助:http://get-simple.info/forums/showthread.php?tid=1347

基本上,只需添加

即可
config.tabSpaces = 4; // or some other value

config.js,每次点击 Tab ,就会得到这个数量的空格。

答案 1 :(得分:1)

如果要保存到config.js,代码为config.tabSpaces = 4;。如果要在文件中设置配置,则代码如下:

var editor = CKEDITOR.replace( 'editor1', {
    tabSpaces: 4
});

值得注意的是,正如卡米尔·萨马在rvighne的回答中所说,这需要标签插件:tab plugin

答案 2 :(得分:0)

<textarea name="text_note" id="text_note"> </textarea> 


 <!-- tabSpaces:4 add this in your script like as bellow code.-->

  <script type="text/javascript">
    CKEDITOR.replace('text_note',{tabSpaces:4});
 </script>

答案 3 :(得分:0)

如果您使用内联元素,则可以这样使用

var editor2 = CKEDITOR.inline('您的div ID',{ tabSpaces:5, });