Ckeditor 3 - 选择工具栏按钮时单击插入元素
Ckeditor 3 - Insert element on click when toolbar button is selected
我想在单击 Ckeditor 文本区域时插入某些文本或 html(默认和重复)window。
我创建了一个自定义插件,它可以在单击工具栏按钮时添加一些文本,或者在通过以下代码段单击文本区域 window 时添加文本。
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',
} );
}
} );
但是,我只想在工具栏按钮处于活动状态时在单击时插入文本,否则指针单击必须正常。
有可能实现吗?
由于没有人回应,我开始深入研究 API 并了解按钮的状态。最后,我得到了我正在寻找的东西,如果它是正确的方法但它对我有用,
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'
} );
}
} );
我想在单击 Ckeditor 文本区域时插入某些文本或 html(默认和重复)window。
我创建了一个自定义插件,它可以在单击工具栏按钮时添加一些文本,或者在通过以下代码段单击文本区域 window 时添加文本。
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',
} );
}
} );
但是,我只想在工具栏按钮处于活动状态时在单击时插入文本,否则指针单击必须正常。
有可能实现吗?
由于没有人回应,我开始深入研究 API 并了解按钮的状态。最后,我得到了我正在寻找的东西,如果它是正确的方法但它对我有用,
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'
} );
}
} );