refactor: 去掉 customConfig 只保留 conf
This commit is contained in:
parent
a5d3f33525
commit
05a9125e78
|
@ -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 = [
|
||||
// '宋体',
|
||||
// '微软雅黑',
|
||||
// ]
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
const E = window.wangEditor
|
||||
const editor = new E('#div1')
|
||||
|
||||
editor.customConfig.styleWithCSS = true
|
||||
editor.config.styleWithCSS = true
|
||||
|
||||
editor.create()
|
||||
</script>
|
||||
|
|
|
@ -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 = $('<div></div>')
|
||||
this.$textContainerElem = $('<div></div>')
|
||||
|
@ -81,9 +78,6 @@ class Editor {
|
|||
* 创建编辑器实例
|
||||
*/
|
||||
public create(): void {
|
||||
// 初始化配置
|
||||
initConfig(this)
|
||||
|
||||
// 初始化 DOM
|
||||
initDom(this)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
// 原先版本中,此处有多语言配置
|
||||
}
|
|
@ -17,7 +17,7 @@ class FontStyle extends DropListMenu implements MenuActive {
|
|||
<i class="w-e-icon-font"></i>
|
||||
</div>`
|
||||
)
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue