@univerjs/sheets 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/es/index.js +3647 -3381
  3. package/lib/types/basics/const/command-listener-const.d.ts +3 -0
  4. package/lib/types/basics/numfmt-kit.d.ts +41 -0
  5. package/lib/types/basics/selection.d.ts +1 -1
  6. package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +1 -1
  7. package/lib/types/commands/commands/insert-row-col.command.d.ts +2 -2
  8. package/lib/types/commands/commands/remove-row-col.command.d.ts +1 -1
  9. package/lib/types/commands/commands/utils/selection-utils.d.ts +10 -1
  10. package/lib/types/commands/commands/utils/target-util.d.ts +33 -0
  11. package/lib/types/commands/mutations/__tests__/create-command-test-bed.d.ts +1 -1
  12. package/lib/types/commands/mutations/numfmt-mutation.d.ts +0 -3
  13. package/lib/types/commands/utils/handle-merge-operation.d.ts +1 -1
  14. package/lib/types/controllers/__tests__/util.d.ts +1 -1
  15. package/lib/types/controllers/calculate-result-apply.controller.d.ts +11 -2
  16. package/lib/types/controllers/feature-calculation.controller.d.ts +2 -2
  17. package/lib/types/index.d.ts +7 -4
  18. package/lib/types/locale/zh-CN.d.ts +10 -2
  19. package/lib/types/services/__tests__/util.d.ts +1 -1
  20. package/lib/types/services/numfmt/numfmt.service.d.ts +5 -25
  21. package/lib/types/services/numfmt/type.d.ts +1 -17
  22. package/lib/types/services/permission/sheet-permission.service.d.ts +7 -8
  23. package/lib/types/services/permission/tool.d.ts +1 -2
  24. package/lib/types/services/ref-range/__tests__/{util.d.ts → __testing__.d.ts} +1 -1
  25. package/lib/types/services/ref-range/__tests__/ref-range.service.spec.d.ts +14 -0
  26. package/lib/types/services/ref-range/__tests__/watch-range.spec.d.ts +16 -0
  27. package/lib/types/services/ref-range/ref-range.service.d.ts +6 -2
  28. package/lib/types/services/ref-range/util.d.ts +23 -4
  29. package/lib/types/services/sheet-interceptor/__tests__/create-core-test-bed.d.ts +1 -1
  30. package/lib/types/services/sheet-interceptor/interceptor-const.d.ts +3 -3
  31. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +3 -3
  32. package/lib/types/services/sheet-interceptor/utils/interceptor.d.ts +7 -0
  33. package/lib/types/sheets-plugin.d.ts +3 -2
  34. package/lib/umd/index.js +2 -2
  35. package/package.json +15 -13
  36. package/lib/types/commands/commands/copy-to-worksheet.command.d.ts +0 -9
  37. package/lib/types/commands/mutations/set-worksheet-config.mutation.d.ts +0 -13
  38. package/lib/types/commands/utils/get-target.d.ts +0 -18
  39. /package/lib/types/{services/__tests__/sheet-permission.spec.d.ts → basics/__tests__/numfmt-kit.spec.d.ts} +0 -0
  40. /package/lib/types/services/ref-range/__tests__/{util.spec.d.ts → utils.spec.d.ts} +0 -0
@@ -13,5 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ /**
17
+ * Mutations those will trigger the skeleton change.
18
+ */
16
19
  export declare const COMMAND_LISTENER_SKELETON_CHANGE: string[];
17
20
  export declare const COMMAND_LISTENER_VALUE_CHANGE: string[];
@@ -0,0 +1,41 @@
1
+ import { ICellData, Nullable, Styles } from '@univerjs/core';
2
+
3
+ /**
4
+ * Handling number formats in styles
5
+ *
6
+ * @param oldCell
7
+ * @param cell
8
+ */
9
+ export declare function handleNumfmtInCell(oldCell: Nullable<ICellData>, cell: Nullable<ICellData>, styles: Styles | undefined): Nullable<ICellData>;
10
+ /**
11
+ * Process the priority of the newly set number format and the original format.
12
+ *
13
+ * Here is the priority of the number format in Excel:
14
+ * ┌─────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
15
+ * │ │ new format │
16
+ * ├─────────────────┼────────────┬────────────┬────────────┬────────────┬──────────┬──────────┬────────────┬──────────┬────────────┬──────────┬────────────┬───────────┤
17
+ * │ Original format │ General │ Number │ Currency │ Accounting │ Date │ Time │ Percentage │ Fraction │ Scientific │ Text │ Special │ Custom │
18
+ * ├─────────────────┼────────────┼────────────┼────────────┼────────────┼──────────┼──────────┼────────────┼──────────┼────────────┼──────────┼────────────┼───────────┤
19
+ * │ General │ General │ Number │ Currency │ Accounting │ Date │ Time │ Percentage │ Fraction │ Scientific │ Text │ Special │ Custom │
20
+ * │ Number │ Number │ Number │ Number │ Number │ Number │ Number │ Number │ Number │ Number │ Number │ Number │ Number │
21
+ * │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │ Currency │
22
+ * │ Accounting │ Accounting │ Accounting │ Accounting │ Accounting │ Date │ Time │ Percentage │ Fraction │ Scientific │ Text │ Accounting │ Custom │
23
+ * │ Date │ Date │ Date │ Currency │ Accounting │ Date │ Time │ Percentage │ Fraction │ Scientific │ Text │ Date │ Custom │
24
+ * │ Time │ Time │ Time │ Time │ Time │ Time │ Time │ Time │ Time │ Time │ Time │ Time │ Time │
25
+ * │ Percentage │ Percentage │ Percentage │ Currency │ Accounting │ Date │ Time │ Percentage │ Fraction │ Scientific │ Text │ Percentage │ Custom │
26
+ * │ Fraction │ Fraction │ Fraction │ Currency │ Accounting │ Date │ Time │ Percentage │ Fraction │ Scientific │ Text │ Fraction │ Custom │
27
+ * │ Scientific │ Scientific │ Scientific │ Currency │ Accounting │ Date │ Time │ Percentage │ Fraction │ Scientific │ Text │ Scientific │ Custom │
28
+ * │ Text │ Text │ Text │ Text │ Text │ Text │ Text │ Text │ Text │ Text │ Text │ Text │ Text │
29
+ * │ Special │ Special │ Special │ Special │ Special │ Special │ Special │ Special │ Special │ Special │ Special │ Special │ Special │
30
+ * │ Custom │ Custom │ Custom │ Currency │ Accounting │ Date │ Custom │ Percentage │ Fraction │ Scientific │ Text │ Custom │ Custom │
31
+ * └─────────────────┴────────────┴────────────┴────────────┴────────────┴──────────┴──────────┴────────────┴──────────┴────────────┴──────────┴────────────┴───────────┘
32
+ *
33
+ * The number formats supported by Univer are different from Excel, so it only processes the parts that are the same as Excel. For different parts, we consider the newly set number format to have a higher priority.
34
+ *
35
+ * In the future, if Univer completely matches Excel, we will implement Excel’s priority rules.
36
+ *
37
+ * @param oldPattern
38
+ * @param pattern
39
+ * @returns
40
+ */
41
+ export declare function compareNumfmtPriority(oldPattern: string, pattern: string): string;
@@ -1,7 +1,7 @@
1
1
  import { IRange, ISelection, ISelectionCellWithCoord, ISelectionWithCoord, Nullable, ThemeService } from '@univerjs/core';
2
2
 
3
3
  export declare const SELECTION_CONTROL_BORDER_BUFFER_WIDTH = 1.5;
4
- export declare const SELECTION_CONTROL_BORDER_BUFFER_COLOR = "rgba(255,255,255, 0.01)";
4
+ export declare const SELECTION_CONTROL_BORDER_BUFFER_COLOR = "rgba(255, 255, 255, 0.01)";
5
5
  /**
6
6
  * Whether to display the controller that modifies the selection, distributed in 8 locations
7
7
  * tl top_left_corner
@@ -6,4 +6,4 @@ export interface ITestBed {
6
6
  get: Injector['get'];
7
7
  sheet: Workbook;
8
8
  }
9
- export declare function createCommandTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): ITestBed;
9
+ export declare function createCommandTestBed(workbookData?: IWorkbookData, dependencies?: Dependency[]): ITestBed;
@@ -17,9 +17,9 @@ export interface IInsertRowCommandParams {
17
17
  }
18
18
  export declare const InsertRowCommandId = "sheet.command.insert-row";
19
19
  /**
20
- * @internal
21
- *
22
20
  * this command and its interface should not be exported from index.ts
21
+ *
22
+ * @internal
23
23
  */
24
24
  export declare const InsertRowCommand: ICommand;
25
25
  export declare const InsertRowBeforeCommand: ICommand;
@@ -7,7 +7,7 @@ export declare const RemoveRowCommandId = "sheet.command.remove-row";
7
7
  /**
8
8
  * This command would remove the selected rows. These selected rows can be non-continuous.
9
9
  */
10
- export declare const RemoveRowCommand: ICommand;
10
+ export declare const RemoveRowCommand: ICommand<IRemoveRowColCommandParams>;
11
11
  export declare const RemoveColCommandId = "sheet.command.remove-col";
12
12
  /**
13
13
  * This command would remove the selected columns. These selected rows can be non-continuous.
@@ -1,5 +1,6 @@
1
+ import { ISelectionWithStyle } from '../../../basics/selection';
1
2
  import { ISetSelectionsOperationParams } from '../../operations/selection.operation';
2
- import { IRange, ISelectionCell, Workbook, Worksheet } from '@univerjs/core';
3
+ import { IRange, ISelectionCell, Nullable, Workbook, Worksheet } from '@univerjs/core';
3
4
 
4
5
  export interface IExpandParams {
5
6
  left?: boolean;
@@ -32,3 +33,11 @@ export declare const followSelectionOperation: (range: IRange, workbook: Workboo
32
33
  id: string;
33
34
  params: ISetSelectionsOperationParams;
34
35
  };
36
+ /**
37
+ * Examine if a selection only contains a single cell (a merged cell is considered as a single cell in this case).
38
+ * @param selection
39
+ * @returns `true` if the selection only contains a single cell.
40
+ */
41
+ export declare function isSingleCellSelection(selection: Nullable<ISelectionWithStyle & {
42
+ primary: ISelectionCell;
43
+ }>): boolean;
@@ -0,0 +1,33 @@
1
+ import { IUniverInstanceService, Nullable, Workbook, Worksheet } from '@univerjs/core';
2
+
3
+ export declare function getSheetCommandTargetWorkbook(univerInstanceService: IUniverInstanceService, params: {
4
+ unitId?: string;
5
+ }): Nullable<{
6
+ workbook: Workbook;
7
+ unitId: string;
8
+ }>;
9
+ interface IResult {
10
+ workbook: Workbook;
11
+ worksheet: Worksheet;
12
+ unitId: string;
13
+ subUnitId: string;
14
+ }
15
+ /**
16
+ * Get targeted Workbook & Worksheet of a command. If `unitId` and `subUnitId` are given, the function would
17
+ * try to get these instances. If not, it would try to get the current active instances.
18
+ *
19
+ * @param univerInstanceService
20
+ * @param params - unitId and subUnitId
21
+ * @param params.unitId - The unitId of the Workbook
22
+ * @param params.subUnitId - The subUnitId of the Worksheet
23
+ * @returns Targeted Workbook & Worksheet
24
+ */
25
+ export declare function getSheetCommandTarget(univerInstanceService: IUniverInstanceService, params?: {
26
+ unitId?: string;
27
+ subUnitId?: string;
28
+ }): Nullable<IResult>;
29
+ export declare function getSheetMutationTarget(univerInstanceService: IUniverInstanceService, params: {
30
+ unitId: string;
31
+ subUnitId: string;
32
+ }): Nullable<Pick<IResult, 'workbook' | 'worksheet'>>;
33
+ export {};
@@ -6,4 +6,4 @@ export interface ITestBed {
6
6
  get: Injector['get'];
7
7
  sheet: Workbook;
8
8
  }
9
- export declare function createCommandTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): ITestBed;
9
+ export declare function createCommandTestBed(workbookData?: IWorkbookData, dependencies?: Dependency[]): ITestBed;
@@ -1,4 +1,3 @@
1
- import { FormatType } from '../../services/numfmt/type';
2
1
  import { IAccessor } from '@wendellhu/redi';
3
2
  import { ICommand, IMutationInfo, IRange } from '@univerjs/core';
4
3
 
@@ -12,7 +11,6 @@ export interface ISetNumfmtMutationParams {
12
11
  refMap: {
13
12
  [id: string]: {
14
13
  pattern: string;
15
- type: FormatType;
16
14
  };
17
15
  };
18
16
  unitId: string;
@@ -31,7 +29,6 @@ export declare const factoryRemoveNumfmtUndoMutation: (accessor: IAccessor, opti
31
29
  }[];
32
30
  export type ISetCellsNumfmt = Array<{
33
31
  pattern: string;
34
- type: FormatType;
35
32
  row: number;
36
33
  col: number;
37
34
  }>;
@@ -1,4 +1,4 @@
1
- import { ISetSelectionsOperationParams } from '../..';
1
+ import { ISetSelectionsOperationParams } from '../operations/selection.operation';
2
2
  import { IAddMergeCommandParams } from '../commands/add-worksheet-merge.command';
3
3
  import { IRange } from '@univerjs/core';
4
4
  import { IAccessor } from '@wendellhu/redi';
@@ -1,7 +1,7 @@
1
1
  import { Dependency } from '@wendellhu/redi';
2
2
  import { IWorkbookData, Univer } from '@univerjs/core';
3
3
 
4
- export declare function createTestBase(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
4
+ export declare function createTestBase(workbookData?: IWorkbookData, dependencies?: Dependency[]): {
5
5
  univer: Univer;
6
6
  get: {
7
7
  <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
@@ -1,8 +1,17 @@
1
- import { Disposable, ICommandService } from '@univerjs/core';
1
+ import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
2
2
 
3
3
  export declare class CalculateResultApplyController extends Disposable {
4
+ private _univerInstanceService;
4
5
  private readonly _commandService;
5
- constructor(_commandService: ICommandService);
6
+ constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService);
6
7
  private _initialize;
7
8
  private _commandExecutedListener;
9
+ /**
10
+ * Priority that mainly deals with number format in unitData
11
+ * @param unitId
12
+ * @param sheetId
13
+ * @param cellData
14
+ * @returns
15
+ */
16
+ private _getMergedCellData;
8
17
  }
@@ -4,9 +4,9 @@ import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/c
4
4
  export declare class FeatureCalculationController extends Disposable {
5
5
  private readonly _commandService;
6
6
  private readonly _featureCalculationManagerService;
7
- private readonly _currentUniverService;
7
+ private readonly _univerInstanceService;
8
8
  private readonly _formulaDataModel;
9
- constructor(_commandService: ICommandService, _featureCalculationManagerService: IFeatureCalculationManagerService, _currentUniverService: IUniverInstanceService, _formulaDataModel: FormulaDataModel);
9
+ constructor(_commandService: ICommandService, _featureCalculationManagerService: IFeatureCalculationManagerService, _univerInstanceService: IUniverInstanceService, _formulaDataModel: FormulaDataModel);
10
10
  /**
11
11
  * Test function access to the formula system example , feature calculation ,
12
12
  * you can register a listening range and callback function ,
@@ -17,7 +17,8 @@ export { type IUniverSheetsConfig, UniverSheetsPlugin } from './sheets-plugin';
17
17
  export { COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE } from './basics/const/command-listener-const';
18
18
  export { type IAddWorksheetMergeMutationParams, type IDeleteRangeMutationParams, type IInsertColMutationParams, type IInsertRangeMutationParams, type IInsertRowMutationParams, type IInsertSheetMutationParams, type IRemoveColMutationParams, type IRemoveRowsMutationParams, type IRemoveSheetMutationParams, type IRemoveWorksheetMergeMutationParams, } from './basics/interfaces/mutation-interface';
19
19
  export { convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, getNormalSelectionStyle, type ISelectionStyle, type ISelectionWidgetConfig, type ISelectionWithCoordAndStyle, type ISelectionWithStyle, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, transformCellDataToSelectionData, } from './basics/selection';
20
- export { alignToMergedCellsBorders, getCellAtRowCol, setEndForRange } from './commands/commands/utils/selection-utils';
20
+ export { getSheetCommandTarget, getSheetCommandTargetWorkbook, getSheetMutationTarget } from './commands/commands/utils/target-util';
21
+ export { alignToMergedCellsBorders, getCellAtRowCol, setEndForRange, isSingleCellSelection } from './commands/commands/utils/selection-utils';
21
22
  export { MAX_CELL_PER_SHEET_KEY } from './controllers/config/config';
22
23
  export { BorderStyleManagerService, type IBorderInfo } from './services/border-style-manager.service';
23
24
  export { getCurrentSheetDisabled$, SheetEditablePermission, SheetPermissionService } from './services/permission';
@@ -83,7 +84,7 @@ export type { ISetRangeValuesMutationParams } from './commands/mutations/set-ran
83
84
  export { SetRangeValuesMutation } from './commands/mutations/set-range-values.mutation';
84
85
  export { SetRangeValuesUndoMutationFactory } from './commands/mutations/set-range-values.mutation';
85
86
  export { type ISetRangeValuesRangeMutationParams } from './commands/mutations/set-range-values.mutation';
86
- export { type ISetRowHiddenMutationParams, type ISetRowVisibleMutationParams, SetRowHiddenMutation, SetRowVisibleMutation } from './commands/mutations/set-row-visible.mutation';
87
+ export { type ISetRowHiddenMutationParams, type ISetRowVisibleMutationParams, SetRowHiddenMutation, SetRowVisibleMutation, } from './commands/mutations/set-row-visible.mutation';
87
88
  export { SetTabColorMutation } from './commands/mutations/set-tab-color.mutation';
88
89
  export { type ISetTabColorMutationParams } from './commands/mutations/set-tab-color.mutation';
89
90
  export { type ISetWorksheetColWidthMutationParams, SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory, } from './commands/mutations/set-worksheet-col-width.mutation';
@@ -103,12 +104,12 @@ export { type ISheetCommandSharedParams } from './commands/utils/interface';
103
104
  export { getAddMergeMutationRangeByType } from './controllers/merge-cell.controller';
104
105
  export { enUS, zhCN } from './locale';
105
106
  export { NumfmtService } from './services/numfmt/numfmt.service';
106
- export type { FormatType, INumfmtItem, INumfmtItemWithCache } from './services/numfmt/type';
107
+ export type { INumfmtItem, INumfmtItemWithCache } from './services/numfmt/type';
107
108
  export { INumfmtService } from './services/numfmt/type';
108
109
  export { RefRangeService } from './services/ref-range/ref-range.service';
109
110
  export type { EffectRefRangeParams, IOperator } from './services/ref-range/type';
110
111
  export { EffectRefRangId, OperatorType } from './services/ref-range/type';
111
- export { handleBaseInsertRange, handleBaseMoveRowsCols, handleBaseRemoveRange, handleDeleteRangeMoveLeft, handleDeleteRangeMoveUp, handleInsertCol, handleInsertRangeMoveDown, handleInsertRangeMoveRight, handleInsertRow, handleIRemoveCol, handleIRemoveRow, handleMoveCols, handleMoveRange, handleMoveRows, rotateRange, runRefRangeMutations, handleDefaultRangeChangeWithEffectRefCommands, handleOtherDefaultRangeChangeWithEffectRefCommands, } from './services/ref-range/util';
112
+ export { handleBaseInsertRange, handleBaseMoveRowsCols, handleBaseRemoveRange, handleDeleteRangeMoveLeft, handleDeleteRangeMoveUp, handleInsertCol, handleInsertRangeMoveDown, handleInsertRangeMoveRight, handleInsertRow, handleIRemoveCol, handleIRemoveRow, handleMoveCols, handleMoveRange, handleMoveRows, rotateRange, runRefRangeMutations, handleCommonDefaultRangeChangeWithEffectRefCommands, handleDefaultRangeChangeWithEffectRefCommands, } from './services/ref-range/util';
112
113
  export { INTERCEPTOR_POINT } from './services/sheet-interceptor/interceptor-const';
113
114
  export { SheetInterceptorService } from './services/sheet-interceptor/sheet-interceptor.service';
114
115
  export type { ISheetLocation } from './services/sheet-interceptor/utils/interceptor';
@@ -118,3 +119,5 @@ export { InsertDefinedNameCommand } from './commands/commands/insert-defined-nam
118
119
  export { RemoveDefinedNameCommand } from './commands/commands/remove-defined-name.command';
119
120
  export { SetDefinedNameCommand, type ISetDefinedNameCommandParams } from './commands/commands/set-defined-name.command';
120
121
  export { ScrollToCellOperation } from './commands/operations/scroll-to-cell.operation';
122
+ export type { FormatType } from './services/numfmt/type';
123
+ export { getMoveRangeUndoRedoMutations } from './commands/commands/move-range.command';
@@ -15,8 +15,16 @@
15
15
  */
16
16
  declare const locale: {
17
17
  sheets: {
18
- sheetCopy: string;
19
- sheet: string;
18
+ tabs: {
19
+ sheetCopy: string;
20
+ sheet: string;
21
+ };
22
+ info: {
23
+ overlappingSelections: string;
24
+ acrossMergedCell: string;
25
+ partOfCell: string;
26
+ hideSheet: string;
27
+ };
20
28
  };
21
29
  };
22
30
  export default locale;
@@ -2,7 +2,7 @@ import { Dependency } from '@wendellhu/redi';
2
2
  import { IWorkbookData, Univer } from '@univerjs/core';
3
3
 
4
4
  export declare const TEST_WORKBOOK_DATA_DEMO: IWorkbookData;
5
- export declare function createTestBase(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
5
+ export declare function createTestBase(workbookData?: IWorkbookData, dependencies?: Dependency[]): {
6
6
  univer: Univer;
7
7
  get: {
8
8
  <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
@@ -1,37 +1,17 @@
1
- import { FormatType, INumfmtItem, INumfmtService, IRefItem } from './type';
2
- import { IRange, Disposable, ICommandService, ILogService, IResourceManagerService, IUniverInstanceService, ObjectMatrix, RefAlias } from '@univerjs/core';
1
+ import { INumfmtService } from './type';
2
+ import { IRange, Disposable, ILogService, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
3
3
 
4
4
  export declare class NumfmtService extends Disposable implements INumfmtService {
5
- private _commandService;
6
5
  private _resourceManagerService;
7
6
  private _univerInstanceService;
8
7
  private _logService;
9
- /**
10
- * Map<unitID ,<sheetId ,ObjectMatrix>>
11
- * @type {Map<string, Map<string, ObjectMatrix<INumfmtItemWithCache>>>}
12
- * @memberof NumfmtService
13
- */
14
- private _numfmtModel;
15
- private _refAliasModel;
16
- private _modelReplace$;
17
- modelReplace$: import('rxjs').Observable<string>;
18
- constructor(_commandService: ICommandService, _resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService, _logService: ILogService);
19
- private _initModel;
20
- private _toJson;
21
- private _parseJson;
22
- private _setValue;
23
- private _getUniqueRefId;
24
- getValue(unitId: string, subUnitId: string, row: number, col: number, model?: ObjectMatrix<INumfmtItem>): {
8
+ constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService, _logService: ILogService);
9
+ getValue(unitId: string, subUnitId: string, row: number, col: number): {
25
10
  pattern: string;
26
- type: FormatType;
27
- } | null;
11
+ } | null | undefined;
28
12
  deleteValues(unitId: string, subUnitId: string, values: IRange[]): void;
29
13
  setValues(unitId: string, subUnitId: string, values: Array<{
30
14
  ranges: IRange[];
31
15
  pattern: string;
32
- type: FormatType;
33
16
  }>): void;
34
- getModel(unitId: string, subUnitId: string): ObjectMatrix<INumfmtItem> | undefined;
35
- getRefModel(unitId: string): RefAlias<IRefItem, "i" | "pattern"> | undefined;
36
- serialTimeToTimestamp(serialValue: number, is1900?: boolean): number;
37
17
  }
@@ -1,5 +1,4 @@
1
- import { Observable } from 'rxjs';
2
- import { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, ObjectMatrix, RefAlias } from '@univerjs/core';
1
+ import { ICellData, IRange, Nullable, ObjectMatrix } from '@univerjs/core';
3
2
 
4
3
  export type INumfmtItem = {
5
4
  i: string;
@@ -11,28 +10,13 @@ export interface INumfmtItemWithCache {
11
10
  parameters: number;
12
11
  };
13
12
  pattern: string;
14
- type: FormatType;
15
13
  }
16
- export type IRefItem = INumfmtItem & {
17
- count: number;
18
- type: FormatType;
19
- pattern: string;
20
- };
21
14
  export interface INumfmtService {
22
15
  getValue(unitId: string, subUnitId: string, row: number, col: number, model?: ObjectMatrix<INumfmtItem>): Nullable<INumfmtItemWithCache>;
23
- getModel(unitId: string, subUnitId: string): Nullable<ObjectMatrix<INumfmtItem>>;
24
16
  setValues(unitId: string, subUnitId: string, values: Array<{
25
17
  ranges: IRange[];
26
18
  pattern: string;
27
- type: FormatType;
28
19
  }>): void;
29
20
  deleteValues(unitId: string, subUnitId: string, values: IRange[]): void;
30
- getRefModel(unitId: string): Nullable<RefAlias<IRefItem, 'i' | 'pattern'>>;
31
- modelReplace$: Observable<string>;
32
- serialTimeToTimestamp: (v: number, is1900?: boolean) => number;
33
- }
34
- export interface ISnapshot {
35
- model: Record<string, IObjectMatrixPrimitiveType<INumfmtItem>>;
36
- refModel: IRefItem[];
37
21
  }
38
22
  export declare const INumfmtService: import('@wendellhu/redi').IdentifierDecorator<INumfmtService>;
@@ -1,16 +1,15 @@
1
- import { SheetInterceptorService } from '../sheet-interceptor/sheet-interceptor.service';
2
- import { PermissionService, Disposable, IUniverInstanceService } from '@univerjs/core';
1
+ import { IPermissionService, IUniverInstanceService, PermissionStatus, RxDisposable } from '@univerjs/core';
3
2
 
4
- export declare class SheetPermissionService extends Disposable {
3
+ export declare class SheetPermissionService extends RxDisposable {
5
4
  private _permissionService;
6
5
  private _univerInstanceService;
7
- private _sheetInterceptorService;
8
- constructor(_permissionService: PermissionService, _univerInstanceService: IUniverInstanceService, _sheetInterceptorService: SheetInterceptorService);
6
+ private _disposableByUnit;
7
+ constructor(_permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService);
9
8
  private _init;
10
- private _interceptCommandPermission;
9
+ private _interceptWorkbook;
11
10
  getEditable$(unitId?: string, sheetId?: string): import('rxjs').Observable<{
12
- value: any;
13
- status: import("@univerjs/core").PermissionStatus;
11
+ value: boolean;
12
+ status: PermissionStatus;
14
13
  }>;
15
14
  getSheetEditable(unitId?: string, sheetId?: string): boolean;
16
15
  setSheetEditable(v: boolean, unitId?: string, sheetId?: string): void;
@@ -1,4 +1,3 @@
1
- import { Observable } from 'rxjs';
2
1
  import { IAccessor } from '@wendellhu/redi';
3
2
 
4
- export declare function getCurrentSheetDisabled$(accessor: IAccessor): Observable<boolean>;
3
+ export declare function getCurrentSheetDisabled$(accessor: IAccessor): import('rxjs').Observable<boolean>;
@@ -2,7 +2,7 @@ import { Dependency } from '@wendellhu/redi';
2
2
  import { IWorkbookData, Univer } from '@univerjs/core';
3
3
 
4
4
  export declare const TEST_WORKBOOK_DATA_DEMO: IWorkbookData;
5
- export declare function createTestBase(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
5
+ export declare function createTestBase(workbookData?: IWorkbookData, dependencies?: Dependency[]): {
6
6
  univer: Univer;
7
7
  get: {
8
8
  <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
@@ -0,0 +1,14 @@
1
+ import { Univer } from '@univerjs/core';
2
+
3
+ export declare function createRefRangeTestBed(): {
4
+ univer: Univer;
5
+ get: {
6
+ <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
7
+ <T_1>(id: import('@wendellhu/redi').DependencyIdentifier<T_1>, quantity: import("@wendellhu/redi").Quantity.MANY, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_1[];
8
+ <T_2>(id: import('@wendellhu/redi').DependencyIdentifier<T_2>, quantity: import("@wendellhu/redi").Quantity.OPTIONAL, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_2 | null;
9
+ <T_3>(id: import('@wendellhu/redi').DependencyIdentifier<T_3>, quantity: import("@wendellhu/redi").Quantity.REQUIRED, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_3;
10
+ <T_4>(id: import('@wendellhu/redi').DependencyIdentifier<T_4>, quantity?: import('@wendellhu/redi').Quantity | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_4 | T_4[] | null;
11
+ <T_5>(id: import('@wendellhu/redi').DependencyIdentifier<T_5>, quantityOrLookup?: import('@wendellhu/redi').Quantity | import('@wendellhu/redi').LookUp | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_5 | T_5[] | null;
12
+ };
13
+ sheet: import('@univerjs/core').Workbook;
14
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -2,7 +2,7 @@ import { EffectRefRangeParams } from './type';
2
2
  import { SheetInterceptorService } from '../sheet-interceptor/sheet-interceptor.service';
3
3
  import { SelectionManagerService } from '../selection-manager.service';
4
4
  import { IDisposable } from '@wendellhu/redi';
5
- import { IMutationInfo, IRange, Disposable, InterceptorManager, IUniverInstanceService } from '@univerjs/core';
5
+ import { IMutationInfo, IRange, Nullable, Disposable, ICommandService, InterceptorManager, IUniverInstanceService } from '@univerjs/core';
6
6
 
7
7
  type RefRangCallback = (params: EffectRefRangeParams) => {
8
8
  redos: IMutationInfo[];
@@ -10,10 +10,12 @@ type RefRangCallback = (params: EffectRefRangeParams) => {
10
10
  preRedos?: IMutationInfo[];
11
11
  preUndos?: IMutationInfo[];
12
12
  };
13
+ export type WatchRangeCallback = (before: IRange, after: Nullable<IRange>) => void;
13
14
  /**
14
15
  * Collect side effects caused by ref range change
15
16
  */
16
17
  export declare class RefRangeService extends Disposable {
18
+ private readonly _commandService;
17
19
  private _sheetInterceptorService;
18
20
  private _univerInstanceService;
19
21
  private _selectionManagerService;
@@ -21,7 +23,9 @@ export declare class RefRangeService extends Disposable {
21
23
  MERGE_REDO: import('@univerjs/core').IInterceptor<IMutationInfo<object>[], null>;
22
24
  MERGE_UNDO: import('@univerjs/core').IInterceptor<IMutationInfo<object>[], null>;
23
25
  }>;
24
- constructor(_sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _selectionManagerService: SelectionManagerService);
26
+ private _watchRanges;
27
+ constructor(_commandService: ICommandService, _sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _selectionManagerService: SelectionManagerService);
28
+ watchRange(unitId: string, subUnitId: string, range: IRange, callback: WatchRangeCallback): IDisposable;
25
29
  private _refRangeManagerMap;
26
30
  private _serializer;
27
31
  private _onRefRangeChange;
@@ -1,5 +1,9 @@
1
1
  import { IDeleteRangeMoveLeftCommand, IDeleteRangeMoveUpCommand, IInsertColCommand, IInsertRangeMoveDownCommand, IInsertRangeMoveRightCommand, IInsertRowCommand, IMoveColsCommand, IMoveRangeCommand, IMoveRowsCommand, IOperator, IRemoveRowColCommand } from './type';
2
- import { ICommandInfo, IRange, RANGE_TYPE } from '@univerjs/core';
2
+ import { ISheetCommandSharedParams } from '../../commands/utils/interface';
3
+ import { IMoveRangeMutationParams } from '../../commands/mutations/move-range.mutation';
4
+ import { IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowsMutationParams, IRemoveSheetMutationParams } from '../../basics';
5
+ import { IMoveColumnsMutationParams, IMoveRowsMutationParams } from '../../commands/mutations/move-rows-cols.mutation';
6
+ import { ICommandInfo, IMutationInfo, IRange, Nullable, RANGE_TYPE } from '@univerjs/core';
3
7
 
4
8
  export declare const handleRangeTypeInput: (range: IRange) => {
5
9
  startColumn: number;
@@ -32,10 +36,11 @@ export declare const handleBaseMoveRowsCols: (fromRange: ILine, toRange: ILine,
32
36
  step: number;
33
37
  };
34
38
  export declare const handleMoveRows: (params: IMoveRowsCommand, targetRange: IRange) => IOperator[];
35
- export declare const handleMoveRowsOther: (params: IMoveRowsCommand, targetRange: IRange) => IRange[] | null;
39
+ export declare const handleMoveRowsCommon: (params: IMoveRowsCommand, targetRange: IRange) => IRange[];
36
40
  export declare const handleMoveCols: (params: IMoveColsCommand, targetRange: IRange) => IOperator[];
37
- export declare const handleMoveColsOther: (params: IMoveColsCommand, targetRange: IRange) => IRange[] | null;
41
+ export declare const handleMoveColsCommon: (params: IMoveColsCommand, targetRange: IRange) => IRange[];
38
42
  export declare const handleMoveRange: (param: IMoveRangeCommand, targetRange: IRange) => IOperator[];
43
+ export declare const handleMoveRangeCommon: (param: IMoveRangeCommand, targetRange: IRange) => IRange[];
39
44
  export declare const handleBaseRemoveRange: (_removeRange: IRange, _targetRange: IRange) => {
40
45
  step: number;
41
46
  length: number;
@@ -49,10 +54,24 @@ export declare const handleBaseInsertRange: (_insertRange: IRange, _targetRange:
49
54
  export declare const handleInsertRow: (param: IInsertRowCommand, targetRange: IRange) => IOperator[];
50
55
  export declare const handleInsertCol: (param: IInsertColCommand, targetRange: IRange) => IOperator[];
51
56
  export declare const handleInsertRangeMoveDown: (param: IInsertRangeMoveDownCommand, targetRange: IRange) => IOperator[];
57
+ export declare const handleInsertRangeMoveDownCommon: (param: IInsertRangeMoveDownCommand, targetRange: IRange) => IRange[];
52
58
  export declare const handleInsertRangeMoveRight: (param: IInsertRangeMoveRightCommand, targetRange: IRange) => IOperator[];
59
+ export declare const handleInsertRangeMoveRightCommon: (param: IInsertRangeMoveRightCommand, targetRange: IRange) => IRange[];
53
60
  export declare const handleDeleteRangeMoveLeft: (param: IDeleteRangeMoveLeftCommand, targetRange: IRange) => IOperator[];
61
+ export declare const handleDeleteRangeMoveLeftCommon: (param: IDeleteRangeMoveLeftCommand, targetRange: IRange) => IRange[];
54
62
  export declare const handleDeleteRangeMoveUp: (param: IDeleteRangeMoveUpCommand, targetRange: IRange) => IOperator[];
63
+ export declare const handleDeleteRangeMoveUpCommon: (param: IDeleteRangeMoveUpCommand, targetRange: IRange) => IRange[];
55
64
  export declare const runRefRangeMutations: (operators: IOperator[], range: IRange) => IRange | null;
56
65
  export declare const handleDefaultRangeChangeWithEffectRefCommands: (range: IRange, commandInfo: ICommandInfo) => IRange | null;
57
- export declare const handleOtherDefaultRangeChangeWithEffectRefCommands: (range: IRange, commandInfo: ICommandInfo) => IRange | IRange[] | null;
66
+ type MutationsAffectRange = ISheetCommandSharedParams | IRemoveSheetMutationParams | IMoveRowsMutationParams | IMoveColumnsMutationParams | IRemoveRowsMutationParams | IRemoveColMutationParams | IInsertColMutationParams | IInsertRowMutationParams | IMoveRangeMutationParams;
67
+ export declare const handleCommonDefaultRangeChangeWithEffectRefCommands: (range: IRange, commandInfo: ICommandInfo) => IRange | IRange[] | null;
68
+ /**
69
+ * This function should work as a pure function.
70
+ *
71
+ * @pure
72
+ * @param range
73
+ * @param mutation
74
+ * @returns the adjusted range
75
+ */
76
+ export declare function adjustRangeOnMutation(range: Readonly<IRange>, mutation: IMutationInfo<MutationsAffectRange>): Nullable<IRange>;
58
77
  export {};
@@ -1,7 +1,7 @@
1
1
  import { Dependency } from '@wendellhu/redi';
2
2
  import { IWorkbookData, Univer } from '@univerjs/core';
3
3
 
4
- export declare function createCoreTestBed(workbookConfig?: IWorkbookData, dependencies?: Dependency[]): {
4
+ export declare function createCoreTestBed(workbookData?: IWorkbookData, dependencies?: Dependency[]): {
5
5
  univer: Univer;
6
6
  get: {
7
7
  <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
@@ -1,7 +1,7 @@
1
- import { ISheetLocation } from './utils/interceptor';
2
- import { ICellDataForSheetInterceptor, ICommandInfo } from '@univerjs/core';
1
+ import { ISheetLocation, ISheetRowLocation } from './utils/interceptor';
2
+ import { ICellDataForSheetInterceptor } from '@univerjs/core';
3
3
 
4
4
  export declare const INTERCEPTOR_POINT: {
5
5
  CELL_CONTENT: import('@univerjs/core').IInterceptor<ICellDataForSheetInterceptor, ISheetLocation>;
6
- PERMISSION: import('@univerjs/core').IInterceptor<boolean, ICommandInfo<object>>;
6
+ ROW_FILTERED: import('@univerjs/core').IInterceptor<boolean, ISheetRowLocation>;
7
7
  };
@@ -11,12 +11,12 @@ export interface ICommandInterceptor {
11
11
  * It would inject Workbook & Worksheet.
12
12
  */
13
13
  export declare class SheetInterceptorService extends Disposable {
14
- private readonly _currentUniverService;
14
+ private readonly _univerInstanceService;
15
15
  private _interceptorsByName;
16
16
  private _commandInterceptors;
17
17
  private readonly _workbookDisposables;
18
18
  private readonly _worksheetDisposables;
19
- constructor(_currentUniverService: IUniverInstanceService);
19
+ constructor(_univerInstanceService: IUniverInstanceService);
20
20
  dispose(): void;
21
21
  interceptCommand(interceptor: ICommandInterceptor): IDisposable;
22
22
  /**
@@ -26,7 +26,7 @@ export declare class SheetInterceptorService extends Disposable {
26
26
  */
27
27
  onCommandExecute(command: ICommandInfo): IUndoRedoCommandInfosByInterceptor;
28
28
  intercept<T extends IInterceptor<any, any>>(name: T, interceptor: T): IDisposable;
29
- fetchThroughInterceptors<T, C>(name: IInterceptor<T, C>): (initValue: import('@univerjs/core/common/type-utils.js').Nullable<T>, initContext: C) => import('@univerjs/core/common/type-utils.js').Nullable<T>;
29
+ fetchThroughInterceptors<T, C>(name: IInterceptor<T, C>): (initValue: import('@univerjs/core/common/type-util.js').Nullable<T>, initContext: C) => import('@univerjs/core/common/type-util.js').Nullable<T>;
30
30
  private _interceptWorkbook;
31
31
  private _disposeWorkbookInterceptor;
32
32
  private _disposeSheetInterceptor;
@@ -8,3 +8,10 @@ export interface ISheetLocation {
8
8
  row: number;
9
9
  col: number;
10
10
  }
11
+ export interface ISheetRowLocation {
12
+ workbook: Workbook;
13
+ worksheet: Worksheet;
14
+ unitId: string;
15
+ subUnitId: string;
16
+ row: number;
17
+ }
@@ -1,5 +1,5 @@
1
1
  import { Injector } from '@wendellhu/redi';
2
- import { ICommandService, LocaleService, Plugin, PluginType } from '@univerjs/core';
2
+ import { ICommandService, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
3
3
 
4
4
  export interface IUniverSheetsConfig {
5
5
  notExecuteFormula?: boolean;
@@ -12,7 +12,8 @@ export declare class UniverSheetsPlugin extends Plugin {
12
12
  private readonly _commandService;
13
13
  private readonly _localeService;
14
14
  readonly _injector: Injector;
15
- static type: PluginType;
15
+ static pluginName: string;
16
+ static type: UniverInstanceType;
16
17
  constructor(_config: IUniverSheetsConfig, _commandService: ICommandService, _localeService: LocaleService, _injector: Injector);
17
18
  onRendered(): void;
18
19
  private _initializeDependencies;