From 05a9125e78e34c3a64abec540fb7a985fc134349 Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Tue, 7 Jul 2020 14:12:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89=20customConfig?= =?UTF-8?q?=20=E5=8F=AA=E4=BF=9D=E7=95=99=20conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/index.html | 8 ++++---- examples/styleWithCSS.html | 2 +- src/editor/index.ts | 6 ------ src/editor/init-fns/init-config.ts | 14 -------------- src/menus/font-style/index.ts | 4 ++-- 5 files changed, 7 insertions(+), 27 deletions(-) delete mode 100644 src/editor/init-fns/init-config.ts diff --git a/examples/index.html b/examples/index.html index bcc6c9d..fcb6ef0 100644 --- a/examples/index.html +++ b/examples/index.html @@ -20,16 +20,16 @@ const E = window.wangEditor const editor = new E('#div1') - // editor.customConfig.onchange = function (newHtml) { + // editor.config.onchange = function (newHtml) { // console.log('onchange', newHtml) // } - // editor.customConfig.onblur = function (newHtml) { + // editor.config.onblur = function (newHtml) { // console.log('onblur', newHtml) // } - // editor.customConfig.onfocus = function (newHtml) { + // editor.config.onfocus = function (newHtml) { // console.log('onfocus', newHtml) // } - // editor.customConfig.fontNames = [ + // editor.config.fontNames = [ // '宋体', // '微软雅黑', // ] diff --git a/examples/styleWithCSS.html b/examples/styleWithCSS.html index edaccb2..677a7bc 100644 --- a/examples/styleWithCSS.html +++ b/examples/styleWithCSS.html @@ -18,7 +18,7 @@ const E = window.wangEditor const editor = new E('#div1') - editor.customConfig.styleWithCSS = true + editor.config.styleWithCSS = true editor.create() diff --git a/src/editor/index.ts b/src/editor/index.ts index 523fdcf..bf12fc1 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -14,7 +14,6 @@ import initDom from './init-fns/init-dom' import initSelection from './init-fns/init-selection' import bindEvent, { changeHandler } from './init-fns/bind-event' import initUpload from './init-fns/init-upload' -import initConfig from './init-fns/init-config' let EDITOR_ID = 1 @@ -22,7 +21,6 @@ class Editor { public id: string public toolbarSelector: string public textSelector: string | undefined - public customConfig: ConfigType public config: ConfigType public $toolbarElem: DomElement public $textContainerElem: DomElement @@ -53,7 +51,6 @@ class Editor { } // 属性的默认值,后面可能会再修改 - this.customConfig = defaultConfig // 自定义配置,先赋值为默认配置 this.config = defaultConfig // 默认配置 this.$toolbarElem = $('
') this.$textContainerElem = $('
') @@ -81,9 +78,6 @@ class Editor { * 创建编辑器实例 */ public create(): void { - // 初始化配置 - initConfig(this) - // 初始化 DOM initDom(this) diff --git a/src/editor/init-fns/init-config.ts b/src/editor/init-fns/init-config.ts deleted file mode 100644 index 9a573c6..0000000 --- a/src/editor/init-fns/init-config.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @description 初始化编辑器配置 - * @author wangfupeng - */ - -import Editor from '../index' -import defaultConfig from '../../config' - -export default function (editor: Editor): void { - // 自定义配置和默认配置,合并 - editor.config = Object.assign({}, defaultConfig, editor.customConfig) - - // 原先版本中,此处有多语言配置 -} diff --git a/src/menus/font-style/index.ts b/src/menus/font-style/index.ts index 40ab3e2..24baab5 100644 --- a/src/menus/font-style/index.ts +++ b/src/menus/font-style/index.ts @@ -17,7 +17,7 @@ class FontStyle extends DropListMenu implements MenuActive { ` ) - let fontStyleList = new FontStyleList(editor.customConfig.fontNames) + let fontStyleList = new FontStyleList(editor.config.fontNames) const fontListConf = { width: 100, title: '设置字体', @@ -47,7 +47,7 @@ class FontStyle extends DropListMenu implements MenuActive { public tryChangeActive(): void { // const editor = this.editor // const cmdValue = editor.cmd.queryCommandValue('fontName') - // if (menusCongfig.fontNames.indexOf(cmdValue) >= 0) { + // if (menusConfig.fontNames.indexOf(cmdValue) >= 0) { // this.active() // } else { // this.unActive()