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.

fix(sheet): delete all row,columns alert (#1171)

Dushusirb10f5394667c
diff --git a/packages/core/src/sheets/column-manager.ts b/packages/core/src/sheets/column-manager.ts
index 75e9a3d99b..98ba5419c8 100644
--- a/packages/core/src/sheets/column-manager.ts
+++ b/packages/core/src/sheets/column-manager.ts
@@ -51,7 +51,13 @@ export class ColumnManager {
return col.hd !== BooleanNumber.TRUE;
}
- getHiddenCols(start: number = 0, end: number = getArrayLength(this._columnData) - 1): IRange[] {
+ /**
+ * Get all hidden columns
+ * @param start Start index
+ * @param end End index
+ * @returns Hidden columns range list
+ */
+ getHiddenCols(start: number = 0, end: number = this.getSize() - 1): IRange[] {
const hiddenCols: IRange[] = [];
let inHiddenRange = false;
@@ -87,6 +93,48 @@ export class ColumnManager {
return hiddenCols;
}
+ /**
+ * Get all visible columns
+ * @param start Start index
+ * @param end End index
+ * @returns Visible columns range list
+ */
+ getVisibleCols(start: number = 0, end: number = this.getSize() - 1): IRange[] {
+ const visibleCols: IRange[] = [];
+
+ let inVisibleRange = false;
+ let startColumn = -1;
+
+ for (let i = start; i <= end; i++) {
+ const visible = this.getColVisible(i);
+ if (inVisibleRange && !visible) {
+ inVisibleRange = false;
+ visibleCols.push({
+ rangeType: RANGE_TYPE.COLUMN,
+ startColumn,
+ endColumn: i - 1,
+ startRow: 0,
+ endRow: 0,
+ });
+ } else if (!inVisibleRange && visible) {
+ inVisibleRange = true;
+ startColumn = i;
+ }
+ }
+
+ if (inVisibleRange) {
+ visibleCols.push({
+ startRow: 0,
+ endRow: 0,
+ startColumn,
+ endColumn: end,
+ rangeType: RANGE_TYPE.COLUMN,
+ });
+ }
+
+ return visibleCols;
+ }
+
getColumnDatas(columnPos: number, numColumns: number): IObjectArrayPrimitiveType<Partial<IColumnData>> {
const columnData: IObjectArrayPrimitiveType<Partial<IColumnData>> = {};
let index = 0;
diff --git a/packages/core/src/sheets/row-manager.ts b/packages/core/src/sheets/row-manager.ts
index 00dc1c4537..5b8d46f2c6 100644
--- a/packages/core/src/sheets/row-manager.ts
+++ b/packages/core/src/sheets/row-manager.ts
@@ -101,7 +101,13 @@ export class RowManager {
return create;
}
- getHiddenRows(start: number = 0, end: number = getArrayLength(this._rowData) - 1): IRange[] {
+ /**
+ * Get all hidden rows
+ * @param start Start index
+ * @param end End index
+ * @returns Hidden rows range list
+ */
+ getHiddenRows(start: number = 0, end: number = this.getSize() - 1): IRange[] {
const hiddenRows: IRange[] = [];
let inHiddenRange = false;
@@ -131,6 +137,42 @@ export class RowManager {
return hiddenRows;
}
+ /**
+ * Get all visible rows
+ * @param start Start index
+ * @param end End index
+ * @returns Visible rows range list
+ */
+ getVisibleRows(start: number = 0, end: number = this.getSize() - 1): IRange[] {
+ const visibleRows: IRange[] = [];
+
+ let inVisibleRange = false;
+ let startRow = -1;
+
+ for (let i = start; i <= end; i++) {
+ const visible = this.getRowVisible(i);
+ if (inVisibleRange && !visible) {
+ inVisibleRange = false;
+ visibleRows.push({
+ startRow,
+ endRow: i - 1,
+ startColumn: 0,
+ endColumn: 0,
+ rangeType: RANGE_TYPE.ROW,
+ });
+ } else if (!inVisibleRange && visible) {
+ inVisibleRange = true;
+ startRow = i;
+ }
+ }
+
+ if (inVisibleRange) {
+ visibleRows.push({ startRow, endRow: end, startColumn: 0, endColumn: 0, rangeType: RANGE_TYPE.ROW });
+ }
+
+ return visibleRows;
+ }
+
getRowVisible(rowPos: number): boolean {
const row = this.getRow(rowPos);
if (!row) {
diff --git a/packages/core/src/sheets/worksheet.ts b/packages/core/src/sheets/worksheet.ts
index 3378999758..7e9c0445ae 100644
--- a/packages/core/src/sheets/worksheet.ts
+++ b/packages/core/src/sheets/worksheet.ts
@@ -424,6 +424,24 @@ export class Worksheet {
return ranges;
}
+ /**
+ * Get all visible rows in the sheet.
+ * @returns Visible rows range list
+ */
+ getVisibleRows(): IRange[] {
+ const rowCount = this.getRowCount();
+ return this._rowManager.getVisibleRows(0, rowCount - 1);
+ }
+
+ /**
+ * Get all visible columns in the sheet.
+ * @returns Visible columns range list
+ */
+ getVisibleCols(): IRange[] {
+ const columnCount = this.getColumnCount();
+ return this._columnManager.getVisibleCols(0, columnCount - 1);
+ }
+
/**
* Returns true if this sheet layout is right-to-left. Returns false if the sheet uses the default left-to-right layout.
* @returns true if this sheet layout is right-to-left. Returns false if the sheet uses the default left-to-right layout.
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts
index d9c5510b20..f388041746 100644
--- a/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts
+++ b/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts
@@ -31,7 +31,6 @@ import {
SelectionManagerService,
SetRangeValuesMutation,
} from '@univerjs/sheets';
-import { createCommandTestBed } from '@univerjs/sheets/commands/commands/__tests__/create-command-test-bed.js';
import { type IConfirmPartMethodOptions, IConfirmService } from '@univerjs/ui';
import type { IDisposable, Injector } from '@wendellhu/redi';
import { Subject } from 'rxjs';
@@ -43,8 +42,9 @@ import {
AddWorksheetMergeHorizontalCommand,
AddWorksheetMergeVerticalCommand,
} from '../add-worksheet-merge.command';
+import { createCommandTestBed } from './create-command-test-bed';
-describe('Test style commands', () => {
+describe('Test add worksheet merge commands', () => {
let univer: Univer;
let get: Injector['get'];
let commandService: ICommandService;
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/auto-fill.controller.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/auto-fill.controller.spec.ts
index 081094bb1b..dcd78ee6c7 100644
--- a/packages/sheets-ui/src/commands/commands/__tests__/auto-fill.controller.spec.ts
+++ b/packages/sheets-ui/src/commands/commands/__tests__/auto-fill.controller.spec.ts
@@ -30,7 +30,6 @@ import {
SetRangeValuesMutation,
SetSelectionsOperation,
} from '@univerjs/sheets';
-import { createCommandTestBed } from '@univerjs/sheets/commands/commands/__tests__/create-command-test-bed.js';
import { DesktopPlatformService, DesktopShortcutService, IPlatformService, IShortcutService } from '@univerjs/ui';
import type { Injector } from '@wendellhu/redi';
import { beforeEach, describe, expect, it } from 'vitest';
@@ -42,6 +41,7 @@ import { EditorBridgeService, IEditorBridgeService } from '../../../services/edi
import { ISelectionRenderService, SelectionRenderService } from '../../../services/selection/selection-render.service';
import { SheetSkeletonManagerService } from '../../../services/sheet-skeleton-manager.service';
import { RefillCommand } from '../refill.command';
+import { createCommandTestBed } from './create-command-test-bed';
const theme = {
colorBlack: '#35322b',
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/sheets-ui/src/commands/commands/__tests__/create-command-test-bed.ts
new file mode 100644
index 0000000000..a727e772ac
--- /dev/null
+++ b/packages/sheets-ui/src/commands/commands/__tests__/create-command-test-bed.ts
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IWorkbookData, Workbook } from '@univerjs/core';
+import {
+ BooleanNumber,
+ ILogService,
+ IUniverInstanceService,
+ LocaleService,
+ LocaleType,
+ LogLevel,
+ Plugin,
+ PluginType,
+ Univer,
+} from '@univerjs/core';
+import { BorderStyleManagerService, SelectionManagerService, SheetInterceptorService } from '@univerjs/sheets';
+import type { Dependency } from '@wendellhu/redi';
+import { Inject, Injector } from '@wendellhu/redi';
+
+import enUS from '../../../locale/en-US';
+
+const getTestWorkbookDataDemo = (): IWorkbookData => {
+ return {
+ id: 'test',
+ appVersion: '3.0.0-alpha',
+ sheets: {
+ sheet1: {
+ id: 'sheet1',
+ name: 'sheet1',
+ cellData: {
+ '0': {
+ '0': {
+ v: 'A1',
+ },
+ '1': {
+ v: 'A2',
+ },
+ },
+ },
+ columnData: {
+ 1: {
+ hd: BooleanNumber.FALSE,
+ },
+ },
+ rowData: {
+ 1: {
+ hd: BooleanNumber.FALSE,
+ },
+ },
+ },
+ },
+ locale: LocaleType.ZH_CN,
+ name: '',
+ sheetOrder: [],
+ styles: {},
+ };
+};
+
+export interface ITestBed {
+ univer: Univer;
+ get: Injector['get'];
+ sheet: Workbook;
+}
+
+export function createCommandTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): ITestBed {
+ const univer = new Univer();
+ const injector = univer.__getInjector();
+
+ class TestSpyPlugin extends Plugin {
+ static override type = PluginType.Sheet;
+
+ constructor(
+ _config: undefined,
+ @Inject(Injector) override readonly _injector: Injector
+ ) {
+ super('test-plugin');
+
+ this._injector = _injector;
+ }
+
+ override onStarting(injector: Injector): void {
+ injector.add([SelectionManagerService]);
+ injector.add([BorderStyleManagerService]);
+ injector.add([SheetInterceptorService]);
+
+ dependencies?.forEach((d) => injector.add(d));
+ }
+ }
+
+ univer.registerPlugin(TestSpyPlugin);
+ const sheet = univer.createUniverSheet(workbookConfig || getTestWorkbookDataDemo());
+
+ const univerInstanceService = injector.get(IUniverInstanceService);
+ univerInstanceService.focusUniverInstance('test');
+ const logService = injector.get(ILogService);
+
+ logService.setLogLevel(LogLevel.SILENT); // change this to `LogLevel.VERBOSE` to debug tests via logs
+
+ const localeService = injector.get(LocaleService);
+ localeService.load({ enUS });
+
+ return {
+ univer,
+ get: injector.get.bind(injector),
+ sheet,
+ };
+}
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/hide-row-col-confirm.command.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/hide-row-col-confirm.command.spec.ts
new file mode 100644
index 0000000000..dddc1afa51
--- /dev/null
+++ b/packages/sheets-ui/src/commands/commands/__tests__/hide-row-col-confirm.command.spec.ts
@@ -0,0 +1,229 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IRange, Univer } from '@univerjs/core';
+import { ICommandService, IUniverInstanceService, LocaleService, RANGE_TYPE } from '@univerjs/core';
+import {
+ AddWorksheetMergeMutation,
+ NORMAL_SELECTION_PLUGIN_NAME,
+ RemoveWorksheetMergeCommand,
+ RemoveWorksheetMergeMutation,
+ SelectionManagerService,
+ SetColHiddenCommand,
+ SetColHiddenMutation,
+ SetRangeValuesMutation,
+ SetRowHiddenCommand,
+ SetRowHiddenMutation,
+} from '@univerjs/sheets';
+import { type IConfirmPartMethodOptions, IConfirmService } from '@univerjs/ui';
+import type { IDisposable, Injector } from '@wendellhu/redi';
+import { Subject } from 'rxjs';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import {
+ AddWorksheetMergeAllCommand,
+ AddWorksheetMergeCommand,
+ AddWorksheetMergeHorizontalCommand,
+ AddWorksheetMergeVerticalCommand,
+} from '../add-worksheet-merge.command';
+import { HideColConfirmCommand, HideRowConfirmCommand } from '../hide-row-col-confirm.command';
+import { createCommandTestBed } from './create-command-test-bed';
+
+describe('Test hide row col confirm commands', () => {
+ let univer: Univer;
+ let get: Injector['get'];
+ let commandService: ICommandService;
+
+ beforeEach(() => {
+ const testBed = createCommandTestBed(undefined, [
+ [
+ IConfirmService,
+ {
+ useClass: class MockConfirmService implements IConfirmService {
+ confirmOptions$: Subject<IConfirmPartMethodOptions[]> = new Subject();
+
+ open(params: IConfirmPartMethodOptions): IDisposable {
+ throw new Error('Method not implemented.');
+ }
+
+ confirm(params: IConfirmPartMethodOptions): Promise<boolean> {
+ return Promise.resolve(true);
+ }
+
+ close(id: string): void {
+ throw new Error('Method not implemented.');
+ }
+ },
+ },
+ ],
+ ]);
+ univer = testBed.univer;
+
+ get = testBed.get;
+
+ commandService = get(ICommandService);
+ commandService.registerCommand(SetRangeValuesMutation);
+ commandService.registerCommand(AddWorksheetMergeCommand);
+ commandService.registerCommand(AddWorksheetMergeAllCommand);
+ commandService.registerCommand(AddWorksheetMergeVerticalCommand);
+ commandService.registerCommand(AddWorksheetMergeHorizontalCommand);
+ commandService.registerCommand(RemoveWorksheetMergeCommand);
+ commandService.registerCommand(AddWorksheetMergeMutation);
+ commandService.registerCommand(RemoveWorksheetMergeMutation);
+ commandService.registerCommand(HideColConfirmCommand);
+ commandService.registerCommand(HideRowConfirmCommand);
+ commandService.registerCommand(SetRowHiddenCommand);
+ commandService.registerCommand(SetRowHiddenMutation);
+ commandService.registerCommand(SetColHiddenCommand);
+ commandService.registerCommand(SetColHiddenMutation);
+
+ get(LocaleService).load({});
+ });
+
+ afterEach(() => {
+ univer.dispose();
+ });
+
+ describe('Hide row', () => {
+ it('Will apply when select some rows', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: 1, startColumn: NaN, endRow: 1, endColumn: NaN, rangeType: RANGE_TYPE.ROW },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getHiddenRows(): IRange[] | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getRowManager()
+ .getHiddenRows();
+ }
+
+ expect(getHiddenRows()).toStrictEqual([]);
+ expect(await commandService.executeCommand(HideRowConfirmCommand.id)).toBeTruthy();
+ expect(getHiddenRows()).toStrictEqual([
+ {
+ endColumn: 0,
+ endRow: 1,
+ rangeType: RANGE_TYPE.ROW,
+ startColumn: 0,
+ startRow: 1,
+ },
+ ]);
+ });
+
+ it('Will not apply when select all rows', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: 0, startColumn: NaN, endRow: 999, endColumn: NaN, rangeType: RANGE_TYPE.ROW },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getHiddenRows(): IRange[] | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getRowManager()
+ .getHiddenRows();
+ }
+
+ expect(getHiddenRows()).toStrictEqual([]);
+ expect(await commandService.executeCommand(HideRowConfirmCommand.id)).toBeFalsy();
+ });
+ });
+
+ describe('Hide col', () => {
+ it('Will apply when select some cols', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: NaN, startColumn: 1, endRow: NaN, endColumn: 1, rangeType: RANGE_TYPE.COLUMN },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getHiddenCols(): IRange[] | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getColumnManager()
+ .getHiddenCols();
+ }
+
+ expect(getHiddenCols()).toStrictEqual([]);
+ expect(await commandService.executeCommand(HideColConfirmCommand.id)).toBeTruthy();
+ expect(getHiddenCols()).toStrictEqual([
+ {
+ endColumn: 1,
+ endRow: 0,
+ rangeType: RANGE_TYPE.COLUMN,
+ startColumn: 1,
+ startRow: 0,
+ },
+ ]);
+ });
+
+ it('Will not apply when select all cols', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: NaN, startColumn: 0, endRow: NaN, endColumn: 19, rangeType: RANGE_TYPE.COLUMN },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getHiddenCols(): IRange[] | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getColumnManager()
+ .getHiddenCols();
+ }
+
+ expect(getHiddenCols()).toStrictEqual([]);
+ expect(await commandService.executeCommand(HideColConfirmCommand.id)).toBeFalsy();
+ });
+ });
+});
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/remove-row-col-confirm.command.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/remove-row-col-confirm.command.spec.ts
new file mode 100644
index 0000000000..d38a6bba46
--- /dev/null
+++ b/packages/sheets-ui/src/commands/commands/__tests__/remove-row-col-confirm.command.spec.ts
@@ -0,0 +1,213 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Univer } from '@univerjs/core';
+import { ICommandService, IUniverInstanceService, LocaleService, RANGE_TYPE } from '@univerjs/core';
+import {
+ AddWorksheetMergeMutation,
+ DeleteRangeMutation,
+ NORMAL_SELECTION_PLUGIN_NAME,
+ RemoveColCommand,
+ RemoveColMutation,
+ RemoveRowCommand,
+ RemoveRowMutation,
+ RemoveWorksheetMergeCommand,
+ RemoveWorksheetMergeMutation,
+ SelectionManagerService,
+ SetRangeValuesMutation,
+} from '@univerjs/sheets';
+import { type IConfirmPartMethodOptions, IConfirmService } from '@univerjs/ui';
+import type { IDisposable, Injector } from '@wendellhu/redi';
+import { Subject } from 'rxjs';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import {
+ AddWorksheetMergeAllCommand,
+ AddWorksheetMergeCommand,
+ AddWorksheetMergeHorizontalCommand,
+ AddWorksheetMergeVerticalCommand,
+} from '../add-worksheet-merge.command';
+import { RemoveColConfirmCommand, RemoveRowConfirmCommand } from '../remove-row-col-confirm.command';
+import { createCommandTestBed } from './create-command-test-bed';
+
+describe('Test remove row col confirm commands', () => {
+ let univer: Univer;
+ let get: Injector['get'];
+ let commandService: ICommandService;
+
+ beforeEach(() => {
+ const testBed = createCommandTestBed(undefined, [
+ [
+ IConfirmService,
+ {
+ useClass: class MockConfirmService implements IConfirmService {
+ confirmOptions$: Subject<IConfirmPartMethodOptions[]> = new Subject();
+
+ open(params: IConfirmPartMethodOptions): IDisposable {
+ throw new Error('Method not implemented.');
+ }
+
+ confirm(params: IConfirmPartMethodOptions): Promise<boolean> {
+ return Promise.resolve(true);
+ }
+
+ close(id: string): void {
+ throw new Error('Method not implemented.');
+ }
+ },
+ },
+ ],
+ ]);
+ univer = testBed.univer;
+
+ get = testBed.get;
+
+ commandService = get(ICommandService);
+ commandService.registerCommand(SetRangeValuesMutation);
+ commandService.registerCommand(AddWorksheetMergeCommand);
+ commandService.registerCommand(AddWorksheetMergeAllCommand);
+ commandService.registerCommand(AddWorksheetMergeVerticalCommand);
+ commandService.registerCommand(AddWorksheetMergeHorizontalCommand);
+ commandService.registerCommand(RemoveWorksheetMergeCommand);
+ commandService.registerCommand(AddWorksheetMergeMutation);
+ commandService.registerCommand(RemoveWorksheetMergeMutation);
+ commandService.registerCommand(RemoveRowConfirmCommand);
+ commandService.registerCommand(RemoveRowCommand);
+ commandService.registerCommand(RemoveRowMutation);
+ commandService.registerCommand(DeleteRangeMutation);
+ commandService.registerCommand(RemoveColConfirmCommand);
+ commandService.registerCommand(RemoveColCommand);
+ commandService.registerCommand(RemoveColMutation);
+
+ get(LocaleService).load({});
+ });
+
+ afterEach(() => {
+ univer.dispose();
+ });
+
+ describe('Remove row', () => {
+ it('Will apply when select some rows', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: 1, startColumn: NaN, endRow: 1, endColumn: NaN, rangeType: RANGE_TYPE.ROW },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getRowCount(): number | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getRowCount();
+ }
+
+ expect(getRowCount()).toBe(1000);
+ expect(await commandService.executeCommand(RemoveRowConfirmCommand.id)).toBeTruthy();
+ expect(getRowCount()).toBe(999);
+ });
+
+ it('Will not apply when select all rows', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: 0, startColumn: NaN, endRow: 999, endColumn: NaN, rangeType: RANGE_TYPE.ROW },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getRowCount(): number | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getRowCount();
+ }
+
+ expect(getRowCount()).toBe(1000);
+ expect(await commandService.executeCommand(RemoveRowConfirmCommand.id)).toBeFalsy();
+ expect(getRowCount()).toBe(1000);
+ });
+ });
+
+ describe('Remove col', () => {
+ it('Will apply when select some cols', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: NaN, startColumn: 1, endRow: NaN, endColumn: 1, rangeType: RANGE_TYPE.COLUMN },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getColumnCount(): number | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getColumnCount();
+ }
+
+ expect(getColumnCount()).toBe(20);
+ expect(await commandService.executeCommand(RemoveColConfirmCommand.id)).toBeTruthy();
+ expect(getColumnCount()).toBe(19);
+ });
+
+ it('Will not apply when select all cols', async () => {
+ const selectionManager = get(SelectionManagerService);
+ selectionManager.setCurrentSelection({
+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,
+ unitId: 'test',
+ sheetId: 'sheet1',
+ });
+ selectionManager.add([
+ {
+ range: { startRow: NaN, startColumn: 0, endRow: NaN, endColumn: 19, rangeType: RANGE_TYPE.COLUMN },
+ primary: null,
+ style: null,
+ },
+ ]);
+
+ function getColumnCount(): number | undefined {
+ return get(IUniverInstanceService)
+ .getUniverSheetInstance('test')
+ ?.getSheetBySheetId('sheet1')
+ ?.getColumnCount();
+ }
+
+ expect(getColumnCount()).toBe(20);
+ expect(await commandService.executeCommand(RemoveColConfirmCommand.id)).toBeFalsy();
+ expect(getColumnCount()).toBe(20);
+ });
+ });
+});
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/selection-utils.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/selection-utils.spec.ts
new file mode 100644
index 0000000000..6963b3d6ce
--- /dev/null
+++ b/packages/sheets-ui/src/commands/commands/__tests__/selection-utils.spec.ts
@@ -0,0 +1,109 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { isAllColumnsCovered, isAllRowsCovered } from '../utils/selection-utils';
+
+describe('Test selection utils', () => {
+ it('Function isAllRowsCovered', () => {
+ // single range
+ expect(
+ isAllRowsCovered(
+ [{ startRow: 0, endRow: 999, startColumn: NaN, endColumn: NaN }],
+ [{ startRow: 0, endRow: 1, startColumn: NaN, endColumn: NaN }]
+ )
+ ).toBeFalsy();
+
+ expect(
+ isAllRowsCovered(
+ [{ startRow: 0, endRow: 999, startColumn: NaN, endColumn: NaN }],
+ [{ startRow: 0, endRow: 999, startColumn: NaN, endColumn: NaN }]
+ )
+ ).toBeTruthy();
+
+ // multiple range
+ expect(
+ isAllRowsCovered(
+ [
+ { startRow: 0, endRow: 999, startColumn: NaN, endColumn: NaN },
+ { startRow: 1000, endRow: 1999, startColumn: NaN, endColumn: NaN },
+ ],
+ [
+ { startRow: 100, endRow: 999, startColumn: NaN, endColumn: NaN },
+ { startRow: 1000, endRow: 1500, startColumn: NaN, endColumn: NaN },
+ ]
+ )
+ ).toBeFalsy();
+
+ expect(
+ isAllRowsCovered(
+ [
+ { startRow: 0, endRow: 999, startColumn: NaN, endColumn: NaN },
+ { startRow: 1000, endRow: 1999, startColumn: NaN, endColumn: NaN },
+ ],
+ [
+ { startRow: 0, endRow: 1500, startColumn: NaN, endColumn: NaN },
+ { startRow: 1000, endRow: 1999, startColumn: NaN, endColumn: NaN },
+ ]
+ )
+ ).toBeTruthy();
+ });
+
+ it('Function isAllColumnsCovered', () => {
+ // single range
+ expect(
+ isAllColumnsCovered(
+ [{ startRow: NaN, endRow: NaN, startColumn: 0, endColumn: 999 }],
+ [{ startRow: NaN, endRow: NaN, startColumn: 0, endColumn: 1 }]
+ )
+ ).toBeFalsy();
+
+ expect(
+ isAllColumnsCovered(
+ [{ startRow: NaN, endRow: NaN, startColumn: 0, endColumn: 999 }],
+ [{ startRow: NaN, endRow: NaN, startColumn: 0, endColumn: 999 }]
+ )
+ ).toBeTruthy();
+
+ // multiple range
+ expect(
+ isAllColumnsCovered(
+ [
+ { startRow: NaN, endRow: NaN, startColumn: 0, endColumn: 999 },
+ { startRow: NaN, endRow: NaN, startColumn: 1000, endColumn: 1999 },
+ ],
+ [
+ { startRow: NaN, endRow: NaN, startColumn: 100, endColumn: 999 },
+ { startRow: NaN, endRow: NaN, startColumn: 1000, endColumn: 1500 },
+ ]
+ )
+ ).toBeFalsy();
+
+ expect(
+ isAllColumnsCovered(
+ [
+ { startRow: NaN, endRow: NaN, startColumn: 0, endColumn: 999 },
+ { startRow: NaN, endRow: NaN, startColumn: 1000, endColumn: 1999 },
+ ],
+ [
+ { startRow: NaN, endRow: NaN, startColumn: 0, endColumn: 1500 },
+ { startRow: NaN, endRow: NaN, startColumn: 1000, endColumn: 1999 },
+ ]
+ )
+ ).toBeTruthy();
+ });
+});
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.ts
index d66bdbedd8..0e80be853e 100644
--- a/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.ts
+++ b/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.ts
@@ -35,7 +35,6 @@ import {
SetRangeValuesMutation,
SetSelectionsOperation,
} from '@univerjs/sheets';
-import { createCommandTestBed } from '@univerjs/sheets/commands/commands/__tests__/create-command-test-bed.js';
import type { Injector } from '@wendellhu/redi';
import { BehaviorSubject } from 'rxjs';
import { beforeEach, describe, expect, it } from 'vitest';
@@ -49,6 +48,7 @@ import {
SetInfiniteFormatPainterCommand,
SetOnceFormatPainterCommand,
} from '../set-format-painter.command';
+import { createCommandTestBed } from './create-command-test-bed';
const theme = {
colorBlack: '#35322b',
diff --git a/packages/sheets-ui/src/commands/commands/hide-row-col-confirm.command.ts b/packages/sheets-ui/src/commands/commands/hide-row-col-confirm.command.ts
new file mode 100644
index 0000000000..d077d0c4c8
--- /dev/null
+++ b/packages/sheets-ui/src/commands/commands/hide-row-col-confirm.command.ts
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { ICommand } from '@univerjs/core';
+import { CommandType, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
+import { SelectionManagerService, SetColHiddenCommand, SetRowHiddenCommand } from '@univerjs/sheets';
+import { IConfirmService } from '@univerjs/ui';
+import type { IAccessor } from '@wendellhu/redi';
+
+import { isAllColumnsCovered, isAllRowsCovered } from './utils/selection-utils';
+
+export const HideRowConfirmCommand: ICommand = {
+ id: 'sheet.command.hide-row-confirm',
+ type: CommandType.COMMAND,
+ handler: async (accessor: IAccessor) => {
+ const selectionManagerService = accessor.get(SelectionManagerService);
+
+ const ranges = selectionManagerService.getSelections()?.map((s) => s.range);
+ if (!ranges?.length) {
+ return false;
+ }
+
+ const commandService = accessor.get(ICommandService);
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const workbook = univerInstanceService.getCurrentUniverSheetInstance();
+ const worksheet = workbook.getActiveSheet();
+ const allRowRanges = worksheet.getVisibleRows();
+
+ if (isAllRowsCovered(allRowRanges, ranges)) {
+ const confirmService = accessor.get(IConfirmService);
+ const localeService = accessor.get(LocaleService);
+
+ await confirmService.confirm({
+ id: 'sheet.confirm.hide-row',
+ title: {
+ title: localeService.t('info.problem'),
+ },
+ children: { title: localeService.t('rightClick.hideAllRowsAlert') },
+ cancelText: localeService.t('button.cancel'),
+ confirmText: localeService.t('button.confirm'),
+ });
+
+ return false;
+ }
+
+ await commandService.executeCommand(SetRowHiddenCommand.id);
+ return true;
+ },
+};
+
+export const HideColConfirmCommand: ICommand = {
+ id: 'sheet.command.hide-col-confirm',
+ type: CommandType.COMMAND,
+ handler: async (accessor: IAccessor) => {
+ const selectionManagerService = accessor.get(SelectionManagerService);
+
+ const ranges = selectionManagerService.getSelections()?.map((s) => s.range);
+ if (!ranges?.length) {
+ return false;
+ }
+
+ const commandService = accessor.get(ICommandService);
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const workbook = univerInstanceService.getCurrentUniverSheetInstance();
+ const worksheet = workbook.getActiveSheet();
+ const allColumnRanges = worksheet.getVisibleCols();
+
+ if (isAllColumnsCovered(allColumnRanges, ranges)) {
+ const confirmService = accessor.get(IConfirmService);
+ const localeService = accessor.get(LocaleService);
+
+ await confirmService.confirm({
+ id: 'sheet.confirm.hide-col',
+ title: {
+ title: localeService.t('info.problem'),
+ },
+ children: { title: localeService.t('rightClick.hideAllColumnsAlert') },
+ cancelText: localeService.t('button.cancel'),
+ confirmText: localeService.t('button.confirm'),
+ });
+
+ return false;
+ }
+
+ await commandService.executeCommand(SetColHiddenCommand.id);
+ return true;
+ },
+};
diff --git a/packages/sheets-ui/src/commands/commands/remove-row-col-confirm.command.ts b/packages/sheets-ui/src/commands/commands/remove-row-col-confirm.command.ts
new file mode 100644
index 0000000000..063b1bd697
--- /dev/null
+++ b/packages/sheets-ui/src/commands/commands/remove-row-col-confirm.command.ts
@@ -0,0 +1,108 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { ICommand } from '@univerjs/core';
+import { CommandType, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
+import type { IRemoveRowColCommandParams } from '@univerjs/sheets';
+import { RemoveColCommand, RemoveRowCommand, SelectionManagerService } from '@univerjs/sheets';
+import { IConfirmService } from '@univerjs/ui';
+import type { IAccessor } from '@wendellhu/redi';
+
+import { isAllColumnsCovered, isAllRowsCovered } from './utils/selection-utils';
+
+export const RemoveRowConfirmCommand: ICommand = {
+ id: 'sheet.command.remove-row-confirm',
+ type: CommandType.COMMAND,
+ handler: async (accessor: IAccessor, params?: IRemoveRowColCommandParams) => {
+ const selectionManagerService = accessor.get(SelectionManagerService);
+
+ let range = params?.range;
+ if (!range) {
+ range = selectionManagerService.getLast()?.range;
+ }
+ if (!range) {
+ return false;
+ }
+
+ const commandService = accessor.get(ICommandService);
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const workbook = univerInstanceService.getCurrentUniverSheetInstance();
+ const worksheet = workbook.getActiveSheet();
+ const allRowRanges = worksheet.getVisibleRows();
+
+ if (isAllRowsCovered(allRowRanges, [range])) {
+ const confirmService = accessor.get(IConfirmService);
+ const localeService = accessor.get(LocaleService);
+
+ await confirmService.confirm({
+ id: 'sheet.confirm.remove-row',
+ title: {
+ title: localeService.t('info.problem'),
+ },
+ children: { title: localeService.t('rightClick.deleteAllRowsAlert') },
+ cancelText: localeService.t('button.cancel'),
+ confirmText: localeService.t('button.confirm'),
+ });
+
+ return false;
+ }
+
+ await commandService.executeCommand(RemoveRowCommand.id, { range });
+ return true;
+ },
+};
+
+export const RemoveColConfirmCommand: ICommand = {
+ id: 'sheet.command.remove-col-confirm',
+ type: CommandType.COMMAND,
+ handler: async (accessor: IAccessor, params?: IRemoveRowColCommandParams) => {
+ const selectionManagerService = accessor.get(SelectionManagerService);
+
+ let range = params?.range;
+ if (!range) {
+ range = selectionManagerService.getLast()?.range;
+ }
+ if (!range) {
+ return false;
+ }
+
+ const commandService = accessor.get(ICommandService);
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const workbook = univerInstanceService.getCurrentUniverSheetInstance();
+ const worksheet = workbook.getActiveSheet();
+ const allColumnRanges = worksheet.getVisibleCols();
+
+ if (isAllColumnsCovered(allColumnRanges, [range])) {
+ const confirmService = accessor.get(IConfirmService);
+ const localeService = accessor.get(LocaleService);
+
+ await confirmService.confirm({
+ id: 'sheet.confirm.remove-col',
+ title: {
+ title: localeService.t('info.problem'),
+ },
+ children: { title: localeService.t('rightClick.deleteAllColumnsAlert') },
+ cancelText: localeService.t('button.cancel'),
+ confirmText: localeService.t('button.confirm'),
+ });
+
+ return false;
+ }
+
+ await commandService.executeCommand(RemoveColCommand.id, { range });
+ return true;
+ },
+};
diff --git a/packages/sheets-ui/src/commands/commands/utils/selection-utils.ts b/packages/sheets-ui/src/commands/commands/utils/selection-utils.ts
index 1151986e12..6e83299492 100644
--- a/packages/sheets-ui/src/commands/commands/utils/selection-utils.ts
+++ b/packages/sheets-ui/src/commands/commands/utils/selection-utils.ts
@@ -635,3 +635,79 @@ export function checkIfShrink(selection: ISelection, direction: Direction, works
return anchorRange.startColumn > range.startColumn;
}
}
+
+/**
+ * Determine whether the entire row is selected
+ * @param allRowRanges Range of all rows
+ * @param ranges Range of selected rows
+ * @returns Whether the entire row is selected
+ */
+export function isAllRowsCovered(allRowRanges: IRange[], ranges: IRange[]): boolean {
+ // Find the minimum start point and maximum end point in all row ranges
+ let start = allRowRanges[0].startRow;
+ let end = allRowRanges[0].endRow;
+ allRowRanges.forEach((range) => {
+ const { startRow, endRow } = range;
+ start = Math.min(start, startRow);
+ end = Math.max(end, endRow);
+ });
+
+ const covered = new Array(end - start + 1).fill(false);
+
+ // Mark true in ranges
+ ranges.forEach((range) => {
+ const { startRow, endRow } = range;
+ for (let i = Math.max(startRow, start); i <= Math.min(endRow, end); i++) {
+ covered[i - start] = true;
+ }
+ });
+
+ // Check if every range in allRowRanges is covered
+ return allRowRanges.every((range) => {
+ const { startRow, endRow } = range;
+ for (let i = startRow; i <= endRow; i++) {
+ if (!covered[i - start]) {
+ return false;
+ }
+ }
+ return true;
+ });
+}
+
+/**
+ * Determine whether the entire column is selected
+ * @param allColumnRanges Range of all columns
+ * @param ranges Range of selected columns
+ * @returns Whether the entire column is selected
+ */
+export function isAllColumnsCovered(allColumnRanges: IRange[], ranges: IRange[]): boolean {
+ // Find the minimum start point and maximum end point in all column ranges
+ let start = allColumnRanges[0].startColumn;
+ let end = allColumnRanges[0].endColumn;
+ allColumnRanges.forEach((range) => {
+ const { startColumn, endColumn } = range;
+ start = Math.min(start, startColumn);
+ end = Math.max(end, endColumn);
+ });
+
+ const covered = new Array(end - start + 1).fill(false);
+
+ // Mark true in ranges
+ ranges.forEach((range) => {
+ const { startColumn, endColumn } = range;
+ for (let i = Math.max(startColumn, start); i <= Math.min(endColumn, end); i++) {
+ covered[i - start] = true;
+ }
+ });
+
+ // Check if every range in allColumnRanges is covered
+ return allColumnRanges.every((range) => {
+ const { startColumn, endColumn } = range;
+ for (let i = startColumn; i <= endColumn; i++) {
+ if (!covered[i - start]) {
+ return false;
+ }
+ }
+ return true;
+ });
+}
diff --git a/packages/sheets-ui/src/controllers/menu/delete.menu.ts b/packages/sheets-ui/src/controllers/menu/delete.menu.ts
index ba7bd0545f..a681c00208 100644
--- a/packages/sheets-ui/src/controllers/menu/delete.menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/delete.menu.ts
@@ -14,12 +14,15 @@
* limitations under the License.
*/
-import { RemoveColCommand, RemoveRowCommand } from '@univerjs/sheets';
import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
import { MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
import { DeleteRangeMoveLeftConfirmCommand } from '../../commands/commands/delete-range-move-left-confirm.command ';
import { DeleteRangeMoveUpConfirmCommand } from '../../commands/commands/delete-range-move-up-confirm.command';
+import {
+ RemoveColConfirmCommand,
+ RemoveRowConfirmCommand,
+} from '../../commands/commands/remove-row-col-confirm.command';
import { SheetMenuPosition } from './menu';
const DELETE_RANGE_MENU_ID = 'sheet.menu.delete';
@@ -36,7 +39,7 @@ export function DeleteRangeMenuItemFactory(): IMenuSelectorItem<string> {
export function RemoveColMenuItemFactory(): IMenuButtonItem {
return {
- id: RemoveColCommand.id,
+ id: RemoveColConfirmCommand.id,
group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'DeleteColumn',
@@ -47,7 +50,7 @@ export function RemoveColMenuItemFactory(): IMenuButtonItem {
export function RemoveRowMenuItemFactory(): IMenuButtonItem {
return {
- id: RemoveRowCommand.id,
+ id: RemoveRowConfirmCommand.id,
group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
icon: 'DeleteRow',
diff --git a/packages/sheets-ui/src/controllers/menu/menu.ts b/packages/sheets-ui/src/controllers/menu/menu.ts
index 4e264c5055..bc60baa204 100644
--- a/packages/sheets-ui/src/controllers/menu/menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/menu.ts
@@ -38,14 +38,12 @@ import {
ResetTextColorCommand,
SelectionManagerService,
SetBackgroundColorCommand,
- SetColHiddenCommand,
SetColHiddenMutation,
SetColVisibleMutation,
SetColWidthCommand,
SetHorizontalTextAlignCommand,
SetRangeValuesMutation,
SetRowHeightCommand,
- SetRowHiddenCommand,
SetRowHiddenMutation,
SetRowVisibleMutation,
SetSelectedColsVisibleCommand,
@@ -75,6 +73,7 @@ import {
SheetPasteFormatCommand,
SheetPasteValueCommand,
} from '../../commands/commands/clipboard.command';
+import { HideColConfirmCommand, HideRowConfirmCommand } from '../../commands/commands/hide-row-col-confirm.command';
import {
SetRangeBoldCommand,
SetRangeFontFamilyCommand,
@@ -1116,7 +1115,7 @@ export function CancelFrozenMenuItemFactory(): IMenuButtonItem {
export function HideRowMenuItemFactory(): IMenuButtonItem {
return {
- id: SetRowHiddenCommand.id,
+ id: HideRowConfirmCommand.id,
group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
@@ -1127,7 +1126,7 @@ export function HideRowMenuItemFactory(): IMenuButtonItem {
export function HideColMenuItemFactory(): IMenuButtonItem {
return {
- id: SetColHiddenCommand.id,
+ id: HideColConfirmCommand.id,
group: MenuGroup.CONTEXT_MENU_LAYOUT,
type: MenuItemType.BUTTON,
positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
diff --git a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
index 59999fce2e..1af435fb53 100644
--- a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
+++ b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
@@ -36,6 +36,7 @@ import {
} from '../commands/commands/add-worksheet-merge.command';
import { DeleteRangeMoveLeftConfirmCommand } from '../commands/commands/delete-range-move-left-confirm.command ';
import { DeleteRangeMoveUpConfirmCommand } from '../commands/commands/delete-range-move-up-confirm.command';
+import { HideColConfirmCommand, HideRowConfirmCommand } from '../commands/commands/hide-row-col-confirm.command';
import {
SetRangeBoldCommand,
SetRangeFontFamilyCommand,
@@ -50,6 +51,7 @@ import {
import { InsertRangeMoveDownConfirmCommand } from '../commands/commands/insert-range-move-down-confirm.command';
import { InsertRangeMoveRightConfirmCommand } from '../commands/commands/insert-range-move-right-confirm.command';
import { RefillCommand } from '../commands/commands/refill.command';
+import { RemoveColConfirmCommand, RemoveRowConfirmCommand } from '../commands/commands/remove-row-col-confirm.command';
import { RemoveSheetConfirmCommand } from '../commands/commands/remove-sheet-confirm.command';
import {
ApplyFormatPainterCommand,
@@ -250,6 +252,10 @@ export class SheetUIController extends Disposable {
MoveSelectionEnterAndTabCommand,
RenameSheetOperation,
RemoveSheetConfirmCommand,
+ RemoveRowConfirmCommand,
+ RemoveColConfirmCommand,
+ HideRowConfirmCommand,
+ HideColConfirmCommand,
ScrollCommand,
SelectAllCommand,
SetActivateCellEditOperation,
diff --git a/packages/sheets-ui/src/locale/en-US.ts b/packages/sheets-ui/src/locale/en-US.ts
index 698c443a76..996d7f2dcf 100644
--- a/packages/sheets-ui/src/locale/en-US.ts
+++ b/packages/sheets-ui/src/locale/en-US.ts
@@ -541,6 +541,10 @@ export default {
freezeRow: 'Freeze to this row',
cancelFreeze: 'Cancel freeze',
zenEditor: 'Full Screen Editor',
+ deleteAllRowsAlert: `You can't delete all the rows on the sheet`,
+ deleteAllColumnsAlert: `You can't delete all the columns on the sheet`,
+ hideAllRowsAlert: `You can't hide all the rows on the sheet`,
+ hideAllColumnsAlert: `You can't hide all the columns on the sheet`,
},
info: {
tooltip: 'Tooltip',
@@ -572,6 +576,7 @@ export default {
tipColumnWidthLimit: 'The column width must be between 0 ~ 2038',
// eslint-disable-next-line no-template-curly-in-string
pageInfoFull: 'Total ${total},${totalPage} page,All data displayed',
+ problem: 'There was a problem',
},
clipboard: {
paste: {
diff --git a/packages/sheets-ui/src/locale/zh-CN.ts b/packages/sheets-ui/src/locale/zh-CN.ts
index 33251f7740..a13c6d48fa 100644
--- a/packages/sheets-ui/src/locale/zh-CN.ts
+++ b/packages/sheets-ui/src/locale/zh-CN.ts
@@ -404,6 +404,10 @@ export default {
freezeRow: '冻结行',
cancelFreeze: '取消冻结',
zenEditor: '禅模式编辑',
+ deleteAllRowsAlert: `您无法删除工作表上的所有行`,
+ deleteAllColumnsAlert: `您无法删除工作表上的所有列`,
+ hideAllRowsAlert: `您无法隐藏工作表上的所有行`,
+ hideAllColumnsAlert: `您无法隐藏工作表上的所有列`,
},
info: {
tooltip: '提示',
@@ -435,6 +439,7 @@ export default {
tipColumnWidthLimit: '列宽必须在0 ~ 2038之间',
// eslint-disable-next-line no-template-curly-in-string
pageInfoFull: '共${total}条,${totalPage}页,已显示全部数据',
+ problem: '出现了一个问题',
},
clipboard: {
paste: {