1. 程式人生 > 實用技巧 >wangEditor 自定義 選單

wangEditor 自定義 選單

https://blog.csdn.net/pan396365044/article/details/87282753?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

1. 在元件 Myeditor

// 配置選單
this.editor.customConfig.menus = [
'head', // 標題
'bold', // 粗體
'fontSize', // 字號
'fontName', // 字型
'italic', // 斜體
'underline', // 下劃線
'strikeThrough', // 刪除線
'foreColor', // 文字顏色
'backColor', // 背景顏色
'link', // 插入連結
'list', // 列表
'justify', // 對齊方式
'quote', // 引用
'emoticon', // 表情
'image', // 插入圖片
'table', // 表格
'video', // 插入視訊
'undo', // 撤銷
'redo', // 重複
'fullscreen' ,// 全屏
'hr'
]
增加 hr

2.在wangEditor.js 增加
function Hr(editor){
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <button>插入</button>\n </div>');
this.type = 'click';
this._active = false;
}
Hr.prototype = {
constructor: Hr,

onClick:function onClick(e) {
var editor = this.editor;
editor.cmd.do('insertHtml','()');
},
}

3.建構函式 增加 set 值

MenuConstructors.hr = Hr;

4.自定義成功