2013-03-20 78 views
2

CKEditor 4可以在「內嵌編輯器」模式下使用,只要相關文本區域獲得焦點,它就會顯示一個工具欄。我需要隱藏工具欄,並且只在用戶選擇一些文本時才顯示它,我該怎麼做?CKEDITOR內嵌編輯器工具欄文本選擇

我想知道如何重新定位工具欄。

+0

問題編輯請查看和更改狀態爲開(@andrewsi) – RGA 2015-01-06 06:51:38

回答

3

你可以嘗試這樣的事:

$('#showEditor').mouseup(function() { 
    if(getSelectedText()){ 
    //show inline editor instance 

CKEDITOR.disableAutoInline = true; 
var editor = CKEDITOR.inline(document.getElementById('showEditor')); 

    } 
}); 

function getSelectedText() { 
    var t = ''; 
    if (window.getSelection) { 
     t = window.getSelection(); 
    } else if (document.getSelection) { 
     t = document.getSelection(); 
    } else if (document.selection) { 
     t = document.selection.createRange().text; 
    } 
    return t; 
}