我想在工具栏上添加一个按钮来调用 Tada()
之类的 JavaScript 函数吗?
关于如何添加这个有什么想法吗?
最佳答案
还有一种很好的方法可以让人们在不创建插件的情况下添加按钮。
html:
<textarea id="container">How are you!</textarea>
JavaScript:
editor = CKEDITOR.replace('container'); // bind editor
editor.addCommand("mySimpleCommand", { // create named command
exec: function(edt) {
alert(edt.getData());
}
});
editor.ui.addButton('SuperButton', { // add new button and bind our command
label: "Click me",
command: 'mySimpleCommand',
toolbar: 'insert',
icon: 'https://avatars1.githubusercontent.com/u/5500999?v=2&s=16'
});
在这里查看它是如何工作的:DEMO
关于javascript - 如何将自定义按钮添加到调用 JavaScript 函数的工具栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1957156/