@univerjs/sheets 0.2.5 → 0.2.7

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.
@@ -1,4 +1,4 @@
1
- import { IRange, Dimension, Disposable, DisposableCollection, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
1
+ import { IRange, Dimension, Disposable, DisposableCollection, ICommandService, Injector, InterceptorManager, IUniverInstanceService } from '@univerjs/core';
2
2
  import { IRemoveWorksheetMergeMutationParams } from '../basics/interfaces/mutation-interface';
3
3
  import { RefRangeService } from '../services/ref-range/ref-range.service';
4
4
  import { EffectRefRangeParams } from '../services/ref-range/type';
@@ -12,6 +12,7 @@ import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-int
12
12
  * @return {*}
13
13
  */
14
14
  export declare function getAddMergeMutationRangeByType(selection: IRange[], type?: Dimension): IRange[];
15
+ export declare const MERGE_CELL_INTERCEPTOR_CHECK: import('@univerjs/core').IInterceptor<boolean, IRange[]>;
15
16
  export declare class MergeCellController extends Disposable {
16
17
  private readonly _commandService;
17
18
  private readonly _refRangeService;
@@ -20,6 +21,9 @@ export declare class MergeCellController extends Disposable {
20
21
  private _sheetInterceptorService;
21
22
  private _selectionManagerService;
22
23
  disposableCollection: DisposableCollection;
24
+ readonly interceptor: InterceptorManager<{
25
+ MERGE_CELL_INTERCEPTOR_CHECK: import('@univerjs/core').IInterceptor<boolean, IRange[]>;
26
+ }>;
23
27
  constructor(_commandService: ICommandService, _refRangeService: RefRangeService, _univerInstanceService: IUniverInstanceService, _injector: Injector, _sheetInterceptorService: SheetInterceptorService, _selectionManagerService: SheetsSelectionsService);
24
28
  private _initCommandInterceptor;
25
29
  refRangeHandle(config: EffectRefRangeParams, unitId: string, subUnitId: string): {
@@ -45,7 +45,7 @@ export { handleBaseInsertRange, handleBaseMoveRowsCols, handleBaseRemoveRange, h
45
45
  export { INTERCEPTOR_POINT } from './services/sheet-interceptor/interceptor-const';
46
46
  export { SheetInterceptorService } from './services/sheet-interceptor/sheet-interceptor.service';
47
47
  export type { ISheetLocation, ISheetLocationBase, ISheetRowLocation } from './services/sheet-interceptor/utils/interceptor';
48
- export { MergeCellController } from './controllers/merge-cell.controller';
48
+ export { MergeCellController, MERGE_CELL_INTERCEPTOR_CHECK } from './controllers/merge-cell.controller';
49
49
  export { AddMergeRedoSelectionsOperationFactory, AddMergeUndoSelectionsOperationFactory } from './commands/utils/handle-merge-operation';
50
50
  export type { FormatType } from './services/numfmt/type';
51
51
  export { expandToContinuousRange } from './basics/utils';
@@ -54,6 +54,7 @@ export type { IWorksheetProtectionRule } from './services/permission/type';
54
54
  export { WorksheetProtectionRuleModel, WorksheetProtectionPointModel } from './services/permission/worksheet-permission';
55
55
  export { getAllWorkbookPermissionPoint, defaultWorkbookPermissionPoints } from './services/permission/workbook-permission';
56
56
  export { WorksheetCopyPermission, WorksheetSelectProtectedCellsPermission, WorksheetSelectUnProtectedCellsPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetViewPermission, WorksheetSetRowStylePermission, WorksheetSetColumnStylePermission, WorksheetInsertRowPermission, WorksheetInsertColumnPermission, WorksheetInsertHyperlinkPermission, WorksheetDeleteRowPermission, WorksheetDeleteColumnPermission, WorksheetSortPermission, WorksheetFilterPermission, WorksheetPivotTablePermission, WorksheetEditExtraObjectPermission, WorksheetManageCollaboratorPermission, WorksheetEditPermission, WorkbookCommentPermission, WorkbookEditablePermission, WorkbookDuplicatePermission, WorkbookPrintPermission, WorkbookExportPermission, WorkbookMoveSheetPermission, WorkbookDeleteSheetPermission, WorkbookHideSheetPermission, WorkbookRenameSheetPermission, WorkbookCreateSheetPermission, WorkbookHistoryPermission, WorkbookViewPermission, WorkbookSharePermission, WorkbookCopyPermission, WorkbookManageCollaboratorPermission, WorkbookViewHistoryPermission, WorkbookRecoverHistoryPermission, } from './services/permission/permission-point';
57
+ export { checkRangesEditablePermission } from './services/permission/util';
57
58
  export { RangeProtectionRenderModel, type ICellPermission } from './model/range-protection-render.model';
58
59
  export { RangeProtectionRuleModel, type IObjectModel, type IRangeProtectionRule, type IModel } from './model/range-protection-rule.model';
59
60
  export type { IWorksheetProtectionRenderCellData } from './services/permission/worksheet-permission/type';
@@ -62,7 +63,7 @@ export { RangeProtectionService } from './services/permission/range-permission/r
62
63
  export { type IRangePermissionPoint, getAllRangePermissionPoint, getDefaultRangePermission, } from './services/permission/range-permission/util';
63
64
  export { RangeProtectionPermissionEditPoint } from './services/permission/permission-point/range/edit';
64
65
  export { RangeProtectionPermissionViewPoint } from './services/permission/permission-point/range/view';
65
- export { generateNullCellValue } from './basics/utils';
66
+ export { generateNullCellValue, generateNullCell } from './basics/utils';
66
67
  export { AddRangeProtectionCommand, type IAddRangeProtectionCommandParams } from './commands/commands/add-range-protection.command';
67
68
  export { AddWorksheetMergeCommand, AddWorksheetMergeAllCommand, AddWorksheetMergeVerticalCommand, AddWorksheetMergeHorizontalCommand, } from './commands/commands/add-worksheet-merge.command';
68
69
  export { ClearSelectionAllCommand } from './commands/commands/clear-selection-all.command';
@@ -0,0 +1,3 @@
1
+ import { IAccessor, IRange } from '@univerjs/core';
2
+
3
+ export declare const checkRangesEditablePermission: (accessor: IAccessor, unitId: string, subUnitId: string, ranges: IRange[]) => boolean;
@@ -60,6 +60,12 @@ export declare class WorkbookSelections extends Disposable {
60
60
  /** Clear all selections in this workbook. */
61
61
  clear(): void;
62
62
  addSelections(sheetId: string, selectionDatas: ISelectionWithStyle[]): void;
63
+ /**
64
+ *
65
+ * @param sheetId
66
+ * @param selectionDatas
67
+ * @param type
68
+ */
63
69
  setSelections(sheetId: string, selectionDatas: ISelectionWithStyle[], type?: SelectionMoveType): void;
64
70
  getCurrentSelections(): Readonly<ISelectionWithStyle[]>;
65
71
  getSelectionOfWorksheet(sheetId: string): ISelectionWithStyle[];
@@ -68,6 +74,11 @@ export declare class WorkbookSelections extends Disposable {
68
74
  primary: ISelectionCell;
69
75
  }>>;
70
76
  private _worksheetSelections;
77
+ /**
78
+ * same as _getCurrentSelections, but would set [] if no selection.
79
+ * @param sheetId
80
+ * @returns this._worksheetSelections
81
+ */
71
82
  private _ensureSheetSelection;
72
83
  private _emitOnEnd;
73
84
  }
@@ -1,9 +1,22 @@
1
- import { ICommandInfo, IDisposable, IInterceptor, IUndoRedoCommandInfosByInterceptor, Disposable, IUniverInstanceService } from '@univerjs/core';
1
+ import { ICommandInfo, IDisposable, IInterceptor, IRange, IUndoRedoCommandInfosByInterceptor, Disposable, IUniverInstanceService } from '@univerjs/core';
2
2
 
3
+ export interface IBeforeCommandInterceptor {
4
+ priority?: number;
5
+ performCheck(info: ICommandInfo): Promise<boolean>;
6
+ }
3
7
  export interface ICommandInterceptor {
4
8
  priority?: number;
5
9
  getMutations(command: ICommandInfo): IUndoRedoCommandInfosByInterceptor;
6
10
  }
11
+ export interface IRangesInfo {
12
+ unitId: string;
13
+ subUnitId: string;
14
+ ranges: IRange[];
15
+ }
16
+ export interface IRangeInterceptors {
17
+ priority?: number;
18
+ getMutations(rangesInfo: IRangesInfo): IUndoRedoCommandInfosByInterceptor;
19
+ }
7
20
  /**
8
21
  * This class expose methods for sheet features to inject code to sheet underlying logic.
9
22
  *
@@ -13,17 +26,33 @@ export declare class SheetInterceptorService extends Disposable {
13
26
  private readonly _univerInstanceService;
14
27
  private _interceptorsByName;
15
28
  private _commandInterceptors;
29
+ private _rangeInterceptors;
30
+ private _beforeCommandInterceptor;
16
31
  private readonly _workbookDisposables;
17
32
  private readonly _worksheetDisposables;
18
33
  constructor(_univerInstanceService: IUniverInstanceService);
19
34
  dispose(): void;
20
35
  interceptCommand(interceptor: ICommandInterceptor): IDisposable;
36
+ interceptBeforeCommand(interceptor: IBeforeCommandInterceptor): IDisposable;
37
+ /**
38
+ * before command execute, call this method to get the flag of whether it can be executed the command,
39
+ * @param info ICommandInfo
40
+ * @returns Promise<boolean>
41
+ */
42
+ beforeCommandExecute(info: ICommandInfo): Promise<boolean>;
43
+ /**
44
+ * By adding callbacks to some Ranges can get some additional mutations, such as clearing all plugin data in a certain area.
45
+ * @param interceptor IRangeInterceptors
46
+ * @returns IDisposable
47
+ */
48
+ interceptRanges(interceptor: IRangeInterceptors): IDisposable;
21
49
  /**
22
50
  * When command is executing, call this method to gether undo redo mutations from upper features.
23
51
  * @param command
24
52
  * @returns
25
53
  */
26
- onCommandExecute(command: ICommandInfo): IUndoRedoCommandInfosByInterceptor;
54
+ onCommandExecute(info: ICommandInfo): IUndoRedoCommandInfosByInterceptor;
55
+ generateMutationsByRanges(info: IRangesInfo): IUndoRedoCommandInfosByInterceptor;
27
56
  intercept<T extends IInterceptor<any, any>>(name: T, interceptor: T): IDisposable;
28
57
  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>;
29
58
  private _interceptWorkbook;