Ckeditor 3-选择工具栏按钮时单击插入元素
我想在单击Ckeditor textarea窗口时插入某些文本或html(默认和重复) 我创建了一个自定义插件,它可以在单击工具栏按钮时添加一些文本,或者在通过下面的代码段单击textarea窗口时添加文本Ckeditor 3-选择工具栏按钮时单击插入元素,ckeditor,Ckeditor,我想在单击Ckeditor textarea窗口时插入某些文本或html(默认和重复) 我创建了一个自定义插件,它可以在单击工具栏按钮时添加一些文本,或者在通过下面的代码段单击textarea窗口时添加文本 CKEDITOR.plugins.add( 'duppointer', { init: function( editor ) { editor.addCommand( 'inse
CKEDITOR.plugins.add( 'duppointer',
{
init: function( editor )
{
editor.addCommand( 'insertDup',
{
modes : { wysiwyg:1, source:1 },
exec : function( editor )
{
editor.insertText( '#' );
}
});
editor.on( 'contentDom', function(){
this.document.on( 'click', function() {
editor.insertText( '#' );
});
});
editor.ui.addButton( 'duppointer',
{
label: 'Insert Duplicate Text',
command: 'insertDup',
} );
}
} );
但是,我只想在工具栏按钮处于活动状态时在单击时插入文本,否则指针单击必须正常
有可能做到这一点吗?由于没有人响应,我开始深入研究按钮,了解按钮的状态。最后,我得到了我一直在寻找的东西,如果这是一种正确的方式,我不知道,但它对我有效
CKEDITOR.plugins.add( 'duppointer',
{
init: function( editor )
{
var ccommand = editor.addCommand( 'duppointer',
{
modes : { wysiwyg:1, source:1 },
exec : function( editor )
{
ccommand.toggleState();
},
editorfocus: true,
});
editor.on( 'contentDom', function(){
this.document.on( 'click', function() {
if(ccommand.state == CKEDITOR.TRISTATE_ON){
editor.insertText( '#' );
}
});
});
editor.ui.addButton( 'duppointer',
{
label: 'Insert Duplicate',
command: 'duppointer',
icon: this.path + 'images/dup.jpg'
} );
}
} );