2

CKEDITOR inline 在使用 content 聚焦或模糊 DOM 元素时显示/隐藏工具栏contenteditable="true"

例如,如果用户单击页面的背景,CKEDITOR 会隐藏工具栏。

我需要始终显示工具栏并禁用任何自动显示/隐藏功能。

有什么方法可以实现吗?

http://jsfiddle.net/vdRYL/28/

<script src="//cdn.ckeditor.com/4.5.3/standard/ckeditor.js"></script>
Default behaviour: 
<div id="first" contenteditable="true">Click me</div>
<br>

我努力了

CKEDITOR.inline(this._cloneDom.id, { startupFocus: false });

但没有成功

4

2 回答 2

2

这是我所做的,它似乎正在工作:

// in config I have set the recommended value:
config.startupFocus = true;

// load the editor
var instance = CKEDITOR.inline(element.id, {
    // ... load config
});

// this works to prevent hiding of the editor, I don't know yet if this breaks anything, 
// but seems to be working fine
instance.on('blur',function(){
   return false;
});


// and because the startupFocus property triggers focus on each element that has the editor
// I scroll the document to the top on the event when editor is ready
instance.on("instanceReady", function(){
     document.body.scrollTop = document.documentElement.scrollTop = 0;
});
于 2015-09-15T13:52:18.147 回答
0

我们可以隐藏和显示工具栏。我使用以下方式实现了此功能:

打开ckeditor.js文件。并在文件末尾粘贴以下代码

$(document).ready(function () {  
   CKEDITOR.on('instanceReady', function (ev) {  
      document.getElementById(ev.editor.id + '_top').style.display = 'none';  


      ev.editor.on('focus', function (e) {  
         document.getElementById(ev.editor.id + '_top').style.display = 'block';  

      });  
      ev.editor.on('blur', function (e) {  
         document.getElementById(ev.editor.id + '_top').style.display = 'none';  

      });  
   });  
});
于 2018-02-09T21:02:33.953 回答