Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

refactor: remove unused fields from the menu item factory (#3329)

白熱c29fa22e198e
diff --git a/packages-experimental/uni-docs-ui/src/controllers/menu.ts b/packages-experimental/uni-docs-ui/src/controllers/menu.ts
index 951264af37..d16f6a3f31 100644
--- a/packages-experimental/uni-docs-ui/src/controllers/menu.ts
+++ b/packages-experimental/uni-docs-ui/src/controllers/menu.ts
@@ -19,8 +19,7 @@ import { BooleanNumber, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, ICommandService, IUniver
import { DocSkeletonManagerService, SetInlineFormatCommand, SetTextSelectionsOperation, TextSelectionManagerService } from '@univerjs/docs';
import { DocumentEditArea, IRenderManagerService } from '@univerjs/engine-render';
-import { getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, type IMenuButtonItem, type IMenuItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
-import { FONT_GROUP_MENU_ID } from '@univerjs/uniui';
+import { getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, type IMenuButtonItem, type IMenuItem, MenuItemType } from '@univerjs/ui';
import { combineLatest, Observable } from 'rxjs';
export const DOC_ITALIC_MUTATION_ID = 'doc.command.uni-italic';
@@ -38,7 +37,6 @@ export function DocBoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
icon: 'BoldSingle',
title: 'Set bold',
tooltip: 'toolbar.bold',
- positions: [FONT_GROUP_MENU_ID],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -69,12 +67,10 @@ export function DocItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: DOC_ITALIC_MUTATION_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'ItalicSingle',
title: 'Set italic',
tooltip: 'toolbar.italic',
- positions: [FONT_GROUP_MENU_ID],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -105,12 +101,10 @@ export function DocUnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonIte
return {
id: DOC_UNDERLINE_MUTATION_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'UnderlineSingle',
title: 'Set underline',
tooltip: 'toolbar.underline',
- positions: [FONT_GROUP_MENU_ID],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -141,12 +135,10 @@ export function DocStrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButto
return {
id: DOC_STRIKE_MUTATION_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'StrikethroughSingle',
title: 'Set strike through',
tooltip: 'toolbar.strikethrough',
- positions: [FONT_GROUP_MENU_ID],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -176,8 +168,6 @@ export function DocTableMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: DOC_TABLE_MUTATION_ID,
type: MenuItemType.BUTTON,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_LAYOUT,
icon: 'GridSingle',
tooltip: 'toolbar.table.main',
disabled$: getTableDisabledObservable(accessor),
diff --git a/packages-experimental/uni-sheets-ui/src/controllers/menu.ts b/packages-experimental/uni-sheets-ui/src/controllers/menu.ts
index 6ef3b44ae4..0219a12654 100644
--- a/packages-experimental/uni-sheets-ui/src/controllers/menu.ts
+++ b/packages-experimental/uni-sheets-ui/src/controllers/menu.ts
@@ -17,10 +17,18 @@
import type { IAccessor } from '@univerjs/core';
import { BooleanNumber, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, EDITOR_ACTIVATED, FOCUSING_SHEET, FontItalic, FontWeight, ICommandService, IContextService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { SetInlineFormatCommand, SetTextSelectionsOperation, TextSelectionManagerService } from '@univerjs/docs';
-import { RangeProtectionPermissionEditPoint, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetActiveOperation, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';
+import {
+ RangeProtectionPermissionEditPoint,
+ SetRangeValuesMutation,
+ SetSelectionsOperation,
+ SetWorksheetActiveOperation,
+ SheetsSelectionsService,
+ WorkbookEditablePermission,
+ WorksheetEditPermission,
+ WorksheetSetCellStylePermission,
+} from '@univerjs/sheets';
import { deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
-import { getMenuHiddenObservable, type IMenuButtonItem, MenuGroup, MenuItemType } from '@univerjs/ui';
-import { FONT_GROUP_MENU_ID } from '@univerjs/uniui';
+import { getMenuHiddenObservable, type IMenuButtonItem, MenuItemType } from '@univerjs/ui';
import { Observable } from 'rxjs';
export const SHEET_BOLD_MUTATION_ID = 'sheet.command.uni-bold';
@@ -36,12 +44,10 @@ export function SheetBoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SHEET_BOLD_MUTATION_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'BoldSingle',
title: 'Set bold',
tooltip: 'toolbar.bold',
- positions: [FONT_GROUP_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
@@ -100,12 +106,10 @@ export function SheetItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: SHEET_ITALIC_MUTATION_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'ItalicSingle',
title: 'Set italic',
tooltip: 'toolbar.italic',
- positions: [FONT_GROUP_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
@@ -156,12 +160,10 @@ export function SheetUnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonI
return {
id: SHEET_UNDERLINE_MUTATION_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'UnderlineSingle',
title: 'Set underline',
tooltip: 'toolbar.underline',
- positions: [FONT_GROUP_MENU_ID],
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -212,12 +214,10 @@ export function SheetStrikeThroughMenuItemFactory(accessor: IAccessor): IMenuBut
return {
id: SHEET_STRIKE_MUTATION_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'StrikethroughSingle',
title: 'Set strike through',
tooltip: 'toolbar.strikethrough',
- positions: [FONT_GROUP_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
diff --git a/packages-experimental/uniui/src/controllers/menu.ts b/packages-experimental/uniui/src/controllers/menu.ts
index 5713514cc0..b1918de88c 100644
--- a/packages-experimental/uniui/src/controllers/menu.ts
+++ b/packages-experimental/uniui/src/controllers/menu.ts
@@ -15,7 +15,7 @@
*/
import { type IAccessor, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { type IMenuButtonItem, type IMenuItem, type IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { type IMenuButtonItem, type IMenuItem, type IMenuSelectorItem, MenuItemType } from '@univerjs/ui';
import { Observable } from 'rxjs';
import { DisposeUnitOperation } from '../commands/operations/uni.operation';
@@ -49,10 +49,8 @@ export function FakeFontFamilySelectorMenuItemFactory(accessor: IAccessor): IMen
return {
id: FAKE_FONT_FAMILY_MENU_ID,
tooltip: 'toolbar.font',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.SELECTOR,
label: 'UI_PLUGIN_DOCS_FONT_FAMILY_COMPONENT',
- positions: [MenuPosition.TOOLBAR_START],
selections: [],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
};
@@ -61,7 +59,6 @@ export function FakeFontFamilySelectorMenuItemFactory(accessor: IAccessor): IMen
export function FakeFontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<number> {
return {
id: FAKE_FONT_SIZE_MENU_ID,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.SELECTOR,
tooltip: 'toolbar.fontSize',
label: {
@@ -71,7 +68,6 @@ export function FakeFontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuS
max: 400,
},
},
- positions: [MenuPosition.TOOLBAR_START],
selections: [],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
};
@@ -82,10 +78,7 @@ export function FakeTextColorSelectorMenuItemFactory(accessor: IAccessor): IMenu
id: FAKE_FONT_COLOR_MENU_ID,
icon: 'FontColor',
tooltip: 'toolbar.textColor.main',
-
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON_SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
selections: [],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
};
@@ -95,9 +88,7 @@ export function FakeBackgroundColorSelectorMenuItemFactory(accessor: IAccessor):
return {
id: FAKE_BG_COLOR_MENU_ID,
tooltip: 'toolbar.fillColor.main',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON_SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
icon: 'PaintBucket',
selections: [],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
@@ -108,8 +99,6 @@ export function FakeImageMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: FAKE_IMAGE_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
icon: 'addition-and-subtraction-single',
tooltip: 'sheetImage.title',
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
@@ -120,10 +109,8 @@ export function FakeUnorderListMenuItemFactory(accessor: IAccessor): IMenuItem {
return {
id: FAKE_UNORDER_LIST_MENU_ID,
type: MenuItemType.BUTTON_SELECTOR,
- group: MenuGroup.TOOLBAR_LAYOUT,
icon: 'UnorderSingle',
tooltip: 'toolbar.unorder',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
};
}
@@ -132,10 +119,8 @@ export function FakeOrderListMenuItemFactory(accessor: IAccessor): IMenuItem {
return {
id: FAKE_ORDER_LIST_MENU_ID,
type: MenuItemType.BUTTON_SELECTOR,
- group: MenuGroup.TOOLBAR_LAYOUT,
icon: 'OrderSingle',
tooltip: 'toolbar.order',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
};
}
@@ -147,7 +132,6 @@ export function FontGroupMenuItemFactory(accessor: IAccessor): IMenuSelectorItem
type: MenuItemType.SUBITEMS,
tooltip: 'Font group',
icon: 'BoldSingle',
- positions: [MenuPosition.TOOLBAR_START],
hidden$: new Observable((subscriber) => {
const subscription = univerInstanceService.focused$.subscribe((unitId) => {
if (unitId == null) {
@@ -178,7 +162,6 @@ export function FakeFontGroupMenuItemFactory(accessor: IAccessor): IMenuSelector
type: MenuItemType.SUBITEMS,
tooltip: 'Font group',
icon: 'BoldSingle',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
};
}
@@ -187,10 +170,8 @@ export function FakePivotTableMenuItemFactory(accessor: IAccessor): IMenuItem {
return {
id: FAKE_TABLE_MENU_ID,
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_OTHERS,
icon: 'PivotTableSingle',
tooltip: 'PivotTable',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable((subscriber) => { subscriber.next(true); }),
};
}
@@ -201,10 +182,6 @@ export function UnitLineColorMenuItemFactory(accessor: IAccessor): IMenuButtonIt
type: MenuItemType.BUTTON,
title: '',
icon: '',
- positions: [
- UNI_MENU_POSITIONS.TOOLBAR_FLOAT,
- ],
-
};
}
@@ -212,13 +189,9 @@ export function DownloadMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: DOWNLOAD_MENU_ID,
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_OTHERS,
title: '',
tooltip: 'Download',
icon: 'DownloadSingle',
- positions: [
- UNI_MENU_POSITIONS.TOOLBAR_FLOAT,
- ],
};
}
@@ -226,14 +199,9 @@ export function ShareMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SHARE_MENU_ID,
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_OTHERS,
title: '',
tooltip: 'Share',
icon: 'ShareSingle',
- positions: [
- UNI_MENU_POSITIONS.TOOLBAR_FLOAT,
- ],
-
};
}
@@ -241,13 +209,9 @@ export function LockMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: LOCK_MENU_ID,
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_OTHERS,
title: '',
tooltip: 'Lock',
icon: 'LockSingle',
- positions: [
- UNI_MENU_POSITIONS.TOOLBAR_FLOAT,
- ],
};
}
@@ -255,14 +219,9 @@ export function PrintMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: PRINT_MENU_ID,
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_OTHERS,
title: '',
tooltip: 'Print',
icon: 'PrintSingle',
- positions: [
- UNI_MENU_POSITIONS.TOOLBAR_FLOAT,
- ],
-
};
}
@@ -273,10 +232,6 @@ export function ZenMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
title: '',
icon: 'ZenSingle',
tooltip: 'Full screen',
- group: MenuGroup.TOOLBAR_OTHERS,
- positions: [
- UNI_MENU_POSITIONS.TOOLBAR_FLOAT,
- ],
};
}
@@ -287,9 +242,5 @@ export function DeleteMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
title: 'Delete',
tooltip: 'Delete',
icon: 'DeleteSingle',
- group: MenuGroup.TOOLBAR_OTHERS,
- positions: [
- UNI_MENU_POSITIONS.TOOLBAR_FLOAT,
- ],
};
}
diff --git a/packages/debugger/src/controllers/menu.ts b/packages/debugger/src/controllers/menu.ts
index e7788bf568..16dc0523f9 100644
--- a/packages/debugger/src/controllers/menu.ts
+++ b/packages/debugger/src/controllers/menu.ts
@@ -17,7 +17,7 @@
import { LocaleType } from '@univerjs/core';
import { defaultTheme, greenTheme } from '@univerjs/design';
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
-import { MenuItemType, MenuPosition } from '@univerjs/ui';
+import { MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { ConfirmOperation } from '../commands/operations/confirm.operation';
@@ -40,7 +40,6 @@ export function LocaleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
icon: 'VueI18nIcon',
tooltip: 'i18n',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'English',
@@ -72,7 +71,6 @@ export function ThemeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
title: 'Theme',
tooltip: 'Theme',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'green',
@@ -92,7 +90,6 @@ export function NotificationMenuItemFactory(accessor: IAccessor): IMenuSelectorI
title: 'Notification',
tooltip: 'Notification',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'Notification Success',
@@ -120,7 +117,6 @@ export function DialogMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
title: 'Dialog',
tooltip: 'Dialog',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'Open Dialog',
@@ -140,7 +136,6 @@ export function ConfirmMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
title: 'Confirm',
tooltip: 'Confirm',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'Open confirm',
@@ -156,7 +151,6 @@ export function MessageMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
title: 'Message',
tooltip: 'Message',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'Open message',
@@ -172,7 +166,6 @@ export function SidebarMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
title: 'Sidebar',
tooltip: 'Sidebar',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'Open sidebar',
@@ -192,7 +185,6 @@ export function SetEditableMenuItemFactory(accessor: IAccessor): IMenuSelectorIt
title: 'Editable',
tooltip: 'Editable',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'changeUniverEditable',
@@ -211,7 +203,6 @@ export function SaveSnapshotSetEditableMenuItemFactory(accessor: IAccessor): IMe
id: SaveSnapshotOptions.id,
type: MenuItemType.SELECTOR,
title: 'Snapshot',
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'saveWorkbook',
@@ -237,7 +228,6 @@ export function UnitMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
title: 'Dispose',
tooltip: 'Lifecycle Related Commands',
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_OTHERS],
};
}
@@ -248,7 +238,6 @@ export function DisposeUniverItemFactory(_accessor: IAccessor): IMenuButtonItem
tooltip: 'Dispose the Univer instance',
icon: 'DS',
type: MenuItemType.BUTTON,
- positions: [UNIT_ITEM_MENU_ID],
};
}
@@ -259,7 +248,6 @@ export function DisposeCurrentUnitMenuItemFactory(accessor: IAccessor): IMenuBut
tooltip: 'Dispose Current Unit',
icon: 'DS',
type: MenuItemType.BUTTON,
- positions: [UNIT_ITEM_MENU_ID],
};
}
@@ -270,7 +258,6 @@ export function CreateEmptySheetMenuItemFactory(accessor: IAccessor): IMenuButto
tooltip: 'Create Another Sheet',
icon: 'CR',
type: MenuItemType.BUTTON,
- positions: [UNIT_ITEM_MENU_ID],
};
}
@@ -282,7 +269,6 @@ export function FloatDomMenuItemFactory(): IMenuSelectorItem {
title: 'FloatDom',
tooltip: 'Float Dom Commands',
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_OTHERS],
};
}
@@ -293,7 +279,6 @@ export function CreateFloatDOMMenuItemFactory(): IMenuButtonItem {
tooltip: 'Create Float Dom',
icon: 'DS',
type: MenuItemType.BUTTON,
- positions: [FLOAT_DOM_ITEM_MENU_ID],
};
}
@@ -302,7 +287,6 @@ export function ShowCellContentMenuItemFactory(accessor: IAccessor): IMenuButton
id: ShowCellContentOperation.id,
type: MenuItemType.BUTTON,
title: 'Cell',
- positions: [FLOAT_DOM_ITEM_MENU_ID],
icon: 'DS',
};
}
@@ -312,7 +296,6 @@ export function ChangeUserMenuItemFactory(): IMenuSelectorItem {
id: ChangeUserCommand.id,
type: MenuItemType.SELECTOR,
title: 'Change User',
- positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'Owner',
@@ -330,4 +313,3 @@ export function ChangeUserMenuItemFactory(): IMenuSelectorItem {
],
};
}
-
diff --git a/packages/docs-drawing-ui/src/views/menu/image.menu.ts b/packages/docs-drawing-ui/src/views/menu/image.menu.ts
index b60ada9284..5b558ef1f7 100644
--- a/packages/docs-drawing-ui/src/views/menu/image.menu.ts
+++ b/packages/docs-drawing-ui/src/views/menu/image.menu.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { getMenuHiddenObservable, type IMenuItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, type IMenuItem, MenuItemType } from '@univerjs/ui';
import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import type { IAccessor } from '@univerjs/core';
@@ -65,8 +65,6 @@ export function ImageMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: IMAGE_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_LAYOUT,
icon: ImageUploadIcon,
tooltip: 'docImage.title',
disabled$: getDisableWhenSelectionInTableObservable(accessor),
@@ -82,7 +80,6 @@ export function UploadFloatImageMenuFactory(_accessor: IAccessor): IMenuItem {
label: {
name: COMPONENT_DOC_UPLOAD_FILE_MENU,
},
- positions: [IMAGE_MENU_ID],
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_DOC),
};
}
diff --git a/packages/docs-hyper-link-ui/src/controllers/menu.ts b/packages/docs-hyper-link-ui/src/controllers/menu.ts
index aa4cc31551..edbdd96a12 100644
--- a/packages/docs-hyper-link-ui/src/controllers/menu.ts
+++ b/packages/docs-hyper-link-ui/src/controllers/menu.ts
@@ -17,7 +17,7 @@
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
import type { IMenuButtonItem, IShortcutItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, KeyCode, MenuGroup, MenuItemType, MenuPosition, MetaKeys } from '@univerjs/ui';
+import { getMenuHiddenObservable, KeyCode, MenuItemType, MetaKeys } from '@univerjs/ui';
import { debounceTime, Observable } from 'rxjs';
import { TextSelectionManagerService } from '@univerjs/docs';
import { whenDocAndEditorFocused } from '@univerjs/docs-ui';
@@ -28,12 +28,10 @@ export const DOC_LINK_ICON = 'doc-hyper-link-icon';
export function AddHyperLinkMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: ShowDocHyperLinkEditPopupOperation.id,
- group: MenuGroup.CONTEXT_MENU_DATA,
type: MenuItemType.BUTTON,
icon: DOC_LINK_ICON,
title: 'docLink.menu.tooltip',
tooltip: 'docLink.menu.tooltip',
- positions: [MenuPosition.TOOLBAR_START, MenuPosition.CONTEXT_MENU],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
disabled$: new Observable(function (subscribe) {
const textSelectionService = accessor.get(TextSelectionManagerService);
diff --git a/packages/docs-thread-comment-ui/src/controllers/menu.ts b/packages/docs-thread-comment-ui/src/controllers/menu.ts
index 46d9447e65..b5c4aa83c5 100644
--- a/packages/docs-thread-comment-ui/src/controllers/menu.ts
+++ b/packages/docs-thread-comment-ui/src/controllers/menu.ts
@@ -17,7 +17,7 @@
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
import type { IMenuButtonItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import { DocSkeletonManagerService, TextSelectionManagerService } from '@univerjs/docs';
import { DocumentEditArea, IRenderManagerService } from '@univerjs/engine-render';
import { debounceTime, Observable } from 'rxjs';
@@ -45,12 +45,10 @@ export const shouldDisableAddComment = (accessor: IAccessor) => {
export function AddDocCommentMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: StartAddCommentOperation.id,
- group: MenuGroup.CONTEXT_MENU_DATA,
type: MenuItemType.BUTTON,
icon: 'CommentSingle',
title: 'threadCommentUI.panel.addComment',
tooltip: 'threadCommentUI.panel.addComment',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
disabled$: new Observable(function (subscribe) {
const textSelectionService = accessor.get(TextSelectionManagerService);
@@ -68,12 +66,10 @@ export function AddDocCommentMenuItemFactory(accessor: IAccessor): IMenuButtonIt
export function ToolbarDocCommentMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: ToggleCommentPanelOperation.id,
- group: MenuGroup.CONTEXT_MENU_DATA,
type: MenuItemType.BUTTON,
icon: 'CommentSingle',
title: 'threadCommentUI.panel.addComment',
tooltip: 'threadCommentUI.panel.addComment',
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
}
diff --git a/packages/docs-ui/src/controllers/menu/context-menu.ts b/packages/docs-ui/src/controllers/menu/context-menu.ts
index 5e4bd2acbc..3dd323f5b4 100644
--- a/packages/docs-ui/src/controllers/menu/context-menu.ts
+++ b/packages/docs-ui/src/controllers/menu/context-menu.ts
@@ -17,9 +17,19 @@
import type { IAccessor } from '@univerjs/core';
import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import { combineLatest, Observable } from 'rxjs';
-import { DeleteLeftCommand, DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, TextSelectionManagerService } from '@univerjs/docs';
+import {
+ DeleteLeftCommand,
+ DocTableDeleteColumnsCommand,
+ DocTableDeleteRowsCommand,
+ DocTableDeleteTableCommand,
+ DocTableInsertColumnLeftCommand,
+ DocTableInsertColumnRightCommand,
+ DocTableInsertRowAboveCommand,
+ DocTableInsertRowBellowCommand,
+ TextSelectionManagerService,
+} from '@univerjs/docs';
import type { RectRange } from '@univerjs/engine-render';
import { DocCopyCommand, DocCutCommand, DocPasteCommand } from '../../commands/commands/clipboard.command';
import { DocParagraphSettingPanelOperation } from '../../commands/operations/doc-paragraph-setting-panel.operation';
@@ -89,11 +99,9 @@ export const CopyMenuFactory = (accessor: IAccessor): IMenuButtonItem => {
return {
id: DocCopyCommand.name,
commandId: DocCopyCommand.id,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.BUTTON,
icon: 'Copy',
title: 'rightClick.copy',
- positions: [MenuPosition.CONTEXT_MENU],
disabled$: getDisableOnCollapsedObservable(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
@@ -105,7 +113,6 @@ export const ParagraphSettingMenuFactory = (accessor: IAccessor): IMenuButtonIte
type: MenuItemType.BUTTON,
icon: 'MenuSingle24',
title: 'doc.menu.paragraphSetting',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
};
@@ -113,11 +120,9 @@ export const ParagraphSettingMenuFactory = (accessor: IAccessor): IMenuButtonIte
export const CutMenuFactory = (accessor: IAccessor): IMenuButtonItem => {
return {
id: DocCutCommand.id,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.BUTTON,
icon: 'Copy',
title: 'rightClick.cut',
- positions: [MenuPosition.CONTEXT_MENU],
disabled$: getDisableOnCollapsedObservable(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
@@ -126,11 +131,9 @@ export const CutMenuFactory = (accessor: IAccessor): IMenuButtonItem => {
export const PasteMenuFactory = (accessor: IAccessor): IMenuButtonItem => {
return {
id: DocPasteCommand.id,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.BUTTON,
icon: 'PasteSpecial',
title: 'rightClick.paste',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
};
@@ -138,11 +141,9 @@ export const PasteMenuFactory = (accessor: IAccessor): IMenuButtonItem => {
export const DeleteMenuFactory = (accessor: IAccessor): IMenuButtonItem => {
return {
id: DeleteLeftCommand.id,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.BUTTON,
icon: 'PasteSpecial',
title: 'rightClick.delete',
- positions: [MenuPosition.CONTEXT_MENU],
disabled$: getDisableOnCollapsedObservable(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
@@ -152,11 +153,9 @@ export const TABLE_INSERT_MENU_ID = 'doc.menu.table-insert';
export function TableInsertMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: TABLE_INSERT_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'table.insert',
icon: 'Insert',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getDisableWhenSelectionNotInTableObservable(accessor), (one, two) => {
return one || two;
}),
@@ -169,7 +168,6 @@ export function InsertRowBeforeMenuItemFactory(accessor: IAccessor): IMenuButton
type: MenuItemType.BUTTON,
title: 'table.insertRowAbove',
icon: 'InsertRowAbove',
- positions: [TABLE_INSERT_MENU_ID],
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
@@ -179,7 +177,6 @@ export function InsertRowAfterMenuItemFactory(accessor: IAccessor): IMenuButtonI
return {
id: DocTableInsertRowBellowCommand.id,
type: MenuItemType.BUTTON,
- positions: [TABLE_INSERT_MENU_ID],
title: 'table.insertRowBelow',
icon: 'InsertRowBelow',
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
@@ -193,7 +190,6 @@ export function InsertColumnLeftMenuItemFactory(accessor: IAccessor): IMenuButto
type: MenuItemType.BUTTON,
title: 'table.insertColumnLeft',
icon: 'LeftInsertColumn',
- positions: [TABLE_INSERT_MENU_ID],
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
@@ -203,7 +199,6 @@ export function InsertColumnRightMenuItemFactory(accessor: IAccessor): IMenuButt
return {
id: DocTableInsertColumnRightCommand.id,
type: MenuItemType.BUTTON,
- positions: [TABLE_INSERT_MENU_ID],
title: 'table.insertColumnRight',
icon: 'RightInsertColumn',
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
@@ -215,11 +210,9 @@ export const TABLE_DELETE_MENU_ID = 'doc.menu.table-delete';
export function TableDeleteMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: TABLE_DELETE_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'table.delete',
icon: 'Reduce',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getDisableWhenSelectionNotInTableObservable(accessor), (one, two) => {
return one || two;
}),
@@ -232,7 +225,6 @@ export function DeleteRowsMenuItemFactory(accessor: IAccessor): IMenuButtonItem
type: MenuItemType.BUTTON,
title: 'table.deleteRows',
icon: 'DeleteRow',
- positions: [TABLE_DELETE_MENU_ID],
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
};
@@ -242,7 +234,6 @@ export function DeleteColumnsMenuItemFactory(accessor: IAccessor): IMenuButtonIt
return {
id: DocTableDeleteColumnsCommand.id,
type: MenuItemType.BUTTON,
- positions: [TABLE_DELETE_MENU_ID],
title: 'table.deleteColumns',
icon: 'DeleteColumn',
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
@@ -254,7 +245,6 @@ export function DeleteTableMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: DocTableDeleteTableCommand.id,
type: MenuItemType.BUTTON,
- positions: [TABLE_DELETE_MENU_ID],
title: 'table.deleteTable',
icon: 'GridSingle',
disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
diff --git a/packages/docs-ui/src/controllers/menu/menu.ts b/packages/docs-ui/src/controllers/menu/menu.ts
index 6d777e178f..f5def0b0c0 100644
--- a/packages/docs-ui/src/controllers/menu/menu.ts
+++ b/packages/docs-ui/src/controllers/menu/menu.ts
@@ -55,9 +55,7 @@ import {
FONT_SIZE_LIST,
getHeaderFooterMenuHiddenObservable,
getMenuHiddenObservable,
- MenuGroup,
MenuItemType,
- MenuPosition,
} from '@univerjs/ui';
import type { IAccessor, PresetListType } from '@univerjs/core';
import type { Subscription } from 'rxjs';
@@ -209,12 +207,10 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetInlineFormatBoldCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'BoldSingle',
title: 'Set bold',
tooltip: 'toolbar.bold',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -247,12 +243,10 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetInlineFormatItalicCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'ItalicSingle',
title: 'Set italic',
tooltip: 'toolbar.italic',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -285,12 +279,10 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetInlineFormatUnderlineCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'UnderlineSingle',
title: 'Set underline',
tooltip: 'toolbar.underline',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -323,12 +315,10 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonIt
return {
id: SetInlineFormatStrikethroughCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'StrikethroughSingle',
title: 'Set strike through',
tooltip: 'toolbar.strikethrough',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -361,11 +351,9 @@ export function SubscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetInlineFormatSubscriptCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'SubscriptSingle',
tooltip: 'toolbar.subscript',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -398,11 +386,9 @@ export function SuperscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: SetInlineFormatSuperscriptCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'SuperscriptSingle',
tooltip: 'toolbar.superscript',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -436,10 +422,8 @@ export function FontFamilySelectorMenuItemFactory(accessor: IAccessor): IMenuSel
return {
id: SetInlineFormatFontFamilyCommand.id,
tooltip: 'toolbar.font',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.SELECTOR,
label: FONT_FAMILY_COMPONENT,
- positions: [MenuPosition.TOOLBAR_START],
selections: FONT_FAMILY_LIST.map((item) => ({
label: {
name: FONT_FAMILY_ITEM_COMPONENT,
@@ -481,7 +465,6 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
return {
id: SetInlineFormatFontSizeCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.SELECTOR,
tooltip: 'toolbar.fontSize',
label: {
@@ -492,7 +475,6 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
// disabled$,
},
},
- positions: [MenuPosition.TOOLBAR_START],
selections: FONT_SIZE_LIST,
// disabled$,
value$: new Observable((subscriber) => {
@@ -532,9 +514,7 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSele
icon: 'FontColor',
tooltip: 'toolbar.textColor.main',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON_SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
selections: [
{
label: {
@@ -564,11 +544,9 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSele
export function HeaderFooterMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: OpenHeaderFooterPanelCommand.id,
- group: MenuGroup.TOOLBAR_OTHERS,
type: MenuItemType.BUTTON,
icon: 'FreezeRowSingle',
tooltip: 'toolbar.headerFooter',
- positions: [MenuPosition.TOOLBAR_START],
hidden$: combineLatest(getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC), getHeaderFooterMenuHiddenObservable(accessor), (one, two) => {
return one || two;
}),
@@ -582,8 +560,6 @@ export function TableMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: TABLE_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_LAYOUT,
icon: TableIcon,
tooltip: 'toolbar.table.main',
disabled$: getTableDisabledObservable(accessor),
@@ -599,7 +575,6 @@ export function InsertTableMenuFactory(_accessor: IAccessor): IMenuButtonItem {
id: DocCreateTableOperation.id,
title: 'toolbar.table.insert',
type: MenuItemType.BUTTON,
- positions: [TABLE_MENU_ID],
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_DOC),
};
}
@@ -609,11 +584,9 @@ export function AlignLeftMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: AlignLeftCommand.id,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'LeftJustifyingSingle',
tooltip: 'toolbar.alignLeft',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: disableMenuWhenNoDocRange(accessor),
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
@@ -645,11 +618,9 @@ export function AlignCenterMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: AlignCenterCommand.id,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'HorizontallySingle',
tooltip: 'toolbar.alignCenter',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -681,11 +652,9 @@ export function AlignRightMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: AlignRightCommand.id,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'RightJustifyingSingle',
tooltip: 'toolbar.alignRight',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -717,11 +686,9 @@ export function AlignJustifyMenuItemFactory(accessor: IAccessor): IMenuButtonIte
return {
id: AlignJustifyCommand.id,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'AlignTextBothSingle',
tooltip: 'toolbar.alignJustify',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -795,7 +762,6 @@ const listValueFactory$ = (accessor: IAccessor) => {
export function OrderListMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<PresetListType, PresetListType> {
return {
id: OrderListCommand.id,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.BUTTON_SELECTOR,
selections: [
{
@@ -808,7 +774,6 @@ export function OrderListMenuItemFactory(accessor: IAccessor): IMenuSelectorItem
],
icon: 'OrderSingle',
tooltip: 'toolbar.order',
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
disabled$: disableMenuWhenNoDocRange(accessor),
activated$: listValueFactory$(accessor).pipe(map((v) => v && v.indexOf('ORDER_LIST') === 0)),
@@ -818,7 +783,6 @@ export function OrderListMenuItemFactory(accessor: IAccessor): IMenuSelectorItem
export function BulletListMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<PresetListType, PresetListType> {
return {
id: BulletListCommand.id,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.BUTTON_SELECTOR,
selections: [
{
@@ -831,7 +795,6 @@ export function BulletListMenuItemFactory(accessor: IAccessor): IMenuSelectorIte
],
icon: 'UnorderSingle',
tooltip: 'toolbar.unorder',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: disableMenuWhenNoDocRange(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
activated$: listValueFactory$(accessor).pipe(map((v) => v && v.indexOf('BULLET_LIST') === 0)),
@@ -841,11 +804,9 @@ export function BulletListMenuItemFactory(accessor: IAccessor): IMenuSelectorIte
export function CheckListMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: CheckListCommand.id,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'TodoList',
tooltip: 'toolbar.checklist',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: disableMenuWhenNoDocRange(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
activated$: listValueFactory$(accessor).pipe(map((v) => v && v.indexOf('CHECK_LIST') === 0)),
@@ -858,7 +819,6 @@ export function ResetBackgroundColorMenuItemFactory(accessor: IAccessor): IMenuB
type: MenuItemType.BUTTON,
title: 'toolbar.resetColor',
icon: 'NoColor',
- positions: SetInlineFormatTextBackgroundColorCommand.id,
};
}
@@ -869,9 +829,7 @@ export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMe
return {
id: SetInlineFormatTextBackgroundColorCommand.id,
tooltip: 'toolbar.fillColor.main',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON_SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
icon: 'PaintBucket',
selections: [
{
diff --git a/packages/facade/src/apis/facade.ts b/packages/facade/src/apis/facade.ts
index be6f75f6fb..80b7e8e01f 100644
--- a/packages/facade/src/apis/facade.ts
+++ b/packages/facade/src/apis/facade.ts
@@ -36,7 +36,9 @@ import {
RedoCommand,
toDisposable,
UndoCommand,
- Univer, UniverInstanceType, WrapStrategy,
+ Univer,
+ UniverInstanceType,
+ WrapStrategy,
} from '@univerjs/core';
import type { ISocket } from '@univerjs/network';
import { ISocketService, WebSocketService } from '@univerjs/network';
diff --git a/packages/find-replace/src/controllers/find-replace.menu.ts b/packages/find-replace/src/controllers/find-replace.menu.ts
index 584c0cabaa..85df025445 100644
--- a/packages/find-replace/src/controllers/find-replace.menu.ts
+++ b/packages/find-replace/src/controllers/find-replace.menu.ts
@@ -16,7 +16,7 @@
import { EDITOR_ACTIVATED, FOCUSING_SHEET, IContextService, UniverInstanceType } from '@univerjs/core';
import type { IMenuButtonItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { combineLatest, map } from 'rxjs';
@@ -29,9 +29,7 @@ export function FindReplaceMenuItemFactory(accessor: IAccessor): IMenuButtonItem
id: OpenFindDialogOperation.id,
icon: 'SearchIcon',
tooltip: 'find-replace.toolbar',
- group: MenuGroup.TOOLBAR_OTHERS,
type: MenuItemType.BUTTON,
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: combineLatest([
contextService.subscribeContextValue$(EDITOR_ACTIVATED),
diff --git a/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.ts b/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.ts
index dec952750d..d244fb9d41 100644
--- a/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.ts
+++ b/packages/sheets-conditional-formatting-ui/src/menu/manage-rule.ts
@@ -17,7 +17,7 @@
import { merge, Observable } from 'rxjs';
import type { IMenuSelectorItem } from '@univerjs/ui';
import type { IAccessor, Workbook } from '@univerjs/core';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import { checkRangesEditablePermission, RangeProtectionPermissionEditPoint, SetWorksheetActiveOperation, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';
import { debounceTime } from 'rxjs/operators';
@@ -157,8 +157,6 @@ export const FactoryManageConditionalFormattingRule = (accessor: IAccessor): IMe
return {
id: OpenConditionalFormattingOperator.id,
type: MenuItemType.SELECTOR,
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
- positions: [MenuPosition.TOOLBAR_START],
icon: 'Conditions',
tooltip: 'sheet.cf.title',
selections: selections$,
diff --git a/packages/sheets-crosshair-highlight/src/controllers/crosshair.menu.ts b/packages/sheets-crosshair-highlight/src/controllers/crosshair.menu.ts
index 3cd974586a..77f49cdc47 100644
--- a/packages/sheets-crosshair-highlight/src/controllers/crosshair.menu.ts
+++ b/packages/sheets-crosshair-highlight/src/controllers/crosshair.menu.ts
@@ -16,7 +16,6 @@
import { type IAccessor, UniverInstanceType } from '@univerjs/core';
import { getMenuHiddenObservable, type IMenuSelectorItem, MenuItemType } from '@univerjs/ui';
-import { SheetMenuPosition } from '@univerjs/sheets-ui';
import { SheetsCrosshairHighlightService } from '../services/crosshair.service';
import { SetCrosshairHighlightColorOperation, ToggleCrosshairHighlightOperation } from '../commands/operations/operation';
@@ -41,6 +40,5 @@ export function CrosshairHighlightMenuItemFactory(accessor: IAccessor): IMenuSel
selectionsCommandId: SetCrosshairHighlightColorOperation.id,
activated$: crosshairHighlightService.enabled$,
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
- positions: [SheetMenuPosition.SHEET_FOOTER],
};
}
diff --git a/packages/sheets-data-validation/src/controllers/dv.menu.ts b/packages/sheets-data-validation/src/controllers/dv.menu.ts
index 2384e0a8f3..7e1e668d01 100644
--- a/packages/sheets-data-validation/src/controllers/dv.menu.ts
+++ b/packages/sheets-data-validation/src/controllers/dv.menu.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { getMenuHiddenObservable, type IMenuItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, type IMenuItem, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
@@ -29,8 +29,6 @@ export function dataValidationMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: DATA_VALIDATION_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
icon: DataValidationIcon,
tooltip: 'dataValidation.title',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -43,7 +41,6 @@ export function openDataValidationMenuFactory(_accessor: IAccessor): IMenuItem {
id: OpenValidationPanelOperation.id,
title: 'dataValidation.panel.title',
type: MenuItemType.BUTTON,
- positions: [DATA_VALIDATION_MENU_ID],
};
}
@@ -52,6 +49,5 @@ export function addDataValidationMenuFactory(_accessor: IAccessor): IMenuItem {
id: AddSheetDataValidationAndOpenCommand.id,
title: 'dataValidation.panel.add',
type: MenuItemType.BUTTON,
- positions: [DATA_VALIDATION_MENU_ID],
};
}
diff --git a/packages/sheets-drawing-ui/src/views/menu/image.menu.ts b/packages/sheets-drawing-ui/src/views/menu/image.menu.ts
index f246e754fc..521e287223 100644
--- a/packages/sheets-drawing-ui/src/views/menu/image.menu.ts
+++ b/packages/sheets-drawing-ui/src/views/menu/image.menu.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { getMenuHiddenObservable, type IMenuItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, type IMenuItem, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
@@ -29,8 +29,6 @@ export function ImageMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: IMAGE_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
icon: IMAGE_UPLOAD_ICON,
tooltip: 'sheetImage.title',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -49,7 +47,6 @@ export function UploadFloatImageMenuFactory(_accessor: IAccessor): IMenuItem {
type: UploadFileType.floatImage,
},
},
- positions: [IMAGE_MENU_ID],
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -65,7 +62,6 @@ export function UploadCellImageMenuFactory(_accessor: IAccessor): IMenuItem {
type: UploadFileType.cellImage,
},
},
- positions: [IMAGE_MENU_ID],
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SHEET),
};
}
diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter.menu.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter.menu.ts
index 5f9a2345a8..fc3fd1d8eb 100644
--- a/packages/sheets-filter-ui/src/controllers/sheets-filter.menu.ts
+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter.menu.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { SheetsFilterService } from '@univerjs/sheets-filter';
@@ -30,11 +30,9 @@ export function SmartToggleFilterMenuItemFactory(accessor: IAccessor): IMenuSele
return {
id: SmartToggleSheetsFilterCommand.id,
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
type: MenuItemType.BUTTON_SELECTOR,
icon: 'FilterSingle',
tooltip: 'sheets-filter.toolbar.smart-toggle-filter-tooltip',
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
activated$: sheetsFilterService.activeFilterModel$.pipe(map((model) => !!model)),
disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission], rangeTypes: [RangeProtectionPermissionViewPoint] })),
@@ -46,10 +44,8 @@ export function ClearFilterCriteriaMenuItemFactory(accessor: IAccessor): IMenuBu
return {
id: ClearSheetsFilterCriteriaCommand.id,
- group: MenuGroup.TOOLBAR_OTHERS,
type: MenuItemType.BUTTON,
title: 'sheets-filter.toolbar.clear-filter-criteria',
- positions: [SmartToggleSheetsFilterCommand.id],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: sheetsFilterService.activeFilterModel$.pipe(switchMap((model) => model?.hasCriteria$.pipe(map((m) => !m)) ?? of(true))),
};
@@ -60,10 +56,8 @@ export function ReCalcFilterMenuItemFactory(accessor: IAccessor): IMenuButtonIte
return {
id: ReCalcSheetsFilterCommand.id,
- group: MenuGroup.TOOLBAR_OTHERS,
type: MenuItemType.BUTTON,
title: 'sheets-filter.toolbar.re-calc-filter-conditions',
- positions: [SmartToggleSheetsFilterCommand.id],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: sheetsFilterService.activeFilterModel$.pipe(switchMap((model) => model?.hasCriteria$.pipe(map((m) => !m)) ?? of(true))),
};
diff --git a/packages/sheets-formula/src/controllers/menu.ts b/packages/sheets-formula/src/controllers/menu.ts
index df86e35a24..acc9c614db 100644
--- a/packages/sheets-formula/src/controllers/menu.ts
+++ b/packages/sheets-formula/src/controllers/menu.ts
@@ -16,9 +16,9 @@
import type { IAccessor, Workbook } from '@univerjs/core';
import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { getCurrentRangeDisable$, PASTE_SPECIAL_MENU_ID } from '@univerjs/sheets-ui';
+import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import type { IMenuItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, IClipboardInterfaceService, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, IClipboardInterfaceService, MenuItemType } from '@univerjs/ui';
import { combineLatestWith, map, Observable, of, switchMap } from 'rxjs';
import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
@@ -31,9 +31,7 @@ export function InsertFunctionMenuItemFactory(accessor: IAccessor): IMenuItem {
id: InsertFunctionOperation.id,
icon: 'FunctionSingle',
tooltip: 'formula.insert.tooltip',
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
selections: [
{
label: 'SUM',
@@ -70,7 +68,6 @@ export function MoreFunctionsMenuItemFactory(accessor: IAccessor): IMenuItem {
return {
id: MoreFunctionsOperation.id,
title: 'formula.insert.more',
- positions: InsertFunctionOperation.id,
type: MenuItemType.BUTTON,
};
}
@@ -97,7 +94,6 @@ export function PasteFormulaMenuItemFactory(accessor: IAccessor): IMenuItem {
id: SheetOnlyPasteFormulaCommand.id,
type: MenuItemType.BUTTON,
title: 'formula.operation.pasteFormula',
- positions: [PASTE_SPECIAL_MENU_ID],
disabled$: menuClipboardDisabledObservable(accessor).pipe(
combineLatestWith(getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], rangeTypes: [RangeProtectionPermissionEditPoint], worksheetTypes: [WorksheetSetCellValuePermission, WorksheetEditPermission] })),
map(([d1, d2]) => d1 || d2)
diff --git a/packages/sheets-hyper-link-ui/src/controllers/menu.ts b/packages/sheets-hyper-link-ui/src/controllers/menu.ts
index 71159897d1..4b414a7acd 100644
--- a/packages/sheets-hyper-link-ui/src/controllers/menu.ts
+++ b/packages/sheets-hyper-link-ui/src/controllers/menu.ts
@@ -16,7 +16,7 @@
import { UniverInstanceType } from '@univerjs/core';
import type { IMenuItem, IShortcutItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, KeyCode, MenuGroup, MenuItemType, MenuPosition, MetaKeys } from '@univerjs/ui';
+import { getMenuHiddenObservable, KeyCode, MenuItemType, MetaKeys } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { getCurrentRangeDisable$, getObservableWithExclusiveRange$, whenSheetEditorFocused } from '@univerjs/sheets-ui';
import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetInsertHyperlinkPermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
@@ -26,7 +26,6 @@ export const insertLinkMenuFactory = (accessor: IAccessor) => {
return {
id: InsertHyperLinkOperation.id,
type: MenuItemType.BUTTON,
- positions: [MenuPosition.CONTEXT_MENU],
title: 'hyperLink.menu.add',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
icon: 'LinkSingle',
@@ -37,8 +36,6 @@ export const insertLinkMenuFactory = (accessor: IAccessor) => {
export const insertLinkMenuToolbarFactory = (accessor: IAccessor) => {
return {
tooltip: 'hyperLink.form.addTitle',
- positions: MenuPosition.TOOLBAR_START,
- group: MenuGroup.TOOLBAR_OTHERS,
id: InsertHyperLinkToolbarOperation.id,
type: MenuItemType.BUTTON,
icon: 'LinkSingle',
diff --git a/packages/sheets-numfmt/src/menu/menu.ts b/packages/sheets-numfmt/src/menu/menu.ts
index 2dd0563c94..85b62ffcfd 100644
--- a/packages/sheets-numfmt/src/menu/menu.ts
+++ b/packages/sheets-numfmt/src/menu/menu.ts
@@ -25,7 +25,7 @@ import {
WorksheetSetCellStylePermission,
} from '@univerjs/sheets';
import type { IMenuSelectorItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { merge, Observable } from 'rxjs';
import { deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
@@ -65,8 +65,6 @@ export const CurrencyMenuItem = (accessor: IAccessor) => {
title: 'sheet.numfmt.currency',
tooltip: 'sheet.numfmt.currency',
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -80,8 +78,6 @@ export const AddDecimalMenuItem = (accessor: IAccessor) => {
title: 'sheet.numfmt.addDecimal',
tooltip: 'sheet.numfmt.addDecimal',
type: MenuItemType.BUTTON,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
@@ -94,8 +90,6 @@ export const SubtractDecimalMenuItem = (accessor: IAccessor) => {
title: 'sheet.numfmt.subtractDecimal',
tooltip: 'sheet.numfmt.subtractDecimal',
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
@@ -108,8 +102,6 @@ export const PercentMenuItem = (accessor: IAccessor) => {
title: 'sheet.numfmt.percent',
tooltip: 'sheet.numfmt.percent',
type: MenuItemType.BUTTON,
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -167,8 +159,6 @@ export const FactoryOtherMenuItem = (accessor: IAccessor): IMenuSelectorItem =>
id: OpenNumfmtPanelOperator.id,
tooltip: 'sheet.numfmt.title',
type: MenuItemType.SELECTOR,
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
- positions: [MenuPosition.TOOLBAR_START],
selections: [
{
label: {
diff --git a/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts b/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts
index 9253b574a0..f31b820e7c 100644
--- a/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts
+++ b/packages/sheets-sort-ui/src/controllers/sheets-sort.menu.ts
@@ -15,9 +15,9 @@
*/
import { UniverInstanceType } from '@univerjs/core';
-import { getMenuHiddenObservable, type IMenuItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, type IMenuItem, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
-import { getCurrentRangeDisable$, SheetMenuPosition } from '@univerjs/sheets-ui';
+import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSortPermission } from '@univerjs/sheets';
import { SortRangeAscCommand, SortRangeAscExtCommand, SortRangeAscExtInCtxMenuCommand, SortRangeAscInCtxMenuCommand, SortRangeCustomCommand, SortRangeCustomInCtxMenuCommand, SortRangeDescCommand, SortRangeDescExtCommand, SortRangeDescExtInCtxMenuCommand, SortRangeDescInCtxMenuCommand } from '../commands/commands/sheets-sort.command';
@@ -34,8 +34,6 @@ export function sortRangeMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: SHEETS_SORT_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
icon: SHEETS_SORT_ASC_ICON,
tooltip: 'sheets-sort.general.sort',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -49,7 +47,6 @@ export function sortRangeAscMenuFactory(_accessor: IAccessor): IMenuItem {
icon: SHEETS_SORT_ASC_ICON,
title: 'sheets-sort.general.sort-asc-cur',
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_MENU_ID],
};
}
@@ -59,7 +56,6 @@ export function sortRangeAscExtMenuFactory(_accessor: IAccessor): IMenuItem {
title: 'sheets-sort.general.sort-asc-ext',
icon: SHEETS_SORT_ASC_EXT_ICON,
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_MENU_ID],
};
}
@@ -69,7 +65,6 @@ export function sortRangeDescMenuFactory(_accessor: IAccessor): IMenuItem {
title: 'sheets-sort.general.sort-desc-cur',
icon: SHEETS_SORT_DESC_ICON,
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_MENU_ID],
};
}
@@ -79,7 +74,6 @@ export function sortRangeDescExtMenuFactory(_accessor: IAccessor): IMenuItem {
title: 'sheets-sort.general.sort-desc-ext',
icon: SHEETS_SORT_DESC_EXT_ICON,
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_MENU_ID],
};
}
@@ -88,7 +82,6 @@ export function sortRangeCustomMenuFactory(_accessor: IAccessor): IMenuItem {
id: SortRangeCustomCommand.id,
title: 'sheets-sort.general.sort-custom',
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_MENU_ID],
icon: SHEETS_SORT_CUSTOM_ICON,
};
}
@@ -98,12 +91,6 @@ export function sortRangeCtxMenuFactory(accessor: IAccessor): IMenuItem {
id: SHEETS_SORT_CTX_MENU_ID,
title: 'sheets-sort.general.sort',
type: MenuItemType.SUBITEMS,
- positions: [
- MenuPosition.CONTEXT_MENU,
- SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
- SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,
- ],
- group: MenuGroup.CONTEXT_MENU_DATA,
icon: SHEETS_SORT_ASC_ICON,
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: getCurrentRangeDisable$(accessor, {
@@ -120,7 +107,6 @@ export function sortRangeAscCtxMenuFactory(_accessor: IAccessor): IMenuItem {
title: 'sheets-sort.general.sort-asc-cur',
type: MenuItemType.BUTTON,
icon: SHEETS_SORT_ASC_ICON,
- positions: [SHEETS_SORT_CTX_MENU_ID],
disabled$: getCurrentRangeDisable$(_accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSortPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
}
@@ -131,7 +117,6 @@ export function sortRangeAscExtCtxMenuFactory(_accessor: IAccessor): IMenuItem {
title: 'sheets-sort.general.sort-asc-ext',
type: MenuItemType.BUTTON,
icon: SHEETS_SORT_ASC_EXT_ICON,
- positions: [SHEETS_SORT_CTX_MENU_ID],
disabled$: getCurrentRangeDisable$(_accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSortPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
}
@@ -141,7 +126,6 @@ export function sortRangeDescCtxMenuFactory(_accessor: IAccessor): IMenuItem {
id: SortRangeDescInCtxMenuCommand.id,
title: 'sheets-sort.general.sort-desc-cur',
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_CTX_MENU_ID],
icon: SHEETS_SORT_DESC_ICON,
disabled$: getCurrentRangeDisable$(_accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSortPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
@@ -152,7 +136,6 @@ export function sortRangeDescExtCtxMenuFactory(_accessor: IAccessor): IMenuItem
id: SortRangeDescExtInCtxMenuCommand.id,
title: 'sheets-sort.general.sort-desc-ext',
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_CTX_MENU_ID],
icon: SHEETS_SORT_DESC_EXT_ICON,
disabled$: getCurrentRangeDisable$(_accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSortPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
@@ -163,7 +146,6 @@ export function sortRangeCustomCtxMenuFactory(_accessor: IAccessor): IMenuItem {
id: SortRangeCustomInCtxMenuCommand.id,
title: 'sheets-sort.general.sort-custom',
type: MenuItemType.BUTTON,
- positions: [SHEETS_SORT_CTX_MENU_ID],
icon: SHEETS_SORT_CUSTOM_ICON,
disabled$: getCurrentRangeDisable$(_accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSortPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
diff --git a/packages/sheets-thread-comment/src/controllers/menu.ts b/packages/sheets-thread-comment/src/controllers/menu.ts
index 3cc9417875..119004067e 100644
--- a/packages/sheets-thread-comment/src/controllers/menu.ts
+++ b/packages/sheets-thread-comment/src/controllers/menu.ts
@@ -15,7 +15,7 @@
*/
import type { IMenuItem, IShortcutItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, KeyCode, MenuGroup, MenuItemType, MenuPosition, MetaKeys } from '@univerjs/ui';
+import { getMenuHiddenObservable, KeyCode, MenuItemType, MetaKeys } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { ToggleSheetCommentPanelOperation } from '@univerjs/thread-comment-ui';
import { UniverInstanceType } from '@univerjs/core';
@@ -28,7 +28,6 @@ export const threadCommentMenuFactory = (accessor: IAccessor) => {
return {
id: ShowAddSheetCommentModalOperation.id,
type: MenuItemType.BUTTON,
- positions: [MenuPosition.CONTEXT_MENU],
icon: COMMENT_SINGLE_ICON,
title: 'sheetThreadComment.menu.addComment',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -46,8 +45,6 @@ export const threadPanelMenuFactory = (accessor: IAccessor) => {
type: MenuItemType.BUTTON,
icon: COMMENT_SINGLE_ICON,
tooltip: 'sheetThreadComment.menu.commentManagement',
- positions: MenuPosition.TOOLBAR_START,
- group: MenuGroup.TOOLBAR_OTHERS,
disabled$: getCurrentRangeDisable$(accessor, {
workbookTypes: [WorkbookCommentPermission],
worksheetTypes: [WorksheetViewPermission],
diff --git a/packages/sheets-ui/src/controllers/menu/border.menu.ts b/packages/sheets-ui/src/controllers/menu/border.menu.ts
index 700c8ac1ea..63720a5d06 100644
--- a/packages/sheets-ui/src/controllers/menu/border.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/border.menu.ts
@@ -18,7 +18,7 @@ import { ICommandService, UniverInstanceType } from '@univerjs/core';
import type { IBorderInfo } from '@univerjs/sheets';
import { BorderStyleManagerService, RangeProtectionPermissionEditPoint, SetBorderBasicCommand, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';
import type { IMenuSelectorItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { Observable } from 'rxjs';
@@ -57,9 +57,7 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSel
return disposable.dispose;
}),
- group: MenuGroup.TOOLBAR_FORMAT,
tooltip: 'toolbar.border.main',
- positions: [MenuPosition.TOOLBAR_START],
type: MenuItemType.BUTTON_SELECTOR,
selections: [
{
diff --git a/packages/sheets-ui/src/controllers/menu/clear.menu.ts b/packages/sheets-ui/src/controllers/menu/clear.menu.ts
index 81533f7a70..6b289ffdf4 100644
--- a/packages/sheets-ui/src/controllers/menu/clear.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/clear.menu.ts
@@ -16,26 +16,19 @@
import { ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
-import { SheetMenuPosition } from './menu';
import { getCurrentRangeDisable$, getObservableWithExclusiveRange$ } from './menu-util';
export const CLEAR_SELECTION_MENU_ID = 'sheet.menu.clear-selection';
export function ClearSelectionMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: CLEAR_SELECTION_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.SUBITEMS,
icon: 'ClearFormat',
title: 'rightClick.clearSelection',
- positions: [
- MenuPosition.CONTEXT_MENU,
- SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
- SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,
- ],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -45,7 +38,6 @@ export function ClearSelectionContentMenuItemFactory(accessor: IAccessor): IMenu
id: ClearSelectionContentCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.clearContent',
- positions: [CLEAR_SELECTION_MENU_ID],
disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
@@ -55,7 +47,6 @@ export function ClearSelectionFormatMenuItemFactory(accessor: IAccessor): IMenuB
id: ClearSelectionFormatCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.clearFormat',
- positions: [CLEAR_SELECTION_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
@@ -65,7 +56,6 @@ export function ClearSelectionAllMenuItemFactory(accessor: IAccessor): IMenuButt
id: ClearSelectionAllCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.clearAll',
- positions: [CLEAR_SELECTION_MENU_ID],
disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
diff --git a/packages/sheets-ui/src/controllers/menu/delete.menu.ts b/packages/sheets-ui/src/controllers/menu/delete.menu.ts
index 2f22d5a365..bbb3689386 100644
--- a/packages/sheets-ui/src/controllers/menu/delete.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/delete.menu.ts
@@ -15,7 +15,7 @@
*/
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
-import { MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetDeleteColumnPermission, WorksheetDeleteRowPermission, WorksheetEditPermission } from '@univerjs/sheets';
@@ -25,18 +25,15 @@ import {
RemoveColConfirmCommand,
RemoveRowConfirmCommand,
} from '../../commands/commands/remove-row-col-confirm.command';
-import { SheetMenuPosition } from './menu';
import { getBaseRangeMenuHidden$, getCellMenuHidden$, getCurrentRangeDisable$, getDeleteMenuHidden$, getObservableWithExclusiveRange$ } from './menu-util';
export const DELETE_RANGE_MENU_ID = 'sheet.menu.delete';
export function DeleteRangeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: DELETE_RANGE_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'rightClick.delete',
icon: 'Reduce',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: getObservableWithExclusiveRange$(accessor, getBaseRangeMenuHidden$(accessor)),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission] }),
};
@@ -45,10 +42,8 @@ export function DeleteRangeMenuItemFactory(accessor: IAccessor): IMenuSelectorIt
export function RemoveColMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: RemoveColConfirmCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'DeleteColumn',
- positions: [DELETE_RANGE_MENU_ID, SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
title: 'rightClick.deleteSelectedColumn',
hidden$: getDeleteMenuHidden$(accessor, 'col'),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetDeleteColumnPermission] }),
@@ -58,10 +53,8 @@ export function RemoveColMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
export function RemoveRowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: RemoveRowConfirmCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'DeleteRow',
- positions: [DELETE_RANGE_MENU_ID, SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
title: 'rightClick.deleteSelectedRow',
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetDeleteRowPermission] }),
hidden$: getDeleteMenuHidden$(accessor, 'row'),
@@ -71,11 +64,9 @@ export function RemoveRowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
export function DeleteRangeMoveLeftMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: DeleteRangeMoveLeftConfirmCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
title: 'rightClick.moveLeft',
icon: 'DeleteCellShiftLeft',
- positions: [DELETE_RANGE_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
hidden$: getCellMenuHidden$(accessor, 'col'),
};
@@ -84,11 +75,9 @@ export function DeleteRangeMoveLeftMenuItemFactory(accessor: IAccessor): IMenuBu
export function DeleteRangeMoveUpMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: DeleteRangeMoveUpConfirmCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
title: 'rightClick.moveUp',
icon: 'DeleteCellShiftUp',
- positions: [DELETE_RANGE_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
hidden$: getCellMenuHidden$(accessor, 'row'),
};
diff --git a/packages/sheets-ui/src/controllers/menu/insert.menu.ts b/packages/sheets-ui/src/controllers/menu/insert.menu.ts
index 3cf3fdbff2..a547854a49 100644
--- a/packages/sheets-ui/src/controllers/menu/insert.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/insert.menu.ts
@@ -26,23 +26,20 @@ import {
WorksheetInsertRowPermission,
} from '@univerjs/sheets';
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
-import { MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { InsertRangeMoveDownConfirmCommand } from '../../commands/commands/insert-range-move-down-confirm.command';
import { InsertRangeMoveRightConfirmCommand } from '../../commands/commands/insert-range-move-right-confirm.command';
-import { SheetMenuPosition } from './menu';
import { getBaseRangeMenuHidden$, getCellMenuHidden$, getCurrentRangeDisable$, getInsertAfterMenuHidden$, getInsertBeforeMenuHidden$, getObservableWithExclusiveRange$ } from './menu-util';
export const COL_INSERT_MENU_ID = 'sheet.menu.col-insert';
export function ColInsertMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: COL_INSERT_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'rightClick.insert',
icon: 'Insert',
- positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
hidden$: getBaseRangeMenuHidden$(accessor),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetInsertColumnPermission] }),
};
@@ -52,11 +49,9 @@ export const ROW_INSERT_MENU_ID = 'sheet.menu.row-insert';
export function RowInsertMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: ROW_INSERT_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'rightClick.insert',
icon: 'Insert',
- positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
hidden$: getBaseRangeMenuHidden$(accessor),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
@@ -66,11 +61,9 @@ export const CELL_INSERT_MENU_ID = 'sheet.menu.cell-insert';
export function CellInsertMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: CELL_INSERT_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'rightClick.insert',
icon: 'Insert',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: getObservableWithExclusiveRange$(accessor, getBaseRangeMenuHidden$(accessor)),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
@@ -82,7 +75,6 @@ export function InsertRowBeforeMenuItemFactory(accessor: IAccessor): IMenuButton
type: MenuItemType.BUTTON,
title: 'rightClick.insertRowBefore',
icon: 'InsertRowAbove',
- positions: [ROW_INSERT_MENU_ID, CELL_INSERT_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
hidden$: getInsertBeforeMenuHidden$(accessor, 'row'),
};
@@ -92,7 +84,6 @@ export function InsertRowAfterMenuItemFactory(accessor: IAccessor): IMenuButtonI
return {
id: InsertRowAfterCommand.id,
type: MenuItemType.BUTTON,
- positions: [ROW_INSERT_MENU_ID],
title: 'rightClick.insertRow',
icon: 'InsertRowBelow',
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -104,13 +95,10 @@ export function InsertColBeforeMenuItemFactory(accessor: IAccessor): IMenuButton
return {
id: InsertColBeforeCommand.id,
type: MenuItemType.BUTTON,
- positions: [COL_INSERT_MENU_ID, CELL_INSERT_MENU_ID],
title: 'rightClick.insertColumnBefore',
icon: 'LeftInsertColumn',
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
-
hidden$: getInsertBeforeMenuHidden$(accessor, 'col'),
-
};
}
@@ -118,11 +106,9 @@ export function InsertColAfterMenuItemFactory(accessor: IAccessor): IMenuButtonI
return {
id: InsertColAfterCommand.id,
type: MenuItemType.BUTTON,
- positions: [COL_INSERT_MENU_ID],
title: 'rightClick.insertColumn',
icon: 'RightInsertColumn',
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
-
hidden$: getInsertAfterMenuHidden$(accessor, 'col'),
};
}
@@ -133,7 +119,6 @@ export function InsertRangeMoveRightMenuItemFactory(accessor: IAccessor): IMenuB
type: MenuItemType.BUTTON,
title: 'rightClick.moveRight',
icon: 'InsertCellShiftRight',
- positions: [CELL_INSERT_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
hidden$: getCellMenuHidden$(accessor, 'col'),
};
@@ -145,9 +130,7 @@ export function InsertRangeMoveDownMenuItemFactory(accessor: IAccessor): IMenuBu
type: MenuItemType.BUTTON,
title: 'rightClick.moveDown',
icon: 'InsertCellDown',
- positions: [CELL_INSERT_MENU_ID],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
-
hidden$: getCellMenuHidden$(accessor, 'row'),
};
}
diff --git a/packages/sheets-ui/src/controllers/menu/menu.ts b/packages/sheets-ui/src/controllers/menu/menu.ts
index c19b0abacd..f0a15f7fb5 100644
--- a/packages/sheets-ui/src/controllers/menu/menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/menu.ts
@@ -75,9 +75,7 @@ import {
FONT_SIZE_LIST,
getMenuHiddenObservable,
IClipboardInterfaceService,
- MenuGroup,
MenuItemType,
- MenuPosition,
} from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { combineLatestWith, map, Observable } from 'rxjs';
@@ -131,12 +129,10 @@ export function FormatPainterMenuItemFactory(accessor: IAccessor): IMenuButtonIt
return {
id: SetOnceFormatPainterCommand.id,
subId: SetInfiniteFormatPainterCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'BrushSingle',
title: 'Format Painter',
tooltip: 'toolbar.formatPainter',
- positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
let active = false;
@@ -164,12 +160,10 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetRangeBoldCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'BoldSingle',
title: 'Set bold',
tooltip: 'toolbar.bold',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
@@ -228,12 +222,10 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetRangeItalicCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'ItalicSingle',
title: 'Set italic',
tooltip: 'toolbar.italic',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
@@ -284,12 +276,10 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetRangeUnderlineCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'UnderlineSingle',
title: 'Set underline',
tooltip: 'toolbar.underline',
- positions: [MenuPosition.TOOLBAR_START],
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
const id = c.id;
@@ -340,12 +330,10 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonIt
return {
id: SetRangeStrickThroughCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON,
icon: 'StrikethroughSingle',
title: 'Set strike through',
tooltip: 'toolbar.strikethrough',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
activated$: deriveStateFromActiveSheet$(univerInstanceService, false, ({ worksheet }) => new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
@@ -402,10 +390,8 @@ export function FontFamilySelectorMenuItemFactory(accessor: IAccessor): IMenuSel
return {
id: SetRangeFontFamilyCommand.id,
tooltip: 'toolbar.font',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.SELECTOR,
label: FONT_FAMILY_COMPONENT,
- positions: [MenuPosition.TOOLBAR_START],
selections: FONT_FAMILY_LIST.map((item) => ({
label: {
name: FONT_FAMILY_ITEM_COMPONENT,
@@ -457,7 +443,6 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
return {
id: SetRangeFontSizeCommand.id,
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.SELECTOR,
tooltip: 'toolbar.fontSize',
label: {
@@ -468,7 +453,6 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
disabled$,
},
},
- positions: [MenuPosition.TOOLBAR_START],
selections: FONT_SIZE_LIST,
disabled$,
value$: deriveStateFromActiveSheet$(univerInstanceService, defaultValue, ({ worksheet }) => new Observable((subscriber) => {
@@ -520,7 +504,6 @@ export function ResetTextColorMenuItemFactory(accessor: IAccessor): IMenuButtonI
type: MenuItemType.BUTTON,
title: 'toolbar.resetColor',
icon: 'NoColor',
- positions: SetRangeTextColorCommand.id,
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
@@ -535,9 +518,7 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSele
icon: 'FontColor',
tooltip: 'toolbar.textColor.main',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON_SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
selections: [
{
label: {
@@ -569,7 +550,6 @@ export function ResetBackgroundColorMenuItemFactory(accessor: IAccessor): IMenuB
type: MenuItemType.BUTTON,
title: 'toolbar.resetColor',
icon: 'NoColor',
- positions: SetBackgroundColorCommand.id,
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
}
@@ -581,9 +561,7 @@ export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMe
return {
id: SetBackgroundColorCommand.id,
tooltip: 'toolbar.fillColor.main',
- group: MenuGroup.TOOLBAR_FORMAT,
type: MenuItemType.BUTTON_SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
icon: 'PaintBucket',
selections: [
{
@@ -637,9 +615,7 @@ export function HorizontalAlignMenuItemFactory(accessor: IAccessor): IMenuSelect
return {
id: SetHorizontalTextAlignCommand.id,
icon: HORIZONTAL_ALIGN_CHILDREN[0].icon,
- positions: [MenuPosition.TOOLBAR_START],
tooltip: 'toolbar.horizontalAlignMode.main',
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.SELECTOR,
selections: HORIZONTAL_ALIGN_CHILDREN,
value$: deriveStateFromActiveSheet$(univerInstanceService, defaultValue, ({ worksheet }) => new Observable<HorizontalAlign>((subscriber) => {
@@ -703,9 +679,7 @@ export function VerticalAlignMenuItemFactory(accessor: IAccessor): IMenuSelector
id: SetVerticalTextAlignCommand.id,
icon: VERTICAL_ALIGN_CHILDREN[2].icon,
tooltip: 'toolbar.verticalAlignMode.main',
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
selections: VERTICAL_ALIGN_CHILDREN,
value$: deriveStateFromActiveSheet$(univerInstanceService, defaultValue, ({ worksheet }) => new Observable<VerticalAlign>((subscriber) => {
const disposable = accessor.get(ICommandService).onCommandExecuted((c) => {
@@ -768,9 +742,7 @@ export function WrapTextMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<
id: SetTextWrapCommand.id,
tooltip: 'toolbar.textWrapMode.main',
icon: TEXT_WRAP_CHILDREN[0].icon,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR_START],
selections: TEXT_WRAP_CHILDREN,
value$: deriveStateFromActiveSheet$<WrapStrategy>(univerInstanceService, defaultValue, ({ worksheet }) => new Observable((subscriber) => {
const disposable = accessor.get(ICommandService).onCommandExecuted((c) => {
@@ -848,10 +820,8 @@ export function TextRotateMenuItemFactory(accessor: IAccessor): IMenuSelectorIte
id: SetTextRotationCommand.id,
tooltip: 'toolbar.textRotateMode.main',
icon: TEXT_ROTATE_CHILDREN[0].icon,
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.SELECTOR,
selections: TEXT_ROTATE_CHILDREN,
- positions: [MenuPosition.TOOLBAR_START],
value$: deriveStateFromActiveSheet$(univerInstanceService, defaultValue, ({ worksheet }) => new Observable<number | string>((subscriber) => {
const disposable = accessor.get(ICommandService).onCommandExecuted((c) => {
const id = c.id;
@@ -905,15 +875,9 @@ export function CopyMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SheetCopyCommand.name,
commandId: SheetCopyCommand.id,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.BUTTON,
title: 'rightClick.copy',
icon: 'Copy',
- positions: [
- MenuPosition.CONTEXT_MENU,
- SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
- SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,
- ],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookCopyPermission], worksheetTypes: [WorksheetCopyPermission], rangeTypes: [RangeProtectionPermissionViewPoint] }),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
@@ -923,14 +887,8 @@ export function CutMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SheetCutCommand.name,
commandId: CutCommand.id,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.BUTTON,
title: 'contextMenu.cut',
- positions: [
- MenuPosition.CONTEXT_MENU,
- SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
- SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,
- ],
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], rangeTypes: [RangeProtectionPermissionEditPoint], worksheetTypes: [WorksheetCopyPermission, WorksheetEditPermission] }),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
@@ -940,7 +898,6 @@ export function PasteMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SheetPasteCommand.name,
commandId: SheetPasteCommand.id,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.BUTTON,
title: 'rightClick.paste',
icon: 'PasteSpecial',
@@ -948,11 +905,6 @@ export function PasteMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
combineLatestWith(getCurrentRangeDisable$(accessor, { rangeTypes: [RangeProtectionPermissionEditPoint], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission], workbookTypes: [WorkbookEditablePermission] })),
map(([d1, d2]) => d1 || d2)
),
- positions: [
- MenuPosition.CONTEXT_MENU,
- SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
- SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,
- ],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -961,15 +913,9 @@ export const PASTE_SPECIAL_MENU_ID = 'sheet.menu.paste-special';
export function PasteSpacialMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
return {
id: PASTE_SPECIAL_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_FORMAT,
type: MenuItemType.SUBITEMS,
icon: 'PasteSpecial',
title: 'rightClick.pasteSpecial',
- positions: [
- MenuPosition.CONTEXT_MENU,
- SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
- SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,
- ],
hidden$: getObservableWithExclusiveRange$(accessor, getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)),
};
}
@@ -979,7 +925,6 @@ export function PasteValueMenuItemFactory(accessor: IAccessor): IMenuButtonItem<
id: SheetPasteValueCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.pasteValue',
- positions: [PASTE_SPECIAL_MENU_ID],
disabled$: menuClipboardDisabledObservable(accessor).pipe(
combineLatestWith(getCurrentRangeDisable$(accessor, { rangeTypes: [RangeProtectionPermissionEditPoint], worksheetTypes: [WorksheetSetCellValuePermission, WorksheetEditPermission], workbookTypes: [WorkbookEditablePermission] })),
map(([d1, d2]) => d1 || d2)
@@ -993,7 +938,6 @@ export function PasteFormatMenuItemFactory(accessor: IAccessor): IMenuButtonItem
id: SheetPasteFormatCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.pasteFormat',
- positions: [PASTE_SPECIAL_MENU_ID],
disabled$: menuClipboardDisabledObservable(accessor).pipe(
combineLatestWith(getCurrentRangeDisable$(accessor, { rangeTypes: [RangeProtectionPermissionEditPoint], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], workbookTypes: [WorkbookEditablePermission] })),
map(([d1, d2]) => d1 || d2)
@@ -1007,7 +951,6 @@ export function PasteColWidthMenuItemFactory(accessor: IAccessor): IMenuButtonIt
id: SheetPasteColWidthCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.pasteColWidth',
- positions: [PASTE_SPECIAL_MENU_ID],
disabled$: menuClipboardDisabledObservable(accessor).pipe(
combineLatestWith(getCurrentRangeDisable$(accessor, { rangeTypes: [RangeProtectionPermissionEditPoint], worksheetTypes: [WorksheetSetColumnStylePermission, WorksheetEditPermission], workbookTypes: [WorkbookEditablePermission] })),
map(([d1, d2]) => d1 || d2)
@@ -1020,7 +963,6 @@ export function PasteBesidesBorderMenuItemFactory(accessor: IAccessor): IMenuBut
id: SheetPasteBesidesBorderCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.pasteBesidesBorder',
- positions: [PASTE_SPECIAL_MENU_ID],
disabled$: menuClipboardDisabledObservable(accessor).pipe(
combineLatestWith(getCurrentRangeDisable$(accessor, { rangeTypes: [RangeProtectionPermissionEditPoint], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetRowStylePermission, WorksheetSetColumnStylePermission], workbookTypes: [WorkbookEditablePermission] })),
map(([d1, d2]) => d1 || d2)
@@ -1032,9 +974,7 @@ export function PasteBesidesBorderMenuItemFactory(accessor: IAccessor): IMenuBut
export function FitContentMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetWorksheetRowIsAutoHeightCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
icon: 'AutoHeight',
title: 'rightClick.fitContent',
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetRowStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -1047,11 +987,9 @@ export const SHEET_FROZEN_MENU_ID = 'sheet.menu.sheet-frozen';
export function SheetFrozenMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: SHEET_FROZEN_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'rightClick.freeze',
icon: 'FreezeToSelectedSingle',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -1061,11 +999,9 @@ export const SHEET_FROZEN_HEADER_MENU_ID = 'sheet.header-menu.sheet-frozen';
export function SheetFrozenHeaderMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: SHEET_FROZEN_HEADER_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'rightClick.freeze',
icon: 'FreezeToSelectedSingle',
- positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU, SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -1074,7 +1010,6 @@ export function FrozenMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetSelectionFrozenCommand.id,
type: MenuItemType.BUTTON,
- positions: [SHEET_FROZEN_MENU_ID, SHEET_FROZEN_HEADER_MENU_ID],
title: 'rightClick.freeze',
icon: 'FreezeToSelectedSingle',
// disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -1086,7 +1021,6 @@ export function FrozenRowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetRowFrozenCommand.id,
type: MenuItemType.BUTTON,
- positions: [SHEET_FROZEN_MENU_ID],
title: 'rightClick.freezeRow',
icon: 'FreezeRowSingle',
// disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -1098,7 +1032,6 @@ export function FrozenColMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetColumnFrozenCommand.id,
type: MenuItemType.BUTTON,
- positions: [SHEET_FROZEN_MENU_ID],
title: 'rightClick.freezeCol',
icon: 'FreezeColumnSingle',
// disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -1110,7 +1043,6 @@ export function CancelFrozenMenuItemFactory(accessor: IAccessor): IMenuButtonIte
return {
id: CancelFrozenCommand.id,
type: MenuItemType.BUTTON,
- positions: [SHEET_FROZEN_MENU_ID, SHEET_FROZEN_HEADER_MENU_ID],
title: 'rightClick.cancelFreeze',
icon: 'CancelFreezeSingle',
// disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -1121,9 +1053,7 @@ export function CancelFrozenMenuItemFactory(accessor: IAccessor): IMenuButtonIte
export function HideRowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: HideRowConfirmCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
icon: 'Hide',
title: 'rightClick.hideSelectedRow',
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetRowStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -1134,9 +1064,7 @@ export function HideRowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
export function HideColMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: HideColConfirmCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
icon: 'Hide',
title: 'rightClick.hideSelectedColumn',
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetColumnStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
@@ -1154,9 +1082,7 @@ export function ShowRowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetSelectedRowsVisibleCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
title: 'rightClick.showHideRow',
hidden$: deriveStateFromActiveSheet$(univerInstanceService, true, ({ worksheet }) => new Observable((subscriber) => {
function hasHiddenRowsInSelections(): boolean {
@@ -1190,9 +1116,7 @@ export function ShowColMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetSelectedColsVisibleCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
title: 'rightClick.showHideColumn',
hidden$: deriveStateFromActiveSheet$(univerInstanceService, true, ({ worksheet }) => new Observable((subscriber) => {
function hasHiddenColsInSelections(): boolean {
@@ -1228,10 +1152,8 @@ export function SetRowHeightMenuItemFactory(accessor: IAccessor): IMenuButtonIte
return {
id: SetRowHeightCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'AdjustHeight',
- positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
label: {
name: MENU_ITEM_INPUT_COMPONENT,
props: {
@@ -1271,10 +1193,8 @@ export function SetColWidthMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: SetColWidthCommand.id,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'AdjustWidth',
- positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
label: {
name: MENU_ITEM_INPUT_COMPONENT,
props: {
diff --git a/packages/sheets-ui/src/controllers/menu/merge.menu.ts b/packages/sheets-ui/src/controllers/menu/merge.menu.ts
index 320d97ca44..208f619d16 100644
--- a/packages/sheets-ui/src/controllers/menu/merge.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/merge.menu.ts
@@ -17,7 +17,7 @@
import { UniverInstanceType } from '@univerjs/core';
import { RangeProtectionPermissionEditPoint, RemoveWorksheetMergeCommand, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { combineLatestWith, map } from 'rxjs';
@@ -38,8 +38,6 @@ export function CellMergeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem
id: AddWorksheetMergeCommand.id,
icon: 'MergeAllSingle',
tooltip: 'toolbar.mergeCell.main',
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_LAYOUT,
type: MenuItemType.SUBITEMS,
// selections: [...MERGE_CHILDREN],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -56,7 +54,6 @@ export function CellMergeAllMenuItemFactory(accessor: IAccessor): IMenuButtonIte
type: MenuItemType.BUTTON,
title: 'merge.all',
icon: 'MergeAllSingle',
- positions: [AddWorksheetMergeCommand.id],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -67,7 +64,6 @@ export function CellMergeVerticalMenuItemFactory(accessor: IAccessor): IMenuButt
type: MenuItemType.BUTTON,
title: 'merge.vertical',
icon: 'VerticalIntegrationSingle',
- positions: [AddWorksheetMergeCommand.id],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -78,7 +74,6 @@ export function CellMergeHorizontalMenuItemFactory(accessor: IAccessor): IMenuBu
type: MenuItemType.BUTTON,
title: 'merge.horizontal',
icon: 'HorizontalMergeSingle',
- positions: [AddWorksheetMergeCommand.id],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -89,7 +84,6 @@ export function CellMergeCancelMenuItemFactory(accessor: IAccessor): IMenuButton
type: MenuItemType.BUTTON,
title: 'merge.cancel',
icon: 'CancelMergeSingle',
- positions: [AddWorksheetMergeCommand.id],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
diff --git a/packages/sheets-ui/src/controllers/menu/permission.menu.ts b/packages/sheets-ui/src/controllers/menu/permission.menu.ts
index 17455a7fae..136f531e0d 100644
--- a/packages/sheets-ui/src/controllers/menu/permission.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/permission.menu.ts
@@ -15,7 +15,7 @@
*/
import type { IMenuButtonItem, IMenuItem, IMenuSelectorItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
@@ -23,7 +23,6 @@ import { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBa
import { permissionLockIconKey, permissionMenuIconKey } from '../../consts/permission';
import { ChangeSheetProtectionFromSheetBarCommand, DeleteWorksheetProtectionFormSheetBarCommand } from '../../commands/commands/worksheet-protection.command';
import { getAddPermissionDisableBase$, getAddPermissionFromSheetBarDisable$, getAddPermissionHidden$, getEditPermissionHidden$, getPermissionDisableBase$, getRemovePermissionDisable$, getRemovePermissionFromSheetBarDisable$, getSetPermissionFromSheetBarDisable$, getViewPermissionDisable$ } from './permission-menu-util';
-import { SheetMenuPosition } from './menu';
export const SHEET_PERMISSION_CONTEXT_MENU_ID = 'sheet.contextMenu.permission';
@@ -31,10 +30,6 @@ export function sheetPermissionToolbarMenuFactory(accessor: IAccessor): IMenuIte
return {
id: AddRangeProtectionFromToolbarCommand.id,
type: MenuItemType.BUTTON,
- positions: [
- MenuPosition.TOOLBAR_START,
- ],
- group: MenuGroup.TOOLBAR_OTHERS,
icon: permissionMenuIconKey,
tooltip: 'permission.toolbarMenu',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -45,11 +40,9 @@ export function sheetPermissionToolbarMenuFactory(accessor: IAccessor): IMenuIte
export function sheetPermissionContextMenuFactory(accessor: IAccessor): IMenuSelectorItem<string> {
return {
id: SHEET_PERMISSION_CONTEXT_MENU_ID,
- group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.SUBITEMS,
title: 'rightClick.protectRange',
icon: permissionLockIconKey,
- positions: [MenuPosition.CONTEXT_MENU, SheetMenuPosition.ROW_HEADER_CONTEXT_MENU, SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
}
@@ -59,7 +52,6 @@ export function sheetPermissionAddProtectContextMenuFactory(accessor: IAccessor)
id: AddRangeProtectionFromContextMenuCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.turnOnProtectRange',
- positions: [SHEET_PERMISSION_CONTEXT_MENU_ID],
hidden$: getAddPermissionHidden$(accessor),
disabled$: getAddPermissionDisableBase$(accessor),
};
@@ -70,7 +62,6 @@ export function sheetPermissionEditProtectContextMenuFactory(accessor: IAccessor
id: SetRangeProtectionFromContextMenuCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.editProtectRange',
- positions: [SHEET_PERMISSION_CONTEXT_MENU_ID],
hidden$: getEditPermissionHidden$(accessor),
disabled$: getPermissionDisableBase$(accessor),
};
@@ -81,7 +72,6 @@ export function sheetPermissionRemoveProtectContextMenuFactory(accessor: IAccess
id: DeleteRangeProtectionFromContextMenuCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.removeProtectRange',
- positions: [SHEET_PERMISSION_CONTEXT_MENU_ID],
disabled$: getRemovePermissionDisable$(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
@@ -92,7 +82,6 @@ export function sheetPermissionViewAllProtectRuleContextMenuFactory(accessor: IA
id: ViewSheetPermissionFromContextMenuCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.viewAllProtectArea',
- positions: [SHEET_PERMISSION_CONTEXT_MENU_ID],
disabled$: getViewPermissionDisable$(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
};
@@ -102,7 +91,6 @@ export function sheetPermissionProtectSheetInSheetBarMenuFactory(accessor: IAcce
return {
id: AddRangeProtectionFromSheetBarCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.addProtectSheet',
disabled$: getAddPermissionFromSheetBarDisable$(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -113,7 +101,6 @@ export function sheetPermissionRemoveProtectionSheetBarMenuFactory(accessor: IAc
return {
id: DeleteWorksheetProtectionFormSheetBarCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.removeProtectSheet',
disabled$: getRemovePermissionFromSheetBarDisable$(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -124,7 +111,6 @@ export function sheetPermissionChangeSheetPermissionSheetBarMenuFactory(accessor
return {
id: ChangeSheetProtectionFromSheetBarCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.changeSheetPermission',
disabled$: getSetPermissionFromSheetBarDisable$(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -135,7 +121,6 @@ export function sheetPermissionViewAllProtectRuleSheetBarMenuFactory(accessor: I
return {
id: ViewSheetPermissionFromSheetBarCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.viewAllProtectArea',
disabled$: getViewPermissionDisable$(accessor),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
diff --git a/packages/sheets-ui/src/controllers/menu/sheet.menu.ts b/packages/sheets-ui/src/controllers/menu/sheet.menu.ts
index e98bad80f0..03be28ad9f 100644
--- a/packages/sheets-ui/src/controllers/menu/sheet.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/sheet.menu.ts
@@ -39,7 +39,6 @@ import { RemoveSheetConfirmCommand } from '../../commands/commands/remove-sheet-
import { ShowMenuListCommand } from '../../commands/commands/unhide.command';
import { RenameSheetOperation } from '../../commands/operations/rename-sheet.operation';
import { COLOR_PICKER_COMPONENT } from '../../components/color-picker';
-import { SheetMenuPosition } from './menu';
import { getWorkbookPermissionDisable$ } from './menu-util';
export function DeleteSheetMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
@@ -67,7 +66,6 @@ export function DeleteSheetMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: RemoveSheetConfirmCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.delete',
disabled$: combineLatest([defaultDisable$, permissionDisable$]).pipe(
map(([defaultDisabled, permissionDisabled]) => {
@@ -82,7 +80,6 @@ export function CopySheetMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: CopySheetCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.copy',
disabled$: getWorkbookPermissionDisable$(accessor, [WorkbookEditablePermission, WorkbookCreateSheetPermission]),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -93,7 +90,6 @@ export function RenameSheetMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: RenameSheetOperation.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.rename',
disabled$: getWorkbookPermissionDisable$(accessor, [WorkbookEditablePermission, WorkbookRenameSheetPermission]),
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -104,7 +100,6 @@ export function ChangeColorSheetMenuItemFactory(accessor: IAccessor): IMenuSelec
return {
id: SetTabColorCommand.id,
title: 'sheetConfig.changeColor',
- positions: [SheetMenuPosition.SHEET_BAR],
type: MenuItemType.SELECTOR,
selections: [
{
@@ -125,7 +120,6 @@ export function HideSheetMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: SetWorksheetHideCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.hide',
disabled$: new Observable<boolean>((subscriber) => {
const disposable = commandService.onCommandExecuted((c) => {
@@ -176,7 +170,6 @@ export function UnHideSheetMenuItemFactory(accessor: IAccessor): IMenuSelectorIt
return {
id: SetWorksheetShowCommand.id,
type: MenuItemType.SELECTOR,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.unhide',
disabled$: defaultDisable$.pipe(
combineLatestWith(getWorkbookPermissionDisable$(accessor, [WorkbookEditablePermission, WorkbookHideSheetPermission])),
@@ -207,7 +200,6 @@ export function ShowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: ShowMenuListCommand.id,
type: MenuItemType.BUTTON,
- positions: [SheetMenuPosition.SHEET_BAR],
title: 'sheetConfig.unhide',
disabled$: new Observable<boolean>((subscriber) => {
function disableFunction() {
diff --git a/packages/sheets-zen-editor/src/views/menu.ts b/packages/sheets-zen-editor/src/views/menu.ts
index aa064ce2ee..655ea35424 100644
--- a/packages/sheets-zen-editor/src/views/menu.ts
+++ b/packages/sheets-zen-editor/src/views/menu.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { type IMenuButtonItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { type IMenuButtonItem, MenuItemType } from '@univerjs/ui';
import { getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import type { IAccessor } from '@univerjs/core';
@@ -24,11 +24,9 @@ import { OpenZenEditorOperation } from '../commands/operations/zen-editor.operat
export function ZenEditorMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: OpenZenEditorOperation.id,
- group: MenuGroup.CONTEXT_MENU_OTHERS,
type: MenuItemType.BUTTON,
title: 'rightClick.zenEditor',
icon: 'AmplifySingle',
- positions: [MenuPosition.CONTEXT_MENU],
hidden$: getCurrentExclusiveRangeInterest$(accessor),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
};
diff --git a/packages/slides-ui/src/controllers/image.menu.ts b/packages/slides-ui/src/controllers/image.menu.ts
index cf51da93ca..7ef0e3539d 100644
--- a/packages/slides-ui/src/controllers/image.menu.ts
+++ b/packages/slides-ui/src/controllers/image.menu.ts
@@ -15,7 +15,7 @@
*/
import type { IMenuItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
import { COMPONENT_UPLOAD_FILE_MENU, UploadFileType } from '../components/upload-component/component-name';
@@ -28,8 +28,6 @@ export function SlideImageMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: IMAGE_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
icon: IMAGE_UPLOAD_ICON,
tooltip: 'slide.image.insert.title',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE),
@@ -48,7 +46,6 @@ export function UploadSlideFloatImageMenuFactory(_accessor: IAccessor): IMenuIte
type: UploadFileType.floatImage,
},
},
- positions: [IMAGE_MENU_ID],
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE),
};
}
diff --git a/packages/slides-ui/src/controllers/shape.menu.ts b/packages/slides-ui/src/controllers/shape.menu.ts
index 751f69b28a..6c7a92c690 100644
--- a/packages/slides-ui/src/controllers/shape.menu.ts
+++ b/packages/slides-ui/src/controllers/shape.menu.ts
@@ -15,7 +15,7 @@
*/
import type { IMenuButtonItem, IMenuItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
import { InsertSlideShapeRectangleCommand } from '../commands/operations/insert-shape.operation';
@@ -27,8 +27,6 @@ export function SlideShapeMenuFactory(accessor: IAccessor): IMenuItem {
return {
id: SHAPE_MENU_ID,
type: MenuItemType.SUBITEMS,
- positions: [MenuPosition.TOOLBAR_START],
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
icon: GRAPH_SINGLE_ICON,
tooltip: 'slide.shape.insert.title',
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE),
@@ -41,7 +39,6 @@ export function UploadSlideFloatShapeMenuFactory(_accessor: IAccessor): IMenuBut
id: InsertSlideShapeRectangleCommand.id,
title: 'slide.shape.insert.rectangle',
type: MenuItemType.BUTTON,
- positions: [SHAPE_MENU_ID],
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE),
};
}
diff --git a/packages/slides-ui/src/controllers/text.menu.ts b/packages/slides-ui/src/controllers/text.menu.ts
index d9c814b1e4..a451ea44c7 100644
--- a/packages/slides-ui/src/controllers/text.menu.ts
+++ b/packages/slides-ui/src/controllers/text.menu.ts
@@ -17,7 +17,7 @@
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
import type { IMenuButtonItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import { SlideAddTextCommand } from '../commands/operations/insert-text.operation';
export const TEXT_ICON_ID = 'text-single';
@@ -25,11 +25,9 @@ export const TEXT_ICON_ID = 'text-single';
export function SlideAddTextMenuItemFactory(_accessor: IAccessor): IMenuButtonItem {
return {
id: SlideAddTextCommand.id,
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
type: MenuItemType.BUTTON,
icon: TEXT_ICON_ID,
tooltip: 'slide.text.insert.title',
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE),
};
}
diff --git a/packages/ui/src/controllers/menus/menus.ts b/packages/ui/src/controllers/menus/menus.ts
index b9412962fd..e14ec92222 100644
--- a/packages/ui/src/controllers/menus/menus.ts
+++ b/packages/ui/src/controllers/menus/menus.ts
@@ -19,19 +19,17 @@ import type { IAccessor } from '@univerjs/core';
import { map } from 'rxjs/operators';
import type { IMenuButtonItem } from '../../services/menu/menu';
-import { MenuGroup, MenuItemType, MenuPosition } from '../../services/menu/menu';
+import { MenuItemType } from '../../services/menu/menu';
export function UndoMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
const undoRedoService = accessor.get(IUndoRedoService);
return {
id: UndoCommand.id,
- group: MenuGroup.TOOLBAR_HISTORY,
type: MenuItemType.BUTTON,
icon: 'UndoSingle',
title: 'Undo',
tooltip: 'toolbar.undo',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: undoRedoService.undoRedoStatus$.pipe(map((v) => v.undos <= 0)),
};
}
@@ -41,12 +39,10 @@ export function RedoMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: RedoCommand.id,
- group: MenuGroup.TOOLBAR_HISTORY,
type: MenuItemType.BUTTON,
icon: 'RedoSingle',
title: 'Redo',
tooltip: 'toolbar.redo',
- positions: [MenuPosition.TOOLBAR_START],
disabled$: undoRedoService.undoRedoStatus$.pipe(map((v) => v.redos <= 0)),
};
}
diff --git a/packages/ui/src/controllers/shortcut-display/menu.ts b/packages/ui/src/controllers/shortcut-display/menu.ts
index 6c731bf1a1..8da1440b71 100644
--- a/packages/ui/src/controllers/shortcut-display/menu.ts
+++ b/packages/ui/src/controllers/shortcut-display/menu.ts
@@ -20,7 +20,7 @@ import type { IAccessor } from '@univerjs/core';
import { ToggleShortcutPanelOperation } from '../../commands/operations/toggle-shortcut-panel.operation';
import { getMenuHiddenObservable } from '../../common/menu-hidden-observable';
import type { IMenuButtonItem } from '../../services/menu/menu';
-import { MenuItemType, MenuPosition } from '../../services/menu/menu';
+import { MenuItemType } from '../../services/menu/menu';
export function ShortcutPanelMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
@@ -29,7 +29,6 @@ export function ShortcutPanelMenuItemFactory(accessor: IAccessor): IMenuButtonIt
tooltip: 'toggle-shortcut-panel',
icon: 'KeyboardSingle',
type: MenuItemType.BUTTON,
- positions: [MenuPosition.TOOLBAR_START],
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
// disabled$: getCurrentSheetDisabled$(accessor),
};
diff --git a/packages/ui/src/services/menu/menu.service.ts b/packages/ui/src/services/menu/menu.service.ts
index b887e00348..3d5c7721e2 100644
--- a/packages/ui/src/services/menu/menu.service.ts
+++ b/packages/ui/src/services/menu/menu.service.ts
@@ -90,7 +90,7 @@ export class MenuService extends Disposable implements IMenuService {
if (Array.isArray(item.positions)) {
item.positions.forEach((menu) => this._appendMenuToPosition(item, menu));
- } else {
+ } else if (item.positions) {
this._appendMenuToPosition(item, item.positions);
}
@@ -150,7 +150,7 @@ export class MenuService extends Disposable implements IMenuService {
menus.splice(index, 1);
}
});
- } else {
+ } else if (item.positions) {
const menus = this._menuByPositions.get(item.positions);
if (!menus) {
return;
@@ -187,7 +187,7 @@ export class MenuService extends Disposable implements IMenuService {
this._menuItemMap.set(item.id, item);
if (Array.isArray(item.positions)) {
item.positions.forEach((menu) => this._updateMenuItems(item, menu));
- } else {
+ } else if (item.positions) {
this._updateMenuItems(item, item.positions);
}
diff --git a/packages/ui/src/services/menu/menu.ts b/packages/ui/src/services/menu/menu.ts
index 5b6b67b110..0044ac28cc 100644
--- a/packages/ui/src/services/menu/menu.ts
+++ b/packages/ui/src/services/menu/menu.ts
@@ -89,7 +89,7 @@ interface IMenuItemBase<V> {
/** In what menu should the item display. */
/** @deprecated positions will be removed in the future. */
- positions: OneOrMany<MenuPosition | string>;
+ positions?: OneOrMany<MenuPosition | string>;
type: MenuItemType;
diff --git a/packages/uniscript/src/controllers/menu.ts b/packages/uniscript/src/controllers/menu.ts
index 766077a7b2..786fbb40e0 100644
--- a/packages/uniscript/src/controllers/menu.ts
+++ b/packages/uniscript/src/controllers/menu.ts
@@ -15,7 +15,7 @@
*/
import type { IMenuButtonItem } from '@univerjs/ui';
-import { getMenuHiddenObservable, MenuItemType, MenuPosition } from '@univerjs/ui';
+import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
@@ -30,7 +30,6 @@ export function UniscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
tooltip: 'script-panel.tooltip.menu-button',
icon: 'CodeSingle',
type: MenuItemType.BUTTON,
- positions: [MenuPosition.TOOLBAR_START],
// FIXME hidden$ and disabled$ are not correctly in doc
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),