Merge branch 'dev' into feature-menus-link

This commit is contained in:
wangfupeng 2020-06-28 15:09:16 +08:00
commit 13cda57ac2
6 changed files with 15 additions and 19 deletions

View File

@ -4,7 +4,7 @@
*/
export default {
menus: ['bold', 'head', 'link', 'underline', 'strikethrough', 'fontStyle'],
menus: ['bold', 'head', 'link', 'underline', 'strikeThrough', 'fontStyle'],
fontNames: ['宋体', '微软雅黑', 'Arial', 'Tahoma', 'Verdana'],

View File

@ -2,12 +2,8 @@
* @description class
* @author dyl
*/
import $, { DomElement } from '../../utils/dom-core'
export type DroListItem = {
$elem: DomElement
value: string
}
import $ from '../../utils/dom-core'
import { DropListItem } from '../menu-constructors/DropList'
/**
* ,
@ -16,7 +12,7 @@ export type DroListItem = {
* ,便ts,
*/
class FontStyleList {
private itemList: DroListItem[]
private itemList: DropListItem[]
constructor(list: string[]) {
this.itemList = []
@ -28,7 +24,7 @@ class FontStyleList {
})
}
public getItemList(): DroListItem[] {
public getItemList(): DropListItem[] {
return this.itemList
}
}

View File

@ -6,7 +6,7 @@ import $, { DomElement } from '../../utils/dom-core'
import DropListMenu from './DropListMenu'
import { EMPTY_FN } from '../../utils/const'
export type DroListItem = {
export type DropListItem = {
$elem: DomElement
value: string
}
@ -14,7 +14,7 @@ export type DroListItem = {
// droplist 的配置数据
export type DropListConf = {
title: string
list: DroListItem[]
list: DropListItem[]
type: string // 'list' 列表形式(如“标题”菜单); 'inline-block' 块状形式(如“颜色”菜单)
clickHandler: Function
width: number | 100

View File

@ -7,7 +7,7 @@ import Bold from './bold/index'
import Head from './head/index'
import Link from './link/index'
import Underline from './underline/index'
import Strikethrough from './strikethrough/index'
import StrikeThrough from './strike-through/index'
import FontStyle from './font-style/index'
export default {
@ -15,6 +15,6 @@ export default {
head: Head,
link: Link,
underline: Underline,
strikethrough: Strikethrough,
strikeThrough: StrikeThrough,
fontStyle: FontStyle,
}

View File

@ -8,7 +8,7 @@ import $ from '../../utils/dom-core'
import Editor from '../../editor/index'
import { MenuActive } from '../menu-constructors/Menu'
class Strikethrough extends BtnMenu implements MenuActive {
class StrikeThrough extends BtnMenu implements MenuActive {
constructor(editor: Editor) {
const $elem = $(
`<div class="w-e-menu">
@ -53,4 +53,4 @@ class Strikethrough extends BtnMenu implements MenuActive {
}
}
export default Strikethrough
export default StrikeThrough

View File

@ -5,21 +5,21 @@
import createEditor from '../fns/create-editor'
import Editor from '../../src/editor'
import Strikethrough from '../../src/menus/strikethrough/index'
import StrikeThrough from '../../src/menus/strike-through/index'
import mockCmdFn from '../fns/command-mock'
import { getMenuInstance } from '../fns/menus'
let editor: Editor
let strikethroughMenu: Strikethrough
let strikeThroughMenu: StrikeThrough
test('加删除线', () => {
editor = createEditor(document, 'div1') // 赋值给全局变量
// 找到 strikeThrough 菜单
strikethroughMenu = getMenuInstance(editor, Strikethrough) as Strikethrough
strikeThroughMenu = getMenuInstance(editor, StrikeThrough) as StrikeThrough
// 执行点击事件,模拟删除线
mockCmdFn(document)
;(strikethroughMenu as Strikethrough).clickHandler()
;(strikeThroughMenu as StrikeThrough).clickHandler()
expect(document.execCommand).toBeCalledWith('strikeThrough', false, undefined) // mock fn 被调用
})