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: domain refactor (#95)

tonytonychopper123cc71cfb6cf34
diff --git a/packages/base-sheets/src/Basics/Interfaces/MutationInterface.ts b/packages/base-sheets/src/Basics/Interfaces/MutationInterface.ts
index 61f778aa7d..577866b2dd 100644
--- a/packages/base-sheets/src/Basics/Interfaces/MutationInterface.ts
+++ b/packages/base-sheets/src/Basics/Interfaces/MutationInterface.ts
@@ -1,4 +1,4 @@
-import { Dimension, ICellData, IRangeData, IWorksheetConfig, Nullable, ObjectMatrixPrimitiveType } from '@univerjs/core';
+import { Dimension, ICellData, IColumnData, IRangeData, IRowData, IWorksheetConfig, ObjectArray, ObjectMatrixPrimitiveType } from '@univerjs/core';
/** Params of `RemoveSheetMutation` */
export interface IRemoveSheetMutationParams {
@@ -17,41 +17,37 @@ export interface IInsertSheetMutationParams {
export interface IInsertRowMutationParams {
workbookId: string;
worksheetId: string;
- rowIndex: number;
- rowCount: number;
- insertRowData: Nullable<ObjectMatrixPrimitiveType<ICellData>>;
+ ranges: IRangeData[];
+ rowInfo?: ObjectArray<IRowData>;
}
/** Params of InsertColMutation */
export interface IInsertColMutationParams {
workbookId: string;
worksheetId: string;
- colIndex: number;
- colCount: number;
- insertColData: Nullable<ObjectMatrixPrimitiveType<ICellData>>;
+ ranges: IRangeData[];
+ colInfo?: ObjectArray<IColumnData>;
}
/** Params of InsertRowMutation */
export interface IRemoveRowMutationParams {
workbookId: string;
worksheetId: string;
- rowIndex: number;
- rowCount: number;
+ ranges: IRangeData[];
}
/** Params of InsertColMutation */
export interface IRemoveColMutationParams {
workbookId: string;
worksheetId: string;
- colIndex: number;
- colCount: number;
+ ranges: IRangeData[];
}
/** Params of DeleteRange */
export interface IDeleteRangeMutationParams {
workbookId: string;
worksheetId: string;
- range: IRangeData;
+ range: IRangeData[];
shiftDimension: Dimension;
}
@@ -59,7 +55,7 @@ export interface IDeleteRangeMutationParams {
export interface IInsertRangeMutationParams {
workbookId: string;
worksheetId: string;
- range: IRangeData;
+ range: IRangeData[];
shiftDimension: Dimension;
cellValue: ObjectMatrixPrimitiveType<ICellData>;
}
@@ -68,12 +64,12 @@ export interface IInsertRangeMutationParams {
export interface IRemoveWorksheetMergeMutationParams {
workbookId: string;
worksheetId: string;
- rectangles: IRangeData[];
+ ranges: IRangeData[];
}
/** Params of AddWorksheetMergeMutation */
export interface IAddWorksheetMergeMutationParams {
workbookId: string;
worksheetId: string;
- rectangles: IRangeData[];
+ ranges: IRangeData[];
}
diff --git a/packages/base-sheets/src/Commands/Commands/add-worksheet-merge.command.ts b/packages/base-sheets/src/Commands/Commands/add-worksheet-merge.command.ts
index b43e5419c2..094e4658f9 100644
--- a/packages/base-sheets/src/Commands/Commands/add-worksheet-merge.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/add-worksheet-merge.command.ts
@@ -1,67 +1,96 @@
-import { CommandType, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService } from '@univerjs/core';
+import { CommandType, Dimension, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
-import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../Mutations/add-worksheet-merge.mutation';
-import { IRemoveWorksheetMergeMutationParams } from '../../Basics/Interfaces/MutationInterface';
-import { RemoveWorksheetMergeMutation } from '../Mutations/remove-worksheet-merge.mutation';
+
+import { IAddWorksheetMergeMutationParams, IRemoveWorksheetMergeMutationParams } from '../../Basics/Interfaces/MutationInterface';
import { ISelectionManager } from '../../Services/tokens';
+import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../Mutations/add-worksheet-merge.mutation';
+import { RemoveWorksheetMergeMutation, RemoveWorksheetMergeMutationFactory } from '../Mutations/remove-worksheet-merge.mutation';
-export interface IAddWorksheetMergeCommandParams {
- workbookId: string;
- worksheetId: string;
- rectangles: IRangeData[];
+interface addMergeCommandParams {
+ direction: Dimension.ROWS | Dimension.COLUMNS;
}
export const AddWorksheetMergeCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.add-worksheet-merge',
- handler: async (accessor: IAccessor, params?: IAddWorksheetMergeCommandParams) => {
+ handler: async (accessor: IAccessor, params?: addMergeCommandParams) => {
const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+ let ranges = selections;
- let redoMutationParams: IAddWorksheetMergeCommandParams;
- if (params == null) {
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- if (!selections.length) {
- return false;
+ if (params) {
+ const rectangles = [];
+ for (let i = 0; i < ranges.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = ranges[i];
+ if (params.direction === Dimension.ROWS) {
+ for (let r = startRow; r <= endRow; r++) {
+ const data = {
+ startRow: r,
+ endRow: r,
+ startColumn,
+ endColumn,
+ };
+ rectangles.push(data);
+ }
+ } else {
+ for (let c = startColumn; c <= endColumn; c++) {
+ const data = {
+ startRow,
+ endRow,
+ startColumn: c,
+ endColumn: c,
+ };
+ rectangles.push(data);
+ }
+ }
}
- const range = selections[0];
- redoMutationParams = {
- workbookId: workbook.getUnitId(),
- worksheetId: workbook.getActiveSheet().getSheetId(),
- rectangles: [
- {
- startRow: range.startRow,
- startColumn: range.startColumn,
- endRow: range.endRow,
- endColumn: range.endColumn,
- },
- ],
- };
- } else {
- redoMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- rectangles: params.rectangles,
- };
+ ranges = rectangles;
}
- const undoMutationParams: IRemoveWorksheetMergeMutationParams = AddWorksheetMergeMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(RemoveWorksheetMergeMutation.id, redoMutationParams);
- if (result) {
+ const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges,
+ };
+ const undoRemoveMergeMutationParams: IAddWorksheetMergeMutationParams = RemoveWorksheetMergeMutationFactory(accessor, removeMergeMutationParams);
+ const removeResult = commandService.executeCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams);
+
+ const addMergeMutationParams: IAddWorksheetMergeMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges,
+ };
+ const undoMutationParams: IRemoveWorksheetMergeMutationParams = AddWorksheetMergeMutationFactory(accessor, addMergeMutationParams);
+ const result = commandService.executeCommand(AddWorksheetMergeMutation.id, addMergeMutationParams);
+
+ if (result && removeResult) {
undoRedoService.pushUndoRedo({
URI: 'sheet',
undo() {
- return commandService.executeCommand(AddWorksheetMergeMutation.id, undoMutationParams);
+ return (commandService.executeCommand(RemoveWorksheetMergeMutation.id, undoMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(AddWorksheetMergeMutation.id, undoRemoveMergeMutationParams);
+ return false;
+ });
},
redo() {
- return commandService.executeCommand(RemoveWorksheetMergeMutation.id, redoMutationParams);
+ return (commandService.executeCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(AddWorksheetMergeMutation.id, addMergeMutationParams);
+ return false;
+ });
},
});
return true;
}
- return true;
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/copy-format-to-range.command.ts b/packages/base-sheets/src/Commands/Commands/copy-format-to-range.command.ts
index 7e92f5a8c7..4ae3239b40 100644
--- a/packages/base-sheets/src/Commands/Commands/copy-format-to-range.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/copy-format-to-range.command.ts
@@ -13,11 +13,9 @@ import {
} from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { ISetRangeStyleMutationParams, SetRangeStyleMutation, SetRangeStyleUndoMutationFactory } from '../Mutations/set-range-styles.mutation';
+import { ISelectionManager } from '../../Services/tokens';
export interface ICopyFormatToRangeCommandParams {
- workbookId: string;
- worksheetId: string;
- originRange: IRangeData;
destinationRange: IRangeData;
}
@@ -25,12 +23,20 @@ export const CopyFormatToRangeCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.copy-format-to-range',
handler: async (accessor: IAccessor, params: ICopyFormatToRangeCommandParams) => {
+ const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
- const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+ const originRange = selections[0];
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
if (!workbook) return false;
- const handleResult = handleCopyRange(accessor, params.workbookId, params.worksheetId, params.originRange, params.destinationRange);
+ const handleResult = handleCopyRange(accessor, workbookId, worksheetId, originRange, params.destinationRange);
if (!handleResult) return false;
const value = handleResult[0];
const range = handleResult[1];
@@ -46,8 +52,8 @@ export const CopyFormatToRangeCommand: ICommand = {
const setRangeStyleMutationParams: ISetRangeStyleMutationParams = {
range: [range],
- worksheetId: params.worksheetId,
- workbookId: params.workbookId,
+ worksheetId,
+ workbookId,
value: stylesMatrix.getData(),
};
@@ -65,7 +71,7 @@ export const CopyFormatToRangeCommand: ICommand = {
});
return true;
}
- return true;
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/copy-range-to.command.ts b/packages/base-sheets/src/Commands/Commands/copy-range-to.command.ts
new file mode 100644
index 0000000000..e8247a7dbf
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/copy-range-to.command.ts
@@ -0,0 +1,186 @@
+import {
+ CommandType,
+ ICellData,
+ ICellDataMatrix,
+ ICommand,
+ ICommandService,
+ ICurrentUniverService,
+ IOptionData,
+ IRangeData,
+ IUndoRedoService,
+ Nullable,
+ ObjectMatrix,
+} from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetRangeValuesMutationParams, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../Mutations/set-range-values.mutation';
+import { ISelectionManager } from '../../Services/tokens';
+
+export interface ICopyRangeToCommandParams {
+ destinationRange: IRangeData;
+ options?: IOptionData;
+}
+
+export const CopyRangeToCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.copy-range-to',
+ handler: async (accessor: IAccessor, params: ICopyRangeToCommandParams) => {
+ const selectionManager = accessor.get(ISelectionManager);
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+ const originRange = selections[0];
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const handleResult = handleCopyRange(accessor, workbookId, worksheetId, originRange, params.destinationRange);
+ if (!handleResult) return false;
+ const value = handleResult[0];
+ const range = handleResult[1];
+ const options = params.options ?? {};
+ const cellValue = new ObjectMatrix<ICellData>();
+ value.forEach((row, r) =>
+ row.forEach((cell, c) => {
+ cell = cell as ICellData;
+ cellValue.setValue(r + range.startRow, c + range.startColumn, cell || {});
+ })
+ );
+
+ const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {
+ rangeData: [range],
+ worksheetId,
+ workbookId,
+ cellValue: cellValue.getData(),
+ options,
+ };
+
+ const undoMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams);
+ const result = commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetRangeValuesMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ },
+ });
+ return true;
+ }
+ return false;
+ },
+};
+
+/**
+ * en:
+ *
+ * The process of copying a range to another range is obtained by the following rules
+ *
+ * [The two-dimensional array composed of the content or format to be assigned] => [Target range]
+ *
+ * 1. 1 -> 1: 1 => 1
+ * 2. N -> 1: N => N
+ * 3. 1 -> N: N => N
+ * 4. N1 -> N2:
+ * 1) N1 <N2: If N2 is a multiple of N1 (X), N1 * X => N2; If not, N1 => N1 (refer to office excel, different from google sheet)
+ * 2) N1> N2: N1 => N1
+ *
+ * The above four cases can be combined and processed as
+ *
+ * Case 1, 1/2/4-2 merged into N1 => N1
+ * Case 2, 3/4-1 merge into N1 * X => N2 or Case 1
+ *
+ * In the end we only need to judge whether N2 is a multiple of N1
+ *
+ * zh:
+ *
+ * 处理复制一个范围到另一个范围,由以下规则得到
+ *
+ * [将要赋值的内容或者格式组成的二维数组] => [目标范围]
+ *
+ * 1. 1 -> 1 : 1 => 1
+ * 2. N -> 1 : N => N
+ * 3. 1 -> N : N => N
+ * 4. N1 -> N2 :
+ * 1) N1 < N2 : 如果N2是N1的倍数X, N1 * X => N2; 如果不是,N1 => N1(参考office excel,和google sheet不同)
+ * 2) N1 > N2 : N1 => N1
+ *
+ * 上面四种情况,可以合并处理为
+ * 情况一, 1/2/4-2合并为 N1 => N1
+ * 情况二, 3/4-1合并为 N1 * X => N2 或者情况一
+ *
+ * 最终我们只需要判断N2是否是N1的倍数
+ *
+ */
+
+function handleCopyRange(
+ accessor: IAccessor,
+ workbookId: string,
+ worksheetId: string,
+ originRange: IRangeData,
+ destinationRange: IRangeData
+): Nullable<[ICellDataMatrix, IRangeData]> {
+ const worksheet = accessor.get(ICurrentUniverService).getUniverSheetInstance(workbookId)?.getWorkBook().getSheetBySheetId(worksheetId);
+ if (!worksheet) return;
+
+ const sheetMatrix = worksheet.getCellMatrix();
+ const rangeMatrix = new ObjectMatrix<ICellData>();
+
+ const { startRow, endRow, startColumn, endColumn } = originRange;
+ for (let r = startRow; r <= endRow; r++) {
+ for (let c = startColumn; c <= endColumn; c++) {
+ rangeMatrix.setValue(r, c, sheetMatrix.getValue(r, c) || null);
+ }
+ }
+
+ const cellData = worksheet.getCellMatrix();
+ // eslint-disable-next-line prefer-const
+ let { startRow: dStartRow, endRow: dEndRow, startColumn: dStartColumn, endColumn: dEndColumn } = destinationRange;
+
+ const originRows = endRow - startRow + 1;
+ const originColumns = endColumn - startColumn + 1;
+ const destinationRows = dEndRow - dStartRow + 1;
+ const destinationColumns = dEndColumn - dStartColumn + 1;
+
+ let value: ICellDataMatrix = [];
+ let range: IRangeData;
+
+ // judge whether N2 is a multiple of N1
+ if (destinationRows % originRows === 0 && destinationColumns % originColumns === 0) {
+ /**
+ * A1,B1 => A1,B1,C1,D1
+ * A2,B2 A2,B2,C2,D2
+ * A3,B3,C3,D3
+ * A4,B4,C4,D4
+ */
+ for (let r = 0; r < destinationRows; r++) {
+ const row = [];
+ for (let c = 0; c < destinationColumns; c++) {
+ // Retrieve the corresponding cell data from the original range, {} as a fallback
+ const cell = cellData.getValue((r + startRow) % originRows, (c + startColumn) % originColumns) || {};
+ row.push(cell);
+ }
+ value.push(row);
+ }
+ range = destinationRange;
+ } else {
+ value = cellData.getFragments(startRow, endRow, startColumn, endColumn).getData() as ICellDataMatrix;
+
+ // Extend the destination to the same size as the original range
+ dEndRow += originRows - destinationRows;
+ dEndColumn += originColumns - destinationColumns;
+
+ range = {
+ startRow: dStartRow,
+ endRow: dEndRow,
+ startColumn: dStartColumn,
+ endColumn: dEndColumn,
+ };
+ }
+
+ return [value, range];
+}
diff --git a/packages/base-sheets/src/Commands/Commands/copy-to-worksheet.command.ts b/packages/base-sheets/src/Commands/Commands/copy-to-worksheet.command.ts
new file mode 100644
index 0000000000..1ebbb756b0
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/copy-to-worksheet.command.ts
@@ -0,0 +1,58 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, Tools } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetWorksheetConfigMutationParams, SetWorksheetConfigMutation, SetWorksheetConfigUndoMutationFactory } from '../Mutations/set-worksheet-config.mutation';
+
+export interface ICopySheetToCommandParams {
+ workbookId?: string;
+ worksheetId?: string;
+ copyToWorkbookId?: string;
+ copyToSheetId?: string;
+}
+
+export const CopySheetToCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.copy-sheet-to',
+ handler: async (accessor: IAccessor, params: ICopySheetToCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const workbookId = params.workbookId || currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = params.worksheetId || currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const copyToWorkbookId = params.workbookId || currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const copyToSheetId = params.copyToSheetId || currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const copyToWorkbook = currentUniverService.getUniverSheetInstance(copyToWorkbookId)?.getWorkBook();
+ if (!copyToWorkbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+ const copyToWorksheet = workbook.getSheetBySheetId(copyToSheetId);
+ if (!copyToWorksheet) return false;
+ if (workbookId === copyToWorkbookId && worksheetId === copyToSheetId) return false;
+
+ const config = Tools.deepClone(worksheet.getConfig());
+
+ const setWorksheetConfigMutationParams: ISetWorksheetConfigMutationParams = {
+ workbookId,
+ worksheetId,
+ config,
+ };
+
+ const undoMutationParams: ISetWorksheetConfigMutationParams = SetWorksheetConfigUndoMutationFactory(accessor, setWorksheetConfigMutationParams);
+ const result = commandService.executeCommand(SetWorksheetConfigMutation.id, setWorksheetConfigMutationParams);
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetWorksheetConfigMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetWorksheetConfigMutation.id, setWorksheetConfigMutationParams);
+ },
+ });
+ return true;
+ }
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/copy-to.command.ts b/packages/base-sheets/src/Commands/Commands/copy-to.command.ts
deleted file mode 100644
index 1ff4d98682..0000000000
--- a/packages/base-sheets/src/Commands/Commands/copy-to.command.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import {
- CommandType,
- ICellData,
- ICellDataMatrix,
- ICommand,
- ICommandService,
- ICurrentUniverService,
- IOptionData,
- IRangeData,
- IStyleData,
- IUndoRedoService,
- Nullable,
- ObjectMatrix,
-} from '@univerjs/core';
-import { IAccessor } from '@wendellhu/redi';
-import { ISetRangeStyleMutationParams, SetRangeStyleMutation, SetRangeStyleUndoMutationFactory } from '../Mutations/set-range-styles.mutation';
-
-
-
-export interface ICopyToCommandParams {
- workbookId: string;
- worksheetId: string;
- originRange: IRangeData;
- destinationRange: IRangeData;
- options?: IOptionData |
-}
-
-export const CopyFormatToRangeCommand: ICommand = {
- type: CommandType.COMMAND,
- id: 'sheet.command.copy-to',
- handler: async (accessor: IAccessor, params: ICopyToCommandParams) => {
- const commandService = accessor.get(ICommandService);
- const undoRedoService = accessor.get(IUndoRedoService);
-
-
-
- const setRangeStyleMutationParams: ISetRangeStyleMutationParams = {
- range: [range],
- worksheetId: params.worksheetId,
- workbookId: params.workbookId,
- value: stylesMatrix.getData(),
- };
-
- const undoMutationParams: ISetRangeStyleMutationParams = SetRangeStyleUndoMutationFactory(accessor, setRangeStyleMutationParams);
- const result = commandService.executeCommand(SetRangeStyleMutation.id, setRangeStyleMutationParams);
- if (result) {
- undoRedoService.pushUndoRedo({
- URI: 'sheet',
- undo() {
- return commandService.executeCommand(SetRangeStyleMutation.id, undoMutationParams);
- },
- redo() {
- return commandService.executeCommand(SetRangeStyleMutation.id, setRangeStyleMutationParams);
- },
- });
- return true;
- }
- return true;
- },
-};
-
diff --git a/packages/base-sheets/src/Commands/Commands/copy-values-to-range.command.ts b/packages/base-sheets/src/Commands/Commands/copy-values-to-range.command.ts
index 03695ae640..68b09a09ce 100644
--- a/packages/base-sheets/src/Commands/Commands/copy-values-to-range.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/copy-values-to-range.command.ts
@@ -13,11 +13,9 @@ import {
} from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { ISetRangeFormattedValueMutationParams, SetRangeFormattedValueMutation, SetRangeFormattedValueUndoMutationFactory } from '../Mutations/set-range-formatted-value.mutation';
+import { ISelectionManager } from '../../Services/tokens';
export interface ICopyValuesToRangeCommandParams {
- workbookId: string;
- worksheetId: string;
- originRange: IRangeData;
destinationRange: IRangeData;
}
@@ -25,12 +23,19 @@ export const CopyValuesToRangeCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.copy-values-to-range',
handler: async (accessor: IAccessor, params: ICopyValuesToRangeCommandParams) => {
+ const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
- const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+ const originRange = selections[0];
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
if (!workbook) return false;
- const handleResult = handleCopyRange(accessor, params.workbookId, params.worksheetId, params.originRange, params.destinationRange);
+ const handleResult = handleCopyRange(accessor, workbookId, worksheetId, originRange, params.destinationRange);
if (!handleResult) return false;
const value = handleResult[0];
const range = handleResult[1];
@@ -38,14 +43,14 @@ export const CopyValuesToRangeCommand: ICommand = {
value.forEach((row, r) =>
row.forEach((cell, c) => {
cell = cell as ICellData;
- cellValue.setValue(r + params.destinationRange.startRow, c + params.destinationRange.startColumn, cell?.v || '');
+ cellValue.setValue(r + range.startRow, c + range.startColumn, cell?.v || '');
})
);
const setRangeFormattedValueMutationParams: ISetRangeFormattedValueMutationParams = {
range: [range],
- worksheetId: params.worksheetId,
- workbookId: params.workbookId,
+ worksheetId,
+ workbookId,
value: cellValue.getData(),
};
@@ -63,7 +68,7 @@ export const CopyValuesToRangeCommand: ICommand = {
});
return true;
}
- return true;
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/copy-worksheet.command.ts b/packages/base-sheets/src/Commands/Commands/copy-worksheet.command.ts
new file mode 100644
index 0000000000..653b6cc7a0
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/copy-worksheet.command.ts
@@ -0,0 +1,74 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, Tools } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Basics/Interfaces/MutationInterface';
+import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../Mutations/insert-sheet.mutation';
+import { ISetWorksheetActivateMutationParams, SetWorksheetActivateMutation, SetWorksheetUnActivateMutationFactory } from '../Mutations/set-worksheet-activate.mutation';
+import { RemoveSheetMutation } from '../Mutations/remove-sheet.mutation';
+
+export interface ICopySheetCommandParams {
+ workbookId?: string;
+ worksheetId?: string;
+}
+
+export const CopySheetCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.copy-sheet',
+ handler: async (accessor: IAccessor, params?: ICopySheetCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ let workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ if (params) {
+ workbookId = params.workbookId ?? workbookId;
+ worksheetId = params.worksheetId ?? worksheetId;
+ }
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const config = Tools.deepClone(worksheet.getConfig());
+ config.name += '副本'; //Todo: 文字国际化
+ config.id = Tools.generateRandomId();
+ const sheetIndex = workbook.getSheetIndex(worksheet);
+
+ const insertSheetMutationParams: IInsertSheetMutationParams = {
+ index: sheetIndex + 1,
+ sheet: config,
+ workbookId,
+ };
+
+ const removeSheetMutationParams: IRemoveSheetMutationParams = InsertSheetUndoMutationFactory(accessor, insertSheetMutationParams);
+ const insertResult = commandService.executeCommand(InsertSheetMutation.id, insertSheetMutationParams);
+
+ const setSheetActiveMutationParams: ISetWorksheetActivateMutationParams = {
+ workbookId,
+ worksheetId: config.id,
+ };
+
+ const undoMutationParams: ISetWorksheetActivateMutationParams = SetWorksheetUnActivateMutationFactory(accessor, setSheetActiveMutationParams);
+ const result = commandService.executeCommand(SetWorksheetActivateMutation.id, setSheetActiveMutationParams);
+
+ if (insertResult && result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return (commandService.executeCommand(RemoveSheetMutation.id, removeSheetMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetWorksheetActivateMutation.id, undoMutationParams);
+ return false;
+ });
+ },
+ redo() {
+ return (commandService.executeCommand(InsertSheetMutation.id, insertSheetMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetWorksheetActivateMutation.id, setSheetActiveMutationParams);
+ return false;
+ });
+ },
+ });
+ return true;
+ }
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/delete-range-move-left.command.ts b/packages/base-sheets/src/Commands/Commands/delete-range-move-left.command.ts
index 11af35f446..c928f871c0 100644
--- a/packages/base-sheets/src/Commands/Commands/delete-range-move-left.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/delete-range-move-left.command.ts
@@ -1,15 +1,10 @@
import { IAccessor } from '@wendellhu/redi';
-import { CommandType, Dimension, ICommand, ICommandService, IRangeData, IUndoRedoService } from '@univerjs/core';
+import { CommandType, Dimension, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, Nullable } from '@univerjs/core';
import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../Mutations/delete-range.mutation';
import { InsertRangeMutation } from '../Mutations/insert-range.mutation';
import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';
-
-export interface IDeleteRangeMoveLeftParams {
- workbookId: string;
- worksheetId: string;
- range: IRangeData;
-}
+import { ISelectionManager } from '../../Services/tokens';
/**
* The command to delete range.
@@ -18,10 +13,21 @@ export const DeleteRangeMoveLeftCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.delete-range-move-left',
- handler: async (accessor: IAccessor, params: IDeleteRangeMoveLeftParams) => {
+ handler: async (accessor: IAccessor) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
- const { range, workbookId, worksheetId } = params;
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const range = selectionManager.getCurrentSelections();
+ if (!range.length) return false;
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
const deleteRangeMutationParams: IDeleteRangeMutationParams = {
range,
@@ -30,7 +36,8 @@ export const DeleteRangeMoveLeftCommand: ICommand = {
shiftDimension: Dimension.COLUMNS,
};
- const insertRangeMutationParams: IInsertRangeMutationParams = DeleteRangeUndoMutationFactory(accessor, deleteRangeMutationParams);
+ const insertRangeMutationParams: Nullable<IInsertRangeMutationParams> = DeleteRangeUndoMutationFactory(accessor, deleteRangeMutationParams);
+ if (!insertRangeMutationParams) return false;
// execute do mutations and add undo mutations to undo stack if completed
const result = commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
diff --git a/packages/base-sheets/src/Commands/Commands/delete-range-move-up.command.ts b/packages/base-sheets/src/Commands/Commands/delete-range-move-up.command.ts
index 09d2095997..ee551da3f4 100644
--- a/packages/base-sheets/src/Commands/Commands/delete-range-move-up.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/delete-range-move-up.command.ts
@@ -1,15 +1,10 @@
import { IAccessor } from '@wendellhu/redi';
-import { CommandType, Dimension, ICommand, ICommandService, IRangeData, IUndoRedoService } from '@univerjs/core';
+import { CommandType, Dimension, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, Nullable } from '@univerjs/core';
import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../Mutations/delete-range.mutation';
import { InsertRangeMutation } from '../Mutations/insert-range.mutation';
import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';
-
-export interface IDeleteRangeMoveUpParams {
- workbookId: string;
- worksheetId: string;
- range: IRangeData;
-}
+import { ISelectionManager } from '../../Services/tokens';
/**
* The command to delete range.
@@ -18,10 +13,21 @@ export const DeleteRangeMoveUpCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.delete-range-move-up',
- handler: async (accessor: IAccessor, params: IDeleteRangeMoveUpParams) => {
+ handler: async (accessor: IAccessor) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
- const { range, workbookId, worksheetId } = params;
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const range = selectionManager.getCurrentSelections();
+ if (!range.length) return false;
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
const deleteRangeMutationParams: IDeleteRangeMutationParams = {
range,
@@ -30,7 +36,8 @@ export const DeleteRangeMoveUpCommand: ICommand = {
shiftDimension: Dimension.ROWS,
};
- const insertRangeMutationParams: IInsertRangeMutationParams = DeleteRangeUndoMutationFactory(accessor, deleteRangeMutationParams);
+ const insertRangeMutationParams: Nullable<IInsertRangeMutationParams> = DeleteRangeUndoMutationFactory(accessor, deleteRangeMutationParams);
+ if (!insertRangeMutationParams) return false;
// execute do mutations and add undo mutations to undo stack if completed
const result = commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
diff --git a/packages/base-sheets/src/Commands/Commands/delete-range.command.ts b/packages/base-sheets/src/Commands/Commands/delete-range.command.ts
deleted file mode 100644
index 2c924f2a2f..0000000000
--- a/packages/base-sheets/src/Commands/Commands/delete-range.command.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { IAccessor } from '@wendellhu/redi';
-import { CommandType, Dimension, ICommand, ICommandService, IRangeData, IUndoRedoService } from '@univerjs/core';
-
-import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../Mutations/delete-range.mutation';
-import { InsertRangeMutation } from '../Mutations/insert-range.mutation';
-import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';
-
-export interface IDeleteRangeParams {
- workbookId: string;
- worksheetId: string;
- range: IRangeData;
- shiftDimension: Dimension;
-}
-
-/**
- * The command to delete range.
- */
-export const DeleteRangeCommand: ICommand = {
- type: CommandType.COMMAND,
- id: 'sheet.command.delete-range',
-
- handler: async (accessor: IAccessor, params: IDeleteRangeParams) => {
- const commandService = accessor.get(ICommandService);
- const undoRedoService = accessor.get(IUndoRedoService);
- const { range, workbookId, worksheetId, shiftDimension } = params;
-
- const deleteRangeMutationParams: IDeleteRangeMutationParams = {
- range,
- worksheetId,
- workbookId,
- shiftDimension,
- };
-
- const insertRangeMutationParams: IInsertRangeMutationParams = DeleteRangeUndoMutationFactory(accessor, deleteRangeMutationParams);
-
- // execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
- if (result) {
- undoRedoService.pushUndoRedo({
- // 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
- // 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: 'sheet', // TODO: this URI is fake
- undo() {
- return commandService.executeCommand(InsertRangeMutation.id, insertRangeMutationParams);
- },
- redo() {
- return commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
- },
- });
-
- return true;
- }
-
- return false;
- },
- // all subsequent mutations should succeed inorder to make the whole process succeed
- // Promise.all([]).then(() => true),
-};
diff --git a/packages/base-sheets/src/Commands/Commands/insert-range-move-bottom.command.ts b/packages/base-sheets/src/Commands/Commands/insert-range-move-down.command.ts
similarity index 62%
rename from packages/base-sheets/src/Commands/Commands/insert-range-move-bottom.command.ts
rename to packages/base-sheets/src/Commands/Commands/insert-range-move-down.command.ts
index 59cf4c23e1..b6040adfe0 100644
--- a/packages/base-sheets/src/Commands/Commands/insert-range-move-bottom.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/insert-range-move-down.command.ts
@@ -1,51 +1,38 @@
import { IAccessor } from '@wendellhu/redi';
-import { CommandType, Dimension, ICellData, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
+import { CommandType, Dimension, ICellData, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
import { DeleteRangeMutation } from '../Mutations/delete-range.mutation';
import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../Mutations/insert-range.mutation';
import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';
-
-export interface IInsertRangeMoveBottomParams {
- workbookId: string;
- worksheetId: string;
- range: IRangeData;
- destination?: IRangeData;
-}
+import { ISelectionManager } from '../../Services/tokens';
/**
* The command to insert range.
*/
-export const InsertRangeMoveBottomCommand: ICommand = {
+export const InsertRangeMoveDownCommand: ICommand = {
type: CommandType.COMMAND,
- id: 'sheet.command.insert-range-move-bottom',
+ id: 'sheet.command.insert-range-move-down',
- handler: async (accessor: IAccessor, params: IInsertRangeMoveBottomParams) => {
- const currentUniverService = accessor.get(ICurrentUniverService);
+ handler: async (accessor: IAccessor) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
- const { destination, workbookId, worksheetId, range } = params;
- let rangeData: IRangeData = range;
- const cellValue = new ObjectMatrix<ICellData>();
- const { startRow, endRow, startColumn, endColumn } = range;
- if (destination) {
- const worksheet = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook().getSheetBySheetId(worksheetId);
- if (!worksheet) return false;
- const sheetMatrix = worksheet.getCellMatrix();
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const range = selectionManager.getCurrentSelections();
+ if (!range.length) return false;
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellValue.setValue(r - startRow, c - startColumn, sheetMatrix.getValue(r, c) || {});
- }
- }
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const cellValue = new ObjectMatrix<ICellData>();
+ for (let i = 0; i < range.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = range[i];
- rangeData = {
- startRow,
- endRow: startRow + destination.endRow - destination.startRow,
- startColumn,
- endColumn: startRow + destination.endColumn - destination.startColumn,
- };
- } else {
for (let r = startRow; r <= endRow; r++) {
for (let c = startColumn; c <= endColumn; c++) {
cellValue.setValue(r, c, { m: '', v: '' });
@@ -54,7 +41,7 @@ export const InsertRangeMoveBottomCommand: ICommand = {
}
const insertRangeMutationParams: IInsertRangeMutationParams = {
- range: rangeData,
+ range,
worksheetId,
workbookId,
shiftDimension: Dimension.ROWS,
diff --git a/packages/base-sheets/src/Commands/Commands/insert-range-move-right.command.ts b/packages/base-sheets/src/Commands/Commands/insert-range-move-right.command.ts
index a92b52cd39..8fce64d7a9 100644
--- a/packages/base-sheets/src/Commands/Commands/insert-range-move-right.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/insert-range-move-right.command.ts
@@ -1,16 +1,10 @@
import { IAccessor } from '@wendellhu/redi';
-import { CommandType, Dimension, ICellData, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
+import { CommandType, Dimension, ICellData, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
import { DeleteRangeMutation } from '../Mutations/delete-range.mutation';
import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../Mutations/insert-range.mutation';
import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';
-
-export interface IInsertRangeMoveRightParams {
- workbookId: string;
- worksheetId: string;
- range: IRangeData;
- destination?: IRangeData;
-}
+import { ISelectionManager } from '../../Services/tokens';
/**
* The command to insert range.
@@ -19,33 +13,26 @@ export const InsertRangeMoveRightCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.insert-range-move-right',
- handler: async (accessor: IAccessor, params: IInsertRangeMoveRightParams) => {
- const currentUniverService = accessor.get(ICurrentUniverService);
+ handler: async (accessor: IAccessor) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
- const { destination, workbookId, worksheetId, range } = params;
- let rangeData: IRangeData = range;
- const cellValue = new ObjectMatrix<ICellData>();
- const { startRow, endRow, startColumn, endColumn } = range;
- if (destination) {
- const worksheet = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook().getSheetBySheetId(worksheetId);
- if (!worksheet) return false;
- const sheetMatrix = worksheet.getCellMatrix();
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const range = selectionManager.getCurrentSelections();
+ if (!range.length) return false;
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellValue.setValue(r - startRow, c - startColumn, sheetMatrix.getValue(r, c) || {});
- }
- }
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const cellValue = new ObjectMatrix<ICellData>();
+ for (let i = 0; i < range.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = range[i];
- rangeData = {
- startRow,
- endRow: startRow + destination.endRow - destination.startRow,
- startColumn,
- endColumn: startRow + destination.endColumn - destination.startColumn,
- };
- } else {
for (let r = startRow; r <= endRow; r++) {
for (let c = startColumn; c <= endColumn; c++) {
cellValue.setValue(r, c, { m: '', v: '' });
@@ -54,7 +41,7 @@ export const InsertRangeMoveRightCommand: ICommand = {
}
const insertRangeMutationParams: IInsertRangeMutationParams = {
- range: rangeData,
+ range,
worksheetId,
workbookId,
shiftDimension: Dimension.COLUMNS,
diff --git a/packages/base-sheets/src/Commands/Commands/insert-range.command.ts b/packages/base-sheets/src/Commands/Commands/insert-range.command.ts
deleted file mode 100644
index 240e388a3d..0000000000
--- a/packages/base-sheets/src/Commands/Commands/insert-range.command.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import { IAccessor } from '@wendellhu/redi';
-import { CommandType, Dimension, ICellData, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
-
-import { DeleteRangeMutation } from '../Mutations/delete-range.mutation';
-import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../Mutations/insert-range.mutation';
-import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';
-
-export interface IInsertRangeParams {
- workbookId: string;
- worksheetId: string;
- range: IRangeData;
- shiftDimension: Dimension;
- destination?: IRangeData;
-}
-
-/**
- * The command to insert range.
- */
-export const InsertRangeCommand: ICommand = {
- type: CommandType.COMMAND,
- id: 'sheet.command.insert-range',
-
- handler: async (accessor: IAccessor, params: IInsertRangeParams) => {
- const currentUniverService = accessor.get(ICurrentUniverService);
- const commandService = accessor.get(ICommandService);
- const undoRedoService = accessor.get(IUndoRedoService);
-
- const { destination, workbookId, worksheetId, range, shiftDimension } = params;
- let rangeData: IRangeData = range;
- const cellValue = new ObjectMatrix<ICellData>();
- const { startRow, endRow, startColumn, endColumn } = range;
- if (destination) {
- const worksheet = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook().getSheetBySheetId(worksheetId);
- if (!worksheet) return false;
- const sheetMatrix = worksheet.getCellMatrix();
-
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellValue.setValue(r - startRow, c - startColumn, sheetMatrix.getValue(r, c) || {});
- }
- }
-
- rangeData = {
- startRow,
- endRow: startRow + destination.endRow - destination.startRow,
- startColumn,
- endColumn: startRow + destination.endColumn - destination.startColumn,
- };
- } else {
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellValue.setValue(r, c, { m: '', v: '' });
- }
- }
- }
-
- const insertRangeMutationParams: IInsertRangeMutationParams = {
- range: rangeData,
- worksheetId,
- workbookId,
- shiftDimension,
- cellValue: cellValue.getData(),
- };
-
- const deleteRangeMutationParams: IDeleteRangeMutationParams = InsertRangeUndoMutationFactory(accessor, insertRangeMutationParams);
-
- // execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(InsertRangeMutation.id, insertRangeMutationParams);
- if (result) {
- undoRedoService.pushUndoRedo({
- // 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
- // 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: 'sheet', // TODO: this URI is fake
- undo() {
- return commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
- },
- redo() {
- return commandService.executeCommand(InsertRangeMutation.id, insertRangeMutationParams);
- },
- });
-
- return true;
- }
-
- return false;
- },
- // all subsequent mutations should succeed inorder to make the whole process succeed
- // Promise.all([]).then(() => true),
-};
diff --git a/packages/base-sheets/src/Commands/Commands/insert-row-col.command.ts b/packages/base-sheets/src/Commands/Commands/insert-row-col.command.ts
index ce4402f1f0..9f1794528f 100644
--- a/packages/base-sheets/src/Commands/Commands/insert-row-col.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/insert-row-col.command.ts
@@ -1,51 +1,47 @@
-import { CommandType, ICellData, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, Nullable, ObjectMatrixPrimitiveType } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
+
import { IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';
+import { ISelectionManager } from '../../Services/tokens';
import { InsertColMutation, InsertColMutationFactory, InsertRowMutation, InsertRowMutationFactory } from '../Mutations/insert-row-col.mutation';
import { RemoveColMutation, RemoveRowMutation } from '../Mutations/remove-row-col.mutation';
-import { ISelectionManager } from '../../Services/tokens';
export interface InsertRowCommandParams {
+ rowCount: number;
+}
+
+export interface InsertRowCommandBaseParams {
workbookId: string;
worksheetId: string;
- rowIndex: number;
rowCount: number;
- insertRowData: Nullable<ObjectMatrixPrimitiveType<ICellData>>;
+ rowIndex: number;
}
-export const InsertRowCommand: ICommand = {
+const InsertRowCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.insert-row',
- handler: async (accessor: IAccessor, params?: InsertRowCommandParams) => {
- const selectionManager = accessor.get(ISelectionManager);
+ handler: async (accessor: IAccessor, params: InsertRowCommandBaseParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
- let redoMutationParams: IInsertRowMutationParams;
- if (params == null) {
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- if (!selections.length) {
- return false;
- }
- const range = selections[0];
- redoMutationParams = {
- workbookId: workbook.getUnitId(),
- worksheetId: workbook.getActiveSheet().getSheetId(),
- rowIndex: range.startRow,
- rowCount: 1,
- insertRowData: null,
- };
- } else {
- redoMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
- insertRowData: params.insertRowData,
- };
- }
+ const workbook = currentUniverService.getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+
+ const redoMutationParams: IInsertRowMutationParams = {
+ workbookId: params.workbookId,
+ worksheetId: params.worksheetId,
+ ranges: [
+ {
+ startRow: params.rowIndex,
+ endRow: params.rowIndex + params.rowCount - 1,
+ startColumn: 0,
+ endColumn: 0,
+ },
+ ],
+ };
const undoMutationParams: IRemoveRowMutationParams = InsertRowMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(InsertRowMutation.id, redoMutationParams);
if (result) {
@@ -60,51 +56,124 @@ export const InsertRowCommand: ICommand = {
});
return true;
}
- return true;
+ return false;
+ },
+};
+
+export const InsertRowBeforeCommand: ICommand<InsertRowCommandParams> = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.insert-row-before',
+ handler: async (accessor: IAccessor, params?: InsertRowCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ let range: IRangeData;
+ const selections = selectionManager.getCurrentSelections();
+ if (selections && selections.length === 1) {
+ range = selections[0];
+ } else {
+ return false;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ let count = range.endRow - range.startRow + 1;
+ if (params) {
+ count = params.rowCount;
+ }
+
+ const insertRowParams: InsertRowCommandBaseParams = {
+ workbookId,
+ worksheetId,
+ rowCount: count,
+ rowIndex: range.startRow,
+ };
+
+ return commandService.executeCommand(InsertRowCommand.id, insertRowParams);
+ },
+};
+
+export const InsertRowAfterCommand: ICommand<InsertRowCommandParams> = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.insert-row-after',
+ handler: async (accessor: IAccessor, params: InsertRowCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ let range: IRangeData;
+ const selections = selectionManager.getCurrentSelections();
+ if (selections && selections.length === 1) {
+ range = selections[0];
+ } else {
+ return false;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ let count = range.endRow - range.startRow + 1;
+ if (params) {
+ count = params.rowCount;
+ }
+
+ const insertRowParams: InsertRowCommandBaseParams = {
+ workbookId,
+ worksheetId,
+ rowCount: count,
+ rowIndex: range.endRow + 1,
+ };
+
+ return commandService.executeCommand(InsertRowCommand.id, insertRowParams);
},
};
export interface InsertColCommandParams {
+ colCount: number;
+}
+
+export interface InsertColCommandBaseParams {
colIndex: number;
colCount: number;
workbookId: string;
worksheetId: string;
- insertColData: ObjectMatrixPrimitiveType<ICellData>;
}
-export const InsertColCommand: ICommand<InsertColCommandParams> = {
+export const InsertColCommand: ICommand<InsertColCommandBaseParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.insert-col',
- handler: async (accessor: IAccessor, params?: InsertColCommandParams) => {
- const selectionManager = accessor.get(ISelectionManager);
+ handler: async (accessor: IAccessor, params: InsertColCommandBaseParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
- let redoMutationParams: IInsertColMutationParams;
- if (params == null) {
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- if (!selections.length) {
- return false;
- }
- const range = selections[0];
- redoMutationParams = {
- workbookId: workbook.getUnitId(),
- worksheetId: workbook.getActiveSheet().getSheetId(),
- colIndex: range.startColumn,
- colCount: 1,
- insertColData: null,
- };
- } else {
- redoMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- colIndex: params.colIndex,
- colCount: params.colCount,
- insertColData: params.insertColData,
- };
- }
+ const workbook = currentUniverService.getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+
+ const redoMutationParams: IInsertColMutationParams = {
+ workbookId: params.workbookId,
+ worksheetId: params.worksheetId,
+ ranges: [
+ {
+ startRow: 0,
+ endRow: 0,
+ startColumn: params.colIndex,
+ endColumn: params.colIndex + params.colCount - 1,
+ },
+ ],
+ };
const undoMutationParams: IRemoveColMutationParams = InsertColMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(InsertColMutation.id, redoMutationParams);
if (result) {
@@ -120,6 +189,82 @@ export const InsertColCommand: ICommand<InsertColCommandParams> = {
return true;
}
- return true;
+ return false;
+ },
+};
+
+export const InsertColBeforeCommand: ICommand<InsertColCommandParams> = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.insert-col-before',
+ handler: async (accessor: IAccessor, params?: InsertColCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ let range: IRangeData;
+ const selections = selectionManager.getCurrentSelections();
+ if (selections && selections.length === 1) {
+ range = selections[0];
+ } else {
+ return false;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ let count = range.endColumn - range.startColumn + 1;
+ if (params) {
+ count = params.colCount;
+ }
+
+ const insertColParams: InsertColCommandBaseParams = {
+ workbookId,
+ worksheetId,
+ colCount: count,
+ colIndex: range.startColumn,
+ };
+ return commandService.executeCommand(InsertColCommand.id, insertColParams);
+ },
+};
+
+export const InsertColAfterCommand: ICommand<InsertColCommandParams> = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.insert-col-after',
+ handler: async (accessor: IAccessor, params?: InsertColCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ let range: IRangeData;
+ const selections = selectionManager.getCurrentSelections();
+ if (selections && selections.length === 1) {
+ range = selections[0];
+ } else {
+ return false;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ let count = range.endColumn - range.startColumn + 1;
+ if (params) {
+ count = params.colCount;
+ }
+
+ const insertColParams: InsertColCommandBaseParams = {
+ workbookId,
+ worksheetId,
+ colCount: count,
+ colIndex: range.endColumn + 1,
+ };
+ return commandService.executeCommand(InsertColCommand.id, insertColParams);
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/insert-sheet.command.ts b/packages/base-sheets/src/Commands/Commands/insert-sheet.command.ts
index 81ca0c3fdc..5ad867819c 100644
--- a/packages/base-sheets/src/Commands/Commands/insert-sheet.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/insert-sheet.command.ts
@@ -1,4 +1,4 @@
-import { CommandType, ICommand, ICommandService, IUndoRedoService, IWorksheetConfig } from '@univerjs/core';
+import { CommandType, DEFAULT_WORKSHEET, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, IWorksheetConfig, Tools } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../Mutations/insert-sheet.mutation';
@@ -6,9 +6,9 @@ import { RemoveSheetMutation } from '../Mutations/remove-sheet.mutation';
import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Basics/Interfaces/MutationInterface';
export interface InsertSheetCommandParams {
- workbookId: string;
- index: number;
- sheet: IWorksheetConfig;
+ workbookId?: string;
+ index?: number;
+ sheet?: IWorksheetConfig;
}
/**
@@ -17,15 +17,39 @@ export interface InsertSheetCommandParams {
export const InsertSheetCommand: ICommand = {
id: 'sheet.command.insert-sheet',
type: CommandType.COMMAND,
- handler: async (accessor: IAccessor, params: InsertSheetCommandParams) => {
+ handler: async (accessor: IAccessor, params?: InsertSheetCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ let workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+
+ if (params) {
+ workbookId = params.workbookId ?? workbookId;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+
+ let index = workbook.getSheets().length;
+ let config = Tools.deepClone(DEFAULT_WORKSHEET);
+ if (params) {
+ index = params.index ?? index;
+ if (params.sheet) {
+ config = params.sheet;
+ } else {
+ config.id = Tools.generateRandomId();
+ config.name = `工作表${++workbook.getSheets().length}`; // Todo: 表名
+ }
+ } else {
+ config.id = Tools.generateRandomId();
+ config.name = `工作表${++workbook.getSheets().length}`; // Todo: 表名
+ }
- const { index, sheet, workbookId } = params;
// prepare do mutations
const insertSheetMutationParams: IInsertSheetMutationParams = {
index,
- sheet,
+ sheet: config,
workbookId,
};
const removeSheetMutationParams: IRemoveSheetMutationParams = InsertSheetUndoMutationFactory(accessor, insertSheetMutationParams);
diff --git a/packages/base-sheets/src/Commands/Commands/move-columns-to.command.ts b/packages/base-sheets/src/Commands/Commands/move-columns-to.command.ts
new file mode 100644
index 0000000000..0e874895eb
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/move-columns-to.command.ts
@@ -0,0 +1,90 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISelectionManager } from '../../Services/tokens';
+import { IInsertColMutationParams, IRemoveColMutationParams } from '../../Basics/Interfaces/MutationInterface';
+import { IRemoveColMutationFactory, RemoveColMutation } from '../Mutations/remove-row-col.mutation';
+import { InsertColMutation, InsertColMutationFactory } from '../Mutations/insert-row-col.mutation';
+
+export interface IMoveColumnsToCommandParams {
+ destinationIndex: number;
+}
+
+export const MoveColumnsToCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.move-columns-to',
+ handler: async (accessor: IAccessor, params: IMoveColumnsToCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const originRange = selectionManager.getCurrentSelections()[0];
+ if (!originRange) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const { startColumn, endColumn } = originRange;
+
+ const removeColumnMutationParams: IRemoveColMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges: [
+ {
+ startColumn,
+ endColumn,
+ startRow: 0,
+ endRow: 0,
+ },
+ ],
+ };
+ const undoRemoveColumnMutationParams: IInsertColMutationParams = IRemoveColMutationFactory(accessor, removeColumnMutationParams);
+
+ const removeResult = commandService.executeCommand(RemoveColMutation.id, removeColumnMutationParams);
+
+ const insertColMutationParams: IInsertColMutationParams = {
+ ...undoRemoveColumnMutationParams,
+ ranges: [
+ {
+ startColumn: params.destinationIndex,
+ endColumn: params.destinationIndex + endColumn - startColumn,
+ startRow: 0,
+ endRow: 0,
+ },
+ ],
+ };
+
+ const undoMutationParams: IRemoveColMutationParams = InsertColMutationFactory(accessor, insertColMutationParams);
+
+ const result = commandService.executeCommand(InsertColMutation.id, insertColMutationParams);
+
+ if (removeResult && result) {
+ undoRedoService.pushUndoRedo({
+ // 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
+ // 通过勾子可以 hook 外部 controller 的代码来增加新的 action
+ URI: 'sheet', // TODO: this URI is fake
+ undo() {
+ return (commandService.executeCommand(InsertColMutation.id, undoRemoveColumnMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(RemoveColMutation.id, undoMutationParams);
+ return false;
+ });
+ },
+ redo() {
+ return (commandService.executeCommand(RemoveColMutation.id, removeColumnMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(InsertColMutation.id, insertColMutationParams);
+ return false;
+ });
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/move-range-to.command.ts b/packages/base-sheets/src/Commands/Commands/move-range-to.command.ts
new file mode 100644
index 0000000000..5709c8d147
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/move-range-to.command.ts
@@ -0,0 +1,85 @@
+import { CommandType, ICellData, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetRangeValuesMutationParams, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../Mutations/set-range-values.mutation';
+import { ISelectionManager } from '../../Services/tokens';
+
+export interface IMoveRangeToCommandParams {
+ destinationRange: IRangeData;
+}
+
+export const MoveRangeToCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.move-range-to',
+ handler: async (accessor: IAccessor, params: IMoveRangeToCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const originRange = selectionManager.getCurrentSelections()[0];
+ if (!originRange) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const clearMutationParams: ISetRangeValuesMutationParams = {
+ rangeData: [originRange],
+ worksheetId,
+ };
+ const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, clearMutationParams);
+
+ const clearResult = commandService.executeCommand(SetRangeValuesMutation.id, clearMutationParams);
+
+ const sheetMatrix = worksheet.getCellMatrix();
+ const { startRow, endRow, startColumn, endColumn } = originRange;
+ const { startRow: targetStartRow, startColumn: targetStartColumn } = params.destinationRange;
+
+ const targetMatrix = new ObjectMatrix<ICellData>();
+
+ for (let r = startRow; r <= endRow; r++) {
+ for (let c = startColumn; c <= endColumn; c++) {
+ targetMatrix.setValue(targetStartRow + (r - startRow), targetStartColumn + (c - startColumn), sheetMatrix.getValue(r, c) || {});
+ }
+ }
+
+ const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {
+ rangeData: [params.destinationRange],
+ worksheetId,
+ workbookId,
+ cellValue: targetMatrix.getData(),
+ };
+
+ const undoMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams);
+
+ const result = commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+
+ if (clearResult && result) {
+ undoRedoService.pushUndoRedo({
+ // 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
+ // 通过勾子可以 hook 外部 controller 的代码来增加新的 action
+ URI: 'sheet', // TODO: this URI is fake
+ undo() {
+ return (commandService.executeCommand(SetRangeValuesMutation.id, undoClearMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetRangeValuesMutation.id, undoMutationParams);
+ return false;
+ });
+ },
+ redo() {
+ return (commandService.executeCommand(SetRangeValuesMutation.id, clearMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ return false;
+ });
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/move-rows-to.command.ts b/packages/base-sheets/src/Commands/Commands/move-rows-to.command.ts
new file mode 100644
index 0000000000..4a6dbc16e9
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/move-rows-to.command.ts
@@ -0,0 +1,90 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISelectionManager } from '../../Services/tokens';
+import { IInsertRowMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';
+import { IRemoveRowMutationFactory, RemoveRowMutation } from '../Mutations/remove-row-col.mutation';
+import { InsertRowMutation, InsertRowMutationFactory } from '../Mutations/insert-row-col.mutation';
+
+export interface IMoveRowsToCommandParams {
+ destinationIndex: number;
+}
+
+export const MoveRowsToCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.move-rows-to',
+ handler: async (accessor: IAccessor, params: IMoveRowsToCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const originRange = selectionManager.getCurrentSelections()[0];
+ if (!originRange) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const { startRow, endRow } = originRange;
+
+ const removeRowMutationParams: IRemoveRowMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges: [
+ {
+ startColumn: 0,
+ endColumn: 0,
+ startRow,
+ endRow,
+ },
+ ],
+ };
+ const undoRemoveRowMutationParams: IInsertRowMutationParams = IRemoveRowMutationFactory(accessor, removeRowMutationParams);
+
+ const removeResult = commandService.executeCommand(RemoveRowMutation.id, removeRowMutationParams);
+
+ const insertRowMutationParams: IInsertRowMutationParams = {
+ ...undoRemoveRowMutationParams,
+ ranges: [
+ {
+ startColumn: 0,
+ endColumn: 0,
+ startRow: params.destinationIndex,
+ endRow: params.destinationIndex + endRow - startRow,
+ },
+ ],
+ };
+
+ const undoMutationParams: IRemoveRowMutationParams = InsertRowMutationFactory(accessor, insertRowMutationParams);
+
+ const result = commandService.executeCommand(InsertRowMutation.id, insertRowMutationParams);
+
+ if (removeResult && result) {
+ undoRedoService.pushUndoRedo({
+ // 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
+ // 通过勾子可以 hook 外部 controller 的代码来增加新的 action
+ URI: 'sheet', // TODO: this URI is fake
+ undo() {
+ return (commandService.executeCommand(InsertRowMutation.id, undoRemoveRowMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(RemoveRowMutation.id, undoMutationParams);
+ return false;
+ });
+ },
+ redo() {
+ return (commandService.executeCommand(RemoveRowMutation.id, removeRowMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(InsertRowMutation.id, insertRowMutationParams);
+ return false;
+ });
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/remove-row-col.command.ts b/packages/base-sheets/src/Commands/Commands/remove-row-col.command.ts
index a6561f355b..f2d70249a9 100644
--- a/packages/base-sheets/src/Commands/Commands/remove-row-col.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/remove-row-col.command.ts
@@ -1,120 +1,124 @@
import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
-import { IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';
+import { IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';
import { InsertColMutation, InsertRowMutation } from '../Mutations/insert-row-col.mutation';
-import { IRemoveColMutationFactory, RemoveRowMutationFactory, RemoveColMutation, RemoveRowMutation } from '../Mutations/remove-row-col.mutation';
+import { IRemoveColMutationFactory, IRemoveRowMutationFactory, RemoveColMutation, RemoveRowMutation } from '../Mutations/remove-row-col.mutation';
import { ISelectionManager } from '../../Services/tokens';
-
-export interface RemoveRowCommandParams {
- rowIndex: number;
- rowCount: number;
- workbookId: string;
- worksheetId: string;
-}
+import { ISetRangeValuesMutationParams, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../Mutations/set-range-values.mutation';
export const RemoveRowCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.remove-row',
- handler: async (accessor: IAccessor, params?: RemoveRowCommandParams) => {
+ handler: async (accessor: IAccessor) => {
const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
- let redoMutationParams: IRemoveRowMutationParams;
- if (params == null) {
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- if (!selections.length) {
- return false;
- }
- const range = selections[0];
- redoMutationParams = {
- workbookId: workbook.getUnitId(),
- worksheetId: workbook.getActiveSheet().getSheetId(),
- rowIndex: range.startRow,
- rowCount: range.endRow - range.startRow,
- };
- } else {
- redoMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
- };
- }
+ const selections = selectionManager.getCurrentSelections();
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ if (!selections.length) return false;
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
- const undoMutationParams: IInsertRowMutationParams = RemoveRowMutationFactory(accessor, redoMutationParams);
+ const redoMutationParams: IRemoveRowMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges: selections,
+ };
+
+ const undoMutationParams: IInsertRowMutationParams = IRemoveRowMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(RemoveRowMutation.id, redoMutationParams);
- if (result) {
+
+ const removeRangeValueMutationParams: ISetRangeValuesMutationParams = {
+ workbookId,
+ worksheetId,
+ rangeData: selections,
+ };
+
+ const undoRemoveRangeValueMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, removeRangeValueMutationParams);
+ const removeResult = commandService.executeCommand(SetRangeValuesMutation.id, removeRangeValueMutationParams);
+
+ if (result && removeResult) {
undoRedoService.pushUndoRedo({
URI: 'sheet',
undo() {
- return commandService.executeCommand(InsertRowMutation.id, undoMutationParams);
+ return (commandService.executeCommand(InsertRowMutation.id, undoMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetRangeValuesMutation.id, undoRemoveRangeValueMutationParams);
+ return false;
+ });
},
redo() {
- return commandService.executeCommand(RemoveRowMutation.id, redoMutationParams);
+ return (commandService.executeCommand(RemoveRowMutation.id, redoMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetRangeValuesMutation.id, removeRangeValueMutationParams);
+ return false;
+ });
},
});
return true;
}
- return true;
+ return false;
},
};
-export interface RemoveColCommandParams {
- colIndex: number;
- colCount: number;
- workbookId: string;
- worksheetId: string;
-}
-
export const RemoveColCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.remove-col',
- handler: async (accessor: IAccessor, params?: RemoveColCommandParams) => {
+ handler: async (accessor: IAccessor) => {
const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
- let redoMutationParams: IRemoveColMutationParams;
- if (params == null) {
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- if (!selections.length) {
- return false;
- }
- const range = selections[0];
- redoMutationParams = {
- workbookId: workbook.getUnitId(),
- worksheetId: workbook.getActiveSheet().getSheetId(),
- colIndex: range.startColumn,
- colCount: range.endColumn - range.startColumn,
- };
- } else {
- redoMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- colIndex: params.colIndex,
- colCount: params.colCount,
- };
- }
- const undoMutationParams: IRemoveColMutationParams = IRemoveColMutationFactory(accessor, redoMutationParams);
+ const selections = selectionManager.getCurrentSelections();
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ if (!selections.length) return false;
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const redoMutationParams: IRemoveColMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges: selections,
+ };
+
+ const undoMutationParams: IInsertColMutationParams = IRemoveColMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(RemoveColMutation.id, redoMutationParams);
- if (result) {
+
+ const removeRangeValueMutationParams: ISetRangeValuesMutationParams = {
+ workbookId,
+ worksheetId,
+ rangeData: selections,
+ };
+
+ const undoRemoveRangeValueMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, removeRangeValueMutationParams);
+ const removeResult = commandService.executeCommand(SetRangeValuesMutation.id, removeRangeValueMutationParams);
+
+ if (result && removeResult) {
undoRedoService.pushUndoRedo({
URI: 'sheet',
undo() {
- return commandService.executeCommand(InsertColMutation.id, undoMutationParams);
+ return (commandService.executeCommand(InsertColMutation.id, undoMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetRangeValuesMutation.id, undoRemoveRangeValueMutationParams);
+ return false;
+ });
},
redo() {
- return commandService.executeCommand(RemoveColMutation.id, redoMutationParams);
+ return (commandService.executeCommand(RemoveColMutation.id, redoMutationParams) as Promise<boolean>).then((res) => {
+ if (res) commandService.executeCommand(SetRangeValuesMutation.id, removeRangeValueMutationParams);
+ return false;
+ });
},
});
return true;
}
- return true;
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/remove-sheet.command.ts b/packages/base-sheets/src/Commands/Commands/remove-sheet.command.ts
index 5ddfbe8c99..43186c69c8 100644
--- a/packages/base-sheets/src/Commands/Commands/remove-sheet.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/remove-sheet.command.ts
@@ -1,4 +1,4 @@
-import { CommandType, ICommand, ICommandService, IUndoRedoService } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from '../Mutations/remove-sheet.mutation';
@@ -6,8 +6,8 @@ import { InsertSheetMutation } from '../Mutations/insert-sheet.mutation';
import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Basics/Interfaces/MutationInterface';
export interface RemoveSheetCommandParams {
- workbookId: string;
- worksheetId: string;
+ workbookId?: string;
+ worksheetId?: string;
}
/**
@@ -16,11 +16,23 @@ export interface RemoveSheetCommandParams {
export const RemoveSheetCommand: ICommand = {
id: 'sheet.command.remove-sheet',
type: CommandType.COMMAND,
- handler: async (accessor: IAccessor, params: RemoveSheetCommandParams) => {
+ handler: async (accessor: IAccessor, params?: RemoveSheetCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ let workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ if (params) {
+ workbookId = params.workbookId ?? workbookId;
+ worksheetId = params.worksheetId ?? worksheetId;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
- const { worksheetId, workbookId } = params;
// prepare do mutations
const RemoveSheetMutationParams: IRemoveSheetMutationParams = {
worksheetId,
diff --git a/packages/base-sheets/src/Commands/Commands/remove-worksheet-merge.command.ts b/packages/base-sheets/src/Commands/Commands/remove-worksheet-merge.command.ts
index 95f2c35fc6..15afa8143a 100644
--- a/packages/base-sheets/src/Commands/Commands/remove-worksheet-merge.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/remove-worksheet-merge.command.ts
@@ -1,55 +1,38 @@
-import { CommandType, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
-import { IRemoveWorksheetMergeMutationParams } from '../../Basics/Interfaces/MutationInterface';
+import { IAddWorksheetMergeMutationParams, IRemoveWorksheetMergeMutationParams } from '../../Basics/Interfaces/MutationInterface';
import { AddWorksheetMergeMutation } from '../Mutations/add-worksheet-merge.mutation';
import { RemoveWorksheetMergeMutation, RemoveWorksheetMergeMutationFactory } from '../Mutations/remove-worksheet-merge.mutation';
import { ISelectionManager } from '../../Services/tokens';
-export interface IRemoveWorksheetMergeCommandParams {
- workbookId: string;
- worksheetId: string;
- rectangles: IRangeData[];
-}
-
export const RemoveWorksheetMergeCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.remove-worksheet-merge',
- handler: async (accessor: IAccessor, params?: IRemoveWorksheetMergeCommandParams) => {
+ handler: async (accessor: IAccessor) => {
const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
- let redoMutationParams: IRemoveWorksheetMergeMutationParams;
- if (params == null) {
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- if (!selections.length) {
- return false;
- }
- const range = selections[0];
- redoMutationParams = {
- workbookId: workbook.getUnitId(),
- worksheetId: workbook.getActiveSheet().getSheetId(),
- rectangles: [
- {
- startRow: range.startRow,
- startColumn: range.startColumn,
- endRow: range.endRow,
- endColumn: range.endColumn,
- },
- ],
- };
- } else {
- redoMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- rectangles: params.rectangles,
- };
- }
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges: selections,
+ };
+
+ const undoMutationParams: IAddWorksheetMergeMutationParams = RemoveWorksheetMergeMutationFactory(accessor, removeMergeMutationParams);
+ const result = commandService.executeCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams);
- const undoMutationParams: IRemoveWorksheetMergeMutationParams = RemoveWorksheetMergeMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(RemoveWorksheetMergeMutation.id, redoMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: 'sheet',
@@ -57,7 +40,7 @@ export const RemoveWorksheetMergeCommand: ICommand = {
return commandService.executeCommand(AddWorksheetMergeMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(RemoveWorksheetMergeMutation.id, redoMutationParams);
+ return commandService.executeCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams);
},
});
return true;
diff --git a/packages/base-sheets/src/Commands/Commands/set-border-styles-command.ts b/packages/base-sheets/src/Commands/Commands/set-border-styles-command.ts
new file mode 100644
index 0000000000..784ffb94e1
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-border-styles-command.ts
@@ -0,0 +1,331 @@
+import {
+ BorderStyleTypes,
+ CommandType,
+ IBorderStyleData,
+ ICommand,
+ ICommandService,
+ ICurrentUniverService,
+ IRangeData,
+ IStyleData,
+ IUndoRedoService,
+ Nullable,
+ ObjectMatrix,
+ Tools,
+} from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetBorderStylesMutationParams, SetBorderStylesMutation, SetBorderStylesUndoMutationFactory } from '../Mutations/set-border-styles.mutatio';
+import { ISelectionManager } from '../../Services/tokens';
+
+export interface ISetBorderCommandParams {
+ workbookId?: string;
+ worksheetId?: string;
+ range?: IRangeData;
+ top?: Nullable<boolean>;
+ left?: Nullable<boolean>;
+ bottom?: Nullable<boolean>;
+ right?: Nullable<boolean>;
+ vertical?: Nullable<boolean>;
+ horizontal?: Nullable<boolean>;
+ color?: string;
+ style?: BorderStyleTypes;
+}
+
+function forEach(rangeData: IRangeData, action: (row: number, column: number) => void): void {
+ const { startRow, startColumn, endRow, endColumn } = rangeData;
+ for (let i = startRow; i <= endRow; i++) {
+ for (let j = startColumn; j <= endColumn; j++) {
+ action(i, j);
+ }
+ }
+}
+
+/**
+ * The command to clear content in current selected ranges.
+ */
+export const SetBorderStylesCommand: ICommand = {
+ id: 'sheet.command.set-border-styles',
+ type: CommandType.COMMAND,
+ // eslint-disable-next-line max-lines-per-function
+ handler: async (accessor: IAccessor, params: ISetBorderCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const range = params.range || selectionManager.getCurrentSelections()[0];
+ if (!range) {
+ return false;
+ }
+
+ const { top = null, left = null, bottom = null, right = null, vertical = null, horizontal = null, color = 'black', style = BorderStyleTypes.DASH_DOT } = params;
+
+ const workbookId = params.workbookId || currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = params.worksheetId || currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+ const sheetMatrix = worksheet.getCellMatrix();
+ const styles = workbook.getStyles();
+ const rangeData = range;
+
+ // Cells in the surrounding range may need to clear the border
+ const topRangeOut = {
+ startRow: rangeData.startRow - 1,
+ startColumn: rangeData.startColumn,
+ endRow: rangeData.startRow - 1,
+ endColumn: rangeData.endColumn,
+ };
+
+ const leftRangeOut = {
+ startRow: rangeData.startRow,
+ startColumn: rangeData.startColumn - 1,
+ endRow: rangeData.endRow,
+ endColumn: rangeData.startColumn - 1,
+ };
+
+ const bottomRangeOut = {
+ startRow: rangeData.endRow + 1,
+ startColumn: rangeData.startColumn,
+ endRow: rangeData.endRow + 1,
+ endColumn: rangeData.endColumn,
+ };
+
+ const rightRangeOut = {
+ startRow: rangeData.startRow,
+ startColumn: rangeData.endColumn + 1,
+ endRow: rangeData.endRow,
+ endColumn: rangeData.endColumn + 1,
+ };
+
+ // Cells in the upper, lower, left and right ranges
+ const topRange = {
+ startRow: rangeData.startRow,
+ startColumn: rangeData.startColumn,
+ endRow: rangeData.startRow,
+ endColumn: rangeData.endColumn,
+ };
+
+ const leftRange = {
+ startRow: rangeData.startRow,
+ startColumn: rangeData.startColumn,
+ endRow: rangeData.endRow,
+ endColumn: rangeData.startColumn,
+ };
+
+ const bottomRange = {
+ startRow: rangeData.endRow,
+ startColumn: rangeData.startColumn,
+ endRow: rangeData.endRow,
+ endColumn: rangeData.endColumn,
+ };
+
+ const rightRange = {
+ startRow: rangeData.startRow,
+ startColumn: rangeData.endColumn,
+ endRow: rangeData.endRow,
+ endColumn: rangeData.endColumn,
+ };
+
+ const mr = new ObjectMatrix<IStyleData>();
+
+ const border: IBorderStyleData = {
+ s: style,
+ cl: {
+ rgb: color,
+ },
+ };
+
+ if (top === true || top === false || top === null) {
+ // Probably to the border, there are no surrounding cells
+ // Clear the bottom border of the top range
+ forEach(topRangeOut, (row, column) => {
+ mr.setValue(row, column, { bd: { b: null } });
+ });
+
+ // first row
+ forEach(topRange, (row, column) => {
+ // update
+ if (top === true) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { t: Tools.deepClone(border) },
+ });
+ mr.setValue(row, column, style);
+ }
+ // delete
+ else if (top === false) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { t: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ });
+ }
+ if (bottom === true || bottom === false || bottom === null) {
+ // Probably to the border, there are no surrounding cells
+ // Clear the top border of the lower range
+ forEach(bottomRangeOut, (row, column) => {
+ mr.setValue(row, column, { bd: { t: null } });
+ });
+
+ // the last row
+ forEach(bottomRange, (row, column) => {
+ // update
+ if (bottom === true) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { b: Tools.deepClone(border) },
+ });
+ mr.setValue(row, column, style);
+ }
+ // delete
+ else if (bottom === false) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { b: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ });
+ }
+ if (left === true || left === false || left === null) {
+ // Probably to the border, there are no surrounding cells
+ // Clear the right border of the left range
+ forEach(leftRangeOut, (row, column) => {
+ mr.setValue(row, column, { bd: { r: null } });
+ });
+
+ // first column
+ forEach(leftRange, (row, column) => {
+ // update
+ if (left === true) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { l: Tools.deepClone(border) },
+ });
+ mr.setValue(row, column, style);
+ }
+ // delete
+ else if (left === false) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { l: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ });
+ }
+ if (right === true || right === false || right === null) {
+ // Probably to the border, there are no surrounding cells
+ // Clear the left border of the right range
+ forEach(rightRangeOut, (row, column) => {
+ mr.setValue(row, column, { bd: { l: null } });
+ });
+
+ // last column
+ forEach(rightRange, (row, column) => {
+ // update
+ if (right === true) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { r: Tools.deepClone(border) },
+ });
+ mr.setValue(row, column, style);
+ }
+ // delete
+ else if (right === false) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { r: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ });
+ }
+
+ // inner vertical border
+ if (vertical === true || vertical === false) {
+ // current range
+ forEach(rangeData, (row, column) => {
+ // Set the right border except the last column
+ if (column !== rangeData.endColumn) {
+ // update
+ if (vertical === true) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { r: Tools.deepClone(border) },
+ });
+ mr.setValue(row, column, style);
+ }
+ // delete
+ else if (vertical === false) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { r: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ }
+
+ // Except for the first column, clear the left border
+ if (column !== rangeData.startColumn) {
+ const style = Tools.deepMerge(Tools.deepClone(styles.get(sheetMatrix.getValue(row, column)?.s)) || {}, {
+ bd: { l: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ });
+ }
+ // inner horizontal border
+ if (horizontal === true || horizontal === false) {
+ // current range
+ forEach(rangeData, (row, column) => {
+ // Except for the last row, set the bottom border
+ if (row !== rangeData.endRow) {
+ // update
+ if (horizontal === true) {
+ const style = Tools.deepMerge(styles.get(sheetMatrix.getValue(row, column)?.s) || {}, {
+ bd: { b: Tools.deepClone(border) },
+ });
+ mr.setValue(row, column, style);
+ }
+ // delete
+ else if (horizontal === false) {
+ const style = Tools.deepMerge(styles.get(sheetMatrix.getValue(row, column)?.s) || {}, {
+ bd: { b: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ }
+
+ // Except for the first row, clear the top border
+ if (row !== rangeData.startRow) {
+ const style = Tools.deepMerge(styles.get(sheetMatrix.getValue(row, column)?.s) || {}, {
+ bd: { t: null },
+ });
+ mr.setValue(row, column, style);
+ }
+ });
+ }
+
+ const setBorderStylesMutationParams: ISetBorderStylesMutationParams = {
+ workbookId,
+ worksheetId,
+ value: mr.getData(),
+ };
+ const undoSetBorderStylesMutationParams: ISetBorderStylesMutationParams = SetBorderStylesUndoMutationFactory(accessor, setBorderStylesMutationParams);
+
+ // execute do mutations and add undo mutations to undo stack if completed
+ const result = commandService.executeCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ // 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
+ // 通过勾子可以 hook 外部 controller 的代码来增加新的 action
+ URI: 'sheet', // TODO: this URI is fake
+ undo() {
+ return commandService.executeCommand(SetBorderStylesMutation.id, undoSetBorderStylesMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
+ },
+ });
+
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/set-hide-gridlines.command.ts b/packages/base-sheets/src/Commands/Commands/set-hide-gridlines.command.ts
new file mode 100644
index 0000000000..63dac7f8fa
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-hide-gridlines.command.ts
@@ -0,0 +1,59 @@
+import { BooleanNumber, CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetHideGridlinesMutationParams, SetHideGridlinesMutation, SetHideGridlinesUndoMutationFactory } from '../Mutations/set-hide-gridlines.mutatiom';
+
+export interface ISetHideGridlinesCommandParams {
+ hideGridlines?: BooleanNumber;
+ workbookId?: string;
+ worksheetId?: string;
+}
+
+export const SetHideGridlinesCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.set-hide-gridlines',
+
+ handler: async (accessor: IAccessor, params?: ISetHideGridlinesCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ let workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ let hideGridlines = BooleanNumber.FALSE;
+
+ if (params) {
+ workbookId = params.workbookId ?? workbookId;
+ worksheetId = params.worksheetId ?? workbookId;
+ hideGridlines = params.hideGridlines ?? BooleanNumber.FALSE;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const setHideGridlinesMutationParams: ISetHideGridlinesMutationParams = {
+ hideGridlines,
+ workbookId,
+ worksheetId,
+ };
+
+ const undoMutationParams = SetHideGridlinesUndoMutationFactory(accessor, setHideGridlinesMutationParams);
+ const result = commandService.executeCommand(SetHideGridlinesMutation.id, setHideGridlinesMutationParams);
+
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetHideGridlinesMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetHideGridlinesMutation.id, setHideGridlinesMutationParams);
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/set-range-formatted-value.command.ts b/packages/base-sheets/src/Commands/Commands/set-range-formatted-value.command.ts
index 19e6ebb4ae..671c76e2b4 100644
--- a/packages/base-sheets/src/Commands/Commands/set-range-formatted-value.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-range-formatted-value.command.ts
@@ -1,13 +1,11 @@
import { IAccessor } from '@wendellhu/redi';
-import { CommandType, ICellV, ICommand, ICommandService, IRangeData, IUndoRedoService, ObjectMatrix, Tools } from '@univerjs/core';
+import { CommandType, ICellV, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, ObjectMatrix, Tools } from '@univerjs/core';
import { ISetRangeFormattedValueMutationParams, SetRangeFormattedValueMutation, SetRangeFormattedValueUndoMutationFactory } from '../Mutations/set-range-formatted-value.mutation';
+import { ISelectionManager } from '../../Services/tokens';
export interface ISetRangeFormattedValueParams {
- range: IRangeData[];
value: ICellV | ICellV[][] | ObjectMatrix<ICellV>;
- workbookId: string;
- worksheetId: string;
}
/**
@@ -20,11 +18,26 @@ export const SetRangeFormattedValueCommand: ICommand = {
handler: async (accessor: IAccessor, params: ISetRangeFormattedValueParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
+
+ const ranges = selectionManager.getCurrentSelections();
+ if (!ranges.length) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
let cellValue = new ObjectMatrix<ICellV>();
const value = params.value;
- for (let i = 0; i < params.range.length; i++) {
- const rangeData = params.range[i];
+ for (let i = 0; i < ranges.length; i++) {
+ const rangeData = ranges[i];
const { startRow, startColumn, endRow, endColumn } = rangeData;
if (Tools.isArray(value)) {
for (let r = 0; r <= endRow - startRow; r++) {
@@ -44,9 +57,9 @@ export const SetRangeFormattedValueCommand: ICommand = {
}
const setRangeFormattedValueMutationParams: ISetRangeFormattedValueMutationParams = {
- range: params.range,
- worksheetId: params.worksheetId,
- workbookId: params.workbookId,
+ range: ranges,
+ worksheetId,
+ workbookId,
value: cellValue.getData(),
};
diff --git a/packages/base-sheets/src/Commands/Commands/set-range-values.command.ts b/packages/base-sheets/src/Commands/Commands/set-range-values.command.ts
index b5e3b6ba02..637fea2fd7 100644
--- a/packages/base-sheets/src/Commands/Commands/set-range-values.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-range-values.command.ts
@@ -1,11 +1,11 @@
-import { CommandType, ICellData, ICommand, ICommandService, IRangeData, IUndoRedoService, ObjectMatrix, ObjectMatrixPrimitiveType, Tools } from '@univerjs/core';
+import { CommandType, ICellData, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, ObjectMatrix, ObjectMatrixPrimitiveType, Tools } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { ISetRangeValuesMutationParams, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../Mutations/set-range-values.mutation';
+import { ISelectionManager } from '../../Services/tokens';
export interface ISetRangeValuesCommandParams {
- worksheetId: string;
- workbookId: string;
- range: IRangeData;
+ worksheetId?: string;
+ workbookId?: string;
value: ICellData | ICellData[][] | ObjectMatrixPrimitiveType<ICellData>;
}
@@ -18,21 +18,33 @@ export const SetRangeValuesCommand: ICommand = {
handler: async (accessor: IAccessor, params: ISetRangeValuesCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const selectionManager = accessor.get(ISelectionManager);
- const { range, value, workbookId, worksheetId } = params;
- const { startRow, startColumn, endRow, endColumn } = range;
+ const range = selectionManager.getCurrentSelections();
+ if (!range.length) {
+ return false;
+ }
+
+ const workbookId = params.workbookId || currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = params.worksheetId || currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ const { value } = params;
let cellValue = new ObjectMatrix<ICellData>();
- if (Tools.isArray(value)) {
- for (let r = 0; r <= endRow - startRow; r++) {
- for (let c = 0; c <= endColumn - startColumn; c++) {
- cellValue.setValue(r + startRow, c + startColumn, value[r][c]);
+ for (let i = 0; i < range.length; i++) {
+ const { startRow, startColumn, endRow, endColumn } = range[i];
+ if (Tools.isArray(value)) {
+ for (let r = 0; r <= endRow - startRow; r++) {
+ for (let c = 0; c <= endColumn - startColumn; c++) {
+ cellValue.setValue(r + startRow, c + startColumn, value[r][c]);
+ }
}
+ } else if (Tools.isObject(value)) {
+ cellValue = value as ObjectMatrix<ICellData>;
+ } else {
+ cellValue.setValue(startRow, startColumn, value);
}
- } else if (Tools.isObject(value)) {
- cellValue = value as ObjectMatrix<ICellData>;
- } else {
- cellValue.setValue(startRow, startColumn, value);
}
const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {
diff --git a/packages/base-sheets/src/Commands/Commands/set-style.command.ts b/packages/base-sheets/src/Commands/Commands/set-style.command.ts
index 4740212b04..a09b48af41 100644
--- a/packages/base-sheets/src/Commands/Commands/set-style.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-style.command.ts
@@ -9,7 +9,6 @@ import {
ICommand,
ICommandService,
ICurrentUniverService,
- IRangeData,
IStyleData,
ITextRotation,
IUndoRedoService,
@@ -30,10 +29,6 @@ export interface IStyleTypeValue<T> {
export interface ISetStyleParams<T> {
style: IStyleTypeValue<T>;
-
- ranges?: IRangeData[];
- workbookId?: string;
- worksheetId?: string;
}
// TODO: @wzhudev: move parameters logic from BasicWorksheetController to here. 30th Aug.
@@ -52,15 +47,20 @@ export const SetStyleCommand: ICommand<ISetStyleParams<unknown>> = {
const selectionManager = accessor.get(ISelectionManager);
const currentUniverService = accessor.get(ICurrentUniverService);
- const ranges = params.ranges || selectionManager.getCurrentSelections();
- if (!ranges) {
+ const ranges = selectionManager.getCurrentSelections();
+ if (!ranges.length) {
return false;
}
- const workbookId = params.workbookId || currentUniverService.getCurrentUniverSheetInstance().getUnitId();
- const worksheetId = params.worksheetId || currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
const style = params.style;
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
let value: ObjectMatrixPrimitiveType<IStyleData>;
for (let i = 0; i < ranges.length; i++) {
const { startRow, endRow, startColumn, endColumn } = ranges[i];
diff --git a/packages/base-sheets/src/Commands/Commands/set-tab-color.command.ts b/packages/base-sheets/src/Commands/Commands/set-tab-color.command.ts
new file mode 100644
index 0000000000..a2c25f439d
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-tab-color.command.ts
@@ -0,0 +1,50 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetTabColorMutationParams, SetTabColorMutation, SetTabColorUndoMutationFactory } from '../Mutations/set-tab-color.mutation';
+
+export interface ISetTabColorCommandParams {
+ color: string;
+}
+
+export const SetTabColorCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.set-tab-color',
+
+ handler: async (accessor: IAccessor, params: ISetTabColorCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const setTabColorMutationParams: ISetTabColorMutationParams = {
+ color: params.color,
+ workbookId,
+ worksheetId,
+ };
+
+ const undoMutationParams = SetTabColorUndoMutationFactory(accessor, setTabColorMutationParams);
+ const result = commandService.executeCommand(SetTabColorMutation.id, setTabColorMutationParams);
+
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetTabColorMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetTabColorMutation.id, setTabColorMutationParams);
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-activate.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-activate.command.ts
index d1c04ac071..da8a3274f4 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-activate.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-activate.command.ts
@@ -1,25 +1,34 @@
-import { CommandType, ICommand, ICommandService, IUndoRedoService } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
-import { ISetWorksheetActivateMutationParams, SetWorksheetActivateMutation, SetWorksheetActivateMutationFactory } from '../Mutations/set-worksheet-activate.mutation';
+import { ISetWorksheetActivateMutationParams, SetWorksheetActivateMutation, SetWorksheetUnActivateMutationFactory } from '../Mutations/set-worksheet-activate.mutation';
export interface ISetWorksheetActivateCommandParams {
- workbookId: string;
- worksheetId: string;
+ workbookId?: string;
+ worksheetId?: string;
}
export const SetWorksheetActivateCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.set-worksheet-activate',
- handler: async (accessor: IAccessor, params: ISetWorksheetActivateCommandParams) => {
+ handler: async (accessor: IAccessor, params?: ISetWorksheetActivateCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ let workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ if (params) {
+ workbookId = params.workbookId ?? workbookId;
+ worksheetId = params.worksheetId ?? worksheetId;
+ }
const redoMutationParams: ISetWorksheetActivateMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
+ workbookId,
+ worksheetId,
};
- const undoMutationParams = SetWorksheetActivateMutationFactory(accessor, redoMutationParams);
+ const undoMutationParams = SetWorksheetUnActivateMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(SetWorksheetActivateMutation.id, redoMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-col-width.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-col-width.command.ts
index c9e30bc3d2..c8c58c889a 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-col-width.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-col-width.command.ts
@@ -7,10 +7,7 @@ import { ISelectionManager } from '../../Services/tokens';
* TODO@Dushusir 支持多个选区
*/
export interface SetWorksheetColWidthCommandParams {
- workbookId?: string;
- worksheetId?: string;
- colIndex?: number;
- value: number | number[];
+ colWidth: number;
}
export const SetWorksheetColWidthCommand: ICommand = {
@@ -21,35 +18,17 @@ export const SetWorksheetColWidthCommand: ICommand = {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- const range = selections[0];
-
- let { worksheetId, workbookId, colIndex, value } = params || {};
- if (!workbookId) {
- workbookId = workbook.getUnitId();
- }
-
- if (!worksheetId) {
- worksheetId = workbook.getActiveSheet().getSheetId();
- }
- if (!colIndex) {
- colIndex = range.startColumn;
- }
-
- if (!Array.isArray(value)) {
- if (typeof value === 'object') {
- value = 1;
- }
- value = new Array(range.endColumn - range.startColumn + 1).fill(value);
- }
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
const redoMutationParams: ISetWorksheetColWidthMutationParams = {
worksheetId,
workbookId,
- colIndex,
- colWidth: value,
+ ranges: selections,
+ colWidth: params.colWidth,
};
const undoMutationParams: ISetWorksheetColWidthMutationParams = SetWorksheetColWidthMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(SetWorksheetColWidthMutation.id, redoMutationParams);
@@ -66,6 +45,6 @@ export const SetWorksheetColWidthCommand: ICommand = {
return true;
}
- return true;
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-column-hide.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-column-hide.command.ts
new file mode 100644
index 0000000000..d30e2726e1
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-column-hide.command.ts
@@ -0,0 +1,51 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetWorksheetColumnHideMutationParams, SetWorksheetColumnHideMutation, SetWorksheetColumnHideMutationFactory } from '../Mutations/set-worksheet-column-hide.mutation';
+import { SetWorksheetColumnShowMutation } from '../Mutations/set-worksheet-column-show.mutation';
+import { ISelectionManager } from '../../Services/tokens';
+
+export const SetWorksheetColumnHideCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.set-worksheet-column-hide',
+ handler: async (accessor: IAccessor) => {
+ const selectionManager = accessor.get(ISelectionManager);
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const redoMutationParams: ISetWorksheetColumnHideMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges: selections,
+ };
+
+ const undoMutationParams = SetWorksheetColumnHideMutationFactory(accessor, redoMutationParams);
+ const result = commandService.executeCommand(SetWorksheetColumnHideMutation.id, redoMutationParams);
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetWorksheetColumnShowMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetWorksheetColumnHideMutation.id, redoMutationParams);
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-column-show.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-column-show.command.ts
new file mode 100644
index 0000000000..63f705b08e
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-column-show.command.ts
@@ -0,0 +1,52 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetWorksheetColumnShowMutationParams, SetWorksheetColumnShowMutation, SetWorksheetColumnShowMutationFactory } from '../Mutations/set-worksheet-column-show.mutation';
+import { SetWorksheetColumnHideMutation } from '../Mutations/set-worksheet-column-hide.mutation';
+import { ISelectionManager } from '../../Services/tokens';
+
+export const SetWorksheetColumnShowCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.set-worksheet-column-show',
+ handler: async (accessor: IAccessor) => {
+ const selectionManager = accessor.get(ISelectionManager);
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const redoMutationParams: ISetWorksheetColumnShowMutationParams = {
+ workbookId,
+ worksheetId,
+ ranges: selections,
+ };
+
+ const undoMutationParams = SetWorksheetColumnShowMutationFactory(accessor, redoMutationParams);
+ const result = commandService.executeCommand(SetWorksheetColumnShowMutation.id, redoMutationParams);
+
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetWorksheetColumnHideMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetWorksheetColumnShowMutation.id, redoMutationParams);
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-hide.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-hide.command.ts
index ce2ca45733..70e9905038 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-hide.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-hide.command.ts
@@ -1,25 +1,39 @@
-import { BooleanNumber, CommandType, ICommand, ICommandService, IUndoRedoService } from '@univerjs/core';
+import { BooleanNumber, CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { ISetWorksheetHideMutationParams, SetWorksheetHideMutation, SetWorksheetHideMutationFactory } from '../Mutations/set-worksheet-hide.mutation';
export interface ISetWorksheetHiddenCommandParams {
- hidden: BooleanNumber;
- workbookId: string;
- worksheetId: string;
+ worksheetId?: string;
}
export const SetWorksheetHideCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.set-worksheet-hidden',
- handler: async (accessor: IAccessor, params: ISetWorksheetHiddenCommandParams) => {
+ handler: async (accessor: IAccessor, params?: ISetWorksheetHiddenCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ if (params) {
+ worksheetId = params.worksheetId ?? worksheetId;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const hidden = worksheet.getConfig().hidden;
+ if (hidden === BooleanNumber.TRUE) return false;
const redoMutationParams: ISetWorksheetHideMutationParams = {
- hidden: params.hidden,
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
+ workbookId,
+ worksheetId,
+ hidden: BooleanNumber.TRUE,
};
const undoMutationParams = SetWorksheetHideMutationFactory(accessor, redoMutationParams);
@@ -37,6 +51,7 @@ export const SetWorksheetHideCommand: ICommand = {
});
return true;
}
- return true;
+
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-name.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-name.command.ts
index e50ec9ecf8..9d69d74691 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-name.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-name.command.ts
@@ -1,15 +1,15 @@
-import { CommandType, ICommand, ICommandService, IUndoRedoService } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { ISetWorksheetNameMutationParams, SetWorksheetNameMutation, SetWorksheetNameMutationFactory } from '../Mutations/set-worksheet-name.mutation';
export interface SetWorksheetNameCommandParams {
name: string;
- worksheetId: string;
- workbookId: string;
+ worksheetId?: string;
+ workbookId?: string;
}
/**
- * The command to insert a row into a worksheet.
+ * The command to set the sheet name.
*/
export const SetWorksheetNameCommand: ICommand = {
type: CommandType.COMMAND,
@@ -18,14 +18,19 @@ export const SetWorksheetNameCommand: ICommand = {
handler: async (accessor: IAccessor, params: SetWorksheetNameCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const workbookId = params.workbookId || currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = params.worksheetId || currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
const redoMutationParams: ISetWorksheetNameMutationParams = {
- worksheetId: params.worksheetId,
+ worksheetId,
name: params.name,
- workbookId: params.workbookId,
+ workbookId,
};
const undoMutationParams: ISetWorksheetNameMutationParams = SetWorksheetNameMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(SetWorksheetNameMutation.id, redoMutationParams);
+
if (result) {
undoRedoService.pushUndoRedo({
URI: 'sheet',
@@ -39,6 +44,7 @@ export const SetWorksheetNameCommand: ICommand = {
return true;
}
- return true;
+
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-order.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-order.command.ts
index d18a39ea9e..0c4fbf9065 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-order.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-order.command.ts
@@ -1,27 +1,39 @@
-import { CommandType, ICommand, ICommandService, IUndoRedoService } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
-import { ISetWorksheetOrderMutationParams, SetWorksheetOrderMutation, SetWorksheetOrderMutationFactory } from '../Mutations/set-worksheet-order.mutation';
+import { ISetWorksheetOrderMutationParams, SetWorksheetOrderMutation, SetWorksheetOrderUndoMutationFactory } from '../Mutations/set-worksheet-order.mutation';
-export interface SetWorksheetOrderCommandParams {
- workbookId: string;
- worksheetId: string;
+export interface ISetWorksheetOrderCommandParams {
order: number;
+ workbookId?: string;
+ worksheetId?: string;
}
export const SetWorksheetOrderCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.set-worksheet-order',
- handler: async (accessor: IAccessor, params: SetWorksheetOrderCommandParams) => {
+
+ handler: async (accessor: IAccessor, params: ISetWorksheetOrderCommandParams) => {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const workbookId = params.workbookId || currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = params.worksheetId || currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
- const redoMutationParams: ISetWorksheetOrderMutationParams = {
- worksheetId: params.worksheetId,
- workbookId: params.workbookId,
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const setWorksheetOrderMutationParams: ISetWorksheetOrderMutationParams = {
order: params.order,
+ workbookId,
+ worksheetId,
};
- const undoMutationParams: ISetWorksheetOrderMutationParams = SetWorksheetOrderMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(SetWorksheetOrderMutation.id, redoMutationParams);
+
+ const undoMutationParams = SetWorksheetOrderUndoMutationFactory(accessor, setWorksheetOrderMutationParams);
+ const result = commandService.executeCommand(SetWorksheetOrderMutation.id, setWorksheetOrderMutationParams);
+
if (result) {
undoRedoService.pushUndoRedo({
URI: 'sheet',
@@ -29,12 +41,12 @@ export const SetWorksheetOrderCommand: ICommand = {
return commandService.executeCommand(SetWorksheetOrderMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetWorksheetOrderMutation.id, redoMutationParams);
+ return commandService.executeCommand(SetWorksheetOrderMutation.id, setWorksheetOrderMutationParams);
},
});
-
return true;
}
- return true;
+
+ return false;
},
};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-right-to-left.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-right-to-left.command.ts
new file mode 100644
index 0000000000..ae54dd7b1e
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-right-to-left.command.ts
@@ -0,0 +1,63 @@
+import { BooleanNumber, CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import {
+ ISetWorksheetRightToLeftMutationParams,
+ SetWorksheetRightToLeftMutation,
+ SetWorksheetRightToLeftUndoMutationFactory,
+} from '../Mutations/set-worksheet-right-to-left.mutation';
+
+export interface ISetWorksheetRightToLeftCommandParams {
+ rightToLeft?: BooleanNumber;
+ workbookId?: string;
+ worksheetId?: string;
+}
+
+export const SetWorksheetRightToLeftCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.set-worksheet-right-to-left',
+
+ handler: async (accessor: IAccessor, params?: ISetWorksheetRightToLeftCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ let workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ let rightToLeft = BooleanNumber.FALSE;
+
+ if (params) {
+ workbookId = params.workbookId ?? workbookId;
+ worksheetId = params.worksheetId ?? worksheetId;
+ rightToLeft = params.rightToLeft ?? BooleanNumber.FALSE;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const setWorksheetRightToLeftMutationParams: ISetWorksheetRightToLeftMutationParams = {
+ rightToLeft,
+ workbookId,
+ worksheetId,
+ };
+
+ const undoMutationParams = SetWorksheetRightToLeftUndoMutationFactory(accessor, setWorksheetRightToLeftMutationParams);
+ const result = commandService.executeCommand(SetWorksheetRightToLeftMutation.id, setWorksheetRightToLeftMutationParams);
+
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetWorksheetRightToLeftMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetWorksheetRightToLeftMutation.id, setWorksheetRightToLeftMutationParams);
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-height.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-row-height.command.ts
index c9d8311d1e..80e1252835 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-height.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-row-height.command.ts
@@ -7,10 +7,7 @@ import { ISelectionManager } from '../../Services/tokens';
* TODO@Dushusir 支持多个选区
*/
export interface SetWorksheetRowHeightCommandParams {
- workbookId?: string;
- worksheetId?: string;
- rowIndex?: number;
- value: number | number[] | string | string[];
+ rowHeight: number;
}
export const SetWorksheetRowHeightCommand: ICommand = {
@@ -21,36 +18,18 @@ export const SetWorksheetRowHeightCommand: ICommand = {
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const currentUniverService = accessor.get(ICurrentUniverService);
- const selections = selectionManager.getCurrentSelections();
- const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- const range = selections[0];
-
- let { worksheetId, workbookId, rowIndex, value } = params;
- if (!workbookId) {
- workbookId = workbook.getUnitId();
- }
-
- if (!worksheetId) {
- worksheetId = workbook.getActiveSheet().getSheetId();
- }
- if (!rowIndex) {
- rowIndex = range.startRow;
- }
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
- if (!Array.isArray(value)) {
- if (typeof value === 'object') {
- value = 1;
- }
- value = new Array(range.endRow - range.startRow + 1).fill(value);
- }
- value = value.map((v) => (typeof v === 'string' ? parseInt(v, 10) : v));
const redoMutationParams: ISetWorksheetRowHeightMutationParams = {
worksheetId,
workbookId,
- rowIndex,
- rowHeight: value as number[],
+ ranges: selections,
+ rowHeight: params.rowHeight,
};
const undoMutationParams: ISetWorksheetRowHeightMutationParams = SetWorksheetRowHeightMutationFactory(accessor, redoMutationParams);
const result = commandService.executeCommand(SetWorksheetRowHeightMutation.id, redoMutationParams);
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-hide.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-row-hide.command.ts
index 1d29d013df..fab197dc51 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-hide.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-row-hide.command.ts
@@ -1,27 +1,34 @@
-import { CommandType, ICommand, ICommandService, IUndoRedoService } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { ISetWorksheetRowHideMutationParams, SetWorksheetRowHideMutation, SetWorksheetRowHideMutationFactory } from '../Mutations/set-worksheet-row-hide.mutation';
import { SetWorksheetRowShowMutation } from '../Mutations/set-worksheet-row-show.mutation';
-
-export interface SetWorksheetRowHideCommandParams {
- workbookId: string;
- worksheetId: string;
- rowIndex: number;
- rowCount: number;
-}
+import { ISelectionManager } from '../../Services/tokens';
export const SetWorksheetRowHideCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.set-worksheet-row-hide',
- handler: async (accessor: IAccessor, params: SetWorksheetRowHideCommandParams) => {
+ handler: async (accessor: IAccessor) => {
+ const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
const redoMutationParams: ISetWorksheetRowHideMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
+ workbookId,
+ worksheetId,
+ ranges: selections,
};
const undoMutationParams = SetWorksheetRowHideMutationFactory(accessor, redoMutationParams);
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-show.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-row-show.command.ts
index 76dbced47d..a2074e9d1e 100644
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-show.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-row-show.command.ts
@@ -1,27 +1,34 @@
-import { CommandType, ICommand, ICommandService, IUndoRedoService } from '@univerjs/core';
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { ISetWorksheetRowShowMutationParams, SetWorksheetRowShowMutation, SetWorksheetRowShowMutationFactory } from '../Mutations/set-worksheet-row-show.mutation';
import { SetWorksheetRowHideMutation } from '../Mutations/set-worksheet-row-hide.mutation';
-
-export interface SetWorksheetRowShowCommandParams {
- workbookId: string;
- worksheetId: string;
- rowIndex: number;
- rowCount: number;
-}
+import { ISelectionManager } from '../../Services/tokens';
export const SetWorksheetRowShowCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.set-worksheet-row-show',
- handler: async (accessor: IAccessor, params: SetWorksheetRowShowCommandParams) => {
+ handler: async (accessor: IAccessor) => {
+ const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) {
+ return false;
+ }
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
const redoMutationParams: ISetWorksheetRowShowMutationParams = {
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
+ workbookId,
+ worksheetId,
+ ranges: selections,
};
const undoMutationParams = SetWorksheetRowShowMutationFactory(accessor, redoMutationParams);
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-show.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-show.command.ts
new file mode 100644
index 0000000000..89bd004e4d
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-worksheet-show.command.ts
@@ -0,0 +1,57 @@
+import { BooleanNumber, CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetWorksheetHideMutationParams, SetWorksheetHideMutation, SetWorksheetHideMutationFactory } from '../Mutations/set-worksheet-hide.mutation';
+
+export interface ISetWorksheetShowCommandParams {
+ worksheetId?: string;
+}
+
+export const SetWorksheetShowCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.set-worksheet-show',
+
+ handler: async (accessor: IAccessor, params?: ISetWorksheetShowCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+
+ if (params) {
+ worksheetId = params.worksheetId ?? worksheetId;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const hidden = worksheet.getConfig().hidden;
+ if (hidden === BooleanNumber.FALSE) return false;
+
+ const redoMutationParams: ISetWorksheetHideMutationParams = {
+ workbookId,
+ worksheetId,
+ hidden: BooleanNumber.FALSE,
+ };
+
+ const undoMutationParams = SetWorksheetHideMutationFactory(accessor, redoMutationParams);
+ const result = commandService.executeCommand(SetWorksheetHideMutation.id, redoMutationParams);
+
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetWorksheetHideMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetWorksheetHideMutation.id, redoMutationParams);
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-status.command.ts b/packages/base-sheets/src/Commands/Commands/set-worksheet-status.command.ts
deleted file mode 100644
index 625c75cb0e..0000000000
--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-status.command.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { CommandType, ICommand } from '@univerjs/core';
-import { IAccessor } from '@wendellhu/redi';
-import { SetWorksheetNameCommandParams } from './set-worksheet-name.command';
-
-export interface SetWorksheetRowShowCommandParams {
- workbookId: string;
- worksheetId: string;
- rowIndex: number;
- rowCount: number;
-}
-
-export const SetWorksheetNameCommand: ICommand = {
- type: CommandType.COMMAND,
- id: 'sheet.command.set-worksheet-name',
- handler: async (accessor: IAccessor, params: SetWorksheetNameCommandParams) => true,
-};
diff --git a/packages/base-sheets/src/Commands/Commands/set-zoom-ratio.command.ts b/packages/base-sheets/src/Commands/Commands/set-zoom-ratio.command.ts
new file mode 100644
index 0000000000..b662f6ca1d
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Commands/set-zoom-ratio.command.ts
@@ -0,0 +1,59 @@
+import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+import { ISetZoomRatioMutationParams, SetZoomRatioMutation, SetZoomRatioUndoMutationFactory } from '../Mutations/set-zoom-ratio.mutation';
+
+export interface ISetZoomRatioCommandParams {
+ zoomRatio?: number;
+ workbookId?: string;
+ worksheetId?: string;
+}
+
+export const SetZoomRatioCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'sheet.command.set-zoom-ratio',
+
+ handler: async (accessor: IAccessor, params?: ISetZoomRatioCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ let workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
+ let zoomRatio = 1;
+
+ if (params) {
+ workbookId = params.workbookId ?? workbookId;
+ worksheetId = params.worksheetId ?? worksheetId;
+ zoomRatio = params.zoomRatio ?? zoomRatio;
+ }
+
+ const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(worksheetId);
+ if (!worksheet) return false;
+
+ const setZoomRatioMutationParams: ISetZoomRatioMutationParams = {
+ zoomRatio,
+ workbookId,
+ worksheetId,
+ };
+
+ const undoMutationParams = SetZoomRatioUndoMutationFactory(accessor, setZoomRatioMutationParams);
+ const result = commandService.executeCommand(SetZoomRatioMutation.id, setZoomRatioMutationParams);
+
+ if (result) {
+ undoRedoService.pushUndoRedo({
+ URI: 'sheet',
+ undo() {
+ return commandService.executeCommand(SetZoomRatioMutation.id, undoMutationParams);
+ },
+ redo() {
+ return commandService.executeCommand(SetZoomRatioMutation.id, setZoomRatioMutationParams);
+ },
+ });
+ return true;
+ }
+
+ return false;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Commands/trim-whitespace.command.ts b/packages/base-sheets/src/Commands/Commands/trim-whitespace.command.ts
index 8110ed0f53..91bd019525 100644
--- a/packages/base-sheets/src/Commands/Commands/trim-whitespace.command.ts
+++ b/packages/base-sheets/src/Commands/Commands/trim-whitespace.command.ts
@@ -1,34 +1,35 @@
import { IAccessor } from '@wendellhu/redi';
-import { CommandType, ICellV, ICommand, ICommandService, ICurrentUniverService, IRangeData, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
+import { CommandType, ICellV, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, ObjectMatrix } from '@univerjs/core';
import { ISetRangeFormattedValueMutationParams, SetRangeFormattedValueMutation, SetRangeFormattedValueUndoMutationFactory } from '../Mutations/set-range-formatted-value.mutation';
-
-export interface ITrimWhitespaceParams {
- workbookId: string;
- worksheetId: string;
- range: IRangeData[];
-}
+import { ISelectionManager } from '../../Services/tokens';
/**
- * The command to insert range.
+ * The command to trim whitespace.
*/
export const TrimWhitespaceCommand: ICommand = {
type: CommandType.COMMAND,
id: 'sheet.command.trim-whitespace',
- handler: async (accessor: IAccessor, params: ITrimWhitespaceParams) => {
- const currentUniverService = accessor.get(ICurrentUniverService);
+ handler: async (accessor: IAccessor) => {
+ const selectionManager = accessor.get(ISelectionManager);
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
+ const currentUniverService = accessor.get(ICurrentUniverService);
+
+ const selections = selectionManager.getCurrentSelections();
+ if (!selections.length) return false;
+
+ const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();
+ const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();
- const { workbookId, worksheetId, range } = params;
const worksheet = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook().getSheetBySheetId(worksheetId);
if (!worksheet) return false;
const sheetMatrix = worksheet.getCellMatrix();
const cellValue = new ObjectMatrix<ICellV>();
- for (let i = 0; i < range.length; i++) {
- const { startRow, endRow, startColumn, endColumn } = range[i];
+ for (let i = 0; i < selections.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = selections[i];
const regx = /\s+/g;
for (let r = startRow; r <= endRow; r++) {
for (let c = startColumn; c <= endColumn; c++) {
@@ -39,7 +40,7 @@ export const TrimWhitespaceCommand: ICommand = {
}
const setRangeFormattedValueMutationParams: ISetRangeFormattedValueMutationParams = {
- range,
+ range: selections,
worksheetId,
workbookId,
value: cellValue.getData(),
diff --git a/packages/base-sheets/src/Commands/Mutations/add-worksheet-merge.mutation.ts b/packages/base-sheets/src/Commands/Mutations/add-worksheet-merge.mutation.ts
index 4eb5179d9f..fe8c7b72e5 100644
--- a/packages/base-sheets/src/Commands/Mutations/add-worksheet-merge.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/add-worksheet-merge.mutation.ts
@@ -13,7 +13,7 @@ export const AddWorksheetMergeMutationFactory = (accessor: IAccessor, params: IA
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- rectangles: params.rectangles,
+ ranges: params.ranges,
};
};
@@ -30,7 +30,7 @@ export const AddWorksheetMergeMutation: IMutation<IAddWorksheetMergeMutationPara
const config = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)?.getConfig()!;
const mergeConfigData = config.mergeData;
- const mergeAppendData = params.rectangles;
+ const mergeAppendData = params.ranges;
for (let i = 0; i < mergeAppendData.length; i++) {
mergeConfigData.push(mergeAppendData[i]);
}
diff --git a/packages/base-sheets/src/Commands/Mutations/delete-range.mutation.ts b/packages/base-sheets/src/Commands/Mutations/delete-range.mutation.ts
index bd2c4ea311..cb51550c24 100644
--- a/packages/base-sheets/src/Commands/Mutations/delete-range.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/delete-range.mutation.ts
@@ -1,4 +1,4 @@
-import { CommandType, IMutation, ICurrentUniverService, ObjectMatrix, Tools, Nullable, ICellV, ICellData, Dimension } from '@univerjs/core';
+import { CommandType, IMutation, ICurrentUniverService, ObjectMatrix, Tools, Nullable, ICellData, Dimension } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';
@@ -10,42 +10,43 @@ import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Ba
* @param {IDeleteRangeMutationParams} params - do mutation params
* @returns {IInsertRangeMutationParams} undo mutation params
*/
-export const DeleteRangeUndoMutationFactory = (accessor: IAccessor, params: IDeleteRangeMutationParams): IInsertRangeMutationParams => {
+export const DeleteRangeUndoMutationFactory = (accessor: IAccessor, params: IDeleteRangeMutationParams): Nullable<IInsertRangeMutationParams> => {
const currentUniverService = accessor.get(ICurrentUniverService);
const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(params.worksheetId);
- const cellMatrix = worksheet?.getCellMatrix();
+ if (!worksheet) return null;
+ const cellMatrix = worksheet.getCellMatrix();
- const undoData = new ObjectMatrix<ICellV>();
- const lastEndRow = worksheet?.getConfig().rowCount ?? 0;
- const lastEndColumn = worksheet?.getConfig().columnCount ?? 0;
+ const undoData = new ObjectMatrix<ICellData>();
+ const lastEndRow = worksheet.getConfig().rowCount;
+ const lastEndColumn = worksheet.getConfig().columnCount;
- const rangeData = params.range;
- const { startRow, endRow, startColumn, endColumn } = rangeData;
+ for (let i = 0; i < params.range.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = params.range[i];
- const result = new ObjectMatrix<ICellData>();
- if (params.shiftDimension === Dimension.ROWS) {
- // build new data
- for (let r = startRow; r <= lastEndRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- // store old value
- if (r <= endRow) {
- const cell: Nullable<ICellData> = cellMatrix?.getValue(r, c);
- result.setValue(r, c, cell as ICellData);
+ if (params.shiftDimension === Dimension.ROWS) {
+ // build new data
+ for (let r = startRow; r <= lastEndRow; r++) {
+ for (let c = startColumn; c <= endColumn; c++) {
+ // store old value
+ if (r <= endRow) {
+ const cell: Nullable<ICellData> = cellMatrix.getValue(r, c);
+ undoData.setValue(r, c, cell as ICellData);
+ }
}
}
- }
- } else if (params.shiftDimension === Dimension.COLUMNS) {
- // build new data
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= lastEndColumn; c++) {
- // store old value
- if (c <= endColumn) {
- const cell: Nullable<ICellData> = cellMatrix?.getValue(r, c);
- result.setValue(r, c, cell as ICellData);
- } else {
- for (let i = 0; i <= endColumn; i++) {
- const cell: Nullable<ICellData> = cellMatrix?.getValue(r, c);
- result.setValue(r, c + i, cell as ICellData);
+ } else if (params.shiftDimension === Dimension.COLUMNS) {
+ // build new data
+ for (let r = startRow; r <= endRow; r++) {
+ for (let c = startColumn; c <= lastEndColumn; c++) {
+ // store old value
+ if (c <= endColumn) {
+ const cell: Nullable<ICellData> = cellMatrix.getValue(r, c);
+ undoData.setValue(r, c, cell as ICellData);
+ } else {
+ for (let i = 0; i <= endColumn; i++) {
+ const cell: Nullable<ICellData> = cellMatrix.getValue(r, c);
+ undoData.setValue(r, c + i, cell as ICellData);
+ }
}
}
}
@@ -69,51 +70,53 @@ export const DeleteRangeMutation: IMutation<IDeleteRangeMutationParams, boolean>
if (!worksheet) return false;
const cellMatrix = worksheet.getCellMatrix();
- const lastEndRow = worksheet?.getConfig().rowCount ?? 0;
- const lastEndColumn = worksheet?.getConfig().columnCount ?? 0;
- const rangeData = params.range;
- const { startRow, endRow, startColumn, endColumn } = rangeData;
+ const lastEndRow = worksheet.getConfig().rowCount;
+ const lastEndColumn = worksheet.getConfig().columnCount;
- const rows = endRow - startRow + 1;
- const columns = endColumn - startColumn + 1;
+ for (let i = 0; i < params.range.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = params.range[i];
- if (params.shiftDimension === Dimension.ROWS) {
- // build new data
- for (let r = startRow; r <= lastEndRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- // get value blow current range
- const value = cellMatrix.getValue(r + rows, c);
- if (value) {
- cellMatrix.setValue(r, c, Tools.deepClone(value as ICellData));
- } else {
- // null means delete
- const originValue = cellMatrix.getValue(r, c);
- if (originValue) {
- cellMatrix.deleteValue(r, c);
- // Deleting data will cause the column number to change, so subtract 1 here in advance
- c--;
+ const rows = endRow - startRow + 1;
+ const columns = endColumn - startColumn + 1;
+
+ if (params.shiftDimension === Dimension.ROWS) {
+ // build new data
+ for (let r = startRow; r <= lastEndRow; r++) {
+ for (let c = startColumn; c <= endColumn; c++) {
+ // get value blow current range
+ const value = cellMatrix.getValue(r + rows, c);
+ if (value) {
+ cellMatrix.setValue(r, c, Tools.deepClone(value as ICellData));
+ } else {
+ // null means delete
+ const originValue = cellMatrix.getValue(r, c);
+ if (originValue) {
+ cellMatrix.deleteValue(r, c);
+ // Deleting data will cause the column number to change, so subtract 1 here in advance
+ c--;
+ }
}
}
}
- }
- } else if (params.shiftDimension === Dimension.COLUMNS) {
- // build new data
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= lastEndColumn; c++) {
- // get value blow current range
+ } else if (params.shiftDimension === Dimension.COLUMNS) {
+ // build new data
+ for (let r = startRow; r <= endRow; r++) {
+ for (let c = startColumn; c <= lastEndColumn; c++) {
+ // get value blow current range
- const value = cellMatrix.getValue(r, c + columns);
- if (value) {
- cellMatrix.setValue(r, c, Tools.deepClone(value as ICellData));
- } else {
- // null means delete
- const originValue = cellMatrix.getValue(r, c);
- if (originValue) {
- for (let i = 0; i <= endColumn; i++) {
- cellMatrix.deleteValue(r, c);
+ const value = cellMatrix.getValue(r, c + columns);
+ if (value) {
+ cellMatrix.setValue(r, c, Tools.deepClone(value as ICellData));
+ } else {
+ // null means delete
+ const originValue = cellMatrix.getValue(r, c);
+ if (originValue) {
+ for (let i = 0; i <= endColumn; i++) {
+ cellMatrix.deleteValue(r, c);
+ }
+ break;
+ // Deleting data will cause the column number to change, so subtract 1 here in advance
}
- break;
- // Deleting data will cause the column number to change, so subtract 1 here in advance
}
}
}
diff --git a/packages/base-sheets/src/Commands/Mutations/insert-range.mutation.ts b/packages/base-sheets/src/Commands/Mutations/insert-range.mutation.ts
index 1412ab9652..7af6f39703 100644
--- a/packages/base-sheets/src/Commands/Mutations/insert-range.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/insert-range.mutation.ts
@@ -28,47 +28,48 @@ export const InsertRangeMutation: IMutation<IInsertRangeMutationParams, boolean>
if (!worksheet) return false;
const cellMatrix = worksheet.getCellMatrix();
- const lastEndRow = worksheet?.getLastRow() ?? 0;
- const lastEndColumn = worksheet!?.getLastColumn() ?? 0;
+ const lastEndRow = worksheet.getLastRow();
+ const lastEndColumn = worksheet.getLastColumn();
- const rangeData = params.range;
- const { startRow, endRow, startColumn, endColumn } = rangeData;
- const rows = endRow - startRow + 1;
- const columns = endColumn - startColumn + 1;
+ for (let i = 0; i < params.range.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = params.range[i];
+ const rows = endRow - startRow + 1;
+ const columns = endColumn - startColumn + 1;
- if (params.shiftDimension === Dimension.ROWS) {
- // build new data
- for (let r = lastEndRow; r >= startRow; r--) {
- for (let c = startColumn; c <= endColumn; c++) {
- // get value blow current range
- const value = cellMatrix?.getValue(r, c);
- cellMatrix?.setValue(r + rows, c, value as ICellData);
+ if (params.shiftDimension === Dimension.ROWS) {
+ // build new data
+ for (let r = lastEndRow; r >= startRow; r--) {
+ for (let c = startColumn; c <= endColumn; c++) {
+ // get value blow current range
+ const value = cellMatrix.getValue(r, c);
+ cellMatrix.setValue(r + rows, c, value as ICellData);
+ }
}
- }
- // insert cell value from user
- for (let r = endRow; r >= startRow; r--) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellMatrix?.setValue(r, c, params.cellValue[r - startRow][c - startColumn]);
+ // insert cell value from user
+ for (let r = endRow; r >= startRow; r--) {
+ for (let c = startColumn; c <= endColumn; c++) {
+ cellMatrix.setValue(r, c, params.cellValue[r - startRow][c - startColumn]);
+ }
}
- }
- } else if (params.shiftDimension === Dimension.COLUMNS) {
- for (let r = startRow; r <= endRow; r++) {
- for (let c = lastEndColumn; c >= startColumn; c--) {
- // get value blow current range
- const value = cellMatrix?.getValue(r, c);
+ } else if (params.shiftDimension === Dimension.COLUMNS) {
+ for (let r = startRow; r <= endRow; r++) {
+ for (let c = lastEndColumn; c >= startColumn; c--) {
+ // get value blow current range
+ const value = cellMatrix.getValue(r, c);
- cellMatrix?.setValue(r, c + columns, value as ICellData);
+ cellMatrix.setValue(r, c + columns, value as ICellData);
+ }
}
- }
- // insert cell value from user
- // for (let r = endRow; r >= startRow; r--) {
- // for (let c = startColumn; c <= endColumn; c++) {
- // cellMatrix.setValue(r, c, (cellValue as ICellData)[r - startRow][c - startColumn]);
- // }
- // }
- for (let r = startRow; r <= endRow; r++) {
- for (let c = endColumn; c >= startColumn; c--) {
- cellMatrix?.setValue(r, c, params.cellValue[r - startRow][c - startColumn]);
+ // insert cell value from user
+ // for (let r = endRow; r >= startRow; r--) {
+ // for (let c = startColumn; c <= endColumn; c++) {
+ // cellMatrix.setValue(r, c, (cellValue as ICellData)[r - startRow][c - startColumn]);
+ // }
+ // }
+ for (let r = startRow; r <= endRow; r++) {
+ for (let c = endColumn; c >= startColumn; c--) {
+ cellMatrix.setValue(r, c, params.cellValue[r - startRow][c - startColumn]);
+ }
}
}
}
diff --git a/packages/base-sheets/src/Commands/Mutations/insert-row-col.mutation.ts b/packages/base-sheets/src/Commands/Mutations/insert-row-col.mutation.ts
index 661c6d60eb..a51dcb4874 100644
--- a/packages/base-sheets/src/Commands/Mutations/insert-row-col.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/insert-row-col.mutation.ts
@@ -13,8 +13,7 @@ export const InsertRowMutationFactory = (accessor: IAccessor, params: IInsertRow
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
+ ranges: params.ranges,
};
};
@@ -30,18 +29,38 @@ export const InsertRowMutation: IMutation<IInsertRowMutationParams> = {
}
const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
- const manager = worksheet!.getRowManager();
+
+ if (worksheet == null) {
+ throw new Error('worksheet is null error!');
+ }
+
+ const manager = worksheet.getRowManager();
const rowPrimitive = manager.getRowData().toJSON();
const rowWrapper = new ObjectArray(rowPrimitive);
- rowWrapper.inserts(params.rowIndex, new ObjectArray(params.rowCount));
-
- const cellPrimitive = worksheet!.getCellMatrix().toJSON();
- const cellWrapper = new ObjectMatrix(cellPrimitive);
- if (params.insertRowData == null) {
- cellWrapper.insertRowCount(params.rowIndex, params.rowCount);
- } else {
- cellWrapper.insertRows(params.rowIndex, new ObjectMatrix(params.insertRowData));
+ const defaultRowHeight = worksheet.getConfig().defaultRowHeight;
+
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ const rowIndex = range.startRow;
+ const rowCount = range.endRow - range.startRow + 1;
+
+ if (params.rowInfo) {
+ for (let j = rowIndex; j < rowIndex + rowCount; j++) {
+ const defaultRowInfo = {
+ h: defaultRowHeight,
+ hd: 0,
+ };
+ rowWrapper.insert(j, params.rowInfo.get(j) ?? defaultRowInfo);
+ }
+ } else {
+ rowWrapper.inserts(rowIndex, new ObjectArray(rowCount));
+ }
+
+ const cellPrimitive = worksheet!.getCellMatrix().toJSON();
+ const cellWrapper = new ObjectMatrix(cellPrimitive);
+ cellWrapper.insertRowCount(rowIndex, rowCount);
}
+
return true;
},
};
@@ -57,8 +76,7 @@ export const InsertColMutationFactory = (accessor: IAccessor, params: IInsertCol
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- colIndex: params.colIndex,
- colCount: params.colCount,
+ ranges: params.ranges,
};
};
@@ -74,18 +92,34 @@ export const InsertColMutation: IMutation<IInsertColMutationParams> = {
}
const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
- const manager = worksheet!.getColumnManager();
+ if (!worksheet) return false;
+ const manager = worksheet.getColumnManager();
const columnPrimitive = manager.getColumnData().toJSON();
const columnWrapper = new ObjectArray(columnPrimitive);
- columnWrapper.inserts(params.colIndex, new ObjectArray(params.colCount));
-
- const cellPrimitive = worksheet!.getCellMatrix().toJSON();
- const cellWrapper = new ObjectMatrix(cellPrimitive);
- if (params.insertColData == null) {
- cellWrapper.insertColumnCount(params.colIndex, params.colCount);
- } else {
- cellWrapper.insertColumns(params.colIndex, new ObjectMatrix(params.insertColData));
+
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ const colIndex = range.startColumn;
+ const colCount = range.endColumn - range.startColumn + 1;
+ const defaultColWidth = worksheet.getConfig().defaultColumnWidth;
+
+ if (params.colInfo) {
+ for (let j = colIndex; j < colIndex + colCount; j++) {
+ const defaultColInfo = {
+ w: defaultColWidth,
+ hd: 0,
+ };
+ columnWrapper.insert(j, params.colInfo.get(j) ?? defaultColInfo);
+ }
+ } else {
+ columnWrapper.inserts(colIndex, new ObjectArray(colCount));
+ }
+
+ const cellPrimitive = worksheet!.getCellMatrix().toJSON();
+ const cellWrapper = new ObjectMatrix(cellPrimitive);
+ cellWrapper.insertColumnCount(colIndex, colCount);
}
+
return true;
},
};
diff --git a/packages/base-sheets/src/Commands/Mutations/remove-row-col.mutation.ts b/packages/base-sheets/src/Commands/Mutations/remove-row-col.mutation.ts
index 19b34901fe..84acd186d7 100644
--- a/packages/base-sheets/src/Commands/Mutations/remove-row-col.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/remove-row-col.mutation.ts
@@ -1,8 +1,8 @@
-import { CommandType, ICurrentUniverService, IMutation, ObjectArray, ObjectMatrix } from '@univerjs/core';
+import { CommandType, IColumnData, ICurrentUniverService, IMutation, IRowData, ObjectArray } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
import { IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';
-export const RemoveRowMutationFactory = (accessor: IAccessor, params: IRemoveRowMutationParams): IInsertRowMutationParams => {
+export const IRemoveRowMutationFactory = (accessor: IAccessor, params: IRemoveRowMutationParams): IInsertRowMutationParams => {
const currentUniverService = accessor.get(ICurrentUniverService);
const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);
@@ -10,14 +10,28 @@ export const RemoveRowMutationFactory = (accessor: IAccessor, params: IRemoveRow
throw new Error('universheet is null error!');
}
- const rowPrimitive = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getCellMatrix().toJSON();
- const rowWrapper = new ObjectMatrix(rowPrimitive);
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (worksheet == null) {
+ throw new Error('universheet is null error!');
+ }
+
+ const manager = worksheet.getRowManager();
+ const rowPrimitive = manager.getRowData().toJSON();
+ const rowWrapper = new ObjectArray(rowPrimitive);
+ const rowInfo = new ObjectArray<IRowData>();
+
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+
+ const slice = rowWrapper.slice(range.startRow, range.endRow);
+ rowInfo.concat(slice);
+ }
+
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
- insertRowData: rowWrapper.sliceRows(params.rowIndex, params.rowCount).toJSON(),
+ ranges: params.ranges,
+ rowInfo,
};
};
@@ -32,14 +46,23 @@ export const RemoveRowMutation: IMutation<IRemoveRowMutationParams> = {
throw new Error('universheet is null error!');
}
- const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getRowManager();
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+
+ const manager = worksheet.getRowManager();
const rowPrimitive = manager.getRowData().toJSON();
const rowWrapper = new ObjectArray(rowPrimitive);
- rowWrapper.splice(params.rowIndex, params.rowCount);
- const cellPrimitive = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getCellMatrix().toJSON();
- const wrapper = new ObjectMatrix(cellPrimitive);
- wrapper.spliceRows(params.rowIndex, params.rowCount);
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ const start = range.startRow;
+ const end = range.endRow - range.startRow + 1;
+
+ for (let j = start; j < end; j++) {
+ rowWrapper.splice(j, 1);
+ }
+ }
+
return true;
},
};
@@ -53,13 +76,28 @@ export const IRemoveColMutationFactory = (accessor: IAccessor, params: IRemoveCo
}
const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
- const cellPrimitive = worksheet!.getCellMatrix().toJSON();
+
+ if (worksheet == null) {
+ throw new Error('worksheet is null error!');
+ }
+
+ const manager = worksheet.getColumnManager();
+ const columnPrimitive = manager.getColumnData().toJSON();
+ const columnWrapper = new ObjectArray(columnPrimitive);
+ const colInfo = new ObjectArray<IColumnData>();
+
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+
+ const slice = columnWrapper.slice(range.startColumn, range.endColumn);
+ colInfo.concat(slice);
+ }
+
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- colIndex: params.colIndex,
- colCount: params.colCount,
- insertColData: new ObjectMatrix(cellPrimitive).sliceColumns(params.colIndex, params.colCount).toJSON(),
+ ranges: params.ranges,
+ colInfo,
};
};
@@ -74,16 +112,23 @@ export const RemoveColMutation: IMutation<IRemoveColMutationParams> = {
throw new Error('universheet is null error!');
}
- const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getColumnManager();
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+
+ const manager = worksheet.getColumnManager();
const columnPrimitive = manager.getColumnData().toJSON();
const columnWrapper = new ObjectArray(columnPrimitive);
- const start = params.colIndex;
- const end = params.colIndex + params.colCount;
- for (let i = start; i < end; i++) columnWrapper.splice(params.colIndex, 1);
- const cellPrimitive = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getCellMatrix().toJSON();
- const cellWrapper = new ObjectMatrix(cellPrimitive);
- cellWrapper.spliceColumns(params.colIndex, params.colCount).toJSON();
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ const start = range.startColumn;
+ const end = range.endColumn - range.startColumn + 1;
+
+ for (let j = start; j < end; j++) {
+ columnWrapper.splice(j, 1);
+ }
+ }
+
return true;
},
};
diff --git a/packages/base-sheets/src/Commands/Mutations/remove-worksheet-merge.mutation.ts b/packages/base-sheets/src/Commands/Mutations/remove-worksheet-merge.mutation.ts
index 48d5953bb6..f77e8c514f 100644
--- a/packages/base-sheets/src/Commands/Mutations/remove-worksheet-merge.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/remove-worksheet-merge.mutation.ts
@@ -10,10 +10,28 @@ export const RemoveWorksheetMergeMutationFactory = (accessor: IAccessor, params:
throw new Error('universheet is null error!');
}
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (worksheet == null) {
+ throw new Error('worksheet is null error!');
+ }
+ const config = worksheet.getConfig();
+ const mergeConfigData = config.mergeData;
+ const mergeRemoveData = params.ranges;
+ const ranges = [];
+ for (let j = 0; j < mergeRemoveData.length; j++) {
+ for (let i = mergeConfigData.length - 1; i >= 0; i--) {
+ const configMerge = mergeConfigData[i];
+ const removeMerge = mergeRemoveData[j];
+ if (Rectangle.intersects(configMerge, removeMerge)) {
+ ranges.push(mergeConfigData[i]);
+ }
+ }
+ }
+
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- rectangles: params.rectangles,
+ ranges,
};
};
@@ -28,9 +46,11 @@ export const RemoveWorksheetMergeMutation: IMutation<IRemoveWorksheetMergeMutati
throw new Error('universheet is null error!');
}
- const config = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getConfig()!;
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ const config = worksheet.getConfig();
const mergeConfigData = config.mergeData;
- const mergeRemoveData = params.rectangles;
+ const mergeRemoveData = params.ranges;
for (let j = 0; j < mergeRemoveData.length; j++) {
for (let i = mergeConfigData.length - 1; i >= 0; i--) {
const configMerge = mergeConfigData[i];
diff --git a/packages/base-sheets/src/Commands/Mutations/set-border-styles.mutatio.ts b/packages/base-sheets/src/Commands/Mutations/set-border-styles.mutatio.ts
new file mode 100644
index 0000000000..88d7c50304
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-border-styles.mutatio.ts
@@ -0,0 +1,249 @@
+import {
+ CommandType,
+ IMutation,
+ IStyleData,
+ ICurrentUniverService,
+ ObjectMatrix,
+ Tools,
+ Nullable,
+ IBorderData,
+ IKeyValue,
+ IDocumentData,
+ ITextStyle,
+ ObjectMatrixPrimitiveType,
+} from '@univerjs/core';
+
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetBorderStylesMutationParams {
+ workbookId: string;
+ worksheetId: string;
+ value: ObjectMatrixPrimitiveType<IStyleData>;
+}
+
+/**
+ * Generate undo mutation of a `SetRangeStyleMutation`
+ *
+ * @param {IAccessor} accessor - injector accessor
+ * @param {ISetRangeStyleMutationParams} params - do mutation params
+ * @returns {ISetRangeStyleMutationParams} undo mutation params
+ */
+export const SetBorderStylesUndoMutationFactory = (accessor: IAccessor, params: ISetBorderStylesMutationParams): ISetBorderStylesMutationParams => {
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
+ const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(params.worksheetId);
+ const cellMatrix = worksheet?.getCellMatrix();
+ const styles = workbook.getStyles();
+ const data = new ObjectMatrix(params.value);
+
+ const undoData = new ObjectMatrix<IStyleData>();
+ data.forValue((row: number, col: number, value: any) => {
+ const cell = cellMatrix?.getValue(row, col) || {};
+ const old = styles.getStyleByCell(cell);
+ undoData.setValue(row, col, transformStyle(old, value as Nullable<IStyleData>));
+ });
+
+ return {
+ ...Tools.deepClone(params),
+ value: undoData.getData(),
+ };
+};
+
+export const SetBorderStylesMutation: IMutation<ISetBorderStylesMutationParams, boolean> = {
+ id: 'sheet.mutation.set-border-styles',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const workbook = currentUniverService.getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+
+ const cellMatrix = worksheet.getCellMatrix();
+ const styles = workbook.getStyles();
+
+ const data = new ObjectMatrix(params.value);
+
+ data.forValue((row: number, col: number, value: any) => {
+ const cell = cellMatrix.getValue(row, col) || {};
+ // use null to clear style
+ const old = styles.getStyleByCell(cell);
+
+ if (old == null) {
+ // clear
+ delete cell.s;
+ }
+
+ // set style
+ const merge = mergeStyle(old, value as Nullable<IStyleData>);
+
+ // then remove null
+ merge && Tools.removeNull(merge);
+
+ if (Tools.isEmptyObject(merge)) {
+ delete cell.s;
+ } else {
+ cell.s = styles.setValue(merge);
+ }
+
+ // When the rich text sets the cell style, you need to modify the style of all rich text
+ // TODO redo/undo use setRangeData to undo rich text setting
+ if (cell.p) {
+ mergeRichTextStyle(cell.p, value as Nullable<IStyleData>);
+ }
+
+ cellMatrix.setValue(row, col, cell);
+ });
+
+ return true;
+ },
+};
+
+/**
+ * Convert old style data for storage
+ * @param style
+ */
+export function transformStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>): Nullable<IStyleData> {
+ const backupStyle = transformNormalKey(oldStyle, newStyle);
+ return backupStyle;
+}
+/**
+ * Convert old style normal key for storage
+ *
+ * @param style
+ */
+export function transformNormalKey(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>): Nullable<IStyleData> {
+ // If there is no newly set style, directly store the historical style
+ if (!newStyle || !Object.keys(newStyle).length) {
+ return oldStyle;
+ }
+ const backupStyle: { [key: string]: any } = Tools.deepClone(oldStyle) || {};
+
+ for (const k in newStyle) {
+ if (k === 'bd') {
+ backupStyle[k] = transformBorders(backupStyle[k] || {}, newStyle[k]);
+ }
+ // 1. To modify the existing style,we need original setting to undo
+ // 2. Newly set the style, we need null to undo
+ else if (!(k in backupStyle)) {
+ backupStyle[k] = null;
+ }
+ }
+ return backupStyle;
+}
+/**
+ * Convert old style border for storage
+ *
+
+ * @param style
+ */
+export function transformBorders(oldBorders: IBorderData, newBorders: Nullable<IBorderData>): IBorderData {
+ // If there is no newly set border, directly store the historical border
+ if (!newBorders || !Object.keys(newBorders).length) {
+ return oldBorders;
+ }
+
+ for (const k in newBorders) {
+ // 1. To modify the existing border,we need original setting to undo
+ // 2. Newly set the border, we need null to undo
+ if (!(k in oldBorders)) {
+ (oldBorders as IKeyValue)[k] = null;
+ }
+ }
+
+ return oldBorders;
+}
+
+/**
+ * merge new style to old style
+ *
+ * @param oldStyle
+ * @param newStyle
+ */
+export function mergeStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>, isRichText: boolean = false): Nullable<IStyleData> {
+ // clear style
+ if (newStyle === null) return newStyle;
+ // don't operate
+ if (newStyle === undefined) return oldStyle;
+
+ const backupStyle: { [key: string]: any } = Tools.deepClone(oldStyle) || {};
+ if (!backupStyle) return;
+ for (const k in newStyle) {
+ if (isRichText && ['bd', 'tr', 'td', 'ht', 'vt', 'tb', 'pd'].includes(k)) {
+ continue;
+ }
+ // you can only choose one of the themeColor and rgbColor of the border setting
+ if (k in backupStyle && k === 'bd') {
+ backupStyle[k] = Object.assign(backupStyle[k], newStyle[k]);
+ } else {
+ backupStyle[k] = (newStyle as IKeyValue)[k];
+
+ // overline/strikethrough/underline add color
+ if ('cl' in backupStyle) {
+ if (['ul', 'ol', 'st'].includes(k)) {
+ backupStyle[k].cl = backupStyle.cl;
+ }
+ }
+ }
+ }
+ return backupStyle;
+}
+
+/**
+ * Find the text style of all paragraphs and modify it to the new style
+ * @param p
+ * @param newStyle
+ */
+export function mergeRichTextStyle(p: IDocumentData, newStyle: Nullable<IStyleData>) {
+ // p.body?.blockElements.forEach((blockElement) => {
+ // if (blockElement.blockType === 0) {
+ // const paragraph = blockElement.paragraph;
+ // paragraph?.elements.forEach((element) => {
+ // if (!element.tr) {
+ // element.tr = {};
+ // }
+
+ // const textRun = element.tr as ITextRun;
+
+ // if (!textRun.ts) {
+ // textRun.ts = {};
+ // }
+
+ // const oldStyle = textRun.ts;
+
+ // const merge = mergeStyle(
+ // oldStyle as Nullable<IStyleData>,
+ // newStyle,
+ // true
+ // );
+
+ // // then remove null
+ // merge && Tools.removeNull(merge);
+
+ // if (Tools.isEmptyObject(merge)) {
+ // delete textRun.ts;
+ // } else {
+ // textRun.ts = merge as ITextStyle;
+ // }
+ // });
+ // }
+ // });
+ p.body?.textRuns?.forEach((textRun) => {
+ if (!textRun.ts) {
+ textRun.ts = {};
+ }
+
+ const oldStyle = textRun.ts || {};
+
+ const merge = mergeStyle(oldStyle as Nullable<IStyleData>, newStyle, true);
+
+ // then remove null
+ merge && Tools.removeNull(merge);
+
+ if (Tools.isEmptyObject(merge)) {
+ delete textRun.ts;
+ } else {
+ textRun.ts = merge as ITextStyle;
+ }
+ });
+}
diff --git a/packages/base-sheets/src/Commands/Mutations/set-hide-gridlines.mutatiom.ts b/packages/base-sheets/src/Commands/Mutations/set-hide-gridlines.mutatiom.ts
new file mode 100644
index 0000000000..0fd646645e
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-hide-gridlines.mutatiom.ts
@@ -0,0 +1,37 @@
+import { BooleanNumber, CommandType, ICurrentUniverService, IMutation, Tools } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetHideGridlinesMutationParams {
+ hideGridlines: BooleanNumber;
+ workbookId: string;
+ worksheetId: string;
+}
+
+export const SetHideGridlinesUndoMutationFactory = (accessor: IAccessor, params: ISetHideGridlinesMutationParams): ISetHideGridlinesMutationParams => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const worksheet = workbook!.getSheetBySheetId(params.worksheetId);
+ const config = worksheet!.getConfig();
+
+ const oldStatus = config.showGridlines;
+
+ return {
+ ...Tools.deepClone(params),
+ hideGridlines: oldStatus,
+ };
+};
+
+export const SetHideGridlinesMutation: IMutation<ISetHideGridlinesMutationParams> = {
+ id: 'sheet.mutation.set-hide-gridlines',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ const config = worksheet.getConfig();
+
+ config.showGridlines = params.hideGridlines;
+
+ return true;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-range-values.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-range-values.mutation.ts
index 04b13a0c7f..711b7812a4 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-range-values.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-range-values.mutation.ts
@@ -14,7 +14,7 @@ import { IAccessor } from '@wendellhu/redi';
/** Params of `SetRangeValuesMutation` */
export interface ISetRangeValuesMutationParams {
- rangeData: IRangeData;
+ rangeData: IRangeData[];
worksheetId: string;
cellValue?: ObjectMatrixPrimitiveType<ICellData>;
@@ -32,14 +32,21 @@ export interface ISetRangeValuesMutationParams {
export const SetRangeValuesUndoMutationFactory = (accessor: IAccessor, params: ISetRangeValuesMutationParams): ISetRangeValuesMutationParams => {
const currentUniverService = accessor.get(ICurrentUniverService);
const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(params.worksheetId);
- const cellMatrix = worksheet?.getCellMatrix();
- const { startRow, endRow, startColumn, endColumn } = params.rangeData;
+ if (worksheet == null) {
+ throw new Error('worksheet is null error!');
+ }
+ const cellMatrix = worksheet.getCellMatrix();
const undoData = new ObjectMatrix<ICellData>();
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- const value = cellMatrix?.getValue(r, c);
- undoData.setValue(r, c, Tools.deepClone(value as ICellData));
+
+ for (let i = 0; i < params.rangeData.length; i++) {
+ const { startRow, endRow, startColumn, endColumn } = params.rangeData[i];
+
+ for (let r = startRow; r <= endRow; r++) {
+ for (let c = startColumn; c <= endColumn; c++) {
+ const value = cellMatrix?.getValue(r, c);
+ undoData.setValue(r, c, Tools.deepClone(value as ICellData));
+ }
}
}
@@ -63,48 +70,51 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, bo
const cellMatrix = worksheet.getCellMatrix();
const { cellValue, rangeData } = params;
- const { startRow, startColumn, endColumn, endRow } = rangeData;
+ const newValues = new ObjectMatrix(cellValue);
- // clear selection content
- createRowColIter(startRow, endRow, startColumn, endColumn).forEach((r, c) => {
- if (cellMatrix.getValue(r, c)) {
- cellMatrix.setValue(r, c, { v: null });
- }
- });
+ for (let i = 0; i < rangeData.length; i++) {
+ const { startRow, startColumn, endColumn, endRow } = rangeData[i];
- const newValues = new ObjectMatrix(cellValue);
- newValues.forValue((row, col, newVal) => {
- const oldVal = cellMatrix.getValue(row, col) || {};
-
- // clear all
- if (!newVal) {
- cellMatrix?.setValue(row, col, {
- v: null,
- });
- } else {
- // TODO: @wzhudev: add config to change value or format only
- if (newVal.p != null) {
- oldVal.p = newVal.p;
+ // clear selection content
+ createRowColIter(startRow, endRow, startColumn, endColumn).forEach((r, c) => {
+ if (cellMatrix.getValue(r, c)) {
+ cellMatrix.setValue(r, c, { v: null });
}
+ });
- if (newVal.v != null) {
- oldVal.v = newVal.v;
- }
+ newValues.forValue((row, col, newVal) => {
+ const oldVal = cellMatrix.getValue(row, col) || {};
- if (newVal.m != null) {
- oldVal.m = newVal.m;
+ // clear all
+ if (!newVal) {
+ cellMatrix?.setValue(row, col, {
+ v: null,
+ });
} else {
- oldVal.m = String(oldVal.v);
- }
+ // TODO: @wzhudev: add config to change value or format only
+ if (newVal.p != null) {
+ oldVal.p = newVal.p;
+ }
- if (newVal.t != null) {
- oldVal.t = newVal.t;
- }
+ if (newVal.v != null) {
+ oldVal.v = newVal.v;
+ }
- cellMatrix.setValue(row, col, oldVal);
- }
- });
+ if (newVal.m != null) {
+ oldVal.m = newVal.m;
+ } else {
+ oldVal.m = String(oldVal.v);
+ }
+
+ if (newVal.t != null) {
+ oldVal.t = newVal.t;
+ }
+
+ cellMatrix.setValue(row, col, oldVal);
+ }
+ });
+ }
return true;
},
-};
\ No newline at end of file
+};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-tab-color.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-tab-color.mutation.ts
new file mode 100644
index 0000000000..7badc67e19
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-tab-color.mutation.ts
@@ -0,0 +1,35 @@
+import { CommandType, ICurrentUniverService, IMutation, Tools } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetTabColorMutationParams {
+ color: string;
+ workbookId: string;
+ worksheetId: string;
+}
+
+export const SetTabColorUndoMutationFactory = (accessor: IAccessor, params: ISetTabColorMutationParams): ISetTabColorMutationParams => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const worksheet = workbook!.getSheetBySheetId(params.worksheetId);
+ const config = worksheet!.getConfig();
+
+ // store old tab color
+ const oldTabColor = config.tabColor;
+ return {
+ ...Tools.deepClone(params),
+ color: oldTabColor,
+ };
+};
+
+export const SetTabColorMutation: IMutation<ISetTabColorMutationParams> = {
+ id: 'sheet.mutation.set-tab-color',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ worksheet.getConfig().tabColor = params.color;
+
+ return true;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-activate.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-activate.mutation.ts
index 6f1db3a6ee..99cdeabd8f 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-activate.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-activate.mutation.ts
@@ -6,7 +6,7 @@ export interface ISetWorksheetActivateMutationParams {
worksheetId: string;
}
-export const SetWorksheetActivateMutationFactory = (accessor: IAccessor, params: ISetWorksheetActivateMutationParams): ISetWorksheetActivateMutationParams => {
+export const SetWorksheetUnActivateMutationFactory = (accessor: IAccessor, params: ISetWorksheetActivateMutationParams): ISetWorksheetActivateMutationParams => {
const universheet = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId);
if (universheet == null) {
@@ -39,17 +39,15 @@ export const SetWorksheetActivateMutation: IMutation<ISetWorksheetActivateMutati
handler: async (accessor, params) => {
const universheet = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId);
- if (universheet == null) {
- return false;
- }
+ if (!universheet) return false;
const worksheets = universheet.getWorkBook().getWorksheets();
for (const [, worksheet] of worksheets) {
if (worksheet.getSheetId() === params.worksheetId) {
- worksheet.setStatus(BooleanNumber.TRUE);
+ worksheet.getConfig().status = BooleanNumber.TRUE;
} else {
- worksheet.setStatus(BooleanNumber.FALSE);
+ worksheet.getConfig().status = BooleanNumber.FALSE;
}
}
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-col-width.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-col-width.mutation.ts
index e4b69c6733..549d0a3f8f 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-col-width.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-col-width.mutation.ts
@@ -1,11 +1,11 @@
-import { CommandType, ICurrentUniverService, IMutation } from '@univerjs/core';
+import { CommandType, ICurrentUniverService, IMutation, IRangeData, ObjectArray } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
export interface ISetWorksheetColWidthMutationParams {
workbookId: string;
worksheetId: string;
- colIndex: number;
- colWidth: number[];
+ ranges: IRangeData[];
+ colWidth: number | ObjectArray<number>;
}
export const SetWorksheetColWidthMutationFactory = (accessor: IAccessor, params: ISetWorksheetColWidthMutationParams): ISetWorksheetColWidthMutationParams => {
@@ -16,18 +16,26 @@ export const SetWorksheetColWidthMutationFactory = (accessor: IAccessor, params:
throw new Error('universheet is null error!');
}
- const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getColumnManager();
- const colWidth = [];
- for (let i = params.colIndex; i < params.colIndex + params.colWidth.length; i++) {
- const column = manager.getColumnOrCreate(i);
- colWidth[i - params.colIndex] = column.w;
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (worksheet == null) {
+ throw new Error('universheet is null error!');
+ }
+ const colWidth = new ObjectArray<number>();
+ const manager = worksheet.getColumnManager();
+ const ranges = params.ranges;
+ for (let i = 0; i < ranges.length; i++) {
+ const range = ranges[i];
+ for (let j = range.startColumn; j < range.endColumn + 1; j++) {
+ const column = manager.getColumnOrCreate(i);
+ colWidth.set(j, column.w);
+ }
}
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- colIndex: params.colIndex,
- colWidth: params.colWidth,
+ ranges: params.ranges,
+ colWidth,
};
};
@@ -42,11 +50,23 @@ export const SetWorksheetColWidthMutation: IMutation<ISetWorksheetColWidthMutati
throw new Error('universheet is null error!');
}
- const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getColumnManager();
- for (let i = params.colIndex; i < params.colIndex + params.colWidth.length; i++) {
- const column = manager.getColumnOrCreate(i);
- column.w = params.colWidth[i - params.colIndex];
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ const defaultColumnWidth = worksheet.getConfig().defaultColumnWidth;
+ const manager = worksheet.getColumnManager();
+ const ranges = params.ranges;
+ for (let i = 0; i < ranges.length; i++) {
+ const range = ranges[i];
+ for (let j = range.startColumn; j < range.endColumn + 1; j++) {
+ const column = manager.getColumnOrCreate(i);
+ if (typeof params.colWidth === 'number') {
+ column.w = params.colWidth;
+ } else {
+ column.w = params.colWidth.get(j) ?? defaultColumnWidth;
+ }
+ }
}
+
return true;
},
};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-hide.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-hide.mutation.ts
new file mode 100644
index 0000000000..00c2fa834c
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-hide.mutation.ts
@@ -0,0 +1,49 @@
+import { CommandType, ICurrentUniverService, IMutation, IRangeData } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetWorksheetColumnHideMutationParams {
+ workbookId: string;
+ worksheetId: string;
+ ranges: IRangeData[];
+}
+
+export const SetWorksheetColumnHideMutationFactory = (accessor: IAccessor, params: ISetWorksheetColumnHideMutationParams) => {
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);
+
+ if (universheet == null) {
+ throw new Error('universheet is null error!');
+ }
+
+ return {
+ workbookId: params.workbookId,
+ worksheetId: params.worksheetId,
+ ranges: params.ranges,
+ };
+};
+
+export const SetWorksheetColumnHideMutation: IMutation<ISetWorksheetColumnHideMutationParams> = {
+ id: 'sheet.mutation.set-worksheet-column-hide',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);
+
+ if (!universheet) {
+ return false;
+ }
+
+ const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getColumnManager();
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ for (let j = range.startColumn; j < range.startColumn + range.endColumn; j++) {
+ const column = manager.getColumnOrCreate(j);
+ if (column != null) {
+ column.hd = 1;
+ }
+ }
+ }
+
+ return true;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-show.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-show.mutation.ts
new file mode 100644
index 0000000000..8c24ade6e9
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-show.mutation.ts
@@ -0,0 +1,49 @@
+import { CommandType, ICurrentUniverService, IMutation, IRangeData } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetWorksheetColumnShowMutationParams {
+ workbookId: string;
+ worksheetId: string;
+ ranges: IRangeData[];
+}
+
+export const SetWorksheetColumnShowMutationFactory = (accessor: IAccessor, params: ISetWorksheetColumnShowMutationParams) => {
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);
+
+ if (universheet == null) {
+ throw new Error('universheet is null error!');
+ }
+
+ return {
+ workbookId: params.workbookId,
+ worksheetId: params.worksheetId,
+ ranges: params.ranges,
+ };
+};
+
+export const SetWorksheetColumnShowMutation: IMutation<ISetWorksheetColumnShowMutationParams> = {
+ id: 'sheet.mutation.set-worksheet-column-show',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const currentUniverService = accessor.get(ICurrentUniverService);
+ const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);
+
+ if (!universheet) {
+ return false;
+ }
+
+ const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getColumnManager();
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ for (let j = range.startColumn; j < range.startColumn + range.endColumn; j++) {
+ const column = manager.getColumnOrCreate(j);
+ if (column != null) {
+ column.hd = 0;
+ }
+ }
+ }
+
+ return true;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-config.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-config.mutation.ts
new file mode 100644
index 0000000000..0a4e216a55
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-config.mutation.ts
@@ -0,0 +1,34 @@
+import { CommandType, ICurrentUniverService, IMutation, IWorksheetConfig, Tools } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetWorksheetConfigMutationParams {
+ workbookId: string;
+ worksheetId: string;
+ config: IWorksheetConfig;
+}
+
+export const SetWorksheetConfigUndoMutationFactory = (accessor: IAccessor, params: ISetWorksheetConfigMutationParams): ISetWorksheetConfigMutationParams => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const worksheet = workbook!.getSheetBySheetId(params.worksheetId)!;
+ const config = Tools.deepClone(worksheet.getConfig());
+
+ return {
+ workbookId: params.workbookId,
+ worksheetId: params.worksheetId,
+ config,
+ };
+};
+
+export const SetWorksheetConfigMutation: IMutation<ISetWorksheetConfigMutationParams> = {
+ id: 'sheet.mutation.set-worksheet-config',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ worksheet.setConfig(params.config);
+
+ return true;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-hide.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-hide.mutation.ts
index d7ac4a0f8c..657fc1d6ad 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-hide.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-hide.mutation.ts
@@ -7,7 +7,7 @@ export interface ISetWorksheetHideMutationParams {
worksheetId: string;
}
-export const SetWorksheetHideMutationFactory = (accessor: IAccessor, params: ISetWorksheetHideMutationParams): ISetWorksheetHiddenMutationParams => {
+export const SetWorksheetHideMutationFactory = (accessor: IAccessor, params: ISetWorksheetHideMutationParams): ISetWorksheetHideMutationParams => {
const universheet = accessor.get(ICurrentUniverService).getCurrentUniverSheetInstance();
const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
if (worksheet == null) {
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-name.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-name.mutation.ts
index cb7745c2d1..9b6d45d375 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-name.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-name.mutation.ts
@@ -36,7 +36,7 @@ export const SetWorksheetNameMutation: IMutation<ISetWorksheetNameMutationParams
return false;
}
- worksheet.setName(params.name);
+ worksheet.getConfig().name = params.name;
return true;
},
};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-order.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-order.mutation.ts
index cb21cb98ea..fd3f6f2a32 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-order.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-order.mutation.ts
@@ -1,4 +1,4 @@
-import { CommandType, ICurrentUniverService, IMutation } from '@univerjs/core';
+import { CommandType, ICurrentUniverService, IMutation, Tools } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
export interface ISetWorksheetOrderMutationParams {
@@ -7,17 +7,13 @@ export interface ISetWorksheetOrderMutationParams {
worksheetId: string;
}
-export const SetWorksheetOrderMutationFactory = (accessor: IAccessor, params: ISetWorksheetOrderMutationParams): ISetWorksheetOrderMutationParams => {
- const universheet = accessor.get(ICurrentUniverService).getCurrentUniverSheetInstance();
- const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
- if (worksheet == null) {
- throw new Error('worksheet is null error!');
- }
- const config = universheet.getWorkBook().getConfig();
+export const SetWorksheetOrderUndoMutationFactory = (accessor: IAccessor, params: ISetWorksheetOrderMutationParams): ISetWorksheetOrderMutationParams => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const config = workbook!.getConfig();
+ const oldIndex = config.sheetOrder.findIndex((current: string) => current === params.worksheetId);
return {
- order: config.sheetOrder.findIndex((current: string) => current === params.worksheetId),
- workbookId: params.workbookId,
- worksheetId: params.worksheetId,
+ ...Tools.deepClone(params),
+ order: oldIndex,
};
};
@@ -25,11 +21,9 @@ export const SetWorksheetOrderMutation: IMutation<ISetWorksheetOrderMutationPara
id: 'sheet.mutation.set-worksheet-order',
type: CommandType.MUTATION,
handler: async (accessor, params) => {
- const universheet = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId);
- if (universheet == null) {
- return false;
- }
- const config = universheet.getWorkBook().getConfig();
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const config = workbook.getConfig();
const exclude = config.sheetOrder.filter((currentId: string) => currentId !== params.worksheetId);
exclude.splice(params.order, 0, params.worksheetId);
config.sheetOrder = exclude;
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-right-to-left.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-right-to-left.mutation.ts
new file mode 100644
index 0000000000..daffd7fbf5
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-right-to-left.mutation.ts
@@ -0,0 +1,37 @@
+import { BooleanNumber, CommandType, ICurrentUniverService, IMutation, Tools } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetWorksheetRightToLeftMutationParams {
+ rightToLeft: BooleanNumber;
+ workbookId: string;
+ worksheetId: string;
+}
+
+export const SetWorksheetRightToLeftUndoMutationFactory = (accessor: IAccessor, params: ISetWorksheetRightToLeftMutationParams): ISetWorksheetRightToLeftMutationParams => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const worksheet = workbook!.getSheetBySheetId(params.worksheetId);
+ const config = worksheet!.getConfig();
+
+ const oldState = config.rightToLeft;
+
+ return {
+ ...Tools.deepClone(params),
+ rightToLeft: oldState,
+ };
+};
+
+export const SetWorksheetRightToLeftMutation: IMutation<ISetWorksheetRightToLeftMutationParams> = {
+ id: 'sheet.mutation.set-worksheet-right-to-left',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ const config = worksheet.getConfig();
+
+ config.rightToLeft = params.rightToLeft;
+
+ return true;
+ },
+};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-rightToLeft.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-rightToLeft.mutation.ts
deleted file mode 100644
index 23bdf13f08..0000000000
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-rightToLeft.mutation.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { CommandType, IMutation } from '@univerjs/core';
-
-export type ISetWorksheetRightToLeftMutationParams = {
- workbookId: string;
- worksheetId: string;
-};
-
-export const SetWorksheetRightToLeftMutation: IMutation<ISetWorksheetRightToLeftMutationParams> = {
- id: 'sheet.mutation.set-worksheet-rightToLeft',
- type: CommandType.MUTATION,
- handler: async (accessor, params) => true,
-};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-height.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-height.mutation.ts
index d8651066ab..4b29c23896 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-height.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-height.mutation.ts
@@ -1,11 +1,11 @@
-import { CommandType, ICurrentUniverService, IMutation } from '@univerjs/core';
+import { CommandType, ICurrentUniverService, IMutation, IRangeData, ObjectArray } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
export interface ISetWorksheetRowHeightMutationParams {
workbookId: string;
worksheetId: string;
- rowIndex: number;
- rowHeight: number[];
+ ranges: IRangeData[];
+ rowHeight: number | ObjectArray<number>;
}
export const SetWorksheetRowHeightMutationFactory = (accessor: IAccessor, params: ISetWorksheetRowHeightMutationParams): ISetWorksheetRowHeightMutationParams => {
@@ -16,18 +16,26 @@ export const SetWorksheetRowHeightMutationFactory = (accessor: IAccessor, params
throw new Error('universheet is null error!');
}
- const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getRowManager();
- const rowHeight = [];
- for (let i = params.rowIndex; i < params.rowIndex + params.rowHeight.length; i++) {
- const row = manager.getRowOrCreate(i);
- rowHeight[i - params.rowIndex] = row.h;
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (worksheet == null) {
+ throw new Error('universheet is null error!');
+ }
+ const rowHeight = new ObjectArray<number>();
+ const manager = worksheet.getRowManager();
+ const ranges = params.ranges;
+ for (let i = 0; i < ranges.length; i++) {
+ const range = ranges[i];
+ for (let j = range.startRow; j < range.endRow + 1; j++) {
+ const row = manager.getRowOrCreate(i);
+ rowHeight.set(j, row.h);
+ }
}
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowHeight: params.rowHeight,
+ ranges: params.ranges,
+ rowHeight,
};
};
@@ -42,11 +50,23 @@ export const SetWorksheetRowHeightMutation: IMutation<ISetWorksheetRowHeightMuta
throw new Error('universheet is null error!');
}
- const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getRowManager();
- for (let i = params.rowIndex; i < params.rowIndex + params.rowHeight.length; i++) {
- const row = manager.getRowOrCreate(i);
- row.h = params.rowHeight[i - params.rowIndex];
+ const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ const defaultRowHeight = worksheet.getConfig().defaultRowHeight;
+ const manager = worksheet.getRowManager();
+ const ranges = params.ranges;
+ for (let i = 0; i < ranges.length; i++) {
+ const range = ranges[i];
+ for (let j = range.startRow; j < range.endRow + 1; j++) {
+ const row = manager.getRowOrCreate(i);
+ if (typeof params.rowHeight === 'number') {
+ row.h = params.rowHeight;
+ } else {
+ row.h = params.rowHeight.get(j) ?? defaultRowHeight;
+ }
+ }
}
+
return true;
},
};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-hide.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-hide.mutation.ts
index 24dc17cf8c..3a837d2e46 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-hide.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-hide.mutation.ts
@@ -1,11 +1,10 @@
-import { CommandType, ICurrentUniverService, IMutation } from '@univerjs/core';
+import { CommandType, ICurrentUniverService, IMutation, IRangeData } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
export interface ISetWorksheetRowHideMutationParams {
workbookId: string;
worksheetId: string;
- rowIndex: number;
- rowCount: number;
+ ranges: IRangeData[];
}
export const SetWorksheetRowHideMutationFactory = (accessor: IAccessor, params: ISetWorksheetRowHideMutationParams) => {
@@ -19,8 +18,7 @@ export const SetWorksheetRowHideMutationFactory = (accessor: IAccessor, params:
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
+ ranges: params.ranges,
};
};
@@ -36,12 +34,17 @@ export const SetWorksheetRowHideMutation: IMutation<ISetWorksheetRowHideMutation
}
const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getRowManager();
- for (let i = params.rowIndex; i < params.rowIndex + params.rowCount; i++) {
- const row = manager.getRowOrCreate(i);
- if (row != null) {
- row.hd = 1;
+
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ for (let j = range.startRow; j < range.endRow + 1; j++) {
+ const row = manager.getRowOrCreate(j);
+ if (row != null) {
+ row.hd = 1;
+ }
}
}
+
return true;
},
};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-show.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-show.mutation.ts
index ae0d938d76..3fee0c24ca 100644
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-show.mutation.ts
+++ b/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-show.mutation.ts
@@ -1,11 +1,10 @@
-import { CommandType, ICurrentUniverService, IMutation } from '@univerjs/core';
+import { CommandType, ICurrentUniverService, IMutation, IRangeData } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
export interface ISetWorksheetRowShowMutationParams {
workbookId: string;
worksheetId: string;
- rowIndex: number;
- rowCount: number;
+ ranges: IRangeData[];
}
export const SetWorksheetRowShowMutationFactory = (accessor: IAccessor, params: ISetWorksheetRowShowMutationParams) => {
@@ -19,8 +18,7 @@ export const SetWorksheetRowShowMutationFactory = (accessor: IAccessor, params:
return {
workbookId: params.workbookId,
worksheetId: params.worksheetId,
- rowIndex: params.rowIndex,
- rowCount: params.rowCount,
+ ranges: params.ranges,
};
};
@@ -36,12 +34,16 @@ export const SetWorksheetRowShowMutation: IMutation<ISetWorksheetRowShowMutation
}
const manager = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getRowManager();
- for (let i = params.rowIndex; i < params.rowIndex + params.rowCount; i++) {
- const row = manager.getRowOrCreate(i);
- if (row != null) {
- row.hd = 0;
+ for (let i = 0; i < params.ranges.length; i++) {
+ const range = params.ranges[i];
+ for (let j = range.startRow; j < range.endRow + 1; j++) {
+ const row = manager.getRowOrCreate(j);
+ if (row != null) {
+ row.hd = 0;
+ }
}
}
+
return true;
},
};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-status.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-worksheet-status.mutation.ts
deleted file mode 100644
index 85b64abd4c..0000000000
--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-status.mutation.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { BooleanNumber, CommandType, ICurrentUniverService, IMutation } from '@univerjs/core';
-
-export interface ISetWorksheetStatusMutationParams {
- workbookId: string;
- worksheetId: string;
- sheetStatus: BooleanNumber;
-}
-
-export const SetWorksheetStatusMutation: IMutation<ISetWorksheetStatusMutationParams> = {
- id: 'sheet.mutation.set-worksheet-status',
- type: CommandType.MUTATION,
- handler: async (accessor, params) => {
- const currentUniverService = accessor.get(ICurrentUniverService);
- const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);
-
- if (universheet == null) {
- throw new Error('universheet is null error!');
- }
-
- const config = universheet.getWorkBook().getSheetBySheetId(params.worksheetId)!.getConfig()!;
- config.status = params.sheetStatus;
- return true;
- },
-};
diff --git a/packages/base-sheets/src/Commands/Mutations/set-zoom-ratio.mutation.ts b/packages/base-sheets/src/Commands/Mutations/set-zoom-ratio.mutation.ts
new file mode 100644
index 0000000000..1e847d7820
--- /dev/null
+++ b/packages/base-sheets/src/Commands/Mutations/set-zoom-ratio.mutation.ts
@@ -0,0 +1,32 @@
+import { CommandType, ICurrentUniverService, IMutation, Tools } from '@univerjs/core';
+import { IAccessor } from '@wendellhu/redi';
+
+export interface ISetZoomRatioMutationParams {
+ zoomRatio: number;
+ workbookId: string;
+ worksheetId: string;
+}
+
+export const SetZoomRatioUndoMutationFactory = (accessor: IAccessor, params: ISetZoomRatioMutationParams): ISetZoomRatioMutationParams => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ const worksheet = workbook!.getSheetBySheetId(params.worksheetId);
+ const old = worksheet!.getConfig().zoomRatio;
+ return {
+ ...Tools.deepClone(params),
+ zoomRatio: old,
+ };
+};
+
+export const SetZoomRatioMutation: IMutation<ISetZoomRatioMutationParams> = {
+ id: 'sheet.mutation.set-zoom-ratio',
+ type: CommandType.MUTATION,
+ handler: async (accessor, params) => {
+ const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();
+ if (!workbook) return false;
+ const worksheet = workbook.getSheetBySheetId(params.worksheetId);
+ if (!worksheet) return false;
+ worksheet.getConfig().zoomRatio = params.zoomRatio;
+
+ return true;
+ },
+};
diff --git a/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts b/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts
index b0563e0c67..acaf9b9327 100644
--- a/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts
+++ b/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts
@@ -1,5 +1,5 @@
import { IDisposable } from '@wendellhu/redi';
-import { Disposable, ICellData, ICellV, ICommandService, IRangeData, IStyleData, ObjectMatrix, ObjectMatrixPrimitiveType } from '@univerjs/core';
+import { Disposable, ICommandService, IStyleData } from '@univerjs/core';
import { ClearSelectionContentCommand } from '../Commands/Commands/clear-selection-content.command';
import { SetRangeValuesMutation } from '../Commands/Mutations/set-range-values.mutation';
@@ -20,12 +20,12 @@ import {
SetVerticalTextAlignCommand,
} from '../Commands/Commands/set-style.command';
import { SetRangeStyleMutation } from '../Commands/Mutations/set-range-styles.mutation';
-import { ISetRangeFormattedValueParams, SetRangeFormattedValueCommand } from '../Commands/Commands/set-range-formatted-value.command';
+import { SetRangeFormattedValueCommand } from '../Commands/Commands/set-range-formatted-value.command';
import { TrimWhitespaceCommand } from '../Commands/Commands/trim-whitespace.command';
-import { ISetRangeValuesCommandParams, SetRangeValuesCommand } from '../Commands/Commands/set-range-values.command';
+import { SetRangeValuesCommand } from '../Commands/Commands/set-range-values.command';
import { SetWorksheetHideCommand } from '../Commands/Commands/set-worksheet-hide.command';
import { SetWorksheetHideMutation } from '../Commands/Mutations/set-worksheet-hide.mutation';
-import { InsertColCommand, InsertRowCommand } from '../Commands/Commands/insert-row-col.command';
+import { InsertColCommand } from '../Commands/Commands/insert-row-col.command';
import { InsertColMutation, InsertRowMutation } from '../Commands/Mutations/insert-row-col.mutation';
import { RemoveColCommand, RemoveRowCommand } from '../Commands/Commands/remove-row-col.command';
import { RemoveColMutation, RemoveRowMutation } from '../Commands/Mutations/remove-row-col.mutation';
@@ -42,11 +42,11 @@ import { DeleteRangeMutation } from '../Commands/Mutations/delete-range.mutation
import { SetRangeFormattedValueMutation } from '../Commands/Mutations/set-range-formatted-value.mutation';
import { IInsertRangeMoveRightParams, InsertRangeMoveRightCommand } from '../Commands/Commands/insert-range-move-right.command';
import { DeleteRangeMoveLeftCommand, IDeleteRangeMoveLeftParams } from '../Commands/Commands/delete-range-move-left.command';
-import { DeleteRangeMoveUpCommand, IDeleteRangeMoveUpParams } from '../Commands/Commands/delete-range-move-up.command';
-import { IInsertRangeMoveBottomParams, InsertRangeMoveBottomCommand } from '../Commands/Commands/insert-range-move-bottom.command';
import { SetWorksheetOrderCommand } from '../Commands/Commands/set-worksheet-order.command';
import { SetWorksheetOrderMutation } from '../Commands/Mutations/set-worksheet-order.mutation';
import { SetBorderColorCommand, SetBorderCommand, SetBorderPositionCommand, SetBorderStyleCommand } from '../Commands/Commands/set-border-command';
+import { DeleteRangeMoveUpCommand } from '../Commands/Commands/delete-range-move-up.command';
+import { InsertRangeMoveDownCommand } from '../Commands/Commands/insert-range-move-down.command';
export interface IStyleTypeValue<T> {
type: keyof IStyleData;
@@ -72,7 +72,6 @@ export class BasicWorksheetController extends Disposable implements IDisposable
SetWorksheetHideCommand,
SetWorksheetHideMutation,
- InsertRowCommand,
InsertRowMutation,
RemoveRowCommand,
RemoveRowMutation,
@@ -95,7 +94,7 @@ export class BasicWorksheetController extends Disposable implements IDisposable
SetRangeValuesCommand,
TrimWhitespaceCommand,
InsertRangeMoveRightCommand,
- InsertRangeMoveBottomCommand,
+ InsertRangeMoveDownCommand,
InsertRangeMutation,
DeleteRangeMoveLeftCommand,
DeleteRangeMoveUpCommand,
@@ -126,113 +125,113 @@ export class BasicWorksheetController extends Disposable implements IDisposable
return this._commandService.executeCommand(ClearSelectionContentCommand.id);
}
- async setStyle<T>(workbookId: string, worksheetId: string, style: IStyleTypeValue<T>, range: IRangeData[]): Promise<boolean> {
- const options: ISetStyleParams<T> = {
- workbookId,
- worksheetId,
- style,
- ranges: range,
- };
- return this._commandService.executeCommand(SetStyleCommand.id, options);
- }
-
- /**
- * Trims the whitespace (such as spaces, tabs, or new lines) in every cell in this range. Removes all whitespace from the start and end of each cell's text, and reduces any subsequence of remaining whitespace characters to a single space.
- */
- async trimWhitespace(workbookId: string, worksheetId: string, range: IRangeData[]): Promise<boolean> {
- const options = {
- workbookId,
- worksheetId,
- range,
- };
- return this._commandService.executeCommand(TrimWhitespaceCommand.id, options);
- }
+ // async setStyle<T>(workbookId: string, worksheetId: string, style: IStyleTypeValue<T>, range: IRangeData[]): Promise<boolean> {
+ // const options: ISetStyleParams<T> = {
+ // workbookId,
+ // worksheetId,
+ // style,
+ // ranges: range,
+ // };
+ // return this._commandService.executeCommand(SetStyleCommand.id, options);
+ // }
- /**
- * Sets a rectangular grid of values (must match dimensions of this range).
- */
- async setValue(workbookId: string, worksheetId: string, value: ICellV | ICellV[][] | ObjectMatrix<ICellV>, range: IRangeData[]): Promise<boolean> {
- const options: ISetRangeFormattedValueParams = {
- workbookId,
- worksheetId,
- value,
- range,
- };
- return this._commandService.executeCommand(SetRangeFormattedValueCommand.id, options);
- }
+ // /**
+ // * Trims the whitespace (such as spaces, tabs, or new lines) in every cell in this range. Removes all whitespace from the start and end of each cell's text, and reduces any subsequence of remaining whitespace characters to a single space.
+ // */
+ // async trimWhitespace(workbookId: string, worksheetId: string, range: IRangeData[]): Promise<boolean> {
+ // const options = {
+ // workbookId,
+ // worksheetId,
+ // range,
+ // };
+ // return this._commandService.executeCommand(TrimWhitespaceCommand.id, options);
+ // }
- /**
- * Sets a rectangular grid of cell obejct data (must match dimensions of this range).
- * @param value A two-dimensional array of cell object data.
- */
- async setRangeValues(workbookId: string, worksheetId: string, value: ICellData | ICellData[][] | ObjectMatrixPrimitiveType<ICellData>, range: IRangeData): Promise<boolean> {
- const options: ISetRangeValuesCommandParams = {
- workbookId,
- worksheetId,
- value,
- range,
- };
- return this._commandService.executeCommand(SetRangeValuesCommand.id, options);
- }
+ // /**
+ // * Sets a rectangular grid of values (must match dimensions of this range).
+ // */
+ // async setValue(workbookId: string, worksheetId: string, value: ICellV | ICellV[][] | ObjectMatrix<ICellV>, range: IRangeData[]): Promise<boolean> {
+ // const options: ISetRangeFormattedValueParams = {
+ // workbookId,
+ // worksheetId,
+ // value,
+ // range,
+ // };
+ // return this._commandService.executeCommand(SetRangeFormattedValueCommand.id, options);
+ // }
- /**
- * Deletes this range of cells. Existing data in the sheet along the provided dimension is shifted towards the deleted range.
- *
- * solution: Clear the range to be deleted, and then set the new value of the cell content at the bottom using setValue
- */
- async deleteRangeMoveLeft(workbookId: string, worksheetId: string, range: IRangeData): Promise<boolean> {
- const options: IDeleteRangeMoveLeftParams = {
- workbookId,
- worksheetId,
- range,
- };
- return this._commandService.executeCommand(DeleteRangeMoveLeftCommand.id, options);
- }
+ // /**
+ // * Sets a rectangular grid of cell obejct data (must match dimensions of this range).
+ // * @param value A two-dimensional array of cell object data.
+ // */
+ // async setRangeValues(workbookId: string, worksheetId: string, value: ICellData | ICellData[][] | ObjectMatrixPrimitiveType<ICellData>, range: IRangeData): Promise<boolean> {
+ // const options: ISetRangeValuesCommandParams = {
+ // workbookId,
+ // worksheetId,
+ // value,
+ // range,
+ // };
+ // return this._commandService.executeCommand(SetRangeValuesCommand.id, options);
+ // }
- async deleteRangeMoveUp(workbookId: string, worksheetId: string, range: IRangeData): Promise<boolean> {
- const options: IDeleteRangeMoveUpParams = {
- workbookId,
- worksheetId,
- range,
- };
- return this._commandService.executeCommand(DeleteRangeMoveUpCommand.id, options);
- }
+ // /**
+ // * Deletes this range of cells. Existing data in the sheet along the provided dimension is shifted towards the deleted range.
+ // *
+ // * solution: Clear the range to be deleted, and then set the new value of the cell content at the bottom using setValue
+ // */
+ // async deleteRangeMoveLeft(workbookId: string, worksheetId: string, range: IRangeData): Promise<boolean> {
+ // const options: IDeleteRangeMoveLeftParams = {
+ // workbookId,
+ // worksheetId,
+ // range,
+ // };
+ // return this._commandService.executeCommand(DeleteRangeMoveLeftCommand.id, options);
+ // }
- /**
- * Inserts empty cells into this range. The new cells retain any formatting present in the cells previously occupying this range. Existing data in the sheet along the provided dimension is shifted away from the inserted range.
- */
- async insertRangeMoveRight(workbookId: string, worksheetId: string, range: IRangeData, destination?: IRangeData): Promise<boolean> {
- const options: IInsertRangeMoveRightParams = {
- workbookId,
- worksheetId,
- range,
- destination,
- };
- return this._commandService.executeCommand(InsertRangeMoveRightCommand.id, options);
- }
+ // async deleteRangeMoveUp(workbookId: string, worksheetId: string, range: IRangeData): Promise<boolean> {
+ // const options: IDeleteRangeMoveUpParams = {
+ // workbookId,
+ // worksheetId,
+ // range,
+ // };
+ // return this._commandService.executeCommand(DeleteRangeMoveUpCommand.id, options);
+ // }
- async insertRangeMoveBottom(workbookId: string, worksheetId: string, range: IRangeData, destination?: IRangeData): Promise<boolean> {
- const options: IInsertRangeMoveBottomParams = {
- workbookId,
- worksheetId,
- range,
- destination,
- };
- return this._commandService.executeCommand(InsertRangeMoveBottomCommand.id, options);
- }
+ // /**
+ // * Inserts empty cells into this range. The new cells retain any formatting present in the cells previously occupying this range. Existing data in the sheet along the provided dimension is shifted away from the inserted range.
+ // */
+ // async insertRangeMoveRight(workbookId: string, worksheetId: string, range: IRangeData, destination?: IRangeData): Promise<boolean> {
+ // const options: IInsertRangeMoveRightParams = {
+ // workbookId,
+ // worksheetId,
+ // range,
+ // destination,
+ // };
+ // return this._commandService.executeCommand(InsertRangeMoveRightCommand.id, options);
+ // }
- /**
- * Cut and paste (both format and values) from this range to the target range.
- * @param target A target range to copy this range to; only the top-left cell position is relevant.
- */
- // async moveTo(workbookId: string, worksheetId: string, range: IRangeData): Promise<boolean> {
- // const options: IInsertRangeParams = {
+ // async insertRangeMoveBottom(workbookId: string, worksheetId: string, range: IRangeData, destination?: IRangeData): Promise<boolean> {
+ // const options: IInsertRangeMoveBottomParams = {
// workbookId,
// worksheetId,
- // shiftDimension,
// range,
// destination,
// };
- // return this._commandService.executeCommand(SetRangeFormattedValueCommand.id, options);
+ // return this._commandService.executeCommand(InsertRangeMoveBottomCommand.id, options);
// }
+
+ // /**
+ // * Cut and paste (both format and values) from this range to the target range.
+ // * @param target A target range to copy this range to; only the top-left cell position is relevant.
+ // */
+ // // async moveTo(workbookId: string, worksheetId: string, range: IRangeData): Promise<boolean> {
+ // // const options: IInsertRangeParams = {
+ // // workbookId,
+ // // worksheetId,
+ // // shiftDimension,
+ // // range,
+ // // destination,
+ // // };
+ // // return this._commandService.executeCommand(SetRangeFormattedValueCommand.id, options);
+ // // }
}
diff --git a/packages/base-sheets/src/index.ts b/packages/base-sheets/src/index.ts
index e46df7ca75..d00c7f39be 100644
--- a/packages/base-sheets/src/index.ts
+++ b/packages/base-sheets/src/index.ts
@@ -46,7 +46,6 @@ export { SetWorksheetActivateCommand } from './Commands/Commands/set-worksheet-a
export { SetWorksheetOrderCommand } from './Commands/Commands/set-worksheet-order.command';
export { SetWorksheetRowHeightCommand } from './Commands/Commands/set-worksheet-row-height.command';
export { SetWorksheetColWidthCommand } from './Commands/Commands/set-worksheet-col-width.command';
-export { DeleteRangeCommand } from './Commands/Commands/delete-range.command';
export { DeleteRangeMoveLeftCommand } from './Commands/Commands/delete-range-move-left.command';
export { DeleteRangeMoveUpCommand } from './Commands/Commands/delete-range-move-up.command';
export { RemoveRowCommand, RemoveColCommand } from './Commands/Commands/remove-row-col.command';
diff --git a/packages/core/src/Shared/Rectangle.ts b/packages/core/src/Shared/Rectangle.ts
index c46e389477..8cfcefb7e2 100644
--- a/packages/core/src/Shared/Rectangle.ts
+++ b/packages/core/src/Shared/Rectangle.ts
@@ -15,12 +15,7 @@ export class Rectangle implements IRangeData {
constructor();
constructor(rectangle: IRangeData);
- constructor(
- startRow: number,
- startColumn: number,
- endRow: number,
- endColumn: number
- );
+ constructor(startRow: number, startColumn: number, endRow: number, endColumn: number);
constructor(...argument: any[]) {
if (Tools.hasLength(argument, 0)) {
this.startRow = 0;
@@ -50,12 +45,7 @@ export class Rectangle implements IRangeData {
}
static equals(src: IRangeData, target: IRangeData): boolean {
- return (
- src.endRow === target.endRow &&
- src.endColumn === target.endColumn &&
- src.startRow === target.startRow &&
- src.startColumn === target.startColumn
- );
+ return src.endRow === target.endRow && src.endColumn === target.endColumn && src.startRow === target.startRow && src.startColumn === target.startColumn;
}
static intersects(src: IRangeData, target: IRangeData): boolean {
@@ -69,21 +59,10 @@ export class Rectangle implements IRangeData {
const incomingStartColumn = target.startColumn;
const incomingEndColumn = target.endColumn;
- const zx = Math.abs(
- currentStartColumn +
- currentEndColumn -
- incomingStartColumn -
- incomingEndColumn
- );
- const x =
- Math.abs(currentStartColumn - currentEndColumn) +
- Math.abs(incomingStartColumn - incomingEndColumn);
- const zy = Math.abs(
- currentStartRow + currentEndRow - incomingStartRow - incomingEndRow
- );
- const y =
- Math.abs(currentStartRow - currentEndRow) +
- Math.abs(incomingStartRow - incomingEndRow);
+ const zx = Math.abs(currentStartColumn + currentEndColumn - incomingStartColumn - incomingEndColumn);
+ const x = Math.abs(currentStartColumn - currentEndColumn) + Math.abs(incomingStartColumn - incomingEndColumn);
+ const zy = Math.abs(currentStartRow + currentEndRow - incomingStartRow - incomingEndRow);
+ const y = Math.abs(currentStartRow - currentEndRow) + Math.abs(incomingStartRow - incomingEndRow);
return zx <= x && zy <= y;
}
@@ -96,9 +75,7 @@ export class Rectangle implements IRangeData {
const { startRow, startColumn, endRow, endColumn } = this;
return new Rectangle(
rectangle.startRow < this.startRow ? rectangle.startRow : startRow,
- rectangle.startColumn < startColumn
- ? rectangle.startColumn
- : startColumn,
+ rectangle.startColumn < startColumn ? rectangle.startColumn : startColumn,
rectangle.endRow > endRow ? rectangle.endRow : endRow,
rectangle.endColumn > endColumn ? rectangle.endColumn : endColumn
);
diff --git a/packages/core/src/Sheets/Domain/Range.ts b/packages/core/src/Sheets/Domain/Range.ts
index daf191040a..1fb722b699 100644
--- a/packages/core/src/Sheets/Domain/Range.ts
+++ b/packages/core/src/Sheets/Domain/Range.ts
@@ -3,46 +3,11 @@ import { ICurrentUniverService } from 'src/Service/Current.service';
// TODO@wzhudev: here we still have some
import { Inject } from '@wendellhu/redi';
-import {
- IInsertRangeActionData,
- IClearRangeActionData,
- IAddMergeActionData,
- IRemoveMergeActionData,
- IDeleteRangeActionData,
- ISetRangeDataActionData,
- ISetRangeStyleActionData,
- ISetRangeFormattedValueActionData,
- SetRangeStyleAction,
-} from '../Action';
-import { CommandManager, ISheetActionData, Command } from '../../Command';
+import { IClearRangeActionData, IAddMergeActionData, IRemoveMergeActionData, ISetRangeDataActionData } from '../Action';
+import { CommandManager, Command } from '../../Command';
import { DEFAULT_RANGE, DEFAULT_STYLES, ACTION_NAMES } from '../../Types/Const';
-import {
- BooleanNumber,
- BorderStyleTypes,
- BorderType,
- Dimension,
- Direction,
- FontItalic,
- FontWeight,
- HorizontalAlign,
- TextDirection,
- VerticalAlign,
- WrapStrategy,
- CopyPasteType,
-} from '../../Types/Enum';
-import {
- IBorderData,
- IBorderStyleData,
- ICellData,
- ICellDataMatrix,
- ICellV,
- IDocumentData,
- IOptionData,
- IRangeData,
- IRangeType,
- IStyleData,
- ITextDecoration,
-} from '../../Types/Interfaces';
+import { BooleanNumber, Dimension, Direction, FontItalic, FontWeight, HorizontalAlign, VerticalAlign, WrapStrategy } from '../../Types/Enum';
+import { IBorderData, ICellData, IDocumentData, IOptionData, IRangeData, IRangeType, IStyleData, ITextDecoration } from '../../Types/Interfaces';
import { Nullable, ObjectMatrix, ObjectMatrixPrimitiveType, Tools, Tuples } from '../../Shared';
import { Worksheet } from './Worksheet';
@@ -677,7 +642,7 @@ export class Range {
* Returns the text rotation settings for the top left cell of the range.
*/
// getTextRotation(): number {
- getTextRotation(): number {
+ getTextRotation() {
return this.getTextRotations()[0][0];
}
@@ -685,8 +650,8 @@ export class Range {
* Returns the text rotation settings for the cells in the range.
*/
// getTextRotations(): number[][] {
- getTextRotations(): number[][] {
- return this._getStyles('tr') as any as number[][]; // FIXME@Dushusir: fix type
+ getTextRotations() {
+ return this._getStyles('tr');
}
/**
@@ -786,1895 +751,234 @@ export class Range {
}
/**
- * Sets the background color of all cells in the range in CSS notation (such as '#ffffff' or 'white').
- *
- * @param color Sets the background color of all cells in the range in CSS notation (such as '#ffffff' or 'white').
- * @returns This range, for chaining.
- */
- setBackground(color: string): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
-
- const colorObj: IStyleData = {
- bg: {
- rgb: color,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, colorObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets a rectangular grid of background colors (must match dimensions of this range). The colors are in CSS notation (such as '#ffffff' or 'white').
- *
- * @param color A two-dimensional array of colors in CSS notation (such as '#ffffff' or 'white'); null values reset the color.
- * @returns This range, for chaining.
- */
- setBackgrounds(color: string[][]): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- const matrix = new ObjectMatrix<IStyleData>();
- for (let r = 0; r < endRow - startRow + 1; r++) {
- for (let c = 0; c < endColumn - startColumn + 1; c++) {
- matrix.setValue(r, c, {
- bg: {
- rgb: color[r][c],
- },
- });
- }
- }
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: matrix.getData(),
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets the background to the given color using RGB values (integers between 0 and 255 inclusive).
- *
- * @param red The red value in RGB notation.
- * @param green The green value in RGB notation.
- * @param blue The blue value in RGB notation.
- * @returns This range, for chaining.
- */
- setBackgroundRGB(red: number, green: number, blue: number): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const rgbString = `RGB(${red},${green},${blue})`;
-
- const colorObj: IStyleData = {
- bg: {
- rgb: rgbString,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, colorObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets a rectangular grid of font colors (must match dimensions of this range). The colors are in CSS notation (such as '#ffffff' or 'white').
- *
- * @param colors A two-dimensional array of colors in CSS notation (such as '#ffffff' or 'white'); null values reset the color.
- * @returns This range, for chaining.
- */
- setFontColors(colors: string[][]): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- const matrix = new ObjectMatrix<IStyleData>();
- for (let r = 0; r < endRow - startRow + 1; r++) {
- for (let c = 0; c < endColumn - startColumn + 1; c++) {
- matrix.setValue(r, c, { cl: { rgb: colors[r][c] } });
- }
- }
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: matrix.getData(),
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets a rectangular grid of font families (must match dimensions of this range). Examples of font families are "Arial" or "Helvetica".
- *
- * @param fontFamilies A two-dimensional array of font families; null values reset the font family.
- * @returns This range, for chaining.
- */
- setFontFamilies(fontFamilies: string[][]): Range {
- this._setStyles(fontFamilies, 'ff');
- return this;
- }
-
- /**
- * Sets the font line style of the given range
- *
- * @param fontLine The font line style; a null value resets the font line style
- * @returns This range, for chaining.
- */
- setOverline(fontLine: Nullable<ITextDecoration>): Range {
- this._setStyle(fontLine, 'ol');
- return this;
- }
-
- /**
- * Sets a rectangular grid of line styles (must match dimensions of this range).
- *
- * @param fontLine The font line style; a null value resets the font line style
- * @returns This range, for chaining.
- */
- setStrikeThrough(fontLine: Nullable<ITextDecoration>): Range {
- this._setStyle(fontLine, 'st');
- return this;
- }
-
- /**
- * Sets the font line style of the given range
- *
- * @param fontLines A two-dimensional array of font line styles ; null values reset the font line style.
- * @returns This range, for chaining.
- */
- setOverlines(fontLines: Array<Array<Nullable<ITextDecoration>>>): Range {
- this._setStyles(fontLines, 'ol');
- return this;
- }
-
- /**
- * Sets a rectangular grid of font sizes (must match dimensions of this range).
- *
- * @param sizes A two-dimensional array of sizes.
- * @returns This range, for chaining.
- */
- setFontSizes(sizes: number[][]): Range {
- this._setStyles(sizes, 'fs');
- return this;
- }
-
- /**
- * Set the font style for the given range ('italic' or 'normal').
- *
- * @param fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
- * @returns This range, for chaining.
- */
- setFontStyle(fontStyle: Nullable<FontItalic>): Range {
- this._setStyle(fontStyle, 'it');
- return this;
- }
-
- /**
- * Sets a rectangular grid of font styles (must match dimensions of this range).
- *
- * @param fontStyles A two-dimensional array of font styles, either 'italic' or 'normal'; null values reset the font style.
- * @returns This range, for chaining.
- */
- setFontStyles(fontStyles: Array<Array<Nullable<FontItalic>>>): Range {
- this._setStyles(fontStyles, 'it');
- return this;
- }
-
- /**
- * Sets a rectangular grid of horizontal alignments.
- *
- * @param alignments A two-dimensional array of alignments, either 'left', 'center' or 'normal'; a null value resets the alignment.
- * @returns This range, for chaining.
- */
- setHorizontalAlignments(alignments: Array<Array<Nullable<HorizontalAlign>>>): Range {
- this._setStyles(alignments, 'ht');
- return this;
- }
-
- /**
- * Sets a rectangular grid of text directions.
- *
- * @param directions The desired text directions; if a specified direction is null it is inferred before setting.
- * @returns This range, for chaining.
- */
- setTextDirections(directions: number[][]): Range {
- this._setStyles(directions, 'td');
- return this;
- }
-
- /**
- * Sets the text rotation settings for the cells in the range.
- *
- * @param degrees The desired angle between the standard orientation and the desired orientation. For left to right text, positive angles are in the counterclockwise direction.
- * @returns This range, for chaining.
- */
- setTextRotation(degrees: Nullable<number>): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const styleObj: IStyleData = {
- tr: {
- v: 0,
- a: Number(degrees),
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets a rectangular grid of text rotations.
- *
- * @param rotations The desired text rotation settings.
- * @returns This range, for chaining.
- */
- setTextRotations(rotations: number[][]): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- const matrix = new ObjectMatrix<IStyleData>();
- for (let r = 0; r < endRow - startRow + 1; r++) {
- for (let c = 0; c < endColumn - startColumn + 1; c++) {
- matrix.setValue(r, c, {
- tr: {
- v: 0,
- a: rotations[r][c]!,
- },
- });
- }
- }
- const a = matrix.getData();
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: matrix.getData(),
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets the text style for the cells in the range.
- *
- * @param style The desired text style.
- * @returns This range, for chaining.
- */
- setTextStyle(style: Nullable<IStyleData>): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const stylesObj = { ...style };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, stylesObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets a rectangular grid of text styles.
- *
- * @param styles The desired text styles.
- * @returns This range, for chaining.
- */
- setTextStyles(styles: Array<Array<Nullable<IStyleData>>>): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- const matrix = new ObjectMatrix<IStyleData>();
- for (let r = 0; r < endRow - startRow + 1; r++) {
- for (let c = 0; c < endColumn - startColumn + 1; c++) {
- matrix.setValue(r, c, { ...styles[r][c] });
- }
- }
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: matrix.getData(),
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets a rectangular grid of vertical alignments (must match dimensions of this range).
- *
- * @param alignments A two-dimensional array of alignments, either 'top', 'middle' or 'bottom'; a null value resets the alignment.
- * @returns This range, for chaining.
- */
- setVerticalAlignments(alignments: Array<Array<Nullable<VerticalAlign>>>): Range {
- this._setStyles(alignments, 'vt');
- return this;
- }
-
- /**
- * Sets whether or not to stack the text for the cells in the range.
- * @param isVertical Whether or not to stack the text.
- * @returns
- */
- setVerticalText(isVertical: BooleanNumber): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const styleObj = {
- tr: {
- v: isVertical,
- a: 90,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Set the cell wrap of the given range
- *
- * @param isWrapEnabled Whether to wrap text or not.
- * @returns This range, for chaining.
- */
- setWrap(isWrapEnabled: BooleanNumber): Range {
- this._setStyle(isWrapEnabled, 'tb');
- return this;
- }
-
- /**
- * Sets a rectangular grid of wrap strategies.
- *
- * @param strategies The desired wrapping strategies.
- * @returns This range, for chaining.
- */
- setWrapStrategies(strategies: Array<Array<Nullable<WrapStrategy>>>): Range {
- this._setStyles(strategies, 'tb');
- return this;
- }
-
- /**
- * Sets a rectangular grid of word wrap policies (must match dimensions of this range).
- *
- * @param isWrapEnabled A two-dimensional array of wrap variables that determine whether to wrap text in a cell or not.
- * @returns This range, for chaining.
- */
- setWraps(isWrapEnabled: BooleanNumber[][]): Range {
- this._setStyles(isWrapEnabled, 'tb');
- return this;
- }
-
- /**
- * Returns a copy of the range expanded in the four cardinal Directions to cover all adjacent cells with data in them.
- *
- * @returns This range, for chaining.
- */
- getDataRegion(): Range;
- /**
- * Returns a copy of the range expanded Direction.UP and Direction.DOWN if the specified dimension is Dimension.ROWS, or Direction.NEXT and Direction.PREVIOUS if the dimension is Dimension.COLUMNS.
- *
- * @returns This range, for chaining.
- */
- getDataRegion(dimension: Dimension): Range;
- // eslint-disable-next-line max-lines-per-function
- getDataRegion(...argument: any): Range {
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
- let numRows: number;
- let numColumns: number;
-
- const data = this._worksheet.getCellMatrix();
- if (Tools.isNumber(argument[0])) {
- const dimension = argument[0];
-
- if (dimension === Dimension.COLUMNS) {
- let start: number = startRow;
- let end: number = startRow;
- const rowMax = this._worksheet.getRowCount();
- for (let i = 1; i < startRow; i++) {
- const element = data.getValue(startRow - i, startColumn);
- if (!element) {
- start = startRow - i + 1;
- break;
- }
- }
- const j = 0;
- while (j < rowMax - startRow) {
- const element = data.getValue(startRow + j, startColumn);
- if (!element) {
- end = startRow - j - 1;
- break;
- }
- }
-
- numColumns = start - end;
- numRows = 0;
- return this._worksheet.getRange(startRow, start, numRows, numColumns);
- }
- if (dimension === Dimension.ROWS) {
- let start: number = startRow;
- let end: number = startRow;
- const colMax = this._worksheet.getColumnCount();
- for (let i = 1; i < startRow; i++) {
- const element = data.getValue(startRow, startColumn - i);
- if (!element) {
- start = startRow - i + 1;
- break;
- }
- }
- const j = 0;
- while (j < colMax - startColumn) {
- const element = data.getValue(startRow, startColumn + j);
- if (!element) {
- end = startRow - j - 1;
- break;
- }
- }
-
- numColumns = 0;
- numRows = start - end;
- return this._worksheet.getRange(start, startColumn, numRows, numColumns);
- }
- } else {
- let rowStart: number = startRow;
- let rowEnd: number = startRow;
- const rowMax = this._worksheet.getRowCount();
- for (let i = 1; i < startRow; i++) {
- const element = data.getValue(startRow - i, startColumn);
- if (!element) {
- rowStart = startRow - i + 1;
- break;
- }
- }
- const rj = 0;
- while (rj < rowMax - startRow) {
- const element = data.getValue(startRow + rj, startColumn);
- if (!element) {
- rowEnd = startRow - rj - 1;
- break;
- }
- }
-
- let columnStart: number = startRow;
- let columnEnd: number = startRow;
- const colMax = this._worksheet.getColumnCount();
- for (let i = 1; i < startRow; i++) {
- const element = data.getValue(startRow, startColumn - i);
- if (!element) {
- columnStart = startRow - i + 1;
- break;
- }
- }
- const cj = 0;
- while (cj < colMax - startColumn) {
- const element = data.getValue(startRow, startColumn + cj);
- if (!element) {
- columnEnd = startRow - cj - 1;
- break;
- }
- }
-
- numColumns = columnStart - columnEnd;
- numColumns = rowStart - rowEnd;
- numRows = startRow;
- return this._worksheet.getRange(rowStart, columnStart, numRows, numColumns);
- }
- return this;
- }
-
- /**
- * Trims the whitespace (such as spaces, tabs, or new lines) in every cell in this range. Removes all whitespace from the start and end of each cell's text, and reduces any subsequence of remaining whitespace characters to a single space.
- *
- * @returns This range, for chaining.
- */
- trimWhitespace(): Range {
- const { _worksheet, _commandManager } = this;
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
- const sheetMatrix = this._worksheet.getCellMatrix();
- const regx = /\s+/g;
-
- const cellValue = new ObjectMatrix<ICellV>();
- for (let r = 0; r <= endRow - startRow; r++) {
- for (let c = 0; c <= endColumn - startColumn; c++) {
- const value = sheetMatrix.getValue(r, c)!.m?.replace(regx, '');
- cellValue.setValue(r + startRow, c + startColumn, value || '');
- }
- }
-
- const setValue: ISetRangeFormattedValueActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_FORMATTED_VALUE_ACTION,
- cellValue: cellValue.getData(),
- rangeData: this._rangeData,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
-
- return this;
- }
- // uncheck
-
- /**
- * Sets the specified range as the active range, with the top left cell in the range as the current cell.
- *
- * @returns This range, for chaining.
- * @internal
- */
- activate(): Range {
- // const { _commandManager } = this;
- // The user entered an invalid range
- if (this._rangeData?.startRow === -1) {
- console.error('Invalid range,default set startRow -1');
- return this;
- }
-
- this._worksheet.getSelection().setSelection({ selection: this });
-
- // This range, for chaining
- return this;
- }
-
- /**
- * Sets the specified cell as the current cell.
- *
- * If the specified cell is present in an existing range, then that range becomes the active range with the cell as the current cell.
- *
- * If the specified cell is not present in any existing range, then the existing selection is removed and the cell becomes the current cell and the active range.
- *
- * Note: The specified Range must consist of one cell, otherwise it throws an exception.
- *
- * @returns This range, for chaining.
- */
- activateAsCurrentCell(): Range {
- this._worksheet.getSelection().setCurrentCell(this);
- return this;
- }
-
- /**
- * Whether the current range and the incoming range have an intersection
- *
- * @param range the incoming range
- * @returns Intersect or not
- */
- isIntersection(range: Range): boolean {
- const currentStartRow = this._rangeData.startRow;
- const currentEndRow = this._rangeData.endRow;
- const currentStartColumn = this._rangeData.startColumn;
- const currentEndColumn = this._rangeData.endColumn;
-
- const incomingStartRow = range.getRangeData().startRow;
- const incomingEndRow = range.getRangeData().endRow;
- const incomingStartColumn = range.getRangeData().startColumn;
- const incomingEndColumn = range.getRangeData().endColumn;
-
- const zx = Math.abs(currentStartColumn + currentEndColumn - incomingStartColumn - incomingEndColumn);
- const x = Math.abs(currentStartColumn - currentEndColumn) + Math.abs(incomingStartColumn - incomingEndColumn);
- const zy = Math.abs(currentStartRow + currentEndRow - incomingStartRow - incomingEndRow);
- const y = Math.abs(currentStartRow - currentEndRow) + Math.abs(incomingStartRow - incomingEndRow);
- if (zx <= x && zy <= y) {
- return true;
- }
- return false;
- }
-
- /**
- * Sets the font color in CSS notation (such as '#ffffff' or 'white').
- *
- * @param color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
- * @returns
- */
- setFontColor(color: string): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
-
- const colorObj: IStyleData = {
- cl: {
- rgb: color,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, colorObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Copies the data from a range of cells to another range of cells. Both the values and formatting are copied.
- *
- * @param destination A destination range to copy to; only the top-left cell position is relevant.
- */
- copyTo(destination: Range): void;
-
- /**
- * Copies the data from a range of cells to another range of cells..
- *
- * @param destination A destination range to copy to; only the top-left cell position is relevant.
- * @param copyPasteType A type that specifies how the range contents are pasted to the destination.
- * @param transposed Whether the range should be pasted in its transposed orientation.
- */
- copyTo(destination: Range, copyPasteType: CopyPasteType, transposed: boolean): void;
-
- /**
- * Copies the data from a range of cells to another range of cells. By default both the values and formatting are copied, but this can be overridden using advanced arguments.
- *
- * @param destination A destination range to copy to; only the top-left cell position is relevant.
- * @param options A JavaScript object that specifies advanced parameters, as listed below.
- */
- copyTo(destination: Range, options: IOptionData): void;
- // eslint-disable-next-line max-lines-per-function
- copyTo(...argument: any): void {
- const { _worksheet, _commandManager } = this;
- const destination = argument[0];
- const [value, range] = this._handleCopyRange(this, destination);
- const { startRow, startColumn, endRow, endColumn } = range;
-
- if (Tuples.checkup(argument, Range, Tuples.BOOLEAN_TYPE)) {
- const copyPasteType = argument[1];
- const transposed = argument[2];
-
- if (copyPasteType === CopyPasteType.PASTE_NORMAL) {
- const cellValue = new ObjectMatrix<ICellData>();
- value.forEach((row, r) =>
- row.forEach((cell, c) => {
- cell = cell as ICellData;
- cellValue.setValue(r + startRow, c + startColumn, cell || {});
- })
- );
-
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue: cellValue.getData(),
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- } else if (copyPasteType === CopyPasteType.PASTE_FORMAT) {
- const styles = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getStyles();
-
- const stylesMatrix = new ObjectMatrix<IStyleData>();
- const stylesArray = value.map((row, r) =>
- row.forEach((cell, c) => {
- cell = cell as ICellData;
- stylesMatrix.setValue(r, c, styles.getStyleByCell(cell) || {});
- })
- );
-
- // Organize the style format of the current range into the format of the destination range
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix.getData(),
- rangeData: range,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- } else if (copyPasteType === CopyPasteType.PASTE_VALUES) {
- const cellValue = new ObjectMatrix<ICellV>();
- value.forEach((row, r) =>
- row.forEach((cell, c) => {
- cell = cell as ICellData;
- cellValue.setValue(r + startRow, c + startColumn, cell?.v || '');
- })
- );
-
- const setValue: ISetRangeFormattedValueActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_FORMATTED_VALUE_ACTION,
- cellValue: cellValue.getData(),
- rangeData: range,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- } else if (copyPasteType === CopyPasteType.PASTE_COLUMN_WIDTHS) {
- const rangeStartColumn = this._rangeData.startColumn;
- for (let i = 0; i < endColumn - rangeStartColumn; i++) {
- const width = _worksheet.getColumnWidth(rangeStartColumn + i);
- _worksheet.setColumnWidth(rangeStartColumn + i, width);
- }
- }
- } else if (Tuples.checkup(argument, Range, Tuples.OBJECT_TYPE)) {
- const options = argument[1];
-
- const cellValue = new ObjectMatrix<ICellData>();
- value.forEach((row, r) =>
- row.forEach((cell, c) => {
- cell = cell as ICellData;
- cellValue.setValue(r + startRow, c + startColumn, cell || {});
- })
- );
-
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue: cellValue.getData(),
- options,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- } else if (Tuples.checkup(argument, Range)) {
- const cellValue = new ObjectMatrix<ICellData>();
- value.forEach((row, r) =>
- row.forEach((cell, c) => {
- cell = cell as ICellData;
- cellValue.setValue(r + startRow, c + startColumn, cell || {});
- })
- );
-
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue: cellValue.getData(),
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- }
- }
-
- /**
- * Copy the formatting of the range to the given location. If the destination is larger or smaller than the source range then the source is repeated or truncated accordingly. Note that this method copies the formatting only.
- *
- * @param sheetId The unique ID of the sheet within the spreadsheet, irrespective of position.
- * @param startRow The start row of the target range.
- * @param endRow The end row of the target range.
- * @param startColumn The first column of the target range.
- * @param endColumn The end column of the target range.
- */
- copyFormatToRange(sheetId: string, startRow: number, endRow: number, startColumn: number, endColumn: number): void;
- /**
- * Copy the formatting of the range to the given location. If the destination is larger or smaller than the source range then the source is repeated or truncated accordingly. Note that this method copies the formatting only.
- *
- * @param sheet The target sheet.
- * @param startRow The start row of the target range.
- * @param endRow The end row of the target range.
- * @param startColumn The first column of the target range.
- * @param endColumn The end column of the target range.
- */
- copyFormatToRange(sheet: Worksheet, startRow: number, endRow: number, startColumn: number, endColumn: number): void;
- copyFormatToRange(...argument: any): void {
- const { _commandManager } = this;
-
- const startRow = argument[1];
- const endRow = argument[2];
- const startColumn = argument[3];
- const endColumn = argument[4];
-
- const sheetId = Tools.isAssignableFrom(argument[0], Worksheet) ? argument[0].getSheetId() : argument[0];
-
- const [value, range] = this._handleCopyRange(this, {
- startRow,
- endRow,
- startColumn,
- endColumn,
- });
-
- const styles = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getStyles();
-
- const stylesMatrix = new ObjectMatrix<IStyleData>();
- value.map((row, r) =>
- row.map((cell, c) => {
- cell = cell as ICellData;
- stylesMatrix.setValue(r, c, styles.getStyleByCell(cell) || {});
- return styles.getStyleByCell(cell) || {};
- })
- );
-
- // Organize the style format of the current range into the format of the destination range
- const setStyle: ISetRangeStyleActionData = {
- sheetId,
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix.getData(),
- rangeData: range,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- }
-
- /**
- * Copy the content of the range to the given location. If the destination is larger or smaller than the source range then the source is repeated or truncated accordingly.For a detailed description of the gridId parameter, see getGridId().
- * @param sheetId The unique ID of the sheet within the spreadsheet, irrespective of position.
- * @param startRow The start row of the target range.
- * @param endRow The end row of the target range.
- * @param startColumn The first column of the target range.
- * @param endColumn The end column of the target range.
- * @returns
- */
- copyValuesToRange(sheetId: string, startRow: number, endRow: number, startColumn: number, endColumn: number): void;
- /**
- * Copy the content of the range to the given location. If the destination is larger or smaller than the source range then the source is repeated or truncated accordingly.
- * @param sheet The target sheet.
- * @param startRow The start row of the target range.
- * @param endRow The end row of the target range.
- * @param startColumn The first column of the target range.
- * @param endColumn The end column of the target range.
- * @returns
- */
- copyValuesToRange(sheet: Worksheet, startRow: number, endRow: number, startColumn: number, endColumn: number): void;
- copyValuesToRange(...argument: any): void {
- const { _commandManager } = this;
-
- const startRow = argument[1];
- const endRow = argument[2];
- const startColumn = argument[3];
- const endColumn = argument[4];
-
- const sheetId = Tools.isAssignableFrom(argument[0], Worksheet) ? argument[0].getSheetId() : argument[0];
-
- const [value, range] = this._handleCopyRange(this, {
- startRow,
- endRow,
- startColumn,
- endColumn,
- });
-
- const cellValue = new ObjectMatrix<ICellV>();
- value.forEach((row, r) =>
- row.forEach((cell, c) => {
- cell = cell as ICellData;
- cellValue.setValue(r + range.startRow, c + range.startColumn, cell?.v || '');
- })
- );
-
- const setValue: ISetRangeFormattedValueActionData = {
- sheetId,
- actionName: ACTION_NAMES.SET_RANGE_FORMATTED_VALUE_ACTION,
- cellValue: cellValue.getData(),
- rangeData: range,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- }
-
- /**
- * Cut and paste (both format and values) from this range to the target range.
- * @param target A target range to copy this range to; only the top-left cell position is relevant.
- * @returns
- */
- moveTo(target: Range): void {
- const { _worksheet, _commandManager, _rangeData } = this;
-
- // clear current range
- const options = {
- formatOnly: true,
- contentsOnly: true,
- commentsOnly: true,
- validationsOnly: true,
- skipFilteredRows: true,
- };
- const clearValue: IClearRangeActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.CLEAR_RANGE_ACTION,
- options,
- rangeData: _rangeData,
- };
-
- // get values from this range
- const currentMatrix = this.getMatrix();
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
- const { startRow: targetStartRow, startColumn: targetStartColumn } = target.getRangeData();
-
- const targetMatrix = new ObjectMatrix<ICellData>();
-
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- targetMatrix.setValue(targetStartRow + (r - startRow), targetStartColumn + (c - startColumn), currentMatrix.getValue(r, c) || {});
- }
- }
-
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue: targetMatrix.getData(),
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- clearValue,
- setValue
- );
- _commandManager.invoke(command);
- }
-
- /**
- * Returns a new range that is offset from this range by the given number of rows and columns (which can be negative). The new range is the same size as the original range.
- * @param rowOffset The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
- * @param columnOffset The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
- * @returns Range — This range, for chaining.
- */
- offset(rowOffset: number, columnOffset: number): Range;
-
- /**
- * Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height in cells.
- * @param rowOffset The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
- * @param columnOffset The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
- * @param numRows The height in rows of the new range.
- * @returns Range — This range, for chaining.
- */
- offset(rowOffset: number, columnOffset: number, numRows: number): Range;
-
- /**
- * Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height and width in cells.
- * @param rowOffset The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
- * @param columnOffset The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
- * @param numRows The height in rows of the new range.
- * @param numColumns The width in columns of the new range.
- * @returns Range — This range, for chaining.
- */
- offset(rowOffset: number, columnOffset: number, numRows: number, numColumns: number): Range;
- offset(...argument: any): Range {
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
- const rowOffset = argument[0];
- const columnOffset = argument[1];
- const numRows = argument[2];
- const numColumns = argument[3];
-
- const offset = {
- startRow: startRow + rowOffset,
- endRow: endRow + rowOffset,
- startColumn: startColumn + columnOffset,
- endColumn: endColumn + columnOffset,
- };
-
- if (Tools.isNumber(numRows)) {
- offset.endRow = offset.startRow + numRows - 1;
- }
-
- if (Tools.isNumber(numColumns)) {
- offset.endColumn = offset.endColumn + numColumns - 1;
- }
-
- return new Range(this._worksheet, offset, this._currentUniverService, this._commandManager);
- }
-
+ * Returns a copy of the range expanded in the four cardinal Directions to cover all adjacent cells with data in them.
+ *
+ * @returns This range, for chaining.
+ */
+ getDataRegion(): Range;
/**
- * Sets the border property with color and/or style. Valid values are true (on), false (off) and null (no change). For color, use Color in CSS notation (such as '#ffffff' or 'white').
+ * Returns a copy of the range expanded Direction.UP and Direction.DOWN if the specified dimension is Dimension.ROWS, or Direction.NEXT and Direction.PREVIOUS if the dimension is Dimension.COLUMNS.
*
- * @param top true for border, false for none, null for no change.
- * @param left true for border, false for none, null for no change.
- * @param bottom true for border, false for none, null for no change.
- * @param right true for border, false for none, null for no change.
- * @param vertical true for internal vertical borders, false for none, null for no change.
- * @param horizontal true for internal horizontal borders, false for none, null for no change.
- * @param color A color in CSS notation (such as '#ffffff' or 'white'), null for default color (black).
- * @param style A style for the borders, null for default style (solid).
- * @returns
+ * @returns This range, for chaining.
*/
- setBorder(
- top: Nullable<boolean>,
- left: Nullable<boolean>,
- bottom: Nullable<boolean>,
- right: Nullable<boolean>,
- vertical: Nullable<boolean>,
- horizontal: Nullable<boolean>
- ): Range;
- setBorder(
- top: Nullable<boolean>,
- left: Nullable<boolean>,
- bottom: Nullable<boolean>,
- right: Nullable<boolean>,
- vertical: Nullable<boolean>,
- horizontal: Nullable<boolean>,
- color: string,
- style: BorderStyleTypes
- ): Range;
+ getDataRegion(dimension: Dimension): Range;
// eslint-disable-next-line max-lines-per-function
- setBorder(...argument: any): Range {
- const top = argument[0];
- const left = argument[1];
- const bottom = argument[2];
- const right = argument[3];
-
- const vertical = argument[4];
- const horizontal = argument[5];
-
- const color = argument[6] ? argument[6] : 'black';
- const style = argument[7] ? argument[7] : BorderStyleTypes.DASH_DOT;
-
- const { _worksheet, _commandManager } = this;
- const _workbook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
-
- const rangeData = this._rangeData;
- const _sheetId = _worksheet.getSheetId();
-
- // Cells in the surrounding range may need to clear the border
- const topRangeOut = {
- startRow: rangeData.startRow - 1,
- startColumn: rangeData.startColumn,
- endRow: rangeData.startRow - 1,
- endColumn: rangeData.endColumn,
- };
-
- const leftRangeOut = {
- startRow: rangeData.startRow,
- startColumn: rangeData.startColumn - 1,
- endRow: rangeData.endRow,
- endColumn: rangeData.startColumn - 1,
- };
-
- const bottomRangeOut = {
- startRow: rangeData.endRow + 1,
- startColumn: rangeData.startColumn,
- endRow: rangeData.endRow + 1,
- endColumn: rangeData.endColumn,
- };
-
- const rightRangeOut = {
- startRow: rangeData.startRow,
- startColumn: rangeData.endColumn + 1,
- endRow: rangeData.endRow,
- endColumn: rangeData.endColumn + 1,
- };
-
- // Cells in the upper, lower, left and right ranges
- const topRange = {
- startRow: rangeData.startRow,
- startColumn: rangeData.startColumn,
- endRow: rangeData.startRow,
- endColumn: rangeData.endColumn,
- };
-
- const leftRange = {
- startRow: rangeData.startRow,
- startColumn: rangeData.startColumn,
- endRow: rangeData.endRow,
- endColumn: rangeData.startColumn,
- };
-
- const bottomRange = {
- startRow: rangeData.endRow,
- startColumn: rangeData.startColumn,
- endRow: rangeData.endRow,
- endColumn: rangeData.endColumn,
- };
-
- const rightRange = {
- startRow: rangeData.startRow,
- startColumn: rangeData.endColumn,
- endRow: rangeData.endRow,
- endColumn: rangeData.endColumn,
- };
-
- const tr = new Range(_worksheet, topRangeOut, this._currentUniverService, this._commandManager);
- const lr = new Range(_worksheet, leftRangeOut, this._currentUniverService, this._commandManager);
- const br = new Range(_worksheet, bottomRangeOut, this._currentUniverService, this._commandManager);
- const rr = new Range(_worksheet, rightRangeOut, this._currentUniverService, this._commandManager);
- const t = new Range(_worksheet, topRange, this._currentUniverService, this._commandManager);
- const l = new Range(_worksheet, leftRange, this._currentUniverService, this._commandManager);
- const b = new Range(_worksheet, bottomRange, this._currentUniverService, this._commandManager);
- const r = new Range(_worksheet, rightRange, this._currentUniverService, this._commandManager);
-
- const mtr = new ObjectMatrix<IStyleData>();
- const mlr = new ObjectMatrix<IStyleData>();
- const mbr = new ObjectMatrix<IStyleData>();
- const mrr = new ObjectMatrix<IStyleData>();
- const mcr = new ObjectMatrix<IStyleData>();
-
- const actions: ISheetActionData[] = [];
-
- const border: IBorderStyleData = {
- s: style,
- cl: {
- rgb: color,
- },
- };
-
- if (top === true || top === false) {
- // Probably to the border, there are no surrounding cells
- if (tr.isValid()) {
- // Clear the bottom border of the top range
- tr.forEach((row, column) => {
- mtr.setValue(row, column, { bd: { b: null } });
- });
-
- const setBottomData: ISetRangeStyleActionData = {
- sheetId: _sheetId,
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: mtr.getArrayData(),
- rangeData: topRangeOut,
- };
- actions.push(setBottomData);
- }
+ getDataRegion(...argument: any): Range {
+ const { startRow, endRow, startColumn, endColumn } = this._rangeData;
+ let numRows: number;
+ let numColumns: number;
- // first row
- t.forEach((row, column) => {
- // update
- if (top === true) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { t: Tools.deepClone(border) },
- });
- mcr.setValue(row, column, style);
- }
- // delete
- else if (top === false) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { t: null },
- });
- mcr.setValue(row, column, style);
- }
- });
- }
- if (bottom === true || bottom === false) {
- // Probably to the border, there are no surrounding cells
- if (br.isValid()) {
- // Clear the top border of the lower range
- br.forEach((row, column) => {
- mbr.setValue(row, column, { bd: { t: null } });
- });
-
- const setTopData: ISetRangeStyleActionData = {
- sheetId: _sheetId,
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: mbr.getArrayData(),
- rangeData: bottomRangeOut,
- };
- actions.push(setTopData);
- }
+ const data = this._worksheet.getCellMatrix();
+ if (Tools.isNumber(argument[0])) {
+ const dimension = argument[0];
- // the last row
- b.forEach((row, column) => {
- // update
- if (bottom === true) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { b: Tools.deepClone(border) },
- });
- mcr.setValue(row, column, style);
+ if (dimension === Dimension.COLUMNS) {
+ let start: number = startRow;
+ let end: number = startRow;
+ const rowMax = this._worksheet.getRowCount();
+ for (let i = 1; i < startRow; i++) {
+ const element = data.getValue(startRow - i, startColumn);
+ if (!element) {
+ start = startRow - i + 1;
+ break;
+ }
}
- // delete
- else if (bottom === false) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { b: null },
- });
- mcr.setValue(row, column, style);
+ const j = 0;
+ while (j < rowMax - startRow) {
+ const element = data.getValue(startRow + j, startColumn);
+ if (!element) {
+ end = startRow - j - 1;
+ break;
+ }
}
- });
- }
- if (left === true || left === false) {
- // Probably to the border, there are no surrounding cells
- if (lr.isValid()) {
- // Clear the right border of the left range
- lr.forEach((row, column) => {
- mlr.setValue(row, column, { bd: { r: null } });
- });
-
- const setRightData: ISetRangeStyleActionData = {
- sheetId: _sheetId,
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: mlr.getArrayData(),
- rangeData: leftRangeOut,
- };
- actions.push(setRightData);
- }
- // first column
- l.forEach((row, column) => {
- // update
- if (left === true) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { l: Tools.deepClone(border) },
- });
- mcr.setValue(row, column, style);
- }
- // delete
- else if (left === false) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { l: null },
- });
- mcr.setValue(row, column, style);
- }
- });
- }
- if (right === true || right === false) {
- // Probably to the border, there are no surrounding cells
- if (rr.isValid()) {
- // Clear the left border of the right range
- rr.forEach((row, column) => {
- mrr.setValue(row, column, { bd: { l: null } });
- });
-
- const setLeftData: ISetRangeStyleActionData = {
- sheetId: _sheetId,
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: mrr.getArrayData(),
- rangeData: rightRangeOut,
- };
- actions.push(setLeftData);
+ numColumns = start - end;
+ numRows = 0;
+ return this._worksheet.getRange(startRow, start, numRows, numColumns);
}
-
- // last column
- r.forEach((row, column) => {
- // update
- if (right === true) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { r: Tools.deepClone(border) },
- });
- mcr.setValue(row, column, style);
- }
- // delete
- else if (right === false) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { r: null },
- });
- mcr.setValue(row, column, style);
- }
- });
- }
-
- // inner vertical border
- if (vertical === true || vertical === false) {
- // current range
- this.forEach((row, column) => {
- // Set the right border except the last column
- if (column !== rangeData.endColumn) {
- // update
- if (vertical === true) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { r: Tools.deepClone(border) },
- });
- mcr.setValue(row, column, style);
+ if (dimension === Dimension.ROWS) {
+ let start: number = startRow;
+ let end: number = startRow;
+ const colMax = this._worksheet.getColumnCount();
+ for (let i = 1; i < startRow; i++) {
+ const element = data.getValue(startRow, startColumn - i);
+ if (!element) {
+ start = startRow - i + 1;
+ break;
}
- // delete
- else if (vertical === false) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { r: null },
- });
- mcr.setValue(row, column, style);
+ }
+ const j = 0;
+ while (j < colMax - startColumn) {
+ const element = data.getValue(startRow, startColumn + j);
+ if (!element) {
+ end = startRow - j - 1;
+ break;
}
}
- // Except for the first column, clear the left border
- if (column !== rangeData.startColumn) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { l: null },
- });
- mcr.setValue(row, column, style);
+ numColumns = 0;
+ numRows = start - end;
+ return this._worksheet.getRange(start, startColumn, numRows, numColumns);
+ }
+ } else {
+ let rowStart: number = startRow;
+ let rowEnd: number = startRow;
+ const rowMax = this._worksheet.getRowCount();
+ for (let i = 1; i < startRow; i++) {
+ const element = data.getValue(startRow - i, startColumn);
+ if (!element) {
+ rowStart = startRow - i + 1;
+ break;
}
- });
- }
- // inner horizontal border
- if (horizontal === true || horizontal === false) {
- // current range
- this.forEach((row, column) => {
- // Except for the last row, set the bottom border
- if (row !== rangeData.endRow) {
- // update
- if (horizontal === true) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { b: Tools.deepClone(border) },
- });
- mcr.setValue(row, column, style);
- }
- // delete
- else if (horizontal === false) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { b: null },
- });
- mcr.setValue(row, column, style);
- }
+ }
+ const rj = 0;
+ while (rj < rowMax - startRow) {
+ const element = data.getValue(startRow + rj, startColumn);
+ if (!element) {
+ rowEnd = startRow - rj - 1;
+ break;
}
+ }
- // Except for the first row, clear the top border
- if (row !== rangeData.startRow) {
- const style = Tools.deepMerge(mcr.getValue(row, column) || {}, {
- bd: { t: null },
- });
- mcr.setValue(row, column, style);
+ let columnStart: number = startRow;
+ let columnEnd: number = startRow;
+ const colMax = this._worksheet.getColumnCount();
+ for (let i = 1; i < startRow; i++) {
+ const element = data.getValue(startRow, startColumn - i);
+ if (!element) {
+ columnStart = startRow - i + 1;
+ break;
}
- });
- }
-
- const setCCData: ISetRangeStyleActionData = {
- sheetId: _sheetId,
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: mcr.getArrayData(),
- rangeData: mcr.getDataRange(),
- };
- actions.push(setCCData);
-
- const commandCC = new Command(
- {
- WorkBookUnit: _workbook,
- },
- ...actions
- );
- _commandManager.invoke(commandCC);
-
- return this;
- }
+ }
+ const cj = 0;
+ while (cj < colMax - startColumn) {
+ const element = data.getValue(startRow, startColumn + cj);
+ if (!element) {
+ columnEnd = startRow - cj - 1;
+ break;
+ }
+ }
- /**
- * Set Border by tool bar
- * @param type border type
- * @param color color
- * @param style size
- */
- setBorderByType(type: BorderType, color: string, style: BorderStyleTypes) {
- let top = null;
- let left = null;
- let bottom = null;
- let right = null;
- let vertical = null;
- let horizontal = null;
-
- switch (type) {
- case BorderType.TOP:
- top = true;
- break;
- case BorderType.BOTTOM:
- bottom = true;
- break;
- case BorderType.LEFT:
- left = true;
- break;
- case BorderType.RIGHT:
- right = true;
- break;
- case BorderType.NONE:
- top = false;
- left = false;
- bottom = false;
- right = false;
- vertical = false;
- horizontal = false;
- break;
- case BorderType.ALL:
- top = true;
- left = true;
- bottom = true;
- right = true;
- vertical = true;
- horizontal = true;
- break;
- case BorderType.OUTSIDE:
- top = true;
- left = true;
- bottom = true;
- right = true;
- break;
- case BorderType.INSIDE:
- vertical = true;
- horizontal = true;
- break;
- case BorderType.HORIZONTAL:
- horizontal = true;
- break;
- case BorderType.VERTICAL:
- vertical = true;
- break;
-
- default:
- break;
+ numColumns = columnStart - columnEnd;
+ numColumns = rowStart - rowEnd;
+ numRows = startRow;
+ return this._worksheet.getRange(rowStart, columnStart, numRows, numColumns);
}
-
- this.setBorder(top, left, bottom, right, vertical, horizontal, color, style);
- }
-
- /**
- * Sets the font family, such as "Arial" or "Helvetica".
- *
- * @param fontFamily The font family to set; a null value resets the font family.
- * @returns
- */
- setFontFamily(fontFamily: Nullable<string>): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const fontFamilyObj: IStyleData = { ff: fontFamily };
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, fontFamilyObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets the font size, with the size being the point size to use.
- *
- * @param size A font size in point size.
- * @returns
- */
- setFontSize(size: number): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const fontSizeObj = { fs: size };
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, fontSizeObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Set the horizontal (left to right) alignment for the given range (left/center/right).
- *
- * @param alignment The alignment, either 'left', 'center' or 'normal'; a null value resets the alignment.
- * @returns
- */
- setHorizontalAlignment(alignment: Nullable<HorizontalAlign>): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const horizontalAlignmentObj = { ht: alignment };
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, horizontalAlignmentObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
- *
- * @param alignment The alignment, either 'top', 'middle' or 'bottom'; a null value resets the alignment.
- * @returns
- */
- setVerticalAlignment(alignment: Nullable<VerticalAlign>): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const verticalAlignmentObj = { vt: alignment };
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, verticalAlignmentObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
- *
- * @param direction The desired text direction; if null the direction is inferred before setting.
- * @returns
- */
- setTextDirection(direction: Nullable<TextDirection>): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const textDirectionObj: IStyleData = { td: direction };
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, textDirectionObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
return this;
}
/**
- * Sets the text wrapping strategy for the cells in the range.
+ * Sets the specified range as the active range, with the top left cell in the range as the current cell.
*
- * @param strategy The desired wrapping strategy.
- * @returns
+ * @returns This range, for chaining.
+ * @internal
*/
- setWrapStrategy(strategy: WrapStrategy): Range {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const wrapStrategyObj = { tb: strategy };
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, wrapStrategyObj);
+ activate(): Range {
+ // const { _commandManager } = this;
+ // The user entered an invalid range
+ if (this._rangeData?.startRow === -1) {
+ console.error('Invalid range,default set startRow -1');
+ return this;
+ }
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
+ this._worksheet.getSelection().setSelection({ selection: this });
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
+ // This range, for chaining
return this;
}
/**
- * Sets the value of the range. The value can be numeric, string, boolean or date. If it begins with '=' it is interpreted as a formula.
- * @param value The value for the range.
- * @returns This range, for chaining.
+ * Sets the specified cell as the current cell.
+ *
+ * If the specified cell is present in an existing range, then that range becomes the active range with the cell as the current cell.
+ *
+ * If the specified cell is not present in any existing range, then the existing selection is removed and the cell becomes the current cell and the active range.
+ *
+ * Note: The specified Range must consist of one cell, otherwise it throws an exception.
+ *
+ * @returns This range, for chaining.
*/
- setValue(value: ICellV): Range {
- const { _rangeData, _commandManager, _worksheet } = this;
- const { startRow, startColumn, endRow, endColumn } = _rangeData;
- const cellValue = new ObjectMatrix<ICellV>();
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellValue.setValue(r, c, value);
- }
- }
- const setValue: ISetRangeFormattedValueActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_FORMATTED_VALUE_ACTION,
- cellValue: cellValue.getData(),
- rangeData: this._rangeData,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
-
+ activateAsCurrentCell(): Range {
+ this._worksheet.getSelection().setCurrentCell(this);
return this;
}
/**
- * Sets a rectangular grid of values (must match dimensions of this range).
- * @param values A two-dimensional array of values.
- * @returns Range — This range, for chaining.
+ * Whether the current range and the incoming range have an intersection
+ *
+ * @param range the incoming range
+ * @returns Intersect or not
*/
- setValues(values: ICellV[][]): Range;
- setValues(values: ObjectMatrix<ICellV>): Range;
- setValues(...argument: any): Range {
- const { _rangeData, _commandManager, _worksheet } = this;
- const values = argument[0];
-
- if (Tuples.checkup(argument, Array)) {
- const { startRow, startColumn, endRow, endColumn } = _rangeData;
+ isIntersection(range: Range): boolean {
+ const currentStartRow = this._rangeData.startRow;
+ const currentEndRow = this._rangeData.endRow;
+ const currentStartColumn = this._rangeData.startColumn;
+ const currentEndColumn = this._rangeData.endColumn;
- const cellValue = new ObjectMatrix<ICellV>();
- for (let r = 0; r <= endRow - startRow; r++) {
- for (let c = 0; c <= endColumn - startColumn; c++) {
- cellValue.setValue(r + startRow, c + startColumn, values[r][c]);
- }
- }
+ const incomingStartRow = range.getRangeData().startRow;
+ const incomingEndRow = range.getRangeData().endRow;
+ const incomingStartColumn = range.getRangeData().startColumn;
+ const incomingEndColumn = range.getRangeData().endColumn;
- const setValue: ISetRangeFormattedValueActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_FORMATTED_VALUE_ACTION,
- cellValue: cellValue.getData(),
- rangeData: this._rangeData,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- } else if (Tuples.checkup(argument, ObjectMatrix)) {
- const setValue: ISetRangeFormattedValueActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_FORMATTED_VALUE_ACTION,
- cellValue: values,
- rangeData: this._rangeData,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
+ const zx = Math.abs(currentStartColumn + currentEndColumn - incomingStartColumn - incomingEndColumn);
+ const x = Math.abs(currentStartColumn - currentEndColumn) + Math.abs(incomingStartColumn - incomingEndColumn);
+ const zy = Math.abs(currentStartRow + currentEndRow - incomingStartRow - incomingEndRow);
+ const y = Math.abs(currentStartRow - currentEndRow) + Math.abs(incomingStartRow - incomingEndRow);
+ if (zx <= x && zy <= y) {
+ return true;
}
-
- return this;
+ return false;
}
/**
- * Sets cell data object for current range
- * @param value Cell data object
- * @returns
+ * Returns a new range that is offset from this range by the given number of rows and columns (which can be negative). The new range is the same size as the original range.
+ * @param rowOffset The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
+ * @param columnOffset The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
+ * @returns Range — This range, for chaining.
*/
- setRangeData(value: ICellData): Range {
- const { _rangeData, _commandManager, _worksheet } = this;
- const { startRow, startColumn } = _rangeData;
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue: {
- [startRow]: {
- [startColumn]: value,
- },
- },
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
+ offset(rowOffset: number, columnOffset: number): Range;
- return this;
- }
+ /**
+ * Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height in cells.
+ * @param rowOffset The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
+ * @param columnOffset The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
+ * @param numRows The height in rows of the new range.
+ * @returns Range — This range, for chaining.
+ */
+ offset(rowOffset: number, columnOffset: number, numRows: number): Range;
/**
- * Sets a rectangular grid of cell obejct data (must match dimensions of this range).
- * @param values A two-dimensional array of cell object data.
+ * Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height and width in cells.
+ * @param rowOffset The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
+ * @param columnOffset The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
+ * @param numRows The height in rows of the new range.
+ * @param numColumns The width in columns of the new range.
* @returns Range — This range, for chaining.
*/
- setRangeDatas(values: ICellData[][]): Range;
- setRangeDatas(values: ObjectMatrixPrimitiveType<ICellData>): Range;
- setRangeDatas(...argument: any): Range {
- const { _rangeData, _commandManager, _worksheet } = this;
- const values = argument[0];
+ offset(rowOffset: number, columnOffset: number, numRows: number, numColumns: number): Range;
+ offset(...argument: any): Range {
+ const { startRow, endRow, startColumn, endColumn } = this._rangeData;
+ const rowOffset = argument[0];
+ const columnOffset = argument[1];
+ const numRows = argument[2];
+ const numColumns = argument[3];
- if (Tuples.checkup(argument, Array)) {
- const { startRow, startColumn, endRow, endColumn } = _rangeData;
+ const offset = {
+ startRow: startRow + rowOffset,
+ endRow: endRow + rowOffset,
+ startColumn: startColumn + columnOffset,
+ endColumn: endColumn + columnOffset,
+ };
- const cellValue = new ObjectMatrix<ICellData>();
- for (let r = 0; r <= endRow - startRow; r++) {
- for (let c = 0; c <= endColumn - startColumn; c++) {
- cellValue.setValue(r + startRow, c + startColumn, values[r][c]);
- }
- }
+ if (Tools.isNumber(numRows)) {
+ offset.endRow = offset.startRow + numRows - 1;
+ }
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue: cellValue.getData(),
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- } else if (Tuples.checkup(argument, Tuples.OBJECT_TYPE)) {
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_DATA_ACTION,
- cellValue: values,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
+ if (Tools.isNumber(numColumns)) {
+ offset.endColumn = offset.endColumn + numColumns - 1;
}
- return this;
+ return new Range(this._worksheet, offset, this._currentUniverService, this._commandManager);
}
/**
@@ -2737,87 +1041,6 @@ export class Range {
return this.clear({ contentsOnly: true });
}
- /**
- * Deletes this range of cells. Existing data in the sheet along the provided dimension is shifted towards the deleted range.
- *
- * solution: Clear the range to be deleted, and then set the new value of the cell content at the bottom using setValue
- * @param {Dimension} shiftDimension The dimension along which to shift existing data.
- * @returns void
- */
- deleteCells(shiftDimension: Dimension): void {
- const { _rangeData, _commandManager, _worksheet } = this;
-
- const setValue: IDeleteRangeActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.DELETE_RANGE_ACTION,
- shiftDimension,
- rangeData: _rangeData,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setValue
- );
- _commandManager.invoke(command);
- }
-
- /**
- * Inserts empty cells into this range. The new cells retain any formatting present in the cells previously occupying this range. Existing data in the sheet along the provided dimension is shifted away from the inserted range.
- * @param {Dimension} shiftDimension The dimension along which to shift existing data.
- * @returns Range This range, for chaining.
- */
- insertCells(shiftDimension: Dimension): Range;
- insertCells(shiftDimension: Dimension, destination: Range): Range;
- insertCells(...argument: any): Range {
- const shiftDimension = argument[0];
- const destination: Range = argument[1];
- const { _commandManager, _worksheet } = this;
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- let rangeData = this._rangeData;
-
- // TODO 1. 补充另一个方向
- // 2. 重载,传入数据,范围根据数据范围变化
-
- // build blank values
- let cellValue = new ObjectMatrix<ICellData>();
- if (destination) {
- cellValue = destination.getMatrixObject();
-
- const destinationRangeData = destination.getRangeData();
-
- rangeData = {
- startRow,
- endRow: startRow + destinationRangeData.endRow - destinationRangeData.startRow,
- startColumn,
- endColumn: startRow + destinationRangeData.endColumn - destinationRangeData.startColumn,
- };
- } else {
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellValue.setValue(r, c, { m: '', v: '' });
- }
- }
- }
-
- const insertValue: IInsertRangeActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.INSERT_RANGE_ACTION,
- shiftDimension,
- rangeData,
- cellValue: cellValue.getData(),
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- insertValue
- );
- _commandManager.invoke(command);
- return this;
- }
-
/**
* Merges the cells in the range together into a single block.
*
@@ -3090,104 +1313,6 @@ export class Range {
return true;
}
- /**
- * en:
- *
- * The process of copying a range to another range is obtained by the following rules
- *
- * [The two-dimensional array composed of the content or format to be assigned] => [Target range]
- *
- * 1. 1 -> 1: 1 => 1
- * 2. N -> 1: N => N
- * 3. 1 -> N: N => N
- * 4. N1 -> N2:
- * 1) N1 <N2: If N2 is a multiple of N1 (X), N1 * X => N2; If not, N1 => N1 (refer to office excel, different from google sheet)
- * 2) N1> N2: N1 => N1
- *
- * The above four cases can be combined and processed as
- *
- * Case 1, 1/2/4-2 merged into N1 => N1
- * Case 2, 3/4-1 merge into N1 * X => N2 or Case 1
- *
- * In the end we only need to judge whether N2 is a multiple of N1
- *
- * zh:
- *
- * 处理复制一个范围到另一个范围,由以下规则得到
- *
- * [将要赋值的内容或者格式组成的二维数组] => [目标范围]
- *
- * 1. 1 -> 1 : 1 => 1
- * 2. N -> 1 : N => N
- * 3. 1 -> N : N => N
- * 4. N1 -> N2 :
- * 1) N1 < N2 : 如果N2是N1的倍数X, N1 * X => N2; 如果不是,N1 => N1(参考office excel,和google sheet不同)
- * 2) N1 > N2 : N1 => N1
- *
- * 上面四种情况,可以合并处理为
- * 情况一, 1/2/4-2合并为 N1 => N1
- * 情况二, 3/4-1合并为 N1 * X => N2 或者情况一
- *
- * 最终我们只需要判断N2是否是N1的倍数
- *
- */
- private _handleCopyRange(originRange: Range, destinationRange: IRangeData): [ICellDataMatrix, IRangeData];
- private _handleCopyRange(originRange: Range, destinationRange: Range): [ICellDataMatrix, IRangeData];
- private _handleCopyRange(...argument: any): [ICellDataMatrix, IRangeData] {
- const originRange = argument[0];
- let destinationRange = argument[1];
- destinationRange = Tuples.checkup(argument, Range, Range) ? destinationRange.getRangeData() : destinationRange;
-
- const cellData = originRange._worksheet.getCellMatrix();
- const { startRow, endRow, startColumn, endColumn } = originRange.getRangeData();
- // eslint-disable-next-line prefer-const
- let { startRow: dStartRow, endRow: dEndRow, startColumn: dStartColumn, endColumn: dEndColumn } = destinationRange;
-
- const originRows = endRow - startRow + 1;
- const originColumns = endColumn - startColumn + 1;
- const destinationRows = dEndRow - dStartRow + 1;
- const destinationColumns = dEndColumn - dStartColumn + 1;
-
- let value: ICellDataMatrix = [];
- let range: IRangeData;
-
- // judge whether N2 is a multiple of N1
- if (destinationRows % originRows === 0 && destinationColumns % originColumns === 0) {
- /**
- * A1,B1 => A1,B1,C1,D1
- * A2,B2 A2,B2,C2,D2
- * A3,B3,C3,D3
- * A4,B4,C4,D4
- */
- for (let r = 0; r < destinationRows; r++) {
- const row = [];
- for (let c = 0; c < destinationColumns; c++) {
- // Retrieve the corresponding cell data from the original range, {} as a fallback
- const cell = cellData.getValue((r + startRow) % originRows, (c + startColumn) % originColumns) || {};
- row.push(cell);
- }
- value.push(row);
- }
-
- range = destinationRange;
- } else {
- value = cellData.getFragments(startRow, endRow, startColumn, endColumn).getData();
-
- // Extend the destination to the same size as the original range
- dEndRow += originRows - destinationRows;
- dEndColumn += originColumns - destinationColumns;
-
- range = {
- startRow: dStartRow,
- endRow: dEndRow,
- startColumn: dStartColumn,
- endColumn: dEndColumn,
- };
- }
-
- return [value, range];
- }
-
/**
*
* @param arg Shorthand for the style that gets
@@ -3203,62 +1328,4 @@ export class Range {
})
);
}
-
- // isStartColumnBounded() {}
- // isStartRowBounded() {}
-
- private _setStyle(value: Nullable<string | number | ITextDecoration>, type: string) {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- // string converted to a two-dimensional array
- const styleObj = { [type]: value };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: SetRangeStyleAction.NAME,
- value: stylesMatrix,
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
-
- private _setStyles(values: Array<Array<Nullable<string | number | ITextDecoration>>>, type: string) {
- const { _worksheet, _commandManager } = this;
-
- const { startRow, endRow, startColumn, endColumn } = this._rangeData;
-
- const matrix = new ObjectMatrix<IStyleData>();
- for (let r = 0; r < endRow - startRow + 1; r++) {
- for (let c = 0; c < endColumn - startColumn + 1; c++) {
- matrix.setValue(r, c, { [type]: values[r][c] });
- }
- }
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: matrix.getData(),
- rangeData: this._rangeData,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setStyle
- );
- _commandManager.invoke(command);
- return this;
- }
}
diff --git a/packages/core/src/Sheets/Domain/RangeList.ts b/packages/core/src/Sheets/Domain/RangeList.ts
index 9a2808faa7..4a7391e0f0 100644
--- a/packages/core/src/Sheets/Domain/RangeList.ts
+++ b/packages/core/src/Sheets/Domain/RangeList.ts
@@ -1,19 +1,9 @@
import { Inject } from '@wendellhu/redi';
import { Worksheet } from './index';
import { Command, CommandManager } from '../../Command';
-import { ACTION_NAMES } from '../../Types/Const';
-import { BooleanNumber, HorizontalAlign, VerticalAlign, WrapStrategy } from '../../Types/Enum';
-import { ICellData, ICellV, IOptionData, IRangeData, IRangeType, IStyleData, ITextDecoration } from '../../Types/Interfaces';
-import { Nullable, ObjectMatrix, Tools, Tuples } from '../../Shared';
-import {
- ClearRangeAction,
- IClearRangeActionData,
- ISetRangeDataActionData,
- ISetRangeFormattedValueActionData,
- ISetRangeStyleActionData,
- SetRangeDataAction,
- SetRangeStyleAction,
-} from '../Action';
+import { IOptionData, IRangeData, IRangeType } from '../../Types/Interfaces';
+import { Tuples } from '../../Shared';
+import { ClearRangeAction, IClearRangeActionData } from '../Action';
import { ICurrentUniverService } from '../../Service/Current.service';
/**
@@ -73,52 +63,6 @@ export class RangeList {
return this;
}
- /**
- * Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
- */
- // TODO
- // breakApart() {}
-
- /**
- * Sets the value for each Range in the range list. The value can be numeric, string, boolean or date. If it begins with '=' it is interpreted as a formula.
- *
- * @param value The value for the range list.
- * @returns This range list, for chaining.
- */
- setValue(value: string | number | boolean): RangeList {
- const { _rangeList, _commandManager, _worksheet } = this;
-
- // collect action list
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
- const cellValue = new ObjectMatrix<ICellData>();
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- cellValue.setValue(startRow, startColumn, {
- m: `${value}`,
- v: value,
- });
- }
- }
-
- const setValue: ISetRangeDataActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: SetRangeDataAction.NAME,
- cellValue: cellValue.getData(),
- };
- return setValue;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
-
/**
* Clears the range of contents, formats, and data validation rules for each Range in the range list.
*
@@ -185,392 +129,4 @@ export class RangeList {
clearContent(): RangeList {
return this.clear({ contentsOnly: true });
}
-
- /**
- * Sets the background color for each Range in the range list.
- *
- * @param color The background color code in CSS notation such as '#ffffff' or 'white'; a null value resets the color.
- * @returns This range list, for chaining.
- */
- setBackground(color: Nullable<string>): RangeList {
- const { _rangeList, _commandManager, _worksheet } = this;
-
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
-
- // string converted to a two-dimensional array
- const styleObj = {
- bg: {
- rgb: color,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: range,
- };
-
- return setStyle;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets the background to the given RGB color.
- *
- * @param red The red value in RGB notation.
- * @param green The green value in RGB notation.
- * @param blue The blue value in RGB notation.
- * @returns This range list, for chaining.
- */
- setBackgroundRGB(red: number, green: number, blue: number): RangeList {
- const rgbString = `RGB(${red},${green},${blue})`;
-
- const { _rangeList, _commandManager, _worksheet } = this;
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
-
- // string converted to a two-dimensional array
- const styleObj = {
- bg: {
- rgb: rgbString,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: range,
- };
-
- return setStyle;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
-
- // TODO
- // setBorder(top, left, bottom, right, vertical, horizontal) {}
- // setBorder(top, left, bottom, right, vertical, horizontal, color, style) {}
-
- /**
- * Sets the font color for each Range in the range list. Color is represented in in CSS notation;
- *
- * @param color The font color in CSS notation such as '#ffffff' or 'white'; a null value resets the color.
- * @returns This range list, for chaining.
- */
- setFontColor(color: Nullable<string>): RangeList {
- const { _rangeList, _commandManager, _worksheet } = this;
-
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
-
- // string converted to a two-dimensional array
- const styleObj = {
- cl: {
- rgb: color,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: range,
- };
-
- return setStyle;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Sets the font family for each Range in the range list.
- *
- * @param fontFamily The font family to set; a null value resets the font family.
- * @returns This range list, for chaining.
- */
- setFontFamily(fontFamily: Nullable<string>): RangeList {
- return this._setStyle(fontFamily, 'ff');
- }
-
- /**
- * Sets the Overline for each Range in the range list.
- *
- * @param fontLine The Overline to set; a null value resets the Overline.
- * @returns This range list, for chaining.
- */
- setOverline(fontLine: Nullable<boolean | BooleanNumber>): RangeList {
- const textDecoration: ITextDecoration = {
- s: fontLine ? BooleanNumber.TRUE : BooleanNumber.FALSE,
- };
- return this._setStyle(textDecoration, 'ol');
- }
-
- /**
- * Sets the font size (in points) for each Range in the range list.
- *
- * @param size A font point size.
- * @returns This range list, for chaining.
- */
- setFontSize(size: Nullable<number>): RangeList {
- return this._setStyle(size, 'fs');
- }
-
- /**
- * Set the font style for each Range in the range list
- *
- * @param fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
- * @returns This range list, for chaining.
- */
- setFontStyle(fontStyle: Nullable<boolean | BooleanNumber>): RangeList {
- const fontBoolean = fontStyle ? BooleanNumber.TRUE : BooleanNumber.FALSE;
- return this._setStyle(fontBoolean, 'it');
- }
-
- /**
- * Set the horizontal alignment for each Range in the range list.
- *
- * @param alignment The alignment, either 'left', 'center' or 'right'; a null value resets the alignment.
- * @returns This range list, for chaining.
- */
- setHorizontalAlignment(alignment: Nullable<HorizontalAlign>): RangeList {
- return this._setStyle(alignment, 'ht');
- }
-
- /**
- * Sets the text direction for the cells in each Range in the range list.
- *
- * @param direction The desired text direction; if null the direction is inferred before setting.
- * @returns This range list, for chaining.
- */
- setTextDirection(direction: Nullable<number>): RangeList {
- return this._setStyle(direction, 'td');
- }
-
- /**
- * Sets the text rotation settings for the cells in each Range in the range list.
- *
- * @param degrees The desired angle between the standard orientation and the desired orientation. For left to right text, positive angles are in the counterclockwise direction.
- * @returns This range list, for chaining.
- */
- setTextRotation(degrees: number): RangeList {
- const { _rangeList, _commandManager, _worksheet } = this;
-
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
-
- const styleObj = {
- tr: {
- v: 0,
- a: Number(degrees),
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: range,
- };
-
- return setStyle;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Set the vertical alignment for each Range in the range list.
- *
- * @param alignment The alignment, either 'top', 'middle' or 'bottom'; a null value resets the alignment.
- * @returns This range list, for chaining.
- */
- setVerticalAlignment(alignment: Nullable<VerticalAlign>): RangeList {
- this._setStyle(alignment, 'vt');
- return this;
- }
-
- /**
- * Sets whether or not to stack the text for the cells for each Range in the range list.
- *
- * @param isVertical Whether or not to stack the text.
- * @returns This range list, for chaining.
- */
- setVerticalText(isVertical: BooleanNumber): RangeList {
- const { _rangeList, _commandManager, _worksheet } = this;
-
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
-
- const styleObj = {
- tr: {
- v: isVertical,
- a: 0,
- },
- };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_STYLE_ACTION,
- value: stylesMatrix,
- rangeData: range,
- };
-
- return setStyle;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * Set text wrapping for each Range in the range list.
- *
- * @param isWrapEnabled Whether to wrap text or not.
- * @returns This range list, for chaining.
- */
- setWrap(isWrapEnabled: BooleanNumber): RangeList {
- return this._setStyle(isWrapEnabled, 'tb');
- }
-
- /**
- * Sets the text wrapping strategy for each Range in the range list.
- *
- * @param strategy The desired wrapping strategy.
- * @returns This range list, for chaining.
- */
- setWrapStrategy(strategy: WrapStrategy): RangeList {
- return this._setStyle(strategy, 'tb');
- }
-
- /**
- * Trims the whitespace (such as spaces, tabs, or new lines) in every cell in this range list.
- *
- * @returns This range list, for chaining.
- */
- trimWhitespace(): RangeList {
- const { _rangeList, _commandManager, _worksheet } = this;
-
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
-
- const sheetMatrix = this._worksheet.getCellMatrix();
- const regx = /\s+/g;
- const cellValue = new ObjectMatrix<ICellV>();
- for (let r = startRow; r < endRow + 1; r++) {
- for (let c = startColumn; c < endColumn + 1; c++) {
- const m = sheetMatrix.getValue(r, c)!.m!;
- const value = m.replace(regx, '');
- cellValue.setValue(r, c, value || '');
- }
- }
-
- const setValue: ISetRangeFormattedValueActionData = {
- sheetId: _worksheet.getSheetId(),
- actionName: ACTION_NAMES.SET_RANGE_FORMATTED_VALUE_ACTION,
- cellValue: cellValue.getData(),
- rangeData: range,
- };
-
- return setValue;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
-
- /**
- * set style
- *
- * @param value style value
- * @param type style type
- * @returns This range list, for chaining.
- * @internal @preapproved
- */
- private _setStyle(value: Nullable<number | string | ITextDecoration | BooleanNumber>, type: string) {
- const { _rangeList, _commandManager, _worksheet } = this;
-
- const setList = _rangeList.map((range) => {
- const { startRow, startColumn, endRow, endColumn } = range;
-
- // string converted to a two-dimensional array
- const styleObj: IStyleData = { [type]: value };
-
- const stylesMatrix = Tools.fillObjectMatrix(endRow - startRow + 1, endColumn - startColumn + 1, styleObj);
-
- const setStyle: ISetRangeStyleActionData = {
- sheetId: _worksheet.getSheetId(),
- value: stylesMatrix,
- rangeData: range,
- actionName: SetRangeStyleAction.NAME,
- };
-
- return setStyle;
- });
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- ...setList
- );
- _commandManager.invoke(command);
- return this;
- }
}
diff --git a/packages/core/src/Sheets/Domain/Workbook.ts b/packages/core/src/Sheets/Domain/Workbook.ts
index faac851960..a2214d07e2 100644
--- a/packages/core/src/Sheets/Domain/Workbook.ts
+++ b/packages/core/src/Sheets/Domain/Workbook.ts
@@ -1,28 +1,16 @@
-import { Inject, Injector, forwardRef } from '@wendellhu/redi';
+import { forwardRef, Inject, Injector } from '@wendellhu/redi';
+import { CommandManager } from '../../Command';
+import { ObserverManager } from '../../Observer';
+import { ICurrentUniverService } from '../../Service/Current.service';
+import { GenName, Nullable, Tools } from '../../Shared';
import { DEFAULT_RANGE_ARRAY, DEFAULT_WORKBOOK, DEFAULT_WORKSHEET } from '../../Types/Const';
-import { Command, CommandManager } from '../../Command';
import { BooleanNumber } from '../../Types/Enum';
-import { InsertSheetAction, ISetSheetOrderActionData, SetSheetOrderAction, IInsertSheetActionData } from '../Action';
-import {
- IColumnStartEndData,
- IGridRange,
- IRangeArrayData,
- IRangeData,
- IRangeStringData,
- IRangeType,
- IRowStartEndData,
- IWorkbookConfig,
- IWorksheetConfig,
-} from '../../Types/Interfaces';
-import { GenName, Nullable, Tools, Tuples } from '../../Shared';
+import { IColumnStartEndData, IGridRange, IRangeArrayData, IRangeData, IRangeStringData, IRangeType, IRowStartEndData, IWorkbookConfig } from '../../Types/Interfaces';
import { RangeList } from './RangeList';
import { Selection } from './Selection';
import { Styles } from './Styles';
import { Worksheet } from './Worksheet';
-import { Range } from './Range';
-import { ObserverManager } from '../../Observer';
-import { ICurrentUniverService } from '../../Service/Current.service';
/**
* Access and create Univer Sheets files
@@ -97,316 +85,6 @@ export class Workbook {
return this._worksheets;
}
- activateSheetByIndex(index: number): Nullable<Worksheet> {
- if (index >= 0) {
- const { sheetOrder } = this._config;
- for (let i = index; i < sheetOrder.length; i++) {
- const worksheet = this._worksheets.get(sheetOrder[i]);
- if (worksheet && !worksheet.isSheetHidden()) {
- worksheet.activate();
- return worksheet;
- }
- }
- if (index < sheetOrder.length) {
- for (let i = index - 1; i >= 0; i--) {
- const worksheet = this._worksheets.get(sheetOrder[i]);
- if (worksheet && !worksheet.isSheetHidden()) {
- worksheet.activate();
- return worksheet;
- }
- }
- }
- const worksheet = this._worksheets.get(sheetOrder[sheetOrder.length - 1]);
- if (worksheet) {
- worksheet.activate();
- }
- return worksheet;
- }
- }
-
- // TODO: @Dushusir: this function has too many function overloads
-
- /**
- * @deprecated
- */
- insertSheet(): Nullable<string>;
- insertSheet(index: number): Nullable<string>;
- insertSheet(name: string): Nullable<string>;
- insertSheet(data: Partial<IWorksheetConfig>): Nullable<string>;
- insertSheet(sheet: Worksheet): Nullable<string>;
- insertSheet(name: string, index: number): Nullable<string>;
- insertSheet(index: number, data: Partial<IWorksheetConfig>): Nullable<string>;
- insertSheet(index: number, sheet: Worksheet): Nullable<string>;
- // eslint-disable-next-line max-lines-per-function
- insertSheet(...argument: any[]): Nullable<string> {
- const genname = this._genName;
- const commandManager = this._commandManager;
- const before = this._observerManager.getObserver<{ index: number; sheetId: string }>('onBeforeInsertSheetObservable', 'core')!;
- const after = this._observerManager.getObserver<{ index: number; sheetId: string }>('onAfterInsertSheetObservable', 'core')!;
- const workbook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
-
- // insert empty sheet
- if (Tools.hasLength(argument, 0)) {
- const worksheetConfig = {
- name: genname.sheetName(),
- status: 0,
- id: Tools.generateRandomId(6),
- };
- const index = this.getSheetSize();
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
-
- if (Tools.hasLength(argument, 1)) {
- // insert clone worksheet instance
- if (Tools.isAssignableFrom(argument[0], Worksheet)) {
- const sheet = argument[0];
- const index = this.getSheetSize();
- const worksheetConfig = sheet.getConfig();
- worksheetConfig.id = Tools.generateRandomId(6);
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
-
- // insert sheet to index
- if (Tools.isNumber(argument[0])) {
- const index = argument[0];
- const worksheetConfig = {
- name: genname.sheetName(),
- status: 0,
- id: Tools.generateRandomId(6),
- };
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
-
- // insert sheet by sheet name
- if (Tools.isString(argument[0])) {
- const name = argument[0];
- const index = this.getSheetSize();
- const worksheetConfig = {
- status: 0,
- name,
- id: Tools.generateRandomId(6),
- };
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
-
- // insert sheet by sheet config
- if (Tools.isPlainObject(argument[0])) {
- const worksheetConfig = argument[0] as IWorksheetConfig;
- const index = this.getSheetSize();
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
- }
-
- if (Tools.hasLength(argument, 2)) {
- // insert sheet name to index
- if (Tools.isString(argument[0])) {
- const name = argument[0];
- const index = argument[1];
- const worksheetConfig = {
- status: 0,
- name,
- id: Tools.generateRandomId(6),
- };
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
- if (Tools.isNumber(argument[0])) {
- // insert clone worksheet instance to index
- if (Tools.isAssignableFrom(argument[1], Worksheet)) {
- const index = argument[0];
- const sheet = argument[1];
- const worksheetConfig = sheet.getConfig();
- worksheetConfig.id = Tools.generateRandomId(6);
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
- if (Tools.isPlainObject(argument[1])) {
- const index = argument[0];
- const worksheetConfig = argument[1] as IWorksheetConfig;
- before.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- commandManager.invoke(
- new Command(
- {
- WorkBookUnit: workbook,
- },
- {
- actionName: InsertSheetAction.NAME,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData
- )
- );
- after.notifyObservers({
- index,
- sheetId: worksheetConfig.id,
- });
- return worksheetConfig.id;
- }
- }
- }
- }
-
- insertSheetByIndexSheet(index: number, sheet: IWorksheetConfig) {
- const { sheets, sheetOrder } = this._config;
- if (sheets[sheet.id]) {
- throw new Error(`Insert sheet fail ${sheet.id} already exists.`);
- }
- sheets[sheet.id] = sheet;
-
- sheetOrder.splice(index, 0, sheet.id);
- const worksheet = this._injector.createInstance(Worksheet, sheet);
- this._worksheets.set(sheet.id, worksheet);
- }
-
getActiveSpreadsheet(): Workbook {
return this;
}
@@ -429,31 +107,6 @@ export class Workbook {
return this._config;
}
- create(name: string, row: number, column: number): Worksheet;
- create(name: string): Worksheet;
- create(...argument: unknown[]): unknown {
- if (Tools.hasLength(argument, 1)) {
- const name = argument[0];
- const conf = { ...DEFAULT_WORKSHEET, name };
- const worksheet = new Worksheet(conf as Partial<IWorksheetConfig>, this._commandManager, this._observerManager, this._currentUniverService);
- this.insertSheet(worksheet);
- return worksheet;
- }
- if (Tools.hasLength(argument, 3)) {
- const name = argument[0];
- const rowCount = argument[1];
- const columnCount = argument[2];
- const conf = { ...DEFAULT_WORKSHEET, name, rowCount, columnCount };
- const worksheet = new Worksheet(conf as Partial<IWorksheetConfig>, this._commandManager, this._observerManager, this._currentUniverService);
- this.insertSheet(worksheet);
- return worksheet;
- }
- }
-
- setDefaultActiveSheet(): void {
- this._setDefaultActiveSheet();
- }
-
getIndexBySheetId(sheetId: string): number {
const { sheetOrder } = this._config;
return sheetOrder.findIndex((id) => id === sheetId);
@@ -537,14 +190,6 @@ export class Workbook {
return this._config.sheetOrder.length;
}
- /**
- * Sets the specified cell as the current cell.
- * @param cell
- */
- setCurrentCell(cell: Range): Range {
- return cell.activateAsCurrentCell();
- }
-
/**
* Applies all pending Sheets changes.
*
@@ -554,27 +199,6 @@ export class Workbook {
//TDOO ..
}
- setSheetOrder(sheetId: string, order: number): void {
- // const { _sheetOrder } = this;
- // const exclude = _sheetOrder.filter((currentId) => currentId !== sheetId);
- // exclude.splice(order, 0, sheetId);
- // this._sheetOrder = exclude;
- const observer = this._observerManager.getObserver('onSheetOrderObservable', 'core')!;
- const config: ISetSheetOrderActionData = {
- actionName: SetSheetOrderAction.NAME,
- sheetId,
- order,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- config
- );
- this._commandManager.invoke(command);
- observer.notifyObservers();
- }
-
getSheets(): Worksheet[] {
const { sheetOrder } = this._config;
return sheetOrder.map((sheetId) => this._worksheets.get(sheetId)) as Worksheet[];
@@ -590,23 +214,6 @@ export class Workbook {
});
}
- removeSheetBySheetId(sheetId: string): void {
- const iSheets = this._worksheets;
- const config = this._config;
-
- const { sheets } = config;
- if (sheets[sheetId] == null) {
- throw new Error(`Remove sheet fail ${sheetId} does not exist`);
- }
- const findIndex = config.sheetOrder.findIndex((id) => id === sheetId);
- delete sheets[sheetId];
-
- config.sheetOrder.splice(findIndex, 1);
- iSheets.delete(sheetId);
-
- // this.activateSheetByIndex(index);
- }
-
getSheetBySheetName(name: string): Nullable<Worksheet> {
const { sheetOrder } = this._config;
const sheetId = sheetOrder.find((sheetId) => {
@@ -620,37 +227,6 @@ export class Workbook {
return this._worksheets.get(sheetId);
}
- /**
- * Sets the active sheet in a spreadsheet. The Google Sheets UI displays the chosen sheet unless the sheet belongs to a different spreadsheet.
- *
- * @param sheet - The new active sheet.
- * @returns {@link WorkSheet } the sheet that has been made the new active sheet
- */
- setActiveSheet(sheet: Worksheet): Worksheet;
- /**
- * Sets the active sheet in a spreadsheet, with the option to restore the most recent selection within that sheet. The Google Sheets UI displays the chosen sheet unless the sheet belongs to a different spreadsheet.
- * @param sheet - The new active sheet.
- * @param restoreSelection - If true, the most recent selection of the new active sheet becomes selected again as the new sheet becomes active; if false, the new sheet becomes active without changing the current selection.
- * @returns {@link WorkSheet} - the new active sheet
- */
- setActiveSheet(sheet: Worksheet, restoreSelection: boolean): Worksheet;
- setActiveSheet(...argument: any): Worksheet {
- let restoreSelection = false;
- const worksheet: Worksheet = argument[0];
- if (Tuples.checkup(argument, Worksheet, Tuples.BOOLEAN_TYPE)) {
- restoreSelection = argument[1];
- }
-
- worksheet.activate();
-
- // restore selection
- if (restoreSelection) {
- worksheet.setActiveSelection();
- }
-
- return worksheet;
- }
-
getPluginMeta<T>(name: string): T {
return this._config.pluginMeta[name];
}
@@ -745,55 +321,6 @@ export class Workbook {
return this._config;
}
- /**
- * Get Default Sheet
- * @private
- */
- private _getDefaultWorkSheet(): void {
- const { _config, _worksheets } = this;
- const { sheets, sheetOrder } = _config;
-
- // One worksheet by default
- if (Tools.isEmptyObject(sheets)) {
- sheets[DEFAULT_WORKSHEET.id] = Object.assign(DEFAULT_WORKSHEET, {
- status: BooleanNumber.TRUE,
- });
- }
-
- let firstWorksheet = null;
-
- for (const sheetId in sheets) {
- const config = sheets[sheetId];
- config.name = this._genName.sheetName(config.name);
- const worksheet = new Worksheet(config, this._commandManager, this._observerManager, this._currentUniverService);
- _worksheets.set(sheetId, worksheet);
- if (!sheetOrder.includes(sheetId)) {
- sheetOrder.push(sheetId);
- }
- if (firstWorksheet == null) {
- firstWorksheet = worksheet;
- }
- }
-
- if (firstWorksheet) {
- firstWorksheet.activate();
- }
- }
-
- /**
- * Get Default Active Sheet
- * @private
- */
- private _setDefaultActiveSheet(): void {
- if (this._worksheets.size > 0) {
- this._worksheets.forEach((sheet) => {
- sheet.setStatus(BooleanNumber.FALSE);
- });
- const { sheetOrder } = this._config;
- this._worksheets.get(sheetOrder[0])?.setStatus(BooleanNumber.TRUE);
- }
- }
-
/**
* Get the range array based on the range string and sheet id
*
@@ -880,4 +407,39 @@ export class Workbook {
};
return item;
}
+
+ /**
+ * Get Default Sheet
+ * @private
+ */
+ private _getDefaultWorkSheet(): void {
+ const { _config, _worksheets } = this;
+ const { sheets, sheetOrder } = _config;
+
+ // One worksheet by default
+ if (Tools.isEmptyObject(sheets)) {
+ sheets[DEFAULT_WORKSHEET.id] = Object.assign(DEFAULT_WORKSHEET, {
+ status: BooleanNumber.TRUE,
+ });
+ }
+
+ let firstWorksheet = null;
+
+ for (const sheetId in sheets) {
+ const config = sheets[sheetId];
+ config.name = this._genName.sheetName(config.name);
+ const worksheet = new Worksheet(config, this._commandManager, this._observerManager, this._currentUniverService);
+ _worksheets.set(sheetId, worksheet);
+ if (!sheetOrder.includes(sheetId)) {
+ sheetOrder.push(sheetId);
+ }
+ if (firstWorksheet == null) {
+ firstWorksheet = worksheet;
+ }
+ }
+
+ // if (firstWorksheet) {
+ // firstWorksheet.activate();
+ // }
+ }
}
diff --git a/packages/core/src/Sheets/Domain/Worksheet.ts b/packages/core/src/Sheets/Domain/Worksheet.ts
index 6bdc52bcca..9dea491854 100644
--- a/packages/core/src/Sheets/Domain/Worksheet.ts
+++ b/packages/core/src/Sheets/Domain/Worksheet.ts
@@ -1,59 +1,19 @@
import { Inject } from '@wendellhu/redi';
-import {
- IInsertColumnDataActionData,
- BorderStyleData,
- SetZoomRatioAction,
- InsertRowDataAction,
- InsertRowAction,
- InsertColumnDataAction,
- InsertColumnAction,
- ClearRangeAction,
- SetTabColorAction,
- SetBorderAction,
- IInsertColumnActionData,
- IRemoveColumnAction,
- RemoveColumnAction,
- RemoveColumnDataAction,
- RemoveRowAction,
- RemoveRowDataAction,
- SetColumnHideAction,
- SetColumnShowAction,
- SetHiddenGridlinesAction,
- SetRightToLeftAction,
- SetRowHideAction,
- SetRowShowAction,
- SetWorkSheetHideAction,
- IClearRangeActionData,
- IInsertRowActionData,
- IInsertRowDataActionData,
- IRemoveColumnDataAction,
- IRemoveRowActionData,
- IRemoveRowDataActionData,
- ISetColumnHideActionData,
- ISetColumnShowActionData,
- ISetRowHideActionData,
- ISetRowShowActionData,
- ISetTabColorActionData,
- ISetWorkSheetActivateActionData,
- ISetWorkSheetHideActionData,
- ISetWorkSheetStatusActionData,
- SetWorkSheetActivateAction,
- SetWorkSheetNameAction,
- SetWorkSheetStatusAction,
-} from '../Action';
-import { DEFAULT_WORKSHEET } from '../../Types/Const';
-import { Direction, BooleanNumber, SheetTypes } from '../../Types/Enum';
-import { IBorderStyleData, ICellData, IOptionData, IRangeData, IRangeStringData, IRangeType, ISelectionData, IStyleData, IWorksheetConfig } from '../../Types/Interfaces';
+
+import { Command, CommandManager } from '../../Command';
+import { ObserverManager } from '../../Observer';
+import { ICurrentUniverService } from '../../Service/Current.service';
import { Nullable, ObjectMatrix, Tools, Tuples } from '../../Shared';
+import { DEFAULT_WORKSHEET } from '../../Types/Const';
+import { BooleanNumber, SheetTypes } from '../../Types/Enum';
+import { ICellData, IOptionData, IRangeStringData, IRangeType, ISelectionData, IWorksheetConfig } from '../../Types/Interfaces';
+import { ClearRangeAction, IClearRangeActionData } from '../Action';
import { ColumnManager } from './ColumnManager';
import { Merges } from './Merges';
import { Range } from './Range';
import { RangeList } from './RangeList';
import { RowManager } from './RowManager';
import { Selection } from './Selection';
-import { Command, CommandManager, ISheetActionData } from '../../Command';
-import { ObserverManager } from '../../Observer';
-import { ICurrentUniverService } from '../../Service/Current.service';
/**
* Access and modify spreadsheet sheets.
@@ -130,46 +90,6 @@ export class Worksheet {
return this._cellData;
}
- /**
- * Activates this sheet. Does not alter the sheet itself, only the parent's notion of the active sheet.
- * @returns Sheet — The newly active sheet.
- */
- activate(): Worksheet {
- if (this._config.status === BooleanNumber.TRUE) {
- return this;
- }
- const _commandManager = this._commandManager;
- const before = this._observerManager.requiredObserver<{ sheet: Worksheet }>('onBeforeChangeActiveSheetObservable', 'core');
- const after = this._observerManager.requiredObserver<{ sheet: Worksheet }>('onAfterChangeActiveSheetObservable', 'core');
- const setActive: ISetWorkSheetActivateActionData = {
- sheetId: this._sheetId,
- actionName: SetWorkSheetActivateAction.NAME,
- status: BooleanNumber.TRUE,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setActive
- );
- before.notifyObservers({ sheet: this });
- _commandManager.invoke(command);
- after.notifyObservers({ sheet: this });
- return this;
- }
-
- /**
- * Sets Update WorkSheet Configure
- * @param config config of worksheet
- * @returns current worksheet instance
- */
- setConfig(config: Partial<IWorksheetConfig>): Worksheet {
- this._config = Tools.commonExtend(DEFAULT_WORKSHEET, config);
- // this._config = Tools.deepMerge(DEFAULT_WORKSHEET, config);
- return this;
- }
-
/**
* Returns Row Manager
* @returns Row Manager
@@ -194,52 +114,6 @@ export class Worksheet {
return this._columnManager;
}
- /**
- * Set the sheet name.
- *
- * @example
- * Set new name:
- * ```
- * worksheet.setName('NewSheet')
- * ```
- *
- * @param name - new sheet name
- * @returns current worksheet instance
- *
- * @alpha
- */
- setName(name: string): Worksheet {
- const { _sheetId } = this;
- const before = this._observerManager.getObserver('onBeforeChangeSheetNameObservable', 'core')!;
- const after = this._observerManager.getObserver<{ name: string; sheet: Worksheet }>('onAfterChangeSheetNameObservable', 'core')!;
- const configure = {
- actionName: SetWorkSheetNameAction.NAME,
- sheetName: name,
- sheetId: _sheetId,
- };
-
- const workbook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- const sheets = workbook.getSheets();
- for (let i = 0; i < sheets.length; i++) {
- const sheet = sheets[i];
- if (sheet !== this && sheet.getName() === name) {
- console.warn('Duplicate name');
- return this;
- }
- }
-
- before.notifyObservers();
- const command = new Command(
- {
- WorkBookUnit: workbook,
- },
- configure
- );
- this._commandManager.invoke(command);
- after.notifyObservers({ name, sheet: this });
- return this;
- }
-
/**
* Returns the name of the sheet.
* @returns name of the sheet
@@ -378,37 +252,6 @@ export class Worksheet {
return _config.status;
}
- // /**
- // * Returns Protection
- // * @returns User Pretection
- // */
- // getProtection(): Protection {
- // return this._protection;
- // }
-
- /**
- * Sets WorkSheet Status
- * @param status type of sheet status
- * @returns WorkSheet Instance
- */
- setStatus(status: BooleanNumber): Worksheet {
- const { _sheetId } = this;
- const configure: ISetWorkSheetStatusActionData = {
- actionName: SetWorkSheetStatusAction.NAME,
- sheetId: _sheetId,
- sheetStatus: status,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- configure
- );
- this._commandManager.invoke(command);
- return this;
- }
-
/**
* Return WorkSheetZoomRatio
* @return zoomRatio
@@ -417,32 +260,6 @@ export class Worksheet {
return this._config.zoomRatio || 1;
}
- /**
- * Sets WorkSheetZoomRatio
- * @param zoomRatio
- */
- setZoomRatio(zoomRatio: number): void {
- const { _sheetId } = this;
- const zoomRation = {
- actionName: SetZoomRatioAction.NAME,
- zoom: zoomRatio,
- sheetId: _sheetId,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- zoomRation
- );
-
- // DEPT: notifyObservers should come before invoking command, and that is ambiguous
- const observer = this._observerManager.getObserver<{ zoomRatio: number }>('onZoomRatioSheetObservable', 'core')!;
- observer.notifyObservers({ zoomRatio });
-
- this._commandManager.invoke(command);
- }
-
/**
* Returns User Selection
* @returns User Selection
@@ -451,35 +268,6 @@ export class Worksheet {
return this._selection;
}
- // /**
- // * Returns Row StructGroup
- // * @returns Row StructGroup
- // */
- // getRowStructGroup(): StructGroup {
- // return this._rowStatusGroup;
- // }
-
- // /**
- // * Returns Column StructGroup
- // * @returns Column StructGroup
- // */
- // getColumnStructGroup(): StructGroup {
- // return this._columnStatusGroup;
- // }
-
- /**
- * Returns Copy WorkSheet
- * @param name sheet name
- * @returns Copy WorkSheet
- */
- copy(name: string): Worksheet {
- const duplicatedConfig = Tools.deepClone(this._config);
- duplicatedConfig.name = name;
- duplicatedConfig.status = BooleanNumber.FALSE;
- duplicatedConfig.id = Tools.generateRandomId();
- return new Worksheet(duplicatedConfig, this._commandManager, this._observerManager, this._currentUniverService);
- }
-
/**
* Returns WorkSheet Configures
* @returns WorkSheet Configures
@@ -488,326 +276,6 @@ export class Worksheet {
return this._config;
}
- /**
- * Inserts a blank row in a sheet at the specified location.
- * @param rowPosition row index
- * @param numberRows numder of inserted rows
- * @returns WorkSheet Instance
- */
- insertRows(rowPosition: number, numberRows: number = 1): Worksheet {
- const { _sheetId } = this;
-
- // TODO: @wzhudev: the two parameters are pretty same, so really not necessary
- // TODO: @wzhudev: is `insertRowData` really necessary? could it replaced by `setRangeData`?
- const insertRowData: IInsertRowDataActionData = {
- actionName: InsertRowDataAction.NAME,
- sheetId: _sheetId,
- rowIndex: rowPosition,
- rowData: ObjectMatrix.MakeObjectMatrixSize<ICellData>(numberRows).toJSON(),
- };
- const insertRow: IInsertRowActionData = {
- actionName: InsertRowAction.NAME,
- sheetId: _sheetId,
- rowIndex: rowPosition,
- rowCount: numberRows,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- insertRowData,
- insertRow
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- // TODO: @wzhudev: the following method would completely be unnecessary
-
- /**
- * Inserts a number of rows after the given row position.
- * @param afterPosition row index
- * @returns WorkSheet Instance
- */
- insertRowAfter(afterPosition: number): Worksheet;
- /**
- * Inserts a number of rows after the given row position.
- * @param afterPosition row index
- * @param howMany row count
- * @returns WorkSheet Instance
- */
- insertRowAfter(afterPosition: number, howMany: number): Worksheet;
- insertRowAfter(...argument: any): Worksheet {
- let rowIndex: number = 0;
- let numRows: number = 1;
-
- if (Tools.hasLength(argument, 1)) {
- rowIndex = argument[0] + 1;
- }
- if (Tools.hasLength(argument, 2)) {
- rowIndex = argument[0] + 1;
- numRows = argument[1];
- }
-
- const { _sheetId } = this;
- const insertRowData = {
- actionName: InsertRowDataAction.NAME,
- sheetId: _sheetId,
- rowIndex,
- rowData: ObjectMatrix.MakeObjectMatrixSize<ICellData>(numRows).toJSON(),
- };
- const insertRow = {
- actionName: InsertRowAction.NAME,
- sheetId: _sheetId,
- rowIndex,
- rowCount: numRows,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- insertRowData,
- insertRow
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Inserts a number of rows before the given row position.
- * @param beforePosition row index
- * @returns WorkSheet Instance
- */
- insertRowBefore(beforePosition: number): Worksheet;
- /**
- * Inserts a number of rows before the given row position.
- * @param beforePosition row index
- * @param howMany row count
- * @returns WorkSheet Instance
- */
- insertRowBefore(beforePosition: number, howMany: number): Worksheet;
- insertRowBefore(...argument: any): Worksheet {
- let rowIndex: number = 0;
- let numRows: number = 1;
-
- if (Tools.hasLength(argument, 1)) {
- rowIndex = argument[0] - 1;
- }
- if (Tools.hasLength(argument, 2)) {
- rowIndex = argument[0] - 1;
- numRows = argument[1];
- }
-
- if (rowIndex < 0) {
- rowIndex = 0;
- }
-
- const { _sheetId } = this;
- const insertRowData = {
- actionName: InsertRowDataAction.NAME,
- sheetId: _sheetId,
- rowIndex,
- rowData: ObjectMatrix.MakeObjectMatrixSize<ICellData>(numRows).toJSON(),
- };
- const insertRow = {
- actionName: InsertRowAction.NAME,
- sheetId: _sheetId,
- rowIndex,
- rowCount: numRows,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- insertRowData,
- insertRow
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Inserts a blank column in a sheet at the specified location.
- * @param columnIndex column index
- * @returns WorkSheet Instance
- */
- insertColumns(columnIndex: number): Worksheet;
- /**
- * Inserts a blank column in a sheet at the specified location.
- * @param columnIndex column index
- * @param numColumns column count
- * @returns WorkSheet Instance
- */
- insertColumns(columnIndex: number, numColumns: number): Worksheet;
- insertColumns(...argument: any): Worksheet {
- let columnIndex: number = 0;
- let numColumns: number = 1;
-
- if (Tools.hasLength(argument, 1)) {
- columnIndex = argument[0];
- }
- if (Tools.hasLength(argument, 2)) {
- columnIndex = argument[0];
- numColumns = argument[1];
- }
-
- const { _sheetId } = this;
- const columnData = new ObjectMatrix<ICellData>();
- this._cellData.forEach((index) => {
- for (let i = columnIndex; i < columnIndex + numColumns; i++) {
- columnData.setValue(index, i - columnIndex, {});
- }
- });
- const insertColumnData = {
- actionName: InsertColumnDataAction.NAME,
- sheetId: _sheetId,
- columnIndex,
- columnData: columnData.toJSON(),
- };
- const insertColumn = {
- actionName: InsertColumnAction.NAME,
- sheetId: _sheetId,
- columnIndex,
- columnCount: numColumns,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- insertColumn,
- insertColumnData
- );
- this._commandManager.invoke(command);
-
- return this;
- }
-
- /**
- * Inserts a number of columns before the given row position.
- * @param beforePosition column index
- * @returns WorkSheet Instance
- */
- insertColumnBefore(beforePosition: number): Worksheet;
- /**
- * Inserts a number of columns before the given row position.
- * @param beforePosition column index
- * @param howMany column count
- * @returns WorkSheet Instance
- */
- insertColumnBefore(beforePosition: number, howMany: number): Worksheet;
- insertColumnBefore(...argument: any): Worksheet {
- let columnIndex: number = 0;
- let numColumns: number = 1;
-
- if (Tools.hasLength(argument, 1)) {
- columnIndex = argument[0] - 1;
- }
- if (Tools.hasLength(argument, 2)) {
- columnIndex = argument[0] - 1;
- numColumns = argument[1];
- }
-
- if (columnIndex < 0) {
- columnIndex = 0;
- }
-
- const { _sheetId } = this;
- const columnData = new ObjectMatrix<ICellData>();
- if (this._cellData.getLength()) {
- this._cellData.forEach((index) => {
- for (let i = columnIndex; i < columnIndex + numColumns; i++) {
- columnData.setValue(index, i - columnIndex, {});
- }
- });
- } else {
- for (let i = 0; i < this._config.rowCount; i++) {
- for (let j = columnIndex; j < columnIndex + numColumns; j++) {
- columnData.setValue(i, j - columnIndex, {});
- }
- }
- }
-
- const insertColumnData: IInsertColumnDataActionData = {
- actionName: InsertColumnDataAction.NAME,
- sheetId: _sheetId,
- columnIndex,
- columnData: columnData.toJSON(),
- };
- const insertColumn: IInsertColumnActionData = {
- actionName: InsertColumnAction.NAME,
- sheetId: _sheetId,
- columnIndex,
- columnCount: numColumns,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- insertColumn,
- insertColumnData
- );
- this._commandManager.invoke(command);
-
- return this;
- }
-
- /**
- * Inserts a number of columns after the given row position.
- * @param afterPosition column index
- * @returns WorkSheet Instance
- */
- insertColumnAfter(afterPosition: number): Worksheet;
- /**
- * Inserts a number of columns after the given row position.
- * @param afterPosition column index
- * @param howMany column count
- * @returns WorkSheet Instance
- */
- insertColumnAfter(afterPosition: number, howMany: number): Worksheet;
- insertColumnAfter(...argument: any): Worksheet {
- let columnIndex: number = 0;
- let numColumns: number = 1;
-
- if (Tools.hasLength(argument, 1)) {
- columnIndex = argument[0] + 1;
- }
- if (Tools.hasLength(argument, 2)) {
- columnIndex = argument[0] + 1;
- numColumns = argument[1];
- }
-
- const { _sheetId } = this;
- const columnData = new ObjectMatrix<ICellData>();
- this._cellData.forEach((index) => {
- for (let i = columnIndex; i < columnIndex + numColumns; i++) {
- columnData.setValue(index, i - columnIndex, {});
- }
- });
- const insertColumnData: IInsertColumnDataActionData = {
- actionName: InsertColumnDataAction.NAME,
- sheetId: _sheetId,
- columnIndex,
- columnData: columnData.toJSON(),
- };
- const insertColumn: IInsertColumnActionData = {
- actionName: InsertColumnAction.NAME,
- sheetId: _sheetId,
- columnIndex,
- columnCount: numColumns,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- insertColumnData,
- insertColumn
- );
- this._commandManager.invoke(command);
-
- return this;
- }
-
/**
* Clears the sheet of content and formatting information.
* @returns WorkSheet Instance
@@ -855,110 +323,32 @@ export class Worksheet {
}
/**
- * Sets the sheet tab color.
- * @param color A color code in CSS notation (like '#ffffff' or 'white'), or null to reset the tab color.
- * @returns WorkSheet This sheet, for chaining.
+ * restore the active selection region for this sheet.
+ * @returns Range — the newly active range
+ */
+ setActiveSelection(): Range;
+ /**
+ * restore the active selection region for this sheet.
+ * @param range Range Instance of Selection
+ * @returns Range — the newly active range
*/
- setTabColor(color: Nullable<string>): Worksheet {
- const setTabColor: ISetTabColorActionData = {
- sheetId: this._sheetId,
- actionName: SetTabColorAction.NAME,
- color,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setTabColor
- );
- this._commandManager.invoke(command);
-
- const observer = this._observerManager.getObserver('onSheetTabColorChangeObservable', 'core');
- observer?.notifyObservers();
+ setActiveSelection(range: Range): Range;
+ /**
+ * restore the active selection region for this sheet.
+ * @param a1Notation One of the range types, the range to set as active, as specified in A1 notation or R1C1 notation
+ * @returns Range — the newly active range
+ */
+ setActiveSelection(a1Notation: IRangeStringData): Range;
+ setActiveSelection(...argument: any): Range {
+ const range = argument[0];
- return this;
+ // just send range, we will handle Range instance or range string in Selection class
+ return range ? this._selection.setSelection({ selection: range }) : this._selection.setSelection();
}
/**
- * Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.
- * @returns Sheet — The current sheet.
- */
- hideSheet(): Worksheet {
- const _workbook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- if (!this._config.hidden) {
- const observer = this._observerManager.getObserver<{ sheet: Worksheet }>('onHideSheetObservable', 'core');
- const setHiddenAction: ISetWorkSheetHideActionData = {
- hidden: BooleanNumber.TRUE,
- sheetId: this._sheetId,
- actionName: SetWorkSheetHideAction.NAME,
- };
- const command = new Command(
- {
- WorkBookUnit: _workbook,
- },
- setHiddenAction
- );
- this._commandManager.invoke(command);
- observer!.notifyObservers({ sheet: this });
- const index = _workbook.getSheetIndex(this);
- if (index != null) {
- _workbook.activateSheetByIndex(index);
- }
- }
- return this;
- }
-
- /**
- * Makes the sheet visible. Has no effect if the sheet is already visible.
- * @returns WorkSheet Instance
- */
- showSheet(): Worksheet {
- if (!this._config.hidden) {
- return this;
- }
- const setHidden: ISetWorkSheetHideActionData = {
- hidden: BooleanNumber.FALSE,
- sheetId: this._sheetId,
- actionName: SetWorkSheetHideAction.NAME,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- setHidden
- );
- this._commandManager.invoke(command);
- this._observerManager.getObserver<{ sheet: Worksheet }>('onShowSheetObservable', 'core')?.notifyObservers({ sheet: this });
- return this;
- }
-
- /**
- * restore the active selection region for this sheet.
- * @returns Range — the newly active range
- */
- setActiveSelection(): Range;
- /**
- * restore the active selection region for this sheet.
- * @param range Range Instance of Selection
- * @returns Range — the newly active range
- */
- setActiveSelection(range: Range): Range;
- /**
- * restore the active selection region for this sheet.
- * @param a1Notation One of the range types, the range to set as active, as specified in A1 notation or R1C1 notation
- * @returns Range — the newly active range
- */
- setActiveSelection(a1Notation: IRangeStringData): Range;
- setActiveSelection(...argument: any): Range {
- const range = argument[0];
-
- // just send range, we will handle Range instance or range string in Selection class
- return range ? this._selection.setSelection({ selection: range }) : this._selection.setSelection();
- }
-
- /**
- * Returns the number of frozen rows.
- * @returns the number of frozen rows
+ * Returns the number of frozen rows.
+ * @returns the number of frozen rows
*/
getFrozenRows(): number {
return this._config.freezeRow;
@@ -1016,163 +406,36 @@ export class Worksheet {
* @returns WorkSheet Instance
*/
clearContents(): Worksheet {
- const { _config } = this;
- const { rowCount, columnCount } = _config;
- this.getRange({
- startRow: 0,
- endRow: rowCount,
- startColumn: 0,
- endColumn: columnCount,
- }).clear({
- contentsOnly: true,
- });
- return this;
+ // const { _config } = this;
+ // const { rowCount, columnCount } = _config;
+ // this.getRange({
+ // startRow: 0,
+ // endRow: rowCount,
+ // startColumn: 0,
+ // endColumn: columnCount,
+ // }).clear({
+ // contentsOnly: true,
+ // });
+ // return this;
}
/**
* Clears the sheet of formatting, while preserving contents.
* @returns WorkSheet Instance
*/
- clearFormats(): Worksheet {
- const { _config } = this;
- const { rowCount, columnCount } = _config;
- this.getRange({
- startRow: 0,
- endRow: rowCount,
- startColumn: 0,
- endColumn: columnCount,
- }).clear({
- formatOnly: true,
- });
- return this;
- }
-
- /**
- * Deletes the column at the given column position.
- * @param columnPosition column index
- * @returns WorkSheet Instance
- */
- deleteColumn(columnPosition: number): Worksheet {
- const { _sheetId } = this;
- const deleteColumnData: IRemoveColumnDataAction = {
- actionName: RemoveColumnDataAction.NAME,
- sheetId: _sheetId,
- columnCount: 1,
- columnIndex: columnPosition,
- };
- const deleteColumn: IRemoveColumnAction = {
- actionName: RemoveColumnAction.NAME,
- sheetId: _sheetId,
- columnCount: 1,
- columnIndex: columnPosition,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- deleteColumnData,
- deleteColumn
- );
- this._commandManager.invoke(command);
-
- return this;
- }
-
- /**
- * Deletes a number of columns starting at the given column position.
- * @param columnPosition column index
- * @param howMany column count
- * @returns WorkSheet Instance
- */
- deleteColumns(columnPosition: number, howMany: number): Worksheet {
- const { _sheetId } = this;
- const deleteColumnData: IRemoveColumnDataAction = {
- actionName: RemoveColumnDataAction.NAME,
- sheetId: _sheetId,
- columnCount: howMany,
- columnIndex: columnPosition,
- };
- const deleteColumn: IRemoveColumnAction = {
- actionName: RemoveColumnAction.NAME,
- sheetId: _sheetId,
- columnCount: howMany,
- columnIndex: columnPosition,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- deleteColumnData,
- deleteColumn
- );
- this._commandManager.invoke(command);
-
- return this;
- }
-
- /**
- * Deletes the row at the given row position.
- * @param rowPosition row index
- * @returns WorkSheet Instance
- */
- deleteRow(rowPosition: number): Worksheet {
- const { _sheetId } = this;
- const dataRowDelete: IRemoveRowDataActionData = {
- actionName: RemoveRowDataAction.NAME,
- sheetId: _sheetId,
- rowCount: 1,
- rowIndex: rowPosition,
- };
- const rowDelete: IRemoveRowActionData = {
- actionName: RemoveRowAction.NAME,
- sheetId: _sheetId,
- rowCount: 1,
- rowIndex: rowPosition,
- };
-
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- dataRowDelete,
- rowDelete
- );
- this._commandManager.invoke(command);
-
- return this;
- }
-
- /**
- * Deletes a number of rows starting at the given row position.
- * @param rowPosition row index
- * @param howMany row count
- * @returns WorkSheet Instance
- */
- deleteRows(rowPosition: number, howMany: number): Worksheet {
- const { _sheetId } = this;
- const dataRowDelete: IRemoveRowDataActionData = {
- actionName: RemoveRowDataAction.NAME,
- sheetId: _sheetId,
- rowCount: howMany,
- rowIndex: rowPosition,
- };
- const rowDelete: IRemoveRowActionData = {
- actionName: RemoveRowAction.NAME,
- sheetId: _sheetId,
- rowCount: howMany,
- rowIndex: rowPosition,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- dataRowDelete,
- rowDelete
- );
- this._commandManager.invoke(command);
-
- return this;
- }
+ // clearFormats(): Worksheet {
+ // const { _config } = this;
+ // const { rowCount, columnCount } = _config;
+ // this.getRange({
+ // startRow: 0,
+ // endRow: rowCount,
+ // startColumn: 0,
+ // endColumn: columnCount,
+ // }).clear({
+ // formatOnly: true,
+ // });
+ // return this;
+ // }
/**
* Returns Row Count
@@ -1190,179 +453,14 @@ export class Worksheet {
return this._config.columnCount;
}
- /**
- * Returns Border Styles
- * @returns Border Styles
- */
- // getBorderStyles(): BorderStyles {
- // return this._borderStyles;
- // }
-
- /**
- * @deprecated
- * Sets the BorderStyles
- * @param rangeData
- * @param style
- * @param directions
- */
- // TODO: fix
- // eslint-disable-next-line max-lines-per-function
- setBorderStyle(rangeData: IRangeData, style: IBorderStyleData, directions: Direction[]) {
- const { _sheetId } = this;
-
- const matrix = this.getCellMatrix();
- const workbook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();
- const styles = workbook.getStyles();
-
- const tr = this.getRange({
- startRow: rangeData.startRow - 1,
- startColumn: rangeData.startColumn,
- endRow: rangeData.startRow - 1,
- endColumn: rangeData.endColumn,
- });
- const lr = this.getRange({
- startRow: rangeData.startRow,
- startColumn: rangeData.startColumn - 1,
- endRow: rangeData.startRow,
- endColumn: rangeData.endColumn - 1,
- });
- const br = this.getRange({
- startRow: rangeData.endRow + 1,
- startColumn: rangeData.startColumn,
- endRow: rangeData.endRow + 1,
- endColumn: rangeData.endColumn,
- });
- const rr = this.getRange({
- startRow: rangeData.startRow,
- startColumn: rangeData.endColumn + 1,
- endRow: rangeData.startRow,
- endColumn: rangeData.endColumn + 1,
- });
- const cc = this.getRange(rangeData);
-
- const mtr = new ObjectMatrix<IStyleData>();
- const mlr = new ObjectMatrix<IStyleData>();
- const mbr = new ObjectMatrix<IStyleData>();
- const mrr = new ObjectMatrix<IStyleData>();
- const mcr = new ObjectMatrix<IStyleData>();
-
- tr.forEach((row, column) => {
- const cell = matrix.getValue(row, column);
- if (cell) {
- const cellStyle = styles.getStyleByCell(cell);
- if (cellStyle) {
- const copy: IStyleData = Tools.deepClone(cellStyle);
- if (copy.bd) {
- delete copy.bd.b;
- }
- mtr.setValue(row, column, copy);
- }
- }
- });
- br.forEach((row, column) => {
- const cell = matrix.getValue(row, column);
- if (cell) {
- const cellStyle = styles.getStyleByCell(cell);
- if (cellStyle) {
- const copy: IStyleData = Tools.deepClone(cellStyle);
- if (copy.bd) {
- delete copy.bd.t;
- }
- mbr.setValue(row, column, copy);
- }
- }
- });
- lr.forEach((row, column) => {
- const cell = matrix.getValue(row, column);
- if (cell) {
- const cellStyle = styles.getStyleByCell(cell);
- if (cellStyle) {
- const copy: IStyleData = Tools.deepClone(cellStyle);
- if (copy.bd) {
- delete copy.bd.r;
- }
- mlr.setValue(row, column, copy);
- }
- }
- });
- rr.forEach((row, column) => {
- const cell = matrix.getValue(row, column);
- if (cell) {
- const cellStyle = styles.getStyleByCell(cell);
- if (cellStyle) {
- const copy: IStyleData = Tools.deepClone(cellStyle);
- if (copy.bd) {
- delete copy.bd.l;
- }
- mrr.setValue(row, column, copy);
- }
- }
- });
- cc.forEach((row, column) => {
- mcr.setValue(row, column, style);
- });
-
- const actions: ISheetActionData[] = [];
-
- if (directions.includes(Direction.UP)) {
- const setBottomData: BorderStyleData = {
- sheetId: _sheetId,
- actionName: SetBorderAction.NAME,
- styles: mbr.toJSON(),
- };
- actions.push(setBottomData);
- }
- if (directions.includes(Direction.DOWN)) {
- const setTopData: BorderStyleData = {
- sheetId: _sheetId,
- actionName: SetBorderAction.NAME,
- styles: mtr.toJSON(),
- };
- actions.push(setTopData);
- }
- if (directions.includes(Direction.LEFT)) {
- const setRightData: BorderStyleData = {
- sheetId: _sheetId,
- actionName: SetBorderAction.NAME,
- styles: mrr.toJSON(),
- };
- actions.push(setRightData);
- }
- if (directions.includes(Direction.RIGHT)) {
- const setLeftData: BorderStyleData = {
- sheetId: _sheetId,
- actionName: SetBorderAction.NAME,
- styles: mlr.toJSON(),
- };
- actions.push(setLeftData);
- }
- const setCCData: BorderStyleData = {
- sheetId: _sheetId,
- actionName: SetBorderAction.NAME,
- styles: mcr.toJSON(),
- };
- actions.push(setCCData);
-
- const commandCC = new Command(
- {
- WorkBookUnit: workbook,
- },
- ...actions
- );
-
- this._commandManager.invoke(commandCC);
-
- return this;
- }
-
/**
* Sets the specified cell as the current cell.
* @param cell cell range
* @returns Range Instance
*/
- setCurrentCell(cell: Range): Range {
- return cell.activateAsCurrentCell();
- }
+ // setCurrentCell(cell: Range): Range {
+ // return cell.activateAsCurrentCell();
+ // }
/**
* Returns the active cell in this sheet.
@@ -1431,256 +529,6 @@ export class Worksheet {
return selection.getActiveRangeList();
}
- /**
- * Hides the rows in the given range.
- * @param row row range
- * @returns WorkSheet Instance
- */
- hideRow(row: Range): Worksheet {
- const range = row.getRangeData();
- const index = range.startRow;
- const count = range.endRow - range.startRow + 1;
- const { _sheetId } = this;
- const hideRow: ISetRowHideActionData = {
- actionName: SetRowHideAction.NAME,
- sheetId: _sheetId,
- rowCount: count,
- rowIndex: index,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- hideRow
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- // TODO: @Dushudir unnecessary function overload here
-
- /**
- * Hides one or more consecutive rows starting at the given index.
- * @param rowIndex row index
- * @returns WorkSheet Instance
- */
- hideRows(rowIndex: number): Worksheet;
- /**
- * Hides one or more consecutive rows starting at the given index.
- * @param rowIndex row index
- * @param numRows row count
- * @returns WorkSheet Instance
- */
- hideRows(rowIndex: number, numRows: number): Worksheet;
- hideRows(...argument: any): Worksheet {
- const index = --argument[0];
- let count = 1;
- if (argument[1]) {
- count = argument[1];
- }
- const { _sheetId } = this;
- const hideRow: ISetRowHideActionData = {
- actionName: SetRowHideAction.NAME,
- sheetId: _sheetId,
- rowCount: count,
- rowIndex: index,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- hideRow
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Hides the columns in the given range.
- * @param column column range
- * @returns WorkSheet Instance
- */
- hideColumn(column: Range): Worksheet {
- const range = column.getRangeData();
- const index = range.startColumn;
- const count = range.endColumn - range.startColumn + 1;
- const { _sheetId } = this;
- const hideColumn: ISetColumnHideActionData = {
- actionName: SetColumnHideAction.NAME,
- sheetId: _sheetId,
- columnCount: count,
- columnIndex: index,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- hideColumn
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Hides one or more consecutive columns starting at the given index.
- * @param columnIndex column index
- * @returns WorkSheet Instance
- */
- hideColumns(columnIndex: number): Worksheet;
- /**
- * Hides one or more consecutive columns starting at the given index.
- * @param columnIndex column index
- * @param numColumns column count
- * @returns WorkSheet Instance
- */
- hideColumns(columnIndex: number, numColumns: number): Worksheet;
- hideColumns(...argument: any): Worksheet {
- const index = argument[0];
- let count = 1;
- if (argument[1]) {
- count = argument[1];
- }
- const { _sheetId } = this;
- const hideColumn: ISetColumnHideActionData = {
- actionName: SetColumnHideAction.NAME,
- sheetId: _sheetId,
- columnCount: count,
- columnIndex: index,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- hideColumn
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Unhide the row in the given range.
- * @param row row range
- * @return WorkSheet Instance
- */
- unhideRow(row: Range): Worksheet {
- const range = row.getRangeData();
- const index = range.startRow;
- const count = range.endRow - range.startRow + 1;
- const { _sheetId } = this;
- const unhideRow: ISetRowShowActionData = {
- actionName: SetRowShowAction.NAME,
- rowCount: count,
- rowIndex: index,
- sheetId: _sheetId,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- unhideRow
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Unhides the column in the given range.
- * @param column column range
- * @return WorkSheet Instance
- */
- unhideColumn(column: Range): Worksheet {
- const range = column.getRangeData();
- const index = range.startColumn;
- const count = range.endColumn - range.startColumn + 1;
- const { _sheetId } = this;
- const unhideColumn: ISetColumnShowActionData = {
- actionName: SetColumnShowAction.NAME,
- sheetId: _sheetId,
- columnCount: count,
- columnIndex: index,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- unhideColumn
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Unhides one or more consecutive columns starting at the given index.
- * @param columnIndex column index
- * @returns WorkSheet Instance
- */
- showColumns(columnIndex: number): Worksheet;
- /**
- * Unhides one or more consecutive columns starting at the given index.
- * @param columnIndex column index
- * @param numColumns column count
- * @returns WorkSheet Instance
- */
- showColumns(columnIndex: number, numColumns: number): Worksheet;
- showColumns(...argument: any): Worksheet {
- const index = argument[0];
- let count = 1;
- if (argument[1]) {
- count = argument[1];
- }
- const { _sheetId } = this;
- const showColumn: ISetColumnShowActionData = {
- actionName: SetColumnShowAction.NAME,
- sheetId: _sheetId,
- columnCount: count,
- columnIndex: index,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- showColumn
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- /**
- * Unhides one or more consecutive rows starting at the given index.
- * @param rowIndex row index
- * @returns WorkSheet Instance
- */
- showRows(rowIndex: number): Worksheet;
- /**
- * Unhides one or more consecutive rows starting at the given index.
- * @param rowIndex row index
- * @param numRows row count
- * @returns WorkSheet Instance
- */
- showRows(rowIndex: number, numRows: number): Worksheet;
- showRows(...argument: any): Worksheet {
- const index = --argument[0];
- let count = 1;
- if (argument[1]) {
- count = argument[1];
- }
- const { _sheetId } = this;
- const showRow: ISetRowShowActionData = {
- actionName: SetRowShowAction.NAME,
- sheetId: _sheetId,
- rowCount: count,
- rowIndex: index,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- showRow
- );
- this._commandManager.invoke(command);
- return this;
- }
-
/**
* Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default.
* @returns Gridlines Hidden Status
@@ -1722,108 +570,6 @@ export class Worksheet {
return this.getRowManager().getRowHeight(rowPosition);
}
- /**
- * Sets the width of the given columns in pixels.
- * @param columnPosition column index
- * @param width column width
- * @returns WorkSheet Instance
- */
- setColumnWidth(columnPosition: number, width: number): Worksheet;
- /**
- * Sets the width of the given columns in pixels.
- * @param startColumn column index
- * @param numColumns column count
- * @param width column width
- * @returns WorkSheet Instance
- */
- setColumnWidth(startColumn: number, numColumns: number, width: number): Worksheet;
- setColumnWidth(...argument: any): Worksheet {
- let columnIndex;
- let columnWidth: number[] = [];
- if (Tools.hasLength(argument, 2)) {
- columnIndex = argument[0];
- columnWidth = [argument[1]];
- }
- if (Tools.hasLength(argument, 3)) {
- columnIndex = argument[0];
- for (let i = 0; i < argument[1]; i++) {
- columnWidth.push(argument[2]);
- }
- }
- this.getColumnManager().setColumnWidth(columnIndex, columnWidth);
- return this;
- }
-
- /**
- * Sets the height of the given rows in pixels.
- * @param startRow row index
- * @param numRows row count
- * @param height row height
- * @returns WorkSheet Instance
- */
- setRowHeights(startRow: number, numRows: number, height: number): Worksheet {
- const rowHeight = [];
- for (let i = 0; i < numRows; i++) {
- rowHeight.push(height);
- }
- this.getRowManager().setRowHeight(startRow, rowHeight);
- return this;
- }
-
- /**
- * Sets the row height of the given row in pixels.
- * @param rowPosition row index
- * @param height row height
- * @returns WorkSheet Instance
- */
- setRowHeight(rowPosition: number, height: number): Worksheet {
- const rowHeight = [height];
- this.getRowManager().setRowHeight(rowPosition, rowHeight);
- return this;
- }
-
- /**
- * Hides or reveals the sheet gridlines.
- * @param hideGridlines hide gridlines status
- * @returns WorkSheet Instance
- */
- setHiddenGridlines(hideGridlines: boolean): Worksheet {
- const { _sheetId } = this;
- const configure = {
- actionName: SetHiddenGridlinesAction.NAME,
- hideGridlines,
- sheetId: _sheetId,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- configure
- );
- this._commandManager.invoke(command);
- return this;
- }
-
- // /**
- // * Freezes the given number of columns. If zero, no columns are frozen.
- // * @param columns freeze columns, 0 - columns
- // * @returns WorkSheet Instance
- // */
- // setFrozenColumns(columns: number): WorkSheet {
- // const frozen = new Freeze(this);
- // return frozen.setFrozenColumns(columns);
- // }
-
- // /**
- // * Freezes the given number of rows. If zero, no rows are frozen.
- // * @param rows freeze rows, 0 - rows
- // * @returns WorkSheet Instance
- // */
- // setFrozenRows(rows: number): WorkSheet {
- // const frozen = new Freeze(this);
- // return frozen.setFrozenRows(rows);
- // }
-
/**
* 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.
@@ -1834,28 +580,6 @@ export class Worksheet {
return rightToLeft;
}
- /**
- * Sets or unsets the sheet layout to right-to-left.
- * @param rightToLeft rightToLeft status
- * @returns WorkSheet Instance
- */
- setRightToLeft(rightToLeft: BooleanNumber): Worksheet {
- const { _sheetId } = this;
- const configure = {
- actionName: SetRightToLeftAction.NAME,
- rightToLeft,
- sheetId: _sheetId,
- };
- const command = new Command(
- {
- WorkBookUnit: this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook(),
- },
- configure
- );
- this._commandManager.invoke(command);
- return this;
- }
-
/**
* @typeParam T - plugin data structure
* @param name - plugin name
@@ -1875,21 +599,6 @@ export class Worksheet {
this._config.pluginMeta[name] = value;
}
- /**
- * Copies the sheet to a given sheet,
- * @param sheetIndex sheet index
- * @returns WorkSheet Instance
- */
- copyTo(sheetIndex: number): Worksheet {
- const worksheet = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheets()[sheetIndex];
- if (!worksheet) return this;
-
- const config = Tools.deepClone(this._config);
- config.sheetId = worksheet.getConfig().id;
- worksheet.setConfig(config);
- return worksheet;
- }
-
/**
* Returns the position of the last row that has content.
* @returns the position of the last row that has content.
@@ -1906,6 +615,13 @@ export class Worksheet {
return this._cellData.getRange().endColumn;
}
+ /**
+ * @deprecated the method here is just to prevent ts errors
+ */
+ setCommandManager(_commandManager: CommandManager): void {
+ throw new Error('This method is deprecated. The method is here to prevent ts errors!');
+ }
+
/**
* Returns the rectangular grid of values for this range starting at the given coordinates. A -1 value given as the row or column position is equivalent to getting the very last row or column that has data in the sheet.
* @param startRow row start index
@@ -1938,41 +654,6 @@ export class Worksheet {
return range;
}
- /**
- * Moves the rows selected by the given range to the position indicated by the destinationIndex. The rowSpec itself does not have to exactly represent an entire row or group of rows to move—it selects all rows that the range spans.
- * @param rowSpec row range
- * @param destinationIndex row index
- * @returns WorkSheet Instance
- */
- moveRows(rowSpec: Range, destinationIndex: number): Worksheet {
- const { startRow } = rowSpec.getRangeData();
- const { endRow } = rowSpec.getRangeData();
- const data = this._cellData.spliceRows(startRow, endRow - startRow + 1);
- this._cellData.insertRows(destinationIndex, data);
- return this;
- }
-
- /**
- * Moves the columns selected by the given range to the position indicated by the destinationIndex. The columnSpec itself does not have to exactly represent an entire column or group of columns to move—it selects all columns that the range spans.
- * @param columnSpec column range
- * @param destinationIndex column index
- * @returns WorkSheet Instance
- */
- moveColumns(columnSpec: Range, destinationIndex: number): Worksheet {
- const startRow = columnSpec.getRangeData().startColumn;
- const endRow = columnSpec.getRangeData().endColumn;
- const data = this._cellData.spliceColumns(startRow, endRow - startRow + 1);
- this._cellData.insertColumns(destinationIndex, data);
- return this;
- }
-
- /**
- * @deprecated the method here is just to prevent ts errors
- */
- setCommandManager(_commandManager: CommandManager): void {
- throw new Error('This method is deprecated. The method is here to prevent ts errors!');
- }
-
private _initialize(): void {
// this._selection = new Selection(this);
this._merges = new Merges(this, this._config.mergeData, this._commandManager, this._currentUniverService);
diff --git a/packages/core/src/Types/Interfaces/IRangeData.ts b/packages/core/src/Types/Interfaces/IRangeData.ts
index e01f34217c..923459ef02 100644
--- a/packages/core/src/Types/Interfaces/IRangeData.ts
+++ b/packages/core/src/Types/Interfaces/IRangeData.ts
@@ -66,9 +66,7 @@ export type IRowStartEndData = [startRow: number, endRow: number] | number[];
/**
* Column data type
*/
-export type IColumnStartEndData =
- | [startColumn: number, endColumn: number]
- | number[];
+export type IColumnStartEndData = [startColumn: number, endColumn: number] | number[];
/**
* One of the range types,
@@ -113,11 +111,7 @@ export type IRangeCellData = {
*
* Allow users to provide one of three formats, we need to convert to IRangeData to store
*/
-export type IRangeType =
- | IRangeData
- | IRangeStringData
- | IRangeArrayData
- | IRangeCellData;
+export type IRangeType = IRangeData | IRangeStringData | IRangeArrayData | IRangeCellData;
// export interface IInfoObjData extends IRangeArrayData {
// sheetId?: Nullable<string>;
diff --git a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts
index c8a90e6aec..49e2acce9f 100644
--- a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts
+++ b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts
@@ -9,12 +9,12 @@ import { DefaultRightMenuConfig, SheetRightMenuConfig } from '../Basics';
import { RightMenu, RightMenuInput, RightMenuItem } from '../View';
import styles from '../View/RightMenu/index.module.less';
import {
- ClearSelectionMenuItemFactory,
- DeleteRangeMenuItemFactory,
- DeleteRangeMoveLeftMenuItemFactory,
- DeleteRangeMoveUpMenuItemFactory,
- InsertColMenuItemFactory,
- InsertRowMenuItemFactory,
+ // ClearSelectionMenuItemFactory,
+ // DeleteRangeMenuItemFactory,
+ // DeleteRangeMoveLeftMenuItemFactory,
+ // DeleteRangeMoveUpMenuItemFactory,
+ // InsertColMenuItemFactory,
+ // InsertRowMenuItemFactory,
RemoveColMenuItemFactory,
RemoveRowMenuItemFactory,
SetColWidthMenuItemFactory,
@@ -305,20 +305,18 @@ export class RightMenuUIController extends Disposable {
}
private _initializeContextMenu() {
- (
- [
- ClearSelectionMenuItemFactory,
- InsertRowMenuItemFactory,
- InsertColMenuItemFactory,
- RemoveRowMenuItemFactory,
- RemoveColMenuItemFactory,
- SetRowHeightMenuItemFactory,
- SetColWidthMenuItemFactory,
- DeleteRangeMenuItemFactory,
- DeleteRangeMoveLeftMenuItemFactory,
- DeleteRangeMoveUpMenuItemFactory,
- ] as IMenuItemFactory[]
- ).forEach((factory) => {
+ [
+ // ClearSelectionMenuItemFactory,
+ // InsertRowMenuItemFactory,
+ // InsertColMenuItemFactory,
+ RemoveRowMenuItemFactory,
+ RemoveColMenuItemFactory,
+ SetRowHeightMenuItemFactory,
+ SetColWidthMenuItemFactory,
+ // DeleteRangeMenuItemFactory,
+ // DeleteRangeMoveLeftMenuItemFactory,
+ // DeleteRangeMoveUpMenuItemFactory,
+ ].forEach((factory) => {
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));
});
}
diff --git a/packages/ui-plugin-sheets/src/Controller/menu.ts b/packages/ui-plugin-sheets/src/Controller/menu.ts
index abaacbb074..8e6dff1c60 100644
--- a/packages/ui-plugin-sheets/src/Controller/menu.ts
+++ b/packages/ui-plugin-sheets/src/Controller/menu.ts
@@ -1,8 +1,5 @@
import {
- ClearSelectionContentCommand,
ISelectionManager,
- InsertColCommand,
- InsertRowCommand,
SetBoldCommand,
SetItalicCommand,
SetSelectionsOperation,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a8ed3f6003..f25d933bf0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -125,7 +125,7 @@ importers:
version: 1.2.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -192,7 +192,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -286,7 +286,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -365,7 +365,7 @@ importers:
version: 0.17.10
esbuild-style-plugin:
specifier: ^1.6.1
- version: 1.6.1
+ version: 1.6.2
identity-obj-proxy:
specifier: ^3.0.0
version: 3.0.0
@@ -383,7 +383,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -447,7 +447,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -538,7 +538,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -599,7 +599,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -642,7 +642,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -682,7 +682,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -728,7 +728,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -780,7 +780,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -829,7 +829,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -893,7 +893,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -948,7 +948,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -979,7 +979,7 @@ importers:
version: 6.1.1([email protected])
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1031,7 +1031,7 @@ importers:
version: 4.1.3
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1080,7 +1080,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
typescript:
specifier: 4.7.2
version: 4.7.2
@@ -1144,7 +1144,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1205,7 +1205,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1266,7 +1266,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1321,7 +1321,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1388,7 +1388,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1446,7 +1446,7 @@ importers:
version: 4.1.1
ts-jest:
specifier: 29.0.1
typescript:
specifier: 4.7.2
version: 4.7.2
@@ -1498,7 +1498,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.2.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1553,7 +1553,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1608,7 +1608,7 @@ importers:
version: 2.3.2
ts-jest:
specifier: 29.0.1
ts-node:
specifier: ^10.2.1
version: 10.9.1(@types/[email protected])([email protected])
@@ -1647,20 +1647,20 @@ packages:
engines: {node: '>=6.9.0'}
dev: true
- resolution: {integrity: sha512-lh7RJrtPdhibbxndr6/xx0w8+CVlY5FJZiaSz908Fpy+G0xkBFTvwLcKJFF4PJxVfGhVWNebikpWGnOoC71juQ==}
+ resolution: {integrity: sha512-PtZqMmgRrvj8ruoEOIwVA3yoF91O+Hgw9o7DAUTNBA6Mo2jpu31clx9a7Nz/9JznqetTR6zwfC4L3LAjKQXUwA==}
engines: {node: '>=6.9.0'}
dependencies:
'@ampproject/remapping': 2.2.1
'@babel/code-frame': 7.22.13
- '@babel/generator': 7.22.10
- '@babel/helper-compilation-targets': 7.22.10
- '@babel/helper-module-transforms': 7.22.9(@babel/[email protected])
- '@babel/helpers': 7.22.11
- '@babel/parser': 7.22.14
- '@babel/template': 7.22.5
- '@babel/traverse': 7.22.11
- '@babel/types': 7.22.11
+ '@babel/generator': 7.22.15
+ '@babel/helper-compilation-targets': 7.22.15
+ '@babel/helper-module-transforms': 7.22.15(@babel/[email protected])
+ '@babel/helpers': 7.22.15
+ '@babel/parser': 7.22.15
+ '@babel/template': 7.22.15
+ '@babel/traverse': 7.22.15
+ '@babel/types': 7.22.15
convert-source-map: 1.9.0
debug: 4.3.4
gensync: 1.0.0-beta.2
@@ -1670,11 +1670,11 @@ packages:
- supports-color
dev: true
- resolution: {integrity: sha512-79KIf7YiWjjdZ81JnLujDRApWtl7BxTqWD88+FFdQEIOG8LJ0etDOM7CXuIgGJa55sGOwZVwuEsaLEm0PJ5/+A==}
+ resolution: {integrity: sha512-Zu9oWARBqeVOW0dZOjXc3JObrzuqothQ3y/n1kUtrjCoCPLkXUwMvOo/F/TCfoHMbWIFlWwpZtkZVb9ga4U2pA==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
'@jridgewell/gen-mapping': 0.3.3
'@jridgewell/trace-mapping': 0.3.19
jsesc: 2.5.2
@@ -1684,33 +1684,33 @@ packages:
resolution: {integrity: sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
- resolution: {integrity: sha512-JMSwHD4J7SLod0idLq5PKgI+6g/hLD/iuWBq08ZX49xE14VpVEojJ5rHWptpirV2j020MvypRLAXAO50igCJ5Q==}
+ resolution: {integrity: sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/compat-data': 7.22.9
- '@babel/helper-validator-option': 7.22.5
+ '@babel/helper-validator-option': 7.22.15
browserslist: 4.21.10
lru-cache: 5.1.1
semver: 6.3.1
dev: true
- resolution: {integrity: sha512-y1grdYL4WzmUDBRGK0pDbIoFd7UZKoDurDzWEoNMYoj1EL+foGRQNyPWDcC+YyegN5y1DUsFFmzjGijB3nSVAQ==}
+ resolution: {integrity: sha512-jKkwA59IXcvSaiK2UN45kKwSC9o+KuoXsBDvHvU/7BecYIp8GQ2UwrVvFgJASUT+hBnwJx6MhvMCuMzwZZ7jlg==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-annotate-as-pure': 7.22.5
'@babel/helper-environment-visitor': 7.22.5
'@babel/helper-function-name': 7.22.5
- '@babel/helper-member-expression-to-functions': 7.22.5
+ '@babel/helper-member-expression-to-functions': 7.22.15
'@babel/helper-optimise-call-expression': 7.22.5
- '@babel/helper-replace-supers': 7.22.9(@babel/[email protected])
+ '@babel/helper-replace-supers': 7.22.9(@babel/[email protected])
'@babel/helper-skip-transparent-expression-wrappers': 7.22.5
'@babel/helper-split-export-declaration': 7.22.6
semver: 6.3.1
@@ -1725,50 +1725,50 @@ packages:
resolution: {integrity: sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/template': 7.22.5
- '@babel/types': 7.22.11
+ '@babel/template': 7.22.15
+ '@babel/types': 7.22.15
dev: true
resolution: {integrity: sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
- resolution: {integrity: sha512-aBiH1NKMG0H2cGZqspNvsaBe6wNGjbJjuLy29aU+eDZjSbbN53BaxlpB02xm9v34pLTZ1nIQPFYn2qMZoa5BQQ==}
+ resolution: {integrity: sha512-qLNsZbgrNh0fDQBCPocSL8guki1hcPvltGDv/NxvUoABwFq7GkKSu1nRXeJkVZc+wJvne2E0RKQz+2SQrz6eAA==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
- resolution: {integrity: sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==}
+ resolution: {integrity: sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
- resolution: {integrity: sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ==}
+ resolution: {integrity: sha512-l1UiX4UyHSFsYt17iQ3Se5pQQZZHa22zyIXURmvkmLCD4t/aU+dvNWHatKac/D9Vm9UES7nvIqHs4jZqKviUmQ==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-environment-visitor': 7.22.5
- '@babel/helper-module-imports': 7.22.5
+ '@babel/helper-module-imports': 7.22.15
'@babel/helper-simple-access': 7.22.5
'@babel/helper-split-export-declaration': 7.22.6
- '@babel/helper-validator-identifier': 7.22.5
+ '@babel/helper-validator-identifier': 7.22.15
dev: true
resolution: {integrity: sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
@@ -1776,15 +1776,15 @@ packages:
engines: {node: '>=6.9.0'}
dev: true
resolution: {integrity: sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-environment-visitor': 7.22.5
- '@babel/helper-member-expression-to-functions': 7.22.5
+ '@babel/helper-member-expression-to-functions': 7.22.15
'@babel/helper-optimise-call-expression': 7.22.5
dev: true
@@ -1792,21 +1792,21 @@ packages:
resolution: {integrity: sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
resolution: {integrity: sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
resolution: {integrity: sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
@@ -1814,23 +1814,23 @@ packages:
engines: {node: '>=6.9.0'}
dev: true
- resolution: {integrity: sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==}
+ resolution: {integrity: sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==}
engines: {node: '>=6.9.0'}
dev: true
- resolution: {integrity: sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==}
+ resolution: {integrity: sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==}
engines: {node: '>=6.9.0'}
dev: true
- resolution: {integrity: sha512-vyOXC8PBWaGc5h7GMsNx68OH33cypkEDJCHvYVVgVbbxJDROYVtexSk0gK5iCF1xNjRIN2s8ai7hwkWDq5szWg==}
+ resolution: {integrity: sha512-7pAjK0aSdxOwR+CcYAqgWOGy5dcfvzsTIfFTb2odQqW47MDfv14UaJDY6eng8ylM2EaeKXdxaSWESbkmaQHTmw==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/template': 7.22.5
- '@babel/traverse': 7.22.11
- '@babel/types': 7.22.11
+ '@babel/template': 7.22.15
+ '@babel/traverse': 7.22.15
+ '@babel/types': 7.22.15
transitivePeerDependencies:
- supports-color
dev: true
@@ -1839,393 +1839,393 @@ packages:
resolution: {integrity: sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/helper-validator-identifier': 7.22.5
+ '@babel/helper-validator-identifier': 7.22.15
chalk: 2.4.2
js-tokens: 4.0.0
dev: true
- resolution: {integrity: sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ==}
+ resolution: {integrity: sha512-RWmQ/sklUN9BvGGpCDgSubhHWfAx24XDTDObup4ffvxaYsptOg2P3KG0j+1eWKLxpkX0j0uHxmpq2Z1SP/VhxA==}
engines: {node: '>=6.0.0'}
hasBin: true
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
resolution: {integrity: sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
- '@babel/helper-create-class-features-plugin': 7.22.11(@babel/[email protected])
+ '@babel/core': 7.22.15
+ '@babel/helper-create-class-features-plugin': 7.22.15(@babel/[email protected])
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-dynamic-import': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-dynamic-import': 7.8.3(@babel/[email protected])
dev: true
resolution: {integrity: sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-export-namespace-from': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-export-namespace-from': 7.8.3(@babel/[email protected])
dev: true
resolution: {integrity: sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/[email protected])
+ '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/[email protected])
dev: true
resolution: {integrity: sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/[email protected])
dev: true
resolution: {integrity: sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/[email protected])
+ '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/[email protected])
dev: true
resolution: {integrity: sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
'@babel/helper-skip-transparent-expression-wrappers': 7.22.5
- '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/[email protected])
dev: true
resolution: {integrity: sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
- '@babel/helper-create-class-features-plugin': 7.22.11(@babel/[email protected])
+ '@babel/core': 7.22.15
+ '@babel/helper-create-class-features-plugin': 7.22.15(@babel/[email protected])
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==}
engines: {node: '>=6.9.0'}
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-annotate-as-pure': 7.22.5
- '@babel/helper-create-class-features-plugin': 7.22.11(@babel/[email protected])
+ '@babel/helper-create-class-features-plugin': 7.22.15(@babel/[email protected])
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/[email protected])
+ '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/[email protected])
dev: true
resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-gvyP4hZrgrs/wWMaocvxZ44Hw0b3W8Pe+cMxc8V1ULQ07oh8VNbIRaoD1LRZVTvD+0nieDKjfgKg89sD7rrKrg==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
resolution: {integrity: sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
dev: true
- resolution: {integrity: sha512-o2+bg7GDS60cJMgz9jWqRUsWkMzLCxp+jFDeDUT5sjRlAxcJWZ2ylNdI7QQ2+CH5hWu7OnN+Cv3htt7AkSf96g==}
+ resolution: {integrity: sha512-jWL4eh90w0HQOTKP2MoXXUpVxilxsB2Vl4ji69rSjS3EcZ/v4sBmn+A3NpepuJzBhOaEBbR7udonlHHn5DWidg==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
- '@babel/helper-module-transforms': 7.22.9(@babel/[email protected])
+ '@babel/core': 7.22.15
+ '@babel/helper-module-transforms': 7.22.15(@babel/[email protected])
'@babel/helper-plugin-utils': 7.22.5
'@babel/helper-simple-access': 7.22.5
dev: true
- resolution: {integrity: sha512-rog5gZaVbUip5iWDMTYbVM15XQq+RkUKhET/IHR6oizR+JEoN6CAfTTuHcK4vwUyzca30qqHqEpzBOnaRMWYMA==}
+ resolution: {integrity: sha512-oKckg2eZFa8771O/5vi7XeTvmM6+O9cxZu+kanTU7tD4sin5nO/G8jGJhq8Hvt2Z0kUoEDRayuZLaUlYl8QuGA==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-annotate-as-pure': 7.22.5
- '@babel/helper-module-imports': 7.22.5
+ '@babel/helper-module-imports': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-jsx': 7.22.5(@babel/[email protected])
- '@babel/types': 7.22.11
+ '@babel/plugin-syntax-jsx': 7.22.5(@babel/[email protected])
+ '@babel/types': 7.22.15
dev: true
- resolution: {integrity: sha512-0E4/L+7gfvHub7wsbTv03oRtD69X31LByy44fGmFzbZScpupFByMcgCJ0VbBTkzyjSJKuRoGN8tcijOWKTmqOA==}
+ resolution: {integrity: sha512-1uirS0TnijxvQLnlv5wQBwOX3E1wCFX7ITv+9pBV2wKEk4K+M5tqDaoNXnTH8tjEIYHLO98MwiTWO04Ggz4XuA==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-annotate-as-pure': 7.22.5
- '@babel/helper-create-class-features-plugin': 7.22.11(@babel/[email protected])
+ '@babel/helper-create-class-features-plugin': 7.22.15(@babel/[email protected])
'@babel/helper-plugin-utils': 7.22.5
- '@babel/plugin-syntax-typescript': 7.22.5(@babel/[email protected])
+ '@babel/plugin-syntax-typescript': 7.22.5(@babel/[email protected])
dev: true
- resolution: {integrity: sha512-tWY5wyCZYBGY7IlalfKI1rLiGlIfnwsRHZqlky0HVv8qviwQ1Uo/05M6+s+TcTCVa6Bmoo2uJW5TMFX6Wa4qVg==}
+ resolution: {integrity: sha512-HblhNmh6yM+cU4VwbBRpxFhxsTdfS1zsvH9W+gEjD0ARV9+8B4sNfpI6GuhePti84nuvhiwKS539jKPFHskA9A==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@babel/helper-plugin-utils': 7.22.5
- '@babel/helper-validator-option': 7.22.5
- '@babel/plugin-syntax-jsx': 7.22.5(@babel/[email protected])
- '@babel/plugin-transform-modules-commonjs': 7.22.11(@babel/[email protected])
- '@babel/plugin-transform-typescript': 7.22.11(@babel/[email protected])
+ '@babel/helper-validator-option': 7.22.15
+ '@babel/plugin-syntax-jsx': 7.22.5(@babel/[email protected])
+ '@babel/plugin-transform-modules-commonjs': 7.22.15(@babel/[email protected])
+ '@babel/plugin-transform-typescript': 7.22.15(@babel/[email protected])
dev: true
- resolution: {integrity: sha512-NhfzUbdWbiE6fCFypbWCPu6AR8xre31EOPF7wwAIJEvGQ2avov04eymayWinCuyXmV1b0+jzoXP/HYzzUYdvwg==}
+ resolution: {integrity: sha512-SAj8oKi8UogVi6eXQXKNPu8qZ78Yzy7zawrlTr0M+IuW/g8Qe9gVDhGcF9h1S69OyACpYoLxEzpjs1M15sI5wQ==}
engines: {node: '>=6.9.0'}
dependencies:
core-js-pure: 3.32.1
regenerator-runtime: 0.14.0
dev: true
- resolution: {integrity: sha512-ee7jVNlWN09+KftVOu9n7S8gQzD/Z6hN/I8VBRXW4P1+Xe7kJGXMwu8vds4aGIMHZnNbdpSWCfZZtinytpcAvA==}
+ resolution: {integrity: sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==}
engines: {node: '>=6.9.0'}
dependencies:
regenerator-runtime: 0.14.0
dev: true
- resolution: {integrity: sha512-i61lDNe0nRm44nZj05g+1HNb0EVfDGaTI6PkoeUMUSel3GTG6T1OM3BdjZIXghnnFB8bSWbmfS1lkBQgNUdu5w==}
+ resolution: {integrity: sha512-8qE83Gths6g29KOpYF9uaFPOXa3oaFF1/88ejKwgkGAZRIkdmoR/jPIzVviAsWNSaZdIdMLWwKSoXpuk9iNGmw==}
engines: {node: '>=6.9.0'}
dev: true
- resolution: {integrity: sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==}
+ resolution: {integrity: sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/code-frame': 7.22.13
- '@babel/parser': 7.22.14
- '@babel/types': 7.22.11
+ '@babel/parser': 7.22.15
+ '@babel/types': 7.22.15
dev: true
- resolution: {integrity: sha512-mzAenteTfomcB7mfPtyi+4oe5BZ6MXxWcn4CX+h4IRJ+OOGXBrWU6jDQavkQI9Vuc5P+donFabBfFCcmWka9lQ==}
+ resolution: {integrity: sha512-DdHPwvJY0sEeN4xJU5uRLmZjgMMDIvMPniLuYzUVXj/GGzysPl0/fwt44JBkyUIzGJPV8QgHMcQdQ34XFuKTYQ==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/code-frame': 7.22.13
- '@babel/generator': 7.22.10
+ '@babel/generator': 7.22.15
'@babel/helper-environment-visitor': 7.22.5
'@babel/helper-function-name': 7.22.5
'@babel/helper-hoist-variables': 7.22.5
'@babel/helper-split-export-declaration': 7.22.6
- '@babel/parser': 7.22.14
- '@babel/types': 7.22.11
+ '@babel/parser': 7.22.15
+ '@babel/types': 7.22.15
debug: 4.3.4
globals: 11.12.0
transitivePeerDependencies:
- supports-color
dev: true
- resolution: {integrity: sha512-siazHiGuZRz9aB9NpHy9GOs9xiQPKnMzgdr493iI1M67vRXpnEq8ZOOKzezC5q7zwuQ6sDhdSp4SD9ixKSqKZg==}
+ resolution: {integrity: sha512-X+NLXr0N8XXmN5ZsaQdm9U2SSC3UbIYq/doL++sueHOTisgZHoKaQtZxGuV2cUPQHMfjKEfg/g6oy7Hm6SKFtA==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/helper-string-parser': 7.22.5
- '@babel/helper-validator-identifier': 7.22.5
+ '@babel/helper-validator-identifier': 7.22.15
to-fast-properties: 2.0.0
dev: true
@@ -2236,7 +2236,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-FMpKF1fRlJyCZVYHr3CbinpZZ+6MwvOtWUuO8uo+svcATEoc1zRDcj23pAurJ2TZ/uVz1wFHH6K3NlACy0PLew==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/config': 2.3.1
'@changesets/get-version-range-type': 0.3.2
'@changesets/git': 2.0.0
@@ -2254,7 +2254,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-xJkWX+1/CUaOUWTguXEbCDTyWJFECEhmdtbkjhn5GVBGxdP/JwaHBIU9sW3FR6gD07UwZ7ovpiPclQZs+j+mvg==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/errors': 0.1.4
'@changesets/get-dependents-graph': 1.3.6
'@changesets/types': 5.2.1
@@ -2272,7 +2272,7 @@ packages:
resolution: {integrity: sha512-4bA3YoBkd5cm5WUxmrR2N9WYE7EeQcM+R3bVYMUj2NvffkQVpU3ckAI+z8UICoojq+HRl2OEwtz+S5UBmYY4zw==}
hasBin: true
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/apply-release-plan': 6.1.4
'@changesets/assemble-release-plan': 5.2.4
'@changesets/changelog-git': 0.1.14
@@ -2298,7 +2298,7 @@ packages:
meow: 6.1.1
outdent: 0.5.0
p-limit: 2.3.0
- preferred-pm: 3.1.1
+ preferred-pm: 3.1.2
resolve-from: 5.0.0
semver: 5.7.2
spawndamnit: 2.0.0
@@ -2337,7 +2337,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-6IwKTubNEgoOZwDontYc2x2cWXfr6IKxP3IhKeK+WjyD6y3M4Gl/jdQvBw+m/5zWILSOCAaGLu2ZF6Q+WiPniw==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/assemble-release-plan': 5.2.4
'@changesets/config': 2.3.1
'@changesets/pre': 1.0.14
@@ -2353,7 +2353,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-Xo8AT2G7rQJSwV87c8PwMm6BAc98BnufRMsML7m7Iw8Or18WFvFmxqG5aOL5PBvhgq9KrKvaeIBNIymracSuHg==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/errors': 0.1.4
'@changesets/types': 5.2.1
'@manypkg/get-packages': 1.1.3
@@ -2364,7 +2364,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-enUVEWbiqUTxqSnmesyJGWfzd51PY4H7mH9yUw0hPVpZBJ6tQZFMU3F3mT/t9OJ/GjyiM4770i+sehAn6ymx6A==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/errors': 0.1.4
'@changesets/types': 5.2.1
'@manypkg/get-packages': 1.1.3
@@ -2389,7 +2389,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-dTsHmxQWEQekHYHbg+M1mDVYFvegDh9j/kySNuDKdylwfMEevTeDouR7IfHNyVodxZXu17sXoJuf2D0vi55FHQ==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/errors': 0.1.4
'@changesets/types': 5.2.1
'@manypkg/get-packages': 1.1.3
@@ -2399,7 +2399,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-T8BJ6JS6j1gfO1HFq50kU3qawYxa4NTbI/ASNVVCBTsKquy2HYwM9r7ZnzkiMe8IEObAJtUVGSrePCOxAK2haQ==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/git': 2.0.0
'@changesets/logger': 0.0.5
'@changesets/parse': 0.3.16
@@ -2420,7 +2420,7 @@ packages:
/@changesets/[email protected]:
resolution: {integrity: sha512-E90ZrsrfJVOOQaP3Mm5Xd7uDwBAqq3z5paVEavTHKA8wxi7NAL8CmjgbGxSFuiP7ubnJA2BuHlrdE4z86voGOg==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/types': 5.2.1
fs-extra: 7.0.1
human-id: 1.0.2
@@ -2515,14 +2515,14 @@ packages:
'@commitlint/types': 17.4.4
'@types/node': 20.4.7
chalk: 4.1.2
- cosmiconfig: 8.2.0
- cosmiconfig-typescript-loader: 4.4.0(@types/[email protected])([email protected])([email protected])([email protected])
+ cosmiconfig: 8.3.4([email protected])
+ cosmiconfig-typescript-loader: 4.4.0(@types/[email protected])([email protected])([email protected])([email protected])
lodash.isplainobject: 4.0.6
lodash.merge: 4.6.2
lodash.uniq: 4.5.0
resolve-from: 5.0.0
- ts-node: 10.9.1(@types/[email protected])([email protected])
- typescript: 4.9.5
+ ts-node: 10.9.1(@types/[email protected])([email protected])
+ typescript: 4.7.4
transitivePeerDependencies:
- '@swc/core'
- '@swc/wasm'
@@ -3473,7 +3473,7 @@ packages:
resolution: {integrity: sha512-8thgRSiXUqtr/pPGY/OsyHuMjGyhVnWrFAwoxmIemlBuiMyU1WFs0tXoNxzcr4A4uErs/ABre76SGmrr5ab/AA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@jest/types': 29.6.3
'@jridgewell/trace-mapping': 0.3.19
babel-plugin-istanbul: 6.1.1
@@ -3578,8 +3578,8 @@ packages:
/@manypkg/[email protected]:
resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==}
dependencies:
- '@babel/runtime': 7.22.11
- '@types/node': 12.20.55
+ '@babel/runtime': 7.22.15
+ '@types/node': 12.20.24
find-up: 4.1.0
fs-extra: 8.1.0
dev: true
@@ -3587,7 +3587,7 @@ packages:
/@manypkg/[email protected]:
resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==}
dependencies:
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@changesets/types': 4.1.0
'@manypkg/find-root': 1.1.0
fs-extra: 8.1.0
@@ -3705,23 +3705,23 @@ packages:
hasBin: true
dependencies:
'@babel/code-frame': 7.22.13
- '@babel/core': 7.22.11
- '@babel/plugin-proposal-class-properties': 7.18.6(@babel/[email protected])
- '@babel/plugin-proposal-dynamic-import': 7.18.6(@babel/[email protected])
- '@babel/plugin-proposal-export-namespace-from': 7.18.9(@babel/[email protected])
- '@babel/plugin-proposal-logical-assignment-operators': 7.20.7(@babel/[email protected])
- '@babel/plugin-proposal-nullish-coalescing-operator': 7.18.6(@babel/[email protected])
- '@babel/plugin-proposal-numeric-separator': 7.18.6(@babel/[email protected])
- '@babel/plugin-proposal-optional-chaining': 7.21.0(@babel/[email protected])
- '@babel/plugin-proposal-private-methods': 7.18.6(@babel/[email protected])
- '@babel/plugin-proposal-private-property-in-object': 7.21.11(@babel/[email protected])
- '@babel/plugin-syntax-async-generators': 7.8.4(@babel/[email protected])
- '@babel/plugin-syntax-json-strings': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/[email protected])
- '@babel/plugin-transform-modules-commonjs': 7.22.11(@babel/[email protected])
- '@babel/plugin-transform-react-jsx': 7.22.5(@babel/[email protected])
- '@babel/preset-typescript': 7.22.11(@babel/[email protected])
+ '@babel/core': 7.22.15
+ '@babel/plugin-proposal-class-properties': 7.18.6(@babel/[email protected])
+ '@babel/plugin-proposal-dynamic-import': 7.18.6(@babel/[email protected])
+ '@babel/plugin-proposal-export-namespace-from': 7.18.9(@babel/[email protected])
+ '@babel/plugin-proposal-logical-assignment-operators': 7.20.7(@babel/[email protected])
+ '@babel/plugin-proposal-nullish-coalescing-operator': 7.18.6(@babel/[email protected])
+ '@babel/plugin-proposal-numeric-separator': 7.18.6(@babel/[email protected])
+ '@babel/plugin-proposal-optional-chaining': 7.21.0(@babel/[email protected])
+ '@babel/plugin-proposal-private-methods': 7.18.6(@babel/[email protected])
+ '@babel/plugin-proposal-private-property-in-object': 7.21.11(@babel/[email protected])
+ '@babel/plugin-syntax-async-generators': 7.8.4(@babel/[email protected])
+ '@babel/plugin-syntax-json-strings': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/[email protected])
+ '@babel/plugin-transform-modules-commonjs': 7.22.15(@babel/[email protected])
+ '@babel/plugin-transform-react-jsx': 7.22.15(@babel/[email protected])
+ '@babel/preset-typescript': 7.22.15(@babel/[email protected])
babel-plugin-module-resolver: 4.1.0
colors: 1.4.0
commander: 8.3.0
@@ -3784,7 +3784,7 @@ packages:
preact: ^10.4.0
vite: '>=2.0.0'
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@prefresh/babel-plugin': 0.5.0
'@prefresh/core': 1.5.1([email protected])
'@prefresh/utils': 1.2.0
@@ -3965,7 +3965,7 @@ packages:
engines: {node: '>=10'}
dependencies:
'@babel/code-frame': 7.22.13
- '@babel/runtime': 7.22.11
+ '@babel/runtime': 7.22.15
'@types/aria-query': 4.2.2
aria-query: 4.2.2
chalk: 4.1.2
@@ -4016,8 +4016,8 @@ packages:
resolution: {integrity: sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==}
dependencies:
- '@babel/parser': 7.22.14
- '@babel/types': 7.22.11
+ '@babel/parser': 7.22.15
+ '@babel/types': 7.22.15
'@types/babel__generator': 7.6.4
'@types/babel__template': 7.4.1
'@types/babel__traverse': 7.20.1
@@ -4026,20 +4026,20 @@ packages:
resolution: {integrity: sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
resolution: {integrity: sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==}
dependencies:
- '@babel/parser': 7.22.14
- '@babel/types': 7.22.11
+ '@babel/parser': 7.22.15
+ '@babel/types': 7.22.15
dev: true
resolution: {integrity: sha512-MitHFXnhtgwsGZWtT68URpOvLN4EREih1u3QtQiN4VdAxWKRVvGCSvw/Qth0M0Qq3pJpnGOu5JaM/ydK7OGbqg==}
dependencies:
- '@babel/types': 7.22.11
+ '@babel/types': 7.22.15
dev: true
@@ -4125,10 +4125,6 @@ packages:
resolution: {integrity: sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ==}
dev: true
- resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==}
- dev: true
-
resolution: {integrity: sha512-FKyawK3o5KL16AwbeFajen8G4K3mmqUrQsehn5wNKs8IzlKHE8TfnSmILXVMVziAEcnB23u1RCFU1NT6hSyr7Q==}
dev: true
@@ -4350,7 +4346,7 @@ packages:
peerDependencies:
vite: ^2.0.0
dependencies:
- '@babel/standalone': 7.22.14
+ '@babel/standalone': 7.22.15
core-js: 3.32.1
magic-string: 0.25.9
regenerator-runtime: 0.13.11
@@ -4517,8 +4513,8 @@ packages:
resolution: {integrity: sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==}
engines: {node: '>=6.0'}
dependencies:
- '@babel/runtime': 7.22.11
- '@babel/runtime-corejs3': 7.22.11
+ '@babel/runtime': 7.22.15
+ '@babel/runtime-corejs3': 7.22.15
dev: true
@@ -4532,8 +4528,8 @@ packages:
resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==}
dev: true
- resolution: {integrity: sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==}
+ resolution: {integrity: sha512-dlcsNBIiWhPkHdOEEKnehA+RNUWDc4UqFtnIXU4uuYDPtA4LDkr7qip2p0VvFAEXNDr0yWZ9PJyIRiGjRLQzwQ==}
engines: {node: '>= 0.4'}
dependencies:
call-bind: 1.0.2
@@ -4548,8 +4544,8 @@ packages:
engines: {node: '>=8'}
dev: true
- resolution: {integrity: sha512-us+UrmGOilqttSOgoWZTpOvHu68vZT2YCjc/H4vhu56vzZpaDFBhB+Se2UwqWzMKbDv7Myq5M5pcZLAtUvTQdQ==}
+ resolution: {integrity: sha512-VizNcj/RGJiUyQBgzwxzE5oHdeuXY5hSbbmKMlphj1cy1Vl7Pn2asCGbSrru6hSQjmCzqTBPVWAF/whmEOVHbw==}
engines: {node: '>= 0.4'}
dependencies:
call-bind: 1.0.2
@@ -4590,13 +4586,14 @@ packages:
es-shim-unscopables: 1.0.0
dev: true
- resolution: {integrity: sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw==}
+ resolution: {integrity: sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==}
engines: {node: '>= 0.4'}
dependencies:
array-buffer-byte-length: 1.0.0
call-bind: 1.0.2
define-properties: 1.2.0
+ es-abstract: 1.22.1
get-intrinsic: 1.2.1
is-array-buffer: 3.0.2
is-shared-array-buffer: 1.0.2
@@ -4634,17 +4631,17 @@ packages:
- debug
dev: true
resolution: {integrity: sha512-meLj23UlSLddj6PC+YTOFRgDAtjnZom8w/ACsrx0gtPtv5cJZk0A5Unk5bV4wixD7XaPCN1fQvpww8czkZURmw==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
peerDependencies:
'@babel/core': ^7.8.0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@jest/transform': 29.6.4
'@types/babel__core': 7.20.1
babel-plugin-istanbul: 6.1.1
- babel-preset-jest: 29.6.3(@babel/[email protected])
+ babel-preset-jest: 29.6.3(@babel/[email protected])
chalk: 4.1.2
graceful-fs: 4.2.11
slash: 3.0.0
@@ -4669,8 +4666,8 @@ packages:
resolution: {integrity: sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
- '@babel/template': 7.22.5
- '@babel/types': 7.22.11
+ '@babel/template': 7.22.15
+ '@babel/types': 7.22.15
'@types/babel__core': 7.20.1
'@types/babel__traverse': 7.20.1
dev: true
@@ -4686,35 +4683,35 @@ packages:
resolve: 1.22.4
dev: true
resolution: {integrity: sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==}
peerDependencies:
'@babel/core': ^7.0.0
dependencies:
- '@babel/core': 7.22.11
- '@babel/plugin-syntax-async-generators': 7.8.4(@babel/[email protected])
- '@babel/plugin-syntax-bigint': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-class-properties': 7.12.13(@babel/[email protected])
- '@babel/plugin-syntax-import-meta': 7.10.4(@babel/[email protected])
- '@babel/plugin-syntax-json-strings': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/[email protected])
- '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/[email protected])
- '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/[email protected])
- '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/[email protected])
- dev: true
-
+ '@babel/core': 7.22.15
+ '@babel/plugin-syntax-async-generators': 7.8.4(@babel/[email protected])
+ '@babel/plugin-syntax-bigint': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-class-properties': 7.12.13(@babel/[email protected])
+ '@babel/plugin-syntax-import-meta': 7.10.4(@babel/[email protected])
+ '@babel/plugin-syntax-json-strings': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/[email protected])
+ '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/[email protected])
+ '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/[email protected])
+ '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/[email protected])
+ dev: true
+
resolution: {integrity: sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
peerDependencies:
'@babel/core': ^7.0.0
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
babel-plugin-jest-hoist: 29.6.3
- babel-preset-current-node-syntax: 1.0.1(@babel/[email protected])
+ babel-preset-current-node-syntax: 1.0.1(@babel/[email protected])
dev: true
@@ -4793,7 +4790,7 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
dependencies:
- caniuse-lite: 1.0.30001525
+ caniuse-lite: 1.0.30001527
electron-to-chromium: 1.4.508
node-releases: 2.0.13
update-browserslist-db: 1.0.11([email protected])
@@ -4871,8 +4868,8 @@ packages:
engines: {node: '>=10'}
dev: true
- resolution: {integrity: sha512-/3z+wB4icFt3r0USMwxujAqRvaD/B7rvGTsKhbhSQErVrJvkZCLhgNLJxU8MevahQVH6hCU9FsHdNUFbiwmE7Q==}
+ resolution: {integrity: sha512-YkJi7RwPgWtXVSgK4lG9AHH57nSzvvOp9MesgXmw4Q7n0C3H04L0foHqfxcmSAm5AcWb8dW9AYj2tR7/5GnddQ==}
dev: true
@@ -5192,7 +5189,7 @@ packages:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
dev: false
resolution: {integrity: sha512-BabizFdC3wBHhbI4kJh0VkQP9GkBfoHPydD0COMce1nJ1kJAB3F2TmJ/I7diULBKtmEWSwEbuN/KDtgnmUUVmw==}
engines: {node: '>=v14.21.3'}
peerDependencies:
@@ -5202,19 +5199,25 @@ packages:
typescript: '>=4'
dependencies:
'@types/node': 20.4.7
- cosmiconfig: 8.2.0
- ts-node: 10.9.1(@types/[email protected])([email protected])
- typescript: 4.9.5
+ cosmiconfig: 8.3.4([email protected])
+ ts-node: 10.9.1(@types/[email protected])([email protected])
+ typescript: 4.7.4
dev: true
- resolution: {integrity: sha512-3rTMnFJA1tCOPwRxtgF4wd7Ab2qvDbL8jX+3smjIbS4HlZBagTlpERbdN7iAbWlrfxE3M8c27kTwTawQ7st+OQ==}
+ resolution: {integrity: sha512-SF+2P8+o/PTV05rgsAjDzL4OFdVXAulSfC/L19VaeVT7+tpOOSscCt2QLxDZ+CLxF2WOiq6y1K5asvs8qUJT/Q==}
engines: {node: '>=14'}
+ peerDependencies:
+ typescript: '>=4.9.5'
+ peerDependenciesMeta:
+ typescript:
+ optional: true
dependencies:
import-fresh: 3.3.0
js-yaml: 4.1.0
parse-json: 5.2.0
path-type: 4.0.0
+ typescript: 4.7.2
dev: true
@@ -5716,7 +5719,7 @@ packages:
engines: {node: '>= 0.4'}
dependencies:
array-buffer-byte-length: 1.0.0
- arraybuffer.prototype.slice: 1.0.1
+ arraybuffer.prototype.slice: 1.0.2
available-typed-arrays: 1.0.5
call-bind: 1.0.2
es-set-tostringtag: 2.0.1
@@ -5743,11 +5746,11 @@ packages:
object-keys: 1.1.1
object.assign: 4.1.4
regexp.prototype.flags: 1.5.0
- safe-array-concat: 1.0.0
+ safe-array-concat: 1.0.1
safe-regex-test: 1.0.0
string.prototype.trim: 1.2.7
string.prototype.trimend: 1.0.6
- string.prototype.trimstart: 1.0.6
+ string.prototype.trimstart: 1.0.7
typed-array-buffer: 1.0.0
typed-array-byte-length: 1.0.0
typed-array-byte-offset: 1.0.0
@@ -5810,17 +5813,6 @@ packages:
globby: 11.1.0
dev: true
- resolution: {integrity: sha512-t5ZtQyGKNiM8DLedz+iwFH0LPWLnMmaEQ2RnnP1ppFHq35najxqJHAhUVVSbTFm5cR2ZumGdBMqnmuKBRBMvDw==}
- dependencies:
- '@types/less': 3.0.4
- '@types/sass': 1.45.0
- '@types/stylus': 0.48.39
- glob: 8.1.0
- postcss: 8.4.29
- postcss-modules: 4.3.1([email protected])
- dev: true
-
resolution: {integrity: sha512-aSzuIUwQTEVVy9gcE4xtXq8Cbq9RNDfJYZ3mYzWg6RJ8HoMydLT+LbGXYwL0DmgOt4eEg/4JrnNMMb02gXFutA==}
dependencies:
@@ -6085,7 +6077,7 @@ packages:
optional: true
dependencies:
'@typescript-eslint/parser': 5.54.0([email protected])([email protected])
- array-includes: 3.1.6
+ array-includes: 3.1.7
array.prototype.findlastindex: 1.2.3
array.prototype.flat: 1.3.1
array.prototype.flatmap: 1.3.1
@@ -6761,7 +6753,7 @@ packages:
hasBin: true
dependencies:
foreground-child: 3.1.1
- jackspeak: 2.3.1
+ jackspeak: 2.3.3
minimatch: 9.0.3
minipass: 7.0.3
path-scurry: 1.10.1
@@ -6778,17 +6770,6 @@ packages:
path-is-absolute: 1.0.1
dev: true
- resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==}
- engines: {node: '>=12'}
- dependencies:
- fs.realpath: 1.0.0
- inflight: 1.0.6
- inherits: 2.0.4
- minimatch: 5.1.6
- once: 1.4.0
- dev: true
-
resolution: {integrity: sha512-NknMLn7F2J7aflwFOlGdNIuCDpN3VGoSoB+aap3KABFWbHVn1TCgFC+np23J8W2BiZbjfEw3BFBycSMv1AFblg==}
engines: {node: '>=4'}
@@ -6975,7 +6956,7 @@ packages:
resolution: {integrity: sha512-6XMlxrAFX4UEEGxctfFnmrFaaZFNf9i5fNuV5wZ3WWQ4FVaNP1aX1LkX9j2mfEx1NpjeE/rL3nmgEn23GdFmrg==}
dependencies:
- array.prototype.filter: 1.0.2
+ array.prototype.filter: 1.0.3
call-bind: 1.0.2
dev: true
@@ -7072,10 +7053,6 @@ packages:
safer-buffer: 2.1.2
dev: true
- resolution: {integrity: sha512-chIaY3Vh2mh2Q3RGXttaDIzeiPvaVXJ+C4DAh/w3c37SKZ/U6PGMmuicR2EQQp9bKG8zLMCl7I+PtIoOOPp8Gg==}
- dev: true
-
resolution: {integrity: sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==}
engines: {node: ^10 || ^12 || >= 14}
@@ -7485,8 +7462,8 @@ packages:
resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==}
engines: {node: '>=8'}
dependencies:
- '@babel/core': 7.22.11
- '@babel/parser': 7.22.14
+ '@babel/core': 7.22.15
+ '@babel/parser': 7.22.15
'@istanbuljs/schema': 0.1.3
istanbul-lib-coverage: 3.2.0
semver: 6.3.1
@@ -7498,8 +7475,8 @@ packages:
resolution: {integrity: sha512-x58orMzEVfzPUKqlbLd1hXCnySCxKdDKa6Rjg97CwuLLRI4g3FHTdnExu1OqffVFay6zeMW+T6/DowFLndWnIw==}
engines: {node: '>=10'}
dependencies:
- '@babel/core': 7.22.11
- '@babel/parser': 7.22.14
+ '@babel/core': 7.22.15
+ '@babel/parser': 7.22.15
'@istanbuljs/schema': 0.1.3
istanbul-lib-coverage: 3.2.0
semver: 7.5.4
@@ -7535,8 +7512,8 @@ packages:
istanbul-lib-report: 3.0.1
dev: true
- resolution: {integrity: sha512-4iSY3Bh1Htv+kLhiiZunUhQ+OYXIn0ze3ulq8JeWrFKmhPAJSySV2+kdtRh2pGcCeF0s6oR8Oc+pYZynJj4t8A==}
+ resolution: {integrity: sha512-R2bUw+kVZFS/h1AZqBKrSgDmdmjApzgY0AlCPumopFiAlbUxE2gf+SCuBzQ0cP5hHmUmFYF5yw55T97Th5Kstg==}
engines: {node: '>=14'}
dependencies:
'@isaacs/cliui': 8.0.2
@@ -7574,7 +7551,7 @@ packages:
jest-util: 29.6.3
p-limit: 3.1.0
pretty-format: 29.6.3
- pure-rand: 6.0.2
+ pure-rand: 6.0.3
slash: 3.0.0
stack-utils: 2.0.6
transitivePeerDependencies:
@@ -7623,11 +7600,11 @@ packages:
ts-node:
optional: true
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
'@jest/test-sequencer': 29.6.4
'@jest/types': 29.6.3
'@types/node': 18.14.0
- babel-jest: 29.6.4(@babel/[email protected])
+ babel-jest: 29.6.4(@babel/[email protected])
chalk: 4.1.2
ci-info: 3.8.0
deepmerge: 4.3.1
@@ -7992,15 +7969,15 @@ packages:
resolution: {integrity: sha512-VC1N8ED7+4uboUKGIDsbvNAZb6LakgIPgAF4RSpF13dN6YaMokfRqO+BaqK4zIh6X3JffgwbzuGqDEjHm/MrvA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
- '@babel/core': 7.22.11
- '@babel/generator': 7.22.10
- '@babel/plugin-syntax-jsx': 7.22.5(@babel/[email protected])
- '@babel/plugin-syntax-typescript': 7.22.5(@babel/[email protected])
- '@babel/types': 7.22.11
+ '@babel/core': 7.22.15
+ '@babel/generator': 7.22.15
+ '@babel/plugin-syntax-jsx': 7.22.5(@babel/[email protected])
+ '@babel/plugin-syntax-typescript': 7.22.5(@babel/[email protected])
+ '@babel/types': 7.22.15
'@jest/expect-utils': 29.6.4
'@jest/transform': 29.6.4
'@jest/types': 29.6.3
- babel-preset-current-node-syntax: 1.0.1(@babel/[email protected])
+ babel-preset-current-node-syntax: 1.0.1(@babel/[email protected])
chalk: 4.1.2
expect: 29.6.4
graceful-fs: 4.2.11
@@ -8804,13 +8781,6 @@ packages:
brace-expansion: 1.1.11
dev: true
- resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==}
- engines: {node: '>=10'}
- dependencies:
- brace-expansion: 2.0.1
- dev: true
-
resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==}
engines: {node: '>=16 || 14 >=14.17'}
@@ -9219,7 +9189,7 @@ packages:
dev: true
- resolution: {integrity: sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==}
+ resolution: {integrity: sha1-juqz5U+laSD+Fro493+iGqzC104=}
dev: true
@@ -9435,22 +9405,6 @@ packages:
postcss: 8.4.29
dev: true
- resolution: {integrity: sha512-ItUhSUxBBdNamkT3KzIZwYNNRFKmkJrofvC2nWab3CPKhYBQ1f27XXh1PAPE27Psx58jeelPsxWB/+og+KEH0Q==}
- peerDependencies:
- postcss: ^8.0.0
- dependencies:
- generic-names: 4.0.0
- icss-replace-symbols: 1.1.0
- lodash.camelcase: 4.3.0
- postcss: 8.4.29
- postcss-modules-extract-imports: 3.0.0([email protected])
- postcss-modules-local-by-default: 4.0.3([email protected])
- postcss-modules-scope: 3.0.0([email protected])
- postcss-modules-values: 4.0.0([email protected])
- string-hash: 1.1.3
- dev: true
-
resolution: {integrity: sha512-7DGfnlyi/ju82BRzTIjWS5C4Tafmzl3R79YP/PASiocj+aa6yYphHhhKUOEoXQToId5rgyFgJ88+ccOUydjBXQ==}
peerDependencies:
@@ -9491,8 +9445,8 @@ packages:
resolution: {integrity: sha512-X9BODrvQ4Ekwv9GURm9AKAGaomqXmip7NQTZgY7gcNmr7XE83adOMJvd3N42id1tMFU7ojiynRsYnY6/BRFxLA==}
- resolution: {integrity: sha512-CsZgOVLKHifdoRu2y66P1s6oLb2WfT5Njkcgi80I/52FWTTVkWG6z0Z13vPkXC4hsT0nMrYXqX30buH8+D2eRQ==}
+ resolution: {integrity: sha512-nk7dKrcW8hfCZ4H6klWcdRknBOXWzNQByJ0oJyX97BOupsYD+FzLS4hflgEu/uPUEHZCuRfMxzCBsuWd7OzT8Q==}
engines: {node: '>=10'}
dependencies:
find-up: 5.0.0
@@ -9605,7 +9559,6 @@ packages:
resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==}
- requiresBuild: true
dev: true
optional: true
@@ -9645,8 +9598,8 @@ packages:
escape-goat: 2.1.1
dev: true
- resolution: {integrity: sha512-6Yg0ekpKICSjPswYOuC5sku/TSWaRYlA0qsXqJgM/d/4pLPHPuTxK7Nbf7jFKzAeedUhR8C7K9Uv63FBsSo8xQ==}
+ resolution: {integrity: sha512-KddyFewCsO0j3+np81IQ+SweXLDnDQTs5s67BOnrYmYe/yNmUhttQyGsYzy8yUnoljGAQ9sl38YB4vH8ur7Y+w==}
dev: true
@@ -9994,8 +9947,8 @@ packages:
dependencies:
tslib: 2.6.2
- resolution: {integrity: sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ==}
+ resolution: {integrity: sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==}
engines: {node: '>=0.4'}
dependencies:
call-bind: 1.0.2
@@ -10036,7 +9989,6 @@ packages:
resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==}
- requiresBuild: true
dev: true
optional: true
@@ -10365,8 +10317,8 @@ packages:
es-abstract: 1.22.1
dev: true
- resolution: {integrity: sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==}
+ resolution: {integrity: sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==}
dependencies:
call-bind: 1.0.2
define-properties: 1.2.0
@@ -10591,7 +10543,7 @@ packages:
engines: {node: '>=8'}
dev: true
resolution: {integrity: sha512-htQOHshgvhn93QLxrmxpiQPk69+M1g7govO1g6kf6GsjCv4uvRV0znVmDrrvjUrVCnTYeY4FBxTYYYD4airyJA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
hasBin: true
@@ -10612,7 +10564,7 @@ packages:
esbuild:
optional: true
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
bs-logger: 0.2.6
esbuild: 0.16.4
fast-json-stable-stringify: 2.1.0
@@ -10626,7 +10578,7 @@ packages:
yargs-parser: 21.1.1
dev: true
resolution: {integrity: sha512-htQOHshgvhn93QLxrmxpiQPk69+M1g7govO1g6kf6GsjCv4uvRV0znVmDrrvjUrVCnTYeY4FBxTYYYD4airyJA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
hasBin: true
@@ -10647,7 +10599,7 @@ packages:
esbuild:
optional: true
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
bs-logger: 0.2.6
esbuild: 0.17.10
fast-json-stable-stringify: 2.1.0
@@ -10661,7 +10613,7 @@ packages:
yargs-parser: 21.1.1
dev: true
resolution: {integrity: sha512-htQOHshgvhn93QLxrmxpiQPk69+M1g7govO1g6kf6GsjCv4uvRV0znVmDrrvjUrVCnTYeY4FBxTYYYD4airyJA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
hasBin: true
@@ -10682,7 +10634,7 @@ packages:
esbuild:
optional: true
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
bs-logger: 0.2.6
esbuild: 0.19.2
fast-json-stable-stringify: 2.1.0
@@ -10696,7 +10648,7 @@ packages:
yargs-parser: 21.1.1
dev: true
resolution: {integrity: sha512-htQOHshgvhn93QLxrmxpiQPk69+M1g7govO1g6kf6GsjCv4uvRV0znVmDrrvjUrVCnTYeY4FBxTYYYD4airyJA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
hasBin: true
@@ -10717,7 +10669,7 @@ packages:
esbuild:
optional: true
dependencies:
- '@babel/core': 7.22.11
+ '@babel/core': 7.22.15
bs-logger: 0.2.6
esbuild: 0.19.2
fast-json-stable-stringify: 2.1.0
@@ -10824,7 +10776,7 @@ packages:
yn: 3.1.1
dev: true
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
hasBin: true
peerDependencies:
@@ -10850,7 +10802,7 @@ packages:
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
- typescript: 4.9.5
+ typescript: 4.7.4
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
dev: true
@@ -11058,12 +11010,6 @@ packages:
hasBin: true
dev: true
- resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
- engines: {node: '>=4.2.0'}
- hasBin: true
- dev: true
-
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
dependencies: