From a463d3298ecf21a34ad63f228e15cfa14c89189c Mon Sep 17 00:00:00 2001 From: 15008401624 <597081433@qq.com> Date: Wed, 2 Dec 2020 15:56:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=AD=97=E5=8F=B7=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/wangEditor/wangEditor.min.js | 120 +++++++++++++++++- 1 file changed, 117 insertions(+), 3 deletions(-) diff --git a/public/static/manager/wangEditor/wangEditor.min.js b/public/static/manager/wangEditor/wangEditor.min.js index 814bcd8..1bcb8e3 100644 --- a/public/static/manager/wangEditor/wangEditor.min.js +++ b/public/static/manager/wangEditor/wangEditor.min.js @@ -546,10 +546,40 @@ var config = { // 默认菜单配置 - menus: ['head', 'bold', 'italic', 'underline', 'strikeThrough', 'foreColor', 'backColor', 'link', 'list', 'justify', 'quote', 'emoticon', 'image', 'table', 'video', 'code', 'undo', 'redo'], - + menus: ['head', 'bold','fontSize','fontName', 'italic', 'underline', 'strikeThrough', 'foreColor', 'backColor', 'link', 'list', 'justify', 'quote', 'emoticon', 'image', 'table', 'video', 'code', 'undo', 'redo'], + fontNames: ['微软雅黑','黑体', '仿宋', '楷体', '标楷体', '华文仿宋', '华文楷体', '宋体', '微软雅黑', 'Arial', 'Tahoma', 'Verdana'], + fontSizes: { + 'x-small': { + name: '10px', + value: '1' + }, + small: { + name: '13px', + value: '2' + }, + normal: { + name: '16px', + value: '3' + }, + large: { + name: '18px', + value: '4' + }, + 'x-large': { + name: '24px', + value: '5' + }, + 'xx-large': { + name: '32px', + value: '6' + }, + 'xxx-large': { + name: '48px', + value: '7' + } + }, colors: ['#000000', '#eeece0', '#1c487f', '#4d80bf', '#c24f4a', '#8baa4a', '#7b5ba1', '#46acc8', '#f9963b', '#ffffff'], - + // // 语言配置 // lang: { // '设置标题': 'title', @@ -1348,6 +1378,86 @@ }); } }; + + function FontSize(editor) { + var _this = this; + + this.editor = editor; + this.$elem = $('
'); + this.type = 'droplist'; + + // 当前是否 active 状态 + this._active = false; + + // 初始化 droplist + this.droplist = new DropList(this, { + width: 160, + $title: $('

字号

'), + type: 'list', // droplist 以列表形式展示 + list: [{ $elem: $('x-small'), value: '1' }, { $elem: $('small'), value: '2' }, { $elem: $('normal'), value: '3' }, { $elem: $('large'), value: '4' }, { $elem: $('x-large'), value: '5' }, { $elem: $('xx-large'), value: '6' }], + onClick: function onClick(value) { + // 注意 this 是指向当前的 FontSize 对象 + _this._command(value); + } + }); + } + + // 原型 + FontSize.prototype = { + constructor: FontSize, + + // 执行命令 + _command: function _command(value) { + var editor = this.editor; + editor.cmd.do('fontSize', value); + } + }; + + /* + menu - fontName + */ + + // 构造函数 + function FontName(editor) { + var _this = this; + + this.editor = editor; + this.$elem = $('
'); + this.type = 'droplist'; + + // 当前是否 active 状态 + this._active = false; + + // 获取配置的字体 + var config = editor.config; + var fontNames = config.fontNames || []; + + // 初始化 droplist + this.droplist = new DropList(this, { + width: 100, + $title: $('

字体

'), + type: 'list', // droplist 以列表形式展示 + list: fontNames.map(function (fontName) { + return { $elem: $('' + fontName + ''), value: fontName }; + }), + onClick: function onClick(value) { + // 注意 this 是指向当前的 FontName 对象 + _this._command(value); + } + }); + } + + // 原型 + FontName.prototype = { + constructor: FontName, + + _command: function _command(value) { + var editor = this.editor; + editor.cmd.do('fontName', value); + } + }; + + /* menu - link @@ -2976,6 +3086,10 @@ MenuConstructors.bold = Bold; MenuConstructors.head = Head; + + MenuConstructors.fontSize = FontSize; + + MenuConstructors.fontName = FontName; MenuConstructors.link = Link;