@univerjs/sheets 0.12.3 → 0.12.4
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.
- package/lib/cjs/index.js +3 -3
- package/lib/es/index.js +4094 -3881
- package/lib/index.js +4094 -3881
- package/lib/types/commands/commands/util.d.ts +1 -0
- package/lib/types/commands/mutations/copy-worksheet-end.mutation.d.ts +10 -0
- package/lib/types/controllers/config.schema.d.ts +23 -0
- package/lib/types/index.d.ts +4 -1
- package/lib/types/services/lazy-execute-schedule.service.d.ts +47 -0
- package/lib/umd/index.js +3 -3
- package/package.json +9 -9
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IMutation } from '@univerjs/core';
|
|
2
|
+
export interface ICopyWorksheetEndMutationParams {
|
|
3
|
+
unitId: string;
|
|
4
|
+
subUnitId: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* This mutation is used to mark the end of a copy worksheet operation that was split into chunks.
|
|
8
|
+
* When this mutation is applied on the server, it should trigger a snapshot save.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CopyWorksheetEndMutation: IMutation<ICopyWorksheetEndMutationParams, boolean>;
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { DependencyOverride } from '@univerjs/core';
|
|
2
2
|
export declare const SHEETS_PLUGIN_CONFIG_KEY = "sheets.config";
|
|
3
3
|
export declare const configSymbol: unique symbol;
|
|
4
|
+
export interface ILargeSheetOperationConfig {
|
|
5
|
+
/**
|
|
6
|
+
* The minimum number of cells that defines a "large sheet".
|
|
7
|
+
* When a sheet has more cells than this threshold:
|
|
8
|
+
* - Copy sheet: the mutation will be split into multiple batches
|
|
9
|
+
* - Remove sheet: undo/redo will not be supported
|
|
10
|
+
* @default 6000
|
|
11
|
+
*/
|
|
12
|
+
largeSheetCellCountThreshold?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The maximum number of cells per batch when splitting mutations for large sheets.
|
|
15
|
+
* @default 3000
|
|
16
|
+
*/
|
|
17
|
+
batchSize?: number;
|
|
18
|
+
}
|
|
4
19
|
export interface IUniverSheetsConfig {
|
|
5
20
|
notExecuteFormula?: boolean;
|
|
6
21
|
override?: DependencyOverride;
|
|
@@ -22,5 +37,13 @@ export interface IUniverSheetsConfig {
|
|
|
22
37
|
* @default true
|
|
23
38
|
*/
|
|
24
39
|
freezeSync?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for large sheet operations.
|
|
42
|
+
* When a sheet has more cells than the threshold:
|
|
43
|
+
* - Copy sheet: the mutation will be split into multiple batches
|
|
44
|
+
* - Remove sheet: undo/redo will not be supported
|
|
45
|
+
*/
|
|
46
|
+
largeSheetOperation?: ILargeSheetOperationConfig;
|
|
25
47
|
}
|
|
48
|
+
export declare const defaultLargeSheetOperationConfig: Required<ILargeSheetOperationConfig>;
|
|
26
49
|
export declare const defaultPluginConfig: IUniverSheetsConfig;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export { type IToggleCellCheckboxCommandParams, ToggleCellCheckboxCommand } from
|
|
|
89
89
|
export { type IToggleGridlinesCommandParams, ToggleGridlinesCommand } from './commands/commands/toggle-gridlines.command';
|
|
90
90
|
export { UnregisterWorksheetRangeThemeStyleCommand } from './commands/commands/unregister-range-theme.command';
|
|
91
91
|
export type { IUnregisterWorksheetRangeThemeStyleCommandParams } from './commands/commands/unregister-range-theme.command';
|
|
92
|
+
export { countCells } from './commands/commands/util';
|
|
92
93
|
export { alignToMergedCellsBorders, getCellAtRowCol, isSingleCellSelection, setEndForRange } from './commands/commands/utils/selection-utils';
|
|
93
94
|
export { followSelectionOperation, getPrimaryForRange } from './commands/commands/utils/selection-utils';
|
|
94
95
|
export { copyRangeStyles } from './commands/commands/utils/selection-utils';
|
|
@@ -99,6 +100,7 @@ export type { IAddRangeThemeMutationParams } from './commands/mutations/add-rang
|
|
|
99
100
|
export { AddMergeUndoMutationFactory, AddWorksheetMergeMutation } from './commands/mutations/add-worksheet-merge.mutation';
|
|
100
101
|
export { AddWorksheetProtectionMutation, type IAddWorksheetProtectionParams } from './commands/mutations/add-worksheet-protection.mutation';
|
|
101
102
|
export { SetWorksheetRangeThemeStyleMutation, SetWorksheetRangeThemeStyleMutationFactory } from './commands/mutations/add-worksheet-range-theme.mutation';
|
|
103
|
+
export { CopyWorksheetEndMutation, type ICopyWorksheetEndMutationParams } from './commands/mutations/copy-worksheet-end.mutation';
|
|
102
104
|
export { DeleteRangeProtectionMutation, FactoryDeleteRangeProtectionMutation, type IDeleteRangeProtectionMutationParams } from './commands/mutations/delete-range-protection.mutation';
|
|
103
105
|
export { DeleteWorksheetProtectionMutation } from './commands/mutations/delete-worksheet-protection.mutation';
|
|
104
106
|
export type { IDeleteWorksheetProtectionParams } from './commands/mutations/delete-worksheet-protection.mutation';
|
|
@@ -153,7 +155,7 @@ export { getInsertRangeMutations, getRemoveRangeMutations } from './commands/uti
|
|
|
153
155
|
export { handleInsertRangeMutation } from './commands/utils/handle-range-mutation';
|
|
154
156
|
export { type ISheetCommandSharedParams } from './commands/utils/interface';
|
|
155
157
|
export { getSelectionsService } from './commands/utils/selection-command-util';
|
|
156
|
-
export { type IUniverSheetsConfig } from './controllers/config.schema';
|
|
158
|
+
export { defaultLargeSheetOperationConfig, type ILargeSheetOperationConfig, type IUniverSheetsConfig, SHEETS_PLUGIN_CONFIG_KEY } from './controllers/config.schema';
|
|
157
159
|
export { MAX_CELL_PER_SHEET_KEY } from './controllers/config/config';
|
|
158
160
|
export { DefinedNameDataController } from './controllers/defined-name-data.controller';
|
|
159
161
|
export { SCOPE_WORKBOOK_VALUE_DEFINED_NAME } from './controllers/defined-name-data.controller';
|
|
@@ -173,6 +175,7 @@ export type { IRangeThemeStyleItem } from './model/range-theme-util';
|
|
|
173
175
|
export { UniverSheetsPlugin } from './plugin';
|
|
174
176
|
export { BorderStyleManagerService, type IBorderInfo } from './services/border-style-manager.service';
|
|
175
177
|
export { ExclusiveRangeService, IExclusiveRangeService } from './services/exclusive-range/exclusive-range-service';
|
|
178
|
+
export { SheetLazyExecuteScheduleService } from './services/lazy-execute-schedule.service';
|
|
176
179
|
export { NumfmtService } from './services/numfmt/numfmt.service';
|
|
177
180
|
export type { INumfmtItem, INumfmtItemWithCache } from './services/numfmt/type';
|
|
178
181
|
export { INumfmtService } from './services/numfmt/type';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IMutationInfo, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { ISetRangeValuesMutationParams } from '../commands/mutations/set-range-values.mutation';
|
|
3
|
+
/**
|
|
4
|
+
* Service to schedule and execute remaining SetRangeValuesMutation tasks
|
|
5
|
+
* during browser idle time after a sheet copy operation.
|
|
6
|
+
*
|
|
7
|
+
* This improves user experience by:
|
|
8
|
+
* 1. Immediately showing the copied sheet with first chunk of data
|
|
9
|
+
* 2. Filling remaining data in background during idle time
|
|
10
|
+
* 3. Automatically canceling tasks if the sheet is deleted
|
|
11
|
+
* 4. Warning user if they try to close while tasks are pending
|
|
12
|
+
*/
|
|
13
|
+
export declare class SheetLazyExecuteScheduleService extends Disposable {
|
|
14
|
+
private readonly _commandService;
|
|
15
|
+
private readonly _univerInstanceService;
|
|
16
|
+
private _tasks;
|
|
17
|
+
private _idleCallbackId;
|
|
18
|
+
private _beforeUnloadHandler;
|
|
19
|
+
constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService);
|
|
20
|
+
/**
|
|
21
|
+
* Check if there are any pending tasks
|
|
22
|
+
*/
|
|
23
|
+
hasPendingTasks(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get the count of pending mutations across all tasks
|
|
26
|
+
*/
|
|
27
|
+
getPendingMutationsCount(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Schedule mutations to be executed during idle time
|
|
30
|
+
* @param unitId - The workbook unit ID
|
|
31
|
+
* @param subUnitId - The sheet ID (newly created sheet)
|
|
32
|
+
* @param mutations - Remaining SetRangeValuesMutation to execute
|
|
33
|
+
*/
|
|
34
|
+
scheduleMutations(unitId: string, subUnitId: string, mutations: IMutationInfo<ISetRangeValuesMutationParams>[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Cancel scheduled mutations for a specific sheet
|
|
37
|
+
* Called when the sheet is deleted
|
|
38
|
+
*/
|
|
39
|
+
cancelScheduledMutations(unitId: string, subUnitId: string): void;
|
|
40
|
+
private _cancelTask;
|
|
41
|
+
private _cancelAllTasks;
|
|
42
|
+
private _scheduleNextIdle;
|
|
43
|
+
private _processIdleTasks;
|
|
44
|
+
private _isSheetExist;
|
|
45
|
+
private _setupBeforeUnloadListener;
|
|
46
|
+
private _removeBeforeUnloadListener;
|
|
47
|
+
}
|