[英]Add ckeditor widget to a custom toolbar
I'm trying to add the placeholder widget to my custom toolbar 我正在尝试将占位符小部件添加到我的自定义工具栏中
- for the life of me I can't figure out how:
-对于我的一生,我不知道如何:
<script src="https://cdn.ckeditor.com/4.5.2/standard-all/ckeditor.js"></script>
It works with the default toolbar: 它适用于默认工具栏:
<textarea cols="80" id="editor1" name="editor1" rows="10">test1</textarea>
CKEDITOR.replace( 'editor1', {
extraPlugins: 'placeholder',
height: 50
} );
But not with a custom toolbar: 但不能使用自定义工具栏:
<textarea cols="80" id="editor2" name="editor2" rows="10">test2</textarea>
CKEDITOR.replace( 'editor2', {
extraPlugins: 'placeholder',
height: 50,
toolbar: [{ name: 'tools',group: 'tools', items: [ 'Bold','Placeholder', 'Redo' ], groups: [ 'tools'] }]
} );
As I understand it there are 2 ways to insert a button to toolbar: 1. use name in toolbar itself (editor 2 example) 2. using editor.ui.addButton
function: 据我了解,有两种方法可以将按钮插入工具栏:1.在工具栏本身中使用名称(编辑器2示例)2.使用
editor.ui.addButton
函数:
editor.ui.addButton && editor.ui.addButton( 'CreatePlaceholder', {
label: lang.toolbar,
command: 'placeholder',
// toolbar: 'insert,5',
toolbar: 'clipboard,0',
icon: 'placeholder'
} );
I created a fiddle to show: 我创建了一个小提琴来显示:
Can you please show/tell me how to add Placeholder to a custom made toolbar? 您能告诉我/如何告诉我如何向自定义工具栏添加占位符吗? Thank you
谢谢
You have named your button 'CreatePlaceholder', so you should use this name in toolbar. 您已将按钮命名为“ CreatePlaceholder”,因此应在工具栏中使用此名称。
editor.ui.addButton && editor.ui.addButton( 'CreatePlaceholder', ...
CKEDITOR.replace( 'editor3', {
...
toolbar: [{ name: 'tools',group: 'tools', items: [ 'Bold','CreatePlaceholder', ...
Full code: http://jsfiddle.net/nw3o4gy5/ 完整代码: http : //jsfiddle.net/nw3o4gy5/
Also take a look at CKEDITOR.ui.addButton . 还要看看CKEDITOR.ui.addButton 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.