@univerjs/sheets 1.0.4 → 1.2.0

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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { ICommand } from '@univerjs/core';
17
+ import type { ISetWorkbookCalculationSettingsMutationParams } from '../mutations/set-workbook-calculation-settings.mutation';
18
+ export declare const SetWorkbookCalculationSettingsCommand: ICommand<ISetWorkbookCalculationSettingsMutationParams>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
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
+ import type { IMutation, IWorkbookCalculationSettings } from '@univerjs/core';
17
+ export interface ISetWorkbookCalculationSettingsMutationParams {
18
+ unitId: string;
19
+ settings: IWorkbookCalculationSettings;
20
+ }
21
+ export declare const SetWorkbookCalculationSettingsMutation: IMutation<ISetWorkbookCalculationSettingsMutationParams>;
@@ -47,6 +47,14 @@ export interface IUniverSheetsConfig {
47
47
  * default false, auto height works for merged cells
48
48
  */
49
49
  autoHeightForMergedCells?: boolean;
50
+ /**
51
+ * Extra space in pixels between lines of cell text, including rich text and cell editors.
52
+ * Applies at initialization to all workbooks in this Univer instance. Existing row heights
53
+ * are unchanged until auto-resized; fixed-height cells may clip additional text.
54
+ * Must be finite and non-negative.
55
+ * @default 0
56
+ */
57
+ textLineGap?: number;
50
58
  /**
51
59
  * Whether synchronize the frozen state to other users in real-time collaboration.
52
60
  * @default true
@@ -31,6 +31,9 @@ export declare class AutoFillController extends Disposable {
31
31
  private _getCopyData;
32
32
  private _getEmptyCopyDataPiece;
33
33
  private _getMergeApplyData;
34
+ private _getFillCells;
35
+ private _prepareFillData;
36
+ private _getRemoveMergeMutations;
34
37
  private _fillData;
35
38
  private _shouldDisableSeries;
36
39
  private _getPreferredApplyType;
@@ -15,10 +15,11 @@
15
15
  */
16
16
  import type { IPermissionTypes, IRange } from '@univerjs/core';
17
17
  import { Disposable, DisposableCollection, ICommandService, IPermissionService, IUniverInstanceService, LocaleService } from '@univerjs/core';
18
- import { IDefinedNamesService, LexerTreeBuilder } from '@univerjs/engine-formula';
18
+ import { FormulaDataModel, IDefinedNamesService, IFunctionService, LexerTreeBuilder } from '@univerjs/engine-formula';
19
19
  import { RangeProtectionRuleModel } from '../../models/range-protection-rule.model';
20
- import { WorksheetProtectionRuleModel } from '../../services/permission/worksheet-permission';
21
- import { SheetsSelectionsService } from '../../services/selections';
20
+ import { IAutoFillService } from '../../services/auto-fill/auto-fill.service';
21
+ import { WorksheetProtectionRuleModel } from '../../services/permission/worksheet-permission/worksheet-permission-rule.model';
22
+ import { SheetsSelectionsService } from '../../services/selections/selection.service';
22
23
  export declare class SheetPermissionCheckController extends Disposable {
23
24
  private readonly _commandService;
24
25
  private readonly _univerInstanceService;
@@ -29,10 +30,13 @@ export declare class SheetPermissionCheckController extends Disposable {
29
30
  private readonly _localeService;
30
31
  private readonly _lexerTreeBuilder;
31
32
  private readonly _definedNamesService;
33
+ private readonly _autoFillService;
34
+ private readonly _formulaDataModel;
35
+ private readonly _functionService;
32
36
  disposableCollection: DisposableCollection;
33
37
  private _triggerPermissionUIEvent$;
34
38
  triggerPermissionUIEvent$: import("rxjs").Observable<string>;
35
- constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _permissionService: IPermissionService, _selectionManagerService: SheetsSelectionsService, _rangeProtectionRuleModel: RangeProtectionRuleModel, _worksheetProtectionRuleModel: WorksheetProtectionRuleModel, _localeService: LocaleService, _lexerTreeBuilder: LexerTreeBuilder, _definedNamesService: IDefinedNamesService);
39
+ constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _permissionService: IPermissionService, _selectionManagerService: SheetsSelectionsService, _rangeProtectionRuleModel: RangeProtectionRuleModel, _worksheetProtectionRuleModel: WorksheetProtectionRuleModel, _localeService: LocaleService, _lexerTreeBuilder: LexerTreeBuilder, _definedNamesService: IDefinedNamesService, _autoFillService: IAutoFillService, _formulaDataModel: FormulaDataModel, _functionService: IFunctionService);
36
40
  private _initialize;
37
41
  private _commandExecutedListener;
38
42
  blockExecuteWithoutPermission(errorMsg: string): void;
@@ -40,6 +44,8 @@ export declare class SheetPermissionCheckController extends Disposable {
40
44
  permissionCheckWithRanges(permissionTypes: IPermissionTypes, selectionRanges?: IRange[], unitId?: string, subUnitId?: string): boolean;
41
45
  permissionCheckWithoutRange(permissionTypes: IPermissionTypes, unitId?: string, subUnitId?: string): boolean;
42
46
  private _permissionCheckWithFormula;
47
+ private _getFormulaReferenceWorkbook;
48
+ private _permissionCheckFormulaReferences;
43
49
  private _permissionCheckBySetRangeValue;
44
50
  private _permissionCheckByMoveRowsColsCommand;
45
51
  private _permissionCheckByMoveRangeCommand;
@@ -1622,6 +1622,7 @@ export declare class FRange extends FBaseInitialable {
1622
1622
  * 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`.
1623
1623
  * The expansion of the range is based on detecting data next to the range that is organized like a table.
1624
1624
  * The expanded range covers all adjacent cells with data in them along the specified dimension including the table boundaries.
1625
+ * Cells connected only diagonally do not cause the range to expand.
1625
1626
  * If the original range is surrounded by empty cells along the specified dimension, the range itself is returned.
1626
1627
  * @param {Dimension} [dimension] - The dimension along which to expand the range. If not provided, the range will be expanded in both dimensions.
1627
1628
  * @returns {FRange} The range's data region or a range covering each column or each row spanned by the original range.
@@ -1642,7 +1643,7 @@ export declare class FRange extends FBaseInitialable {
1642
1643
  * fWorksheet.getRange('D3').setValue(100);
1643
1644
  * fWorksheet.getRange('C4').setValue(100);
1644
1645
  *
1645
- * // Get C3 data region along the rows dimension, the range will be C2:D4
1646
+ * // Get C3 data region along the rows dimension, the range will be C2:C4
1646
1647
  * const range = fWorksheet.getRange('C3').getDataRegion(univerAPI.Enum.Dimension.ROWS);
1647
1648
  * console.log(range.getA1Notation()); // C2:C4
1648
1649
  *
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { CommandListener, CustomData, IDisposable, IRange, IStyleData, IWorkbookData, IWorksheetData, Workbook } from '@univerjs/core';
16
+ import type { CommandListener, CustomData, IDisposable, IRange, IStyleData, IWorkbookCalculationSettings, IWorkbookData, IWorksheetData, Workbook } from '@univerjs/core';
17
17
  import type { ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
18
18
  import type { IRangeThemeStyleJSON } from '@univerjs/sheets';
19
19
  import { ICommandService, ILogService, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService } from '@univerjs/core';
@@ -763,4 +763,34 @@ export declare class FWorkbook extends FBaseInitialable {
763
763
  * ```
764
764
  */
765
765
  removeStyles(styleKeys: string[]): void;
766
+ /**
767
+ * Get the workbook's iterative calculation settings.
768
+ * Missing or invalid settings use the defaults: iteration disabled, 100 iterations and a maximum change of 0.001.
769
+ * @returns {IWorkbookCalculationSettings} A copy of the normalized workbook calculation settings.
770
+ * @example
771
+ * ```ts
772
+ * const fWorkbook = univerAPI.getActiveWorkbook();
773
+ * const settings = fWorkbook.getCalculationSettings();
774
+ * console.log(settings.iterativeCalculation, settings.maxIterations, settings.maxChange);
775
+ * ```
776
+ */
777
+ getCalculationSettings(): IWorkbookCalculationSettings;
778
+ /**
779
+ * Set iterative calculation settings for the entire workbook through an undoable command.
780
+ * @param {IWorkbookCalculationSettings} settings The complete calculation settings.
781
+ * Set `iterativeCalculation` to enable or disable iterative evaluation of circular references.
782
+ * `maxIterations` must be an integer from 1 to 32767, and `maxChange` must be a finite positive number.
783
+ * @returns {boolean} Whether the settings command succeeded. Returns false if the workbook cannot be edited or found.
784
+ * @example
785
+ * ```ts
786
+ * const fWorkbook = univerAPI.getActiveWorkbook();
787
+ * const success = fWorkbook.setCalculationSettings({
788
+ * iterativeCalculation: true,
789
+ * maxIterations: 100,
790
+ * maxChange: 0.001,
791
+ * });
792
+ * console.log('Calculation settings updated:', success);
793
+ * ```
794
+ */
795
+ setCalculationSettings(settings: IWorkbookCalculationSettings): boolean;
766
796
  }
@@ -102,6 +102,7 @@ export type { ISetRowHiddenCommandParams, ISetSpecificRowsVisibleCommandParams,
102
102
  export { AFFECT_LAYOUT_STYLES, ResetBackgroundColorCommand, ResetTextColorCommand, SetBackgroundColorCommand, SetBoldCommand, SetFontFamilyCommand, SetFontSizeCommand, SetHorizontalTextAlignCommand, SetItalicCommand, SetOverlineCommand, SetShrinkToFitCommand, SetStrikeThroughCommand, SetStyleCommand, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, } from './commands/commands/set-style.command';
103
103
  export type { ISetColorCommandParams, ISetFontFamilyCommandParams, ISetFontSizeCommandParams, ISetHorizontalTextAlignCommandParams, ISetShrinkToFitCommandParams, ISetStyleCommandParams, ISetTextRotationCommandParams, ISetTextWrapCommandParams, ISetVerticalTextAlignCommandParams, IStyleTypeValue, } from './commands/commands/set-style.command';
104
104
  export { SetTabColorCommand } from './commands/commands/set-tab-color.command';
105
+ export { SetWorkbookCalculationSettingsCommand } from './commands/commands/set-workbook-calculation-settings.command';
105
106
  export { SetWorkbookNameCommand } from './commands/commands/set-workbook-name.command';
106
107
  export type { ISetWorkbookNameCommandParams } from './commands/commands/set-workbook-name.command';
107
108
  export { SetWorksheetActivateCommand } from './commands/commands/set-worksheet-activate.command';
@@ -193,6 +194,8 @@ export { SetRowHiddenMutation, SetRowVisibleMutation } from './commands/mutation
193
194
  export type { ISetRowHiddenMutationParams, ISetRowVisibleMutationParams, } from './commands/mutations/set-row-visible.mutation';
194
195
  export { SetTabColorMutation } from './commands/mutations/set-tab-color.mutation';
195
196
  export type { ISetTabColorMutationParams } from './commands/mutations/set-tab-color.mutation';
197
+ export { SetWorkbookCalculationSettingsMutation } from './commands/mutations/set-workbook-calculation-settings.mutation';
198
+ export type { ISetWorkbookCalculationSettingsMutationParams } from './commands/mutations/set-workbook-calculation-settings.mutation';
196
199
  export { SetWorkbookNameMutation } from './commands/mutations/set-workbook-name.mutation';
197
200
  export type { ISetWorkbookNameMutationParams } from './commands/mutations/set-workbook-name.mutation';
198
201
  export { SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory, } from './commands/mutations/set-worksheet-col-width.mutation';
@@ -15,8 +15,8 @@
15
15
  */
16
16
  import type { IDisposable, IRange, Nullable } from '@univerjs/core';
17
17
  import type { Observable } from 'rxjs';
18
- import type { IAutoFillLocation, IAutoFillRule, ISheetAutoFillHook } from './type';
19
18
  import { Direction, Disposable, ICommandService, Injector, IUndoRedoService, IUniverInstanceService } from '@univerjs/core';
19
+ import type { IAutoFillLocation, IAutoFillRule, ISheetAutoFillHook } from './type';
20
20
  import { AUTO_FILL_APPLY_TYPE } from './type';
21
21
  export interface IAutoFillService {
22
22
  applyType$: Observable<AUTO_FILL_APPLY_TYPE>;
@@ -34,7 +34,7 @@ export interface IAutoFillService {
34
34
  setFillingStyle(isFillingStyle: boolean): void;
35
35
  registerRule(rule: IAutoFillRule): void;
36
36
  getAllHooks(): ISheetAutoFillHook[];
37
- getActiveHooks(): ISheetAutoFillHook[];
37
+ getActiveHooks(applyType?: AUTO_FILL_APPLY_TYPE): ISheetAutoFillHook[];
38
38
  addHook(hook: ISheetAutoFillHook): IDisposable;
39
39
  fillData(applyType: AUTO_FILL_APPLY_TYPE): boolean;
40
40
  triggerAutoFill(unitId: string, subUnitId: string, source: IRange, target: IRange, manualApplyType?: AUTO_FILL_APPLY_TYPE): Promise<boolean>;
@@ -71,7 +71,7 @@ export declare class AutoFillService extends Disposable implements IAutoFillServ
71
71
  registerRule(rule: IAutoFillRule): void;
72
72
  getRules(): IAutoFillRule[];
73
73
  getAllHooks(): ISheetAutoFillHook[];
74
- getActiveHooks(): ISheetAutoFillHook[];
74
+ getActiveHooks(applyType?: AUTO_FILL_APPLY_TYPE): ISheetAutoFillHook[];
75
75
  get applyType(): AUTO_FILL_APPLY_TYPE;
76
76
  set applyType(type: AUTO_FILL_APPLY_TYPE);
77
77
  get menu(): IApplyMenuItem[];
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Direction, IAccessor, ICellData, IMutationInfo, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
17
- import type { IDiscreteRange } from '../../basics';
17
+ import type { IDiscreteRange } from '../../basics/interfaces/selection-config';
18
18
  export declare enum AUTO_FILL_APPLY_TYPE {
19
19
  COPY = "COPY",
20
20
  SERIES = "SERIES",
@@ -50,11 +50,18 @@ export interface ISheetAutoFillHook {
50
50
  bindUnit?: string;
51
51
  disable?: (location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE) => boolean;
52
52
  onBeforeFillData?(location: IAutoFillLocation, direction: Direction): AUTO_FILL_APPLY_TYPE | void;
53
+ /** Prepare and validate without mutations; the returned callback captures undo data after reverting a previous fill. */
54
+ onPrepareFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE): () => {
55
+ undos: IMutationInfo[];
56
+ redos: IMutationInfo[];
57
+ };
53
58
  onFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE): {
54
59
  undos: IMutationInfo[];
55
60
  redos: IMutationInfo[];
56
61
  };
57
62
  onAfterFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE): boolean | void;
63
+ /** Validate proposed values before reverting or applying any fill mutations. Throw to reject the entire fill. */
64
+ onValidateFillData?(location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
58
65
  onBeforeSubmit?: (location: IAutoFillLocation, direction: Direction, applyType: AUTO_FILL_APPLY_TYPE, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>) => void;
59
66
  }
60
67
  export type IAutoFillCopyDataInTypeIndexInfo = number[];
@@ -14,6 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { UnitAction } from '@univerjs/protocol';
17
- import { WorkbookCommentPermission } from '../permission-point';
18
- export declare const getAllWorkbookPermissionPoint: () => (typeof WorkbookCommentPermission)[];
17
+ import { WorkbookEditablePermission } from '../permission-point';
18
+ export declare const getAllWorkbookPermissionPoint: () => (typeof WorkbookEditablePermission)[];
19
19
  export declare const defaultWorkbookPermissionPoints: UnitAction[];