[英]How to disable auto hide/show toolbar in CKEDITOR inline
CKEDITOR inline shows/hide the toolbar when focusing or blurring the DOM element with content contenteditable="true"
.当使用
contenteditable="true"
聚焦或模糊 DOM 元素时,CKEDITOR 内联显示/隐藏工具栏。
For example if a user click on a background of the page, CKEDITOR hide the toolbar.例如,如果用户单击页面背景,CKEDITOR 会隐藏工具栏。
I need instead show always the toolbar and disable any auto show/hide feature.我需要始终显示工具栏并禁用任何自动显示/隐藏功能。
Any way how to achieve it?任何方式如何实现它?
http://jsfiddle.net/vdRYL/28/ 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>
I have tried我试过了
CKEDITOR.inline(this._cloneDom.id, { startupFocus: false });
but with no success但没有成功
Here is what I did and it seem to be working:这是我所做的,它似乎有效:
// 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;
});
We can hide and show toolbar.我们可以隐藏和显示工具栏。 I have achieved this functionality using following way:
我使用以下方式实现了此功能:
Open ckeditor.js
file.打开
ckeditor.js
文件。 And paste below code at the end of the file并在文件末尾粘贴以下代码
$(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';
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.