From a84ecd15f05cf34da5febdf40b0c35aed39aa2ae Mon Sep 17 00:00:00 2001 From: CodePencil Date: Sun, 18 Aug 2024 10:25:58 +0800 Subject: [PATCH] refactor(format painter menu): adjusted format painter menu display order --- .../format-painter-menu.test.ts | 30 +++++++++++++++++++ .../format-painter/menu/FormatPainter.ts | 2 +- .../src/init-default-config/config/toolbar.ts | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 packages/basic-modules/__tests__/format-painter/format-painter-menu.test.ts diff --git a/packages/basic-modules/__tests__/format-painter/format-painter-menu.test.ts b/packages/basic-modules/__tests__/format-painter/format-painter-menu.test.ts new file mode 100644 index 000000000..3451e8f16 --- /dev/null +++ b/packages/basic-modules/__tests__/format-painter/format-painter-menu.test.ts @@ -0,0 +1,30 @@ +/** + * @description format painter menu test + * @author CodePencil + */ + +import { Editor } from 'slate' +import FormatPainter from '../../src/modules/format-painter/menu/FormatPainter' +import createEditor from '../../../../tests/utils/create-editor' + +describe('format painter menu', () => { + let editor: any + let startLocation: any + + const menus = [ + { + mark: 'formatPainter', + menu: new FormatPainter(), + }, + ] + + beforeEach(() => { + editor = createEditor() + startLocation = Editor.start(editor, []) + }) + + afterEach(() => { + editor = null + startLocation = null + }) +}) diff --git a/packages/basic-modules/src/modules/format-painter/menu/FormatPainter.ts b/packages/basic-modules/src/modules/format-painter/menu/FormatPainter.ts index 094f33165..9723dd3a1 100644 --- a/packages/basic-modules/src/modules/format-painter/menu/FormatPainter.ts +++ b/packages/basic-modules/src/modules/format-painter/menu/FormatPainter.ts @@ -6,7 +6,7 @@ import { IButtonMenu, IDomEditor, t } from '@wangeditor-next/core' import { SlateEditor } from '@wangeditor-next/editor' import { FORMAT_PAINTER } from '../../../constants/icon-svg' -import { Element, Text } from 'slate' +import { Text } from 'slate' import { clearAllMarks } from '../helper' interface FormatPaintAttributes { diff --git a/packages/editor/src/init-default-config/config/toolbar.ts b/packages/editor/src/init-default-config/config/toolbar.ts index 1b3b9e593..bac3479b4 100644 --- a/packages/editor/src/init-default-config/config/toolbar.ts +++ b/packages/editor/src/init-default-config/config/toolbar.ts @@ -14,7 +14,6 @@ import { export function genDefaultToolbarKeys() { return [ - 'formatPainter', 'headerSelect', // 'header1', // 'header2', @@ -83,6 +82,7 @@ export function genDefaultToolbarKeys() { 'undo', 'redo', '|', + 'formatPainter', 'fullScreen', ] }