2014-02-14 35 views
1

我正在開發一個插件來顯示CKEditor工具欄上的「下一行」按鈕。但是當我開始打字並按下下一行按鈕時,它不能在一次單擊中工作,即我必須點擊兩次才能進入下一行。在CKEditor中添加單行換行的按鈕

我使用的CKEditor 4.

我應該怎麼做額外的去下一行上一個單一的點擊。任何人都可以幫我解決這個問題嗎?

這是我plugin.js代碼

CKEDITOR.plugins.add('newline', 
{ 
    init: function (editor) { 

     var pluginName = 'newline'; 

     editor.ui.addButton('newline', 

      { 
       label: 'New Line', 
       command: 'NewLine', 
       icon: CKEDITOR.plugins.getPath('newline') + 'images/new_line.png' 
      }); 

     var cmd = editor.addCommand('NewLine', { exec: showNewLine }); 

    } 

}); 

function showNewLine(e) { 

    e.insertHtml('<br />'); 

    // Here if I replace the above line with e.insertHtml('<br />&nbsp;'); it will work fine but is adding an extra space at the beggining of each line. 

} 

所有我需要的是一個按鈕(點擊時)的作品完全一樣Shift + Enter鍵在CKEditor的。

+0

請任何人都可以回答這個問題嗎? – user2742122

回答

1

您的按鈕應執行shiftEnter命令。這比插入<br />複雜得多。

editor.execCommand('shiftEnter'); 
+0

謝謝,它現在剛剛完美。 – user2742122