下面的链接解释了如何自定义插件(@toast-ui/editor),但是我不知道如何在vue中实现这个(@toast-ui/vue-editor)。
tutorial-example15-customizing-toolbar-buttons(纯 JavaScript 组件)
vue中不完整的代码:
import '@toast-ui/editor/dist/toastui-editor.css'
import { Editor } from '@toast-ui/vue-editor'
export default {
name: 'TextEditor',
methods:{
createLastButton: function(){
const button = document.createElement('button');
button.className = 'toastui-editor-toolbar-icons last';
button.style.backgroundImage = 'none';
button.style.margin = '0';
button.innerHTML = `<i>Bold</i>`;
button.addEventListener('click', () => {
Editor.exec('bold');
});
return button;
},
},
data () {
return {
editorText:'',
editorOpttions:{
minHeight: '200px',
language: 'en-US',
useCommandShortcut: true,
usageStatistics: true,
hideModeSwitch: false,
toolbarItems: [
['heading', 'bold', 'italic', 'strike'],
['hr', 'quote'],
['ul', 'ol', 'task', 'indent', 'outdent'],
['table', 'image', 'link'],
['code', 'codeblock'],
['scrollSync'],
// Using Option: Customize the last button
[{
el: this.createLastButton(),
command: 'bold',
tooltip: 'Custom Bold'
}]
]
},
}
},
components: {
'editor': Editor
},
};
这个实现我在一定程度上做了,但是不知道如何在vue中实现下面的代码片段
editor.insertToolbarItem({ groupIndex: 0, itemIndex: 0 }, {
name: 'myItem',
tooltip: 'Custom Button',
command: 'bold',
text: '@',
className: 'toastui-editor-toolbar-icons first',
style: { backgroundImage: 'none' }
});