CKEditor openDialog placeholders
CKEditor openDialog placeholders
我有一个函数,当按下某个键时打开占位符对话框。但是,当我选择一个占位符并单击"Ok"时,占位符值不会插入编辑器中。但是当我通过工具栏按钮打开占位符对话框时,占位符确实被插入到编辑器中。
谁能告诉我我做错了什么?我在plugin.js
中添加了:
editor.on('key', function(e) {
if (e.data.domEvent.$.key == "[") {
editor.openDialog('placeholder');
};
});
我改变了placeholder.js
中的一些东西:
可用的占位符位于下拉列表中。
占位符数据已被init传递。
正如你所看到的,我在commit: function( widget ){
里面放了一个console.log(this.getValue());
。当我通过工具栏中的占位符按钮打开对话框时,console.log
在firebug控制台上是可见的,但是当我通过按键打开对话框时,它是不可见的。
'use strict';
CKEDITOR.dialog.add( 'placeholder', function( editor ) {
var lang = editor.lang.placeholder,
generalLabel = editor.lang.common.generalTab,
validNameRegex = /^[^'[']<>]+$/;
return {
title: lang.title,
minWidth: 300,
minHeight: 80,
contents: [
{
id: 'info',
label: generalLabel,
title: generalLabel,
elements: [
// Dialog window UI elements.
{
id: 'name',
type: 'select',
items: editor.config.placeholders,
style: 'width: 100%;',
label: lang.name,
'default': '',
required: true,
validate: CKEDITOR.dialog.validate.regex( validNameRegex, lang.invalidName ),
setup: function( widget ) {
this.setValue( widget.data.name );
},
commit: function( widget ) {
console.log(this.getValue());
widget.setData( 'name', this.getValue() );
}
}
]
}
]
};
} );
在我的placeholder/plugin.js中使用以下代码:
editor.on('key', function(e) {
console.log(e.data.domEvent.$);
if (e.data.domEvent.$.key == "[") {
editor.openDialog('placeholder');
};
});
我在启动编辑器时使用了setKeystroke函数:
var editor = CKEDITOR.replace( 'editor',{
placeholders: ["test1", "test2"],
extraPlugins: 'placeholder'
});
editor.setKeystroke( 219, 'placeholder');
这是可行的!
相关文章:
- no-op if 语句会导致 Google 图表失败
- 左侧赋值无效(railo.transformer.bytecode.op.OpString)
- rails应用程序中的AJAX请求错误:xhr.send((options.hasContent&&op
- 使用js-op和svg绘制循环
- JS-op.继承和apply()函数.为什么没有'不起作用
- CKEditor openDialog placeholders
- 委托的OP概念是什么?它与其他委托概念有何不同?
- Javascript placeholders
- Javascript placeholders
- 在HTML中有NO-OP标签吗?
- 如何使用Javascript从父窗口设置子pop-op元素的值