> wangEditor2 版本過低,已停止維護。請使用 wangEditor 最新版本,參考[官網](https://www.wangeditor.com/)。
可通過修改 `editor.config.menus` 來自定義編輯器的菜單的顯示/隱藏、排序、分組。注意,該操作必須在 `editor.create()` 方法之前。
```html
<div id="div1">
<p>請輸入內容...</p>
</div>
<!--這里引用jquery和wangEditor.js-->
<script type="text/javascript">
var editor = new wangEditor('div1');
// 普通的自定義菜單
editor.config.menus = [
'source',
'|', // '|' 是菜單組的分割線
'bold',
'underline',
'italic',
'strikethrough',
'eraser',
'forecolor',
'bgcolor'
];
// 僅僅想移除某幾個菜單,例如想移除『插入代碼』和『全屏』菜單:
// 其中的 wangEditor.config.menus 可獲取默認情況下的菜單配置
// editor.config.menus = $.map(wangEditor.config.menus, function(item, key) {
// if (item === 'insertcode') {
// return null;
// }
// if (item === 'fullscreen') {
// return null;
// }
// return item;
// });
editor.create();
</script>
```
另外,`wangEditor`默認的菜單配置,可在下載下來的`wangEditor.js`文件中搜索**`E.config.menus`**關鍵字來找到。
目前的默認菜單配置如下,**以在最新代碼中搜索出來的結果為準**
```javascript
[
'source',
'|',
'bold',
'underline',
'italic',
'strikethrough',
'eraser',
'forecolor',
'bgcolor',
'|',
'quote',
'fontfamily',
'fontsize',
'head',
'unorderlist',
'orderlist',
'alignleft',
'aligncenter',
'alignright',
'|',
'link',
'unlink',
'table',
'emotion',
'|',
'img',
'video',
'location',
'insertcode',
'|',
'undo',
'redo',
'fullscreen'
];
```
-----
**如果需要『行高』和『縮進』菜單,可直接使用`lineheight`和`indent`這兩個菜單id。因為wangEditor中已經集成了這兩個自定義菜單的代碼。**
- 關于wangEditor
- 遇到問題如何解決和提問【重要】
- 開始使用
- 下載
- 創建頁面
- 生成編輯器(使用ID)
- 生成編輯器(使用element)
- 調整尺寸
- 銷毀與恢復
- 一個頁面多個編輯器
- 內容處理
- 初始化內容
- 獲取內容
- 追加內容
- 清空內容
- 用 editor.$txt 做其他內容處理
- onchange事件
- 禁用/啟用
- 參數配置
- 自定義菜單
- 自定義顏色、字體、字號
- 自定義表情
- 切換語言
- 百度地圖key
- 菜單欄吸頂
- 配置全屏的z-index
- 關閉瀏覽器打印log
- 關閉過濾javascript
- 關閉粘貼過濾樣式
- 只粘貼純文本
- 插入代碼-配置默認語言
- 自定義編輯器樣式
- 自定義顏色
- 自定義菜單UI
- 自定義表格、引用、代碼的樣式
- 代碼高亮樣式
- 圖片上傳
- 使用前必讀
- 支持情況
- 配置說明
- log提示輔助排錯
- 后臺代碼示例
- C#
- java - 例1
- java - 例2
- php
- nodejs
- python
- 自定義上傳事件
- 集成plupload插件
- 集成七牛云存儲
- 跨域上傳
- 上傳圖片出錯時的解決步驟
- 使用模塊定義
- 使用require.js
- 使用seajs
- 使用webpack
- 插件開發
- 對象結構
- 常用API
- 全局API
- 對象API
- 基礎API
- 選區API
- 命令API
- 擴展一個菜單
- 『縮進』菜單
- 『行高』菜單
- 『插入符號』菜單
- 開發一個插件
- 常見問題
- 關于markdown
- 關于上傳附件
- 關于背景圖片
- 關于顯示壓縮圖片
- 集成到React
- 集成到angular
- 集成到vue.js
- 如何避免與項目中的css沖突
- xss過濾
- 如何插入視頻鏈接
- 關于mobile端編輯器
- 查看源碼第一行有空格