ckeditor:全屏模式的不同工具栏
对于标准模式和全屏模式,是否可能有不同的工具栏元素 有内置的选项吗ckeditor:全屏模式的不同工具栏,ckeditor,Ckeditor,对于标准模式和全屏模式,是否可能有不同的工具栏元素 有内置的选项吗 如果没有,在不调整ckeditor.js本身的情况下,是否有任何解决方法?很抱歉,但在运行期间,无论如何都无法更改工具栏,包括全屏视图。您需要销毁编辑器editor.destroy(),并创建一个具有不同配置的新编辑器,以具有不同的工具栏 变通办法 尽管这并不简单,但假设,您可以如下绕过此问题: 一些解释 此代码观察最大化按钮单击,并在用户单击按钮时,使用自定义工具栏配置创建一个新的最大化编辑器实例 如果实例已被最大化,则单击该
如果没有,在不调整ckeditor.js本身的情况下,是否有任何解决方法?很抱歉,但在运行期间,无论如何都无法更改工具栏,包括全屏视图。您需要销毁编辑器
editor.destroy()
,并创建一个具有不同配置的新编辑器,以具有不同的工具栏
变通办法
尽管这并不简单,但假设
,您可以如下绕过此问题:
一些解释
此代码观察最大化按钮单击,并在用户单击按钮时,使用自定义工具栏配置创建一个新的最大化编辑器实例
如果实例已被最大化,则单击该按钮将创建一个具有默认工具栏配置的新的“最小化”实例
最后说明
注意#1:由于总是创建一个新实例,因此选择将丢失(需要添加大量代码以保留它),其他内容也将丢失。这是一种权衡
注意#2:自CKEditor 4.1以来,该功能已实现。这意味着更改工具栏将禁用编辑器功能,并相应地修改编辑的内容,例如,无链接按钮→ 无链接功能→ 内容中没有链接→ <代码>)
我希望这对你有帮助;) 整洁,但等待一些帮助,我选择了更为粗糙的方法:CKEDITOR.replace('textarea',{toolbar:[这里有一些工具],在:{maximize:function(e){if(e.data==1){//fullscreen(1)//jQuery css show menu elements}else{//reg.screen(2)//jQuery css hide menu elements}});
// Custom config for maximized editor.
var maximizedConfig = {
toolbarGroups: [
{
name: 'maximized',
groups: [
'basicstyles',
'clipboard',
'undo',
'tools'
]
}
]
};
var createEditor = (function() {
var editor;
function invokeInstance( state ) {
// Destroy the instance if it exists.
editor && editor.destroy();
// Create a new instance
editor = CKEDITOR.replace( 'editor1', CKEDITOR.tools.extend( {
on: {
instanceReady: function () {
// If it wasn't maximized, maximize the instance.
if ( state === CKEDITOR.TRISTATE_OFF )
this.execCommand( 'maximize' );
// When clicking maximize button, create a new instance
// with a desired maximization state.
this.commands.maximize.once( 'exec', function( evt ) {
CKEDITOR.tools.setTimeout( function( state ) {
createEditor( state );
}, 0, null, this.state );
return false;
} );
}
}
// Use different configs according to the maximization state.
}, state === CKEDITOR.TRISTATE_OFF ? maximizedConfig : {} ) );
};
return function( state ) {
// If there's some working instance of the editor...
if ( editor ) {
// If it was maximized...
if ( state == CKEDITOR.TRISTATE_ON ) {
// Create the new instance once de-maximized.
editor.once( 'maximize', function( evt ) {
invokeInstance( state );
} );
// Un-maximize the instance.
editor.execCommand( 'maximize' );
}
// If it wasn't maximized, basically create a new one.
else
invokeInstance( state );
}
// If there is NO working instance, create a new one.
else
invokeInstance();
};
})();
// Create the first editor.
createEditor();