From a3ce557e64c04f47701c93a4598f4cde536c13a4 Mon Sep 17 00:00:00 2001 From: lkw199711 Date: Wed, 24 Jun 2020 17:43:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?test:=E6=9B=B4=E6=94=B9=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E4=B8=BA=E9=A9=BC=E5=B3=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/menus.ts | 2 +- src/menus/menu-list.ts | 4 ++-- src/menus/{strikethrough => strike-through}/index.ts | 4 ++-- .../{strikethrough.test.ts => strikeThrough.test.ts} | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/menus/{strikethrough => strike-through}/index.ts (93%) rename test/menus/{strikethrough.test.ts => strikeThrough.test.ts} (70%) diff --git a/src/config/menus.ts b/src/config/menus.ts index 8f9d251..37b2773 100644 --- a/src/config/menus.ts +++ b/src/config/menus.ts @@ -4,7 +4,7 @@ */ export default { - menus: ['bold', 'head', 'link', 'underline', 'strikethrough'], + menus: ['bold', 'head', 'link', 'underline', 'strikeThrough'], fontNames: ['宋体', '微软雅黑', 'Arial', 'Tahoma', 'Verdana'], diff --git a/src/menus/menu-list.ts b/src/menus/menu-list.ts index 55abd52..bdb6a50 100644 --- a/src/menus/menu-list.ts +++ b/src/menus/menu-list.ts @@ -7,12 +7,12 @@ 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' export default { bold: Bold, head: Head, link: Link, underline: Underline, - strikethrough: Strikethrough, + strikeThrough: StrikeThrough, } diff --git a/src/menus/strikethrough/index.ts b/src/menus/strike-through/index.ts similarity index 93% rename from src/menus/strikethrough/index.ts rename to src/menus/strike-through/index.ts index e71cd8c..1f59942 100644 --- a/src/menus/strikethrough/index.ts +++ b/src/menus/strike-through/index.ts @@ -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 = $( `
@@ -53,4 +53,4 @@ class Strikethrough extends BtnMenu implements MenuActive { } } -export default Strikethrough +export default StrikeThrough diff --git a/test/menus/strikethrough.test.ts b/test/menus/strikeThrough.test.ts similarity index 70% rename from test/menus/strikethrough.test.ts rename to test/menus/strikeThrough.test.ts index c83c7e7..f62b7a9 100644 --- a/test/menus/strikethrough.test.ts +++ b/test/menus/strikeThrough.test.ts @@ -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 被调用 }) From e43ac56cdc6b7a31bf35211216e0751c45338e75 Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Sun, 28 Jun 2020 09:47:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E5=8D=95=E8=AF=8D=E6=8B=BC=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/menus/font-style/FontStyleList.ts | 6 +++--- src/menus/menu-constructors/DropList.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/menus/font-style/FontStyleList.ts b/src/menus/font-style/FontStyleList.ts index d461173..b5e13fd 100644 --- a/src/menus/font-style/FontStyleList.ts +++ b/src/menus/font-style/FontStyleList.ts @@ -4,7 +4,7 @@ */ import $, { DomElement } from '../../utils/dom-core' -export type DroListItem = { +export type DropListItem = { $elem: DomElement value: string } @@ -16,7 +16,7 @@ export type DroListItem = { * 因此,想着顺便研究实践下ts,遍创建了这样一个类 */ class FontStyleList { - private itemList: DroListItem[] + private itemList: DropListItem[] constructor(list: string[]) { this.itemList = [] @@ -28,7 +28,7 @@ class FontStyleList { }) } - public getItemList(): DroListItem[] { + public getItemList(): DropListItem[] { return this.itemList } } diff --git a/src/menus/menu-constructors/DropList.ts b/src/menus/menu-constructors/DropList.ts index 5cae9d8..1ace0d0 100644 --- a/src/menus/menu-constructors/DropList.ts +++ b/src/menus/menu-constructors/DropList.ts @@ -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 From 868fc7e641380e9cddbf72b2982e76ddaf1e0dc0 Mon Sep 17 00:00:00 2001 From: wangfupeng Date: Sun, 28 Jun 2020 09:50:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20type=20DropListItem=20=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/menus/font-style/FontStyleList.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/menus/font-style/FontStyleList.ts b/src/menus/font-style/FontStyleList.ts index b5e13fd..2776381 100644 --- a/src/menus/font-style/FontStyleList.ts +++ b/src/menus/font-style/FontStyleList.ts @@ -2,12 +2,8 @@ * @description 字体 class * @author dyl */ -import $, { DomElement } from '../../utils/dom-core' - -export type DropListItem = { - $elem: DomElement - value: string -} +import $ from '../../utils/dom-core' +import { DropListItem } from '../menu-constructors/DropList' /** * 封装的一个字体菜单列表数据的组装对象,