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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: insert cols&rows from rigth mouse btn menu (#5764)
Roman Sergeev57f727bb6299
diff --git a/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.tsindex cad5083344..9b018e3d09 100644--- a/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.ts@@ -201,7 +201,7 @@ describe('Test insert and remove rows cols commands', () => {expect(getRowCount()).toBe(20);expect(getCellStyle(2, 1)).toBe('s4');- const result = await commandService.executeCommand(InsertRowBeforeCommand.id);+ const result = await commandService.executeCommand(InsertRowBeforeCommand.id, { value: 1 });expect(result).toBeTruthy();expect(getRowCount()).toBe(21);// the merged cell should be moved down@@ -251,7 +251,7 @@ describe('Test insert and remove rows cols commands', () => {selectColumn(1, 1);expect(getColCount()).toBe(20);- const result = await commandService.executeCommand(InsertColBeforeCommand.id);+ const result = await commandService.executeCommand(InsertColBeforeCommand.id, { value: 1 });expect(result).toBeTruthy();expect(getColCount()).toBe(21);// Insert column style@@ -267,6 +267,7 @@ describe('Test insert and remove rows cols commands', () => {it("Should 'insert after' work", async () => {selectColumn(1, 1);+ expect(getColCount()).toBe(20);const result = await commandService.executeCommand(InsertColAfterCommand.id);expect(result).toBeTruthy();diff --git a/packages/sheets/src/commands/commands/insert-row-col.command.ts b/packages/sheets/src/commands/commands/insert-row-col.command.tsindex 2f1bf9d2fb..92b1af2709 100644--- a/packages/sheets/src/commands/commands/insert-row-col.command.ts+++ b/packages/sheets/src/commands/commands/insert-row-col.command.ts@@ -175,7 +175,7 @@ export const InsertRowByRangeCommand: ICommand = {export const InsertRowBeforeCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.insert-row-before',- handler: async (accessor: IAccessor) => {+ handler: async (accessor: IAccessor, params: IInsertMultiRowsCommandParams) => {const selectionManagerService = accessor.get(SheetsSelectionsService);const selections = selectionManagerService.getCurrentSelections()?.map((s) => s.range);let range: IRange;@@ -193,7 +193,10 @@ export const InsertRowBeforeCommand: ICommand = {if (!target) return false;const { worksheet, subUnitId, unitId } = target;- const { startRow, endRow } = range;+ const count = params.value || 0;++ const startRow = range.startRow;+ const endRow = range.startRow + count - 1;const startColumn = 0;const endColumn = worksheet.getColumnCount() - 1;const insertRowParams: IInsertRowCommandParams = {@@ -474,7 +477,7 @@ export const InsertColByRangeCommand: ICommand<IInsertColCommandParams> = {export const InsertColBeforeCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.insert-col-before',- handler: async (accessor: IAccessor) => {+ handler: async (accessor: IAccessor, params: IInsertMultiRowsCommandParams) => {const selectionManagerService = accessor.get(SheetsSelectionsService);const selections = selectionManagerService.getCurrentSelections();let range: IRange;@@ -490,8 +493,9 @@ export const InsertColBeforeCommand: ICommand = {if (!target) return false;const { worksheet, unitId, subUnitId } = target;-- const { startColumn, endColumn } = range;+ const count = params.value || 0;+ const startColumn = range.startColumn;+ const endColumn = range.startColumn + count - 1;const startRow = 0;const endRow = worksheet.getRowCount() - 1;