From 5f5eed207c0fec2f41c7b969cd0779deca694005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Fri, 8 Jul 2022 17:20:28 +0800 Subject: [PATCH] refactor:internal context menu register --- src/editor/core/contextmenu/ContextMenu.ts | 10 +++++++++- src/editor/index.ts | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/editor/core/contextmenu/ContextMenu.ts b/src/editor/core/contextmenu/ContextMenu.ts index cf8f6bc..d231395 100644 --- a/src/editor/core/contextmenu/ContextMenu.ts +++ b/src/editor/core/contextmenu/ContextMenu.ts @@ -6,6 +6,9 @@ import { Command } from '../command/Command' import { Draw } from '../draw/Draw' import { Position } from '../position/Position' import { RangeManager } from '../range/RangeManager' +import { globalMenus } from './menus/globalMenus' +import { imageMenus } from './menus/imageMenus' +import { tableMenus } from './menus/tableMenus' interface IRenderPayload { contextMenuList: IRegisterContextMenu[]; @@ -31,7 +34,12 @@ export class ContextMenu { this.range = draw.getRange() this.position = draw.getPosition() this.container = draw.getContainer() - this.contextMenuList = [] + // 内部菜单 + this.contextMenuList = [ + ...globalMenus, + ...tableMenus, + ...imageMenus + ] this.contextMenuContainerList = [] this.contextMenuRelationShip = new Map() // 接管菜单权限 diff --git a/src/editor/index.ts b/src/editor/index.ts index 87f7e8f..e5dd7b3 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -9,9 +9,7 @@ import { RowFlex } from './dataset/enum/Row' import { ElementType } from './dataset/enum/Element' import { formatElementList } from './utils/element' import { Register } from './core/register/Register' -import { globalMenus } from './core/contextmenu/menus/globalMenus' import { ContextMenu } from './core/contextmenu/ContextMenu' -import { tableMenus } from './core/contextmenu/menus/tableMenus' import { IContextMenuContext, IRegisterContextMenu } from './interface/contextmenu/ContextMenu' import { EditorComponent, EditorMode, PageMode } from './dataset/enum/Editor' import { EDITOR_COMPONENT } from './dataset/constant/Editor' @@ -25,7 +23,6 @@ import { IControlOption } from './interface/Control' import { ICheckboxOption } from './interface/Checkbox' import { defaultCheckboxOption } from './dataset/constant/Checkbox' import { DeepRequired } from './interface/Common' -import { imageMenus } from './core/contextmenu/menus/imageMenus' export default class Editor { @@ -104,9 +101,6 @@ export default class Editor { this.register = new Register({ contextMenu }) - this.register.contextMenuList(globalMenus) - this.register.contextMenuList(tableMenus) - this.register.contextMenuList(imageMenus) } }