@univerjs/sheets 0.2.1 → 0.2.3

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,14 @@
1
+ {
2
+ "sheets": {
3
+ "tabs": {
4
+ "sheetCopy": "(Bản sao {0})",
5
+ "sheet": "Bảng tính"
6
+ },
7
+ "info": {
8
+ "overlappingSelections": "Không thể sử dụng lệnh này trên các vùng chọn chồng chéo nhau",
9
+ "acrossMergedCell": "Không thể vượt qua các ô đã hợp nhất",
10
+ "partOfCell": "Chỉ chọn một phần của ô đã hợp nhất",
11
+ "hideSheet": "Không có bảng tính nào hiển thị sau khi ẩn"
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "sheets": {
3
+ "tabs": {
4
+ "sheetCopy": "(副本{0})",
5
+ "sheet": "工作表"
6
+ },
7
+ "info": {
8
+ "overlappingSelections": "無法對重疊選區使用該命令",
9
+ "acrossMergedCell": "無法跨越合併儲存格",
10
+ "partOfCell": "僅選擇了合併儲存格的一部份",
11
+ "hideSheet": "隱藏後無可見工作表"
12
+ }
13
+ }
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 {};
@@ -0,0 +1,8 @@
1
+ import { ICellData, IStyleData, Nullable, Styles } from '@univerjs/core';
2
+
3
+ export declare function handleStyle(styles: Styles, oldVal: ICellData, newVal: ICellData): void;
4
+ /**
5
+ * Convert old style data for storage
6
+ * @param style
7
+ */
8
+ export declare function transformStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>): Nullable<IStyleData>;
@@ -0,0 +1,19 @@
1
+ import { CellValue, ICellData, Nullable, Styles, CellValueType } from '@univerjs/core';
2
+
3
+ /**
4
+ * Get cell value type by style, new value and old value.
5
+ * If the new value contains t, then take t directly. In other cases, we need to dynamically determine based on actual data and styles
6
+ * @param newVal
7
+ * @param oldVal
8
+ * @returns
9
+ */
10
+ export declare function getCellType(styles: Styles, newVal: ICellData, oldVal: ICellData): void | CellValueType | null;
11
+ /**
12
+ * Get the correct type after setting values to a cell.
13
+ *
14
+ * @param v the new value
15
+ * @param type the old type
16
+ * @returns the new type
17
+ */
18
+ export declare function checkCellValueType(v: Nullable<CellValue>, type: Nullable<CellValueType>): Nullable<CellValueType>;
19
+ export declare function getCellTypeByPattern(cell: ICellData, pattern: string): Nullable<CellValueType>;
@@ -0,0 +1,22 @@
1
+ import { ICellData, Nullable, CellValueType } from '@univerjs/core';
2
+
3
+ /**
4
+ * Get cell value from new value by type
5
+ * @param type
6
+ * @param cell
7
+ * @returns
8
+ */
9
+ export declare function getCellValue(type: Nullable<CellValueType>, cell: ICellData): Nullable<import('@univerjs/core').CellValue>;
10
+ /**
11
+ * Check if the value can be casted to a boolean.
12
+ * @internal
13
+ * @param value
14
+ * @returns It would return null if the value cannot be casted to a boolean, and would return the boolean value if it can be casted.
15
+ */
16
+ export declare function extractBooleanValue(value: Nullable<string | number | boolean>): Nullable<boolean>;
17
+ /**
18
+ * Supplement the data of the cell, set the other value to NULL, Used to reset properties when undoing
19
+ * @param value
20
+ * @returns
21
+ */
22
+ export declare function setNull(value: Nullable<ICellData>): ICellData | null;
@@ -1,4 +1,4 @@
1
- import { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, Worksheet } from '@univerjs/core';
1
+ import { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, UniverInstanceService, Workbook, Worksheet } from '@univerjs/core';
2
2
  import { IExpandParams } from '../commands/commands/utils/selection-utils';
3
3
 
4
4
  export declare const groupByKey: <T = Record<string, unknown>>(arr: T[], key: string, blankKey?: string) => Record<string, T[]>;
@@ -17,3 +17,4 @@ export declare function generateNullCell(range: IRange[]): IObjectMatrixPrimitiv
17
17
  */
18
18
  export declare function generateNullCellValue(range: IRange[]): IObjectMatrixPrimitiveType<ICellData>;
19
19
  export declare function generateNullCellStyle(ranges: IRange[]): IObjectMatrixPrimitiveType<ICellData>;
20
+ export declare function getActiveWorksheet(instanceService: UniverInstanceService): [Nullable<Workbook>, Nullable<Worksheet>];
@@ -1,4 +1,4 @@
1
- import { CellValue, IBorderData, ICellData, ICopyToOptionsData, IDocumentData, IMutation, IMutationCommonParams, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable, CellValueType } from '@univerjs/core';
1
+ import { ICellData, ICopyToOptionsData, IMutation, IMutationCommonParams, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
2
2
  import { IAccessor } from '@wendellhu/redi';
3
3
 
4
4
  /** Params of `SetRangeValuesMutation` */
@@ -31,49 +31,3 @@ export declare const SetRangeValuesUndoMutationFactory: (accessor: IAccessor, pa
31
31
  Intercept 15-digit number reference function truncateNumber
32
32
  */
33
33
  export declare const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, boolean>;
34
- /**
35
- * Get the correct type after setting values to a cell.
36
- *
37
- * @param v the new value
38
- * @param oldType the old type
39
- * @returns the new type
40
- */
41
- export declare function checkCellValueType(v: Nullable<CellValue>, oldType: Nullable<CellValueType>): Nullable<CellValueType>;
42
- /**
43
- * Check if the value can be casted to a boolean.
44
- * @internal
45
- * @param value
46
- * @returns It would return null if the value cannot be casted to a boolean, and would return the boolean value if it can be casted.
47
- */
48
- export declare function extractBooleanValue(value: Nullable<string | number | boolean>): Nullable<boolean>;
49
- /**
50
- * Convert old style data for storage
51
- * @param style
52
- */
53
- export declare function transformStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>): Nullable<IStyleData>;
54
- /**
55
- * Convert old style normal key for storage
56
- *
57
- * @param style
58
- */
59
- export declare function transformNormalKey(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>): Nullable<IStyleData>;
60
- /**
61
- * Convert old style border for storage
62
- *
63
-
64
- * @param style
65
- */
66
- export declare function transformBorders(oldBorders: IBorderData, newBorders: Nullable<IBorderData>): IBorderData;
67
- /**
68
- * merge new style to old style
69
- *
70
- * @param oldStyle
71
- * @param newStyle
72
- */
73
- export declare function mergeStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>, isRichText?: boolean): Nullable<IStyleData>;
74
- /**
75
- * Find the text style of all paragraphs and modify it to the new style
76
- * @param p
77
- * @param newStyle
78
- */
79
- export declare function mergeRichTextStyle(p: IDocumentData, newStyle: Nullable<IStyleData>): void;
@@ -1,11 +1,10 @@
1
1
  import { IOperation } from '@univerjs/core';
2
2
  import { ISelectionWithStyle } from '../../basics/selection';
3
- import { SelectionMoveType } from '../../services/selection-manager.service';
3
+ import { SelectionMoveType } from '../../services/selections/selection-manager.service';
4
4
 
5
5
  export interface ISetSelectionsOperationParams {
6
6
  unitId: string;
7
7
  subUnitId: string;
8
- pluginName: string;
9
8
  selections: ISelectionWithStyle[];
10
9
  type?: SelectionMoveType;
11
10
  }
@@ -0,0 +1,4 @@
1
+ import { IAccessor } from '@wendellhu/redi';
2
+ import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';
3
+
4
+ export declare function getSelectionsService(accessor: IAccessor): SheetsSelectionsService;
@@ -3,7 +3,7 @@ import { Injector } from '@wendellhu/redi';
3
3
  import { IRemoveWorksheetMergeMutationParams } from '../basics/interfaces/mutation-interface';
4
4
  import { RefRangeService } from '../services/ref-range/ref-range.service';
5
5
  import { EffectRefRangeParams } from '../services/ref-range/type';
6
- import { SelectionManagerService } from '../services/selection-manager.service';
6
+ import { SheetsSelectionsService } from '../services/selections/selection-manager.service';
7
7
  import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';
8
8
 
9
9
  /**
@@ -21,7 +21,7 @@ export declare class MergeCellController extends Disposable {
21
21
  private _sheetInterceptorService;
22
22
  private _selectionManagerService;
23
23
  disposableCollection: DisposableCollection;
24
- constructor(_commandService: ICommandService, _refRangeService: RefRangeService, _univerInstanceService: IUniverInstanceService, _injector: Injector, _sheetInterceptorService: SheetInterceptorService, _selectionManagerService: SelectionManagerService);
24
+ constructor(_commandService: ICommandService, _refRangeService: RefRangeService, _univerInstanceService: IUniverInstanceService, _injector: Injector, _sheetInterceptorService: SheetInterceptorService, _selectionManagerService: SheetsSelectionsService);
25
25
  private _initCommandInterceptor;
26
26
  refRangeHandle(config: EffectRefRangeParams, unitId: string, subUnitId: string): {
27
27
  redos: {
@@ -20,6 +20,7 @@ export { convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, getNorma
20
20
  export { rangeMerge, createTopMatrixFromRanges, createTopMatrixFromMatrix, findAllRectangle, RangeMergeUtil } from './basics/rangeMerge';
21
21
  export { getSheetCommandTarget, getSheetCommandTargetWorkbook, getSheetMutationTarget } from './commands/commands/utils/target-util';
22
22
  export { alignToMergedCellsBorders, getCellAtRowCol, setEndForRange, isSingleCellSelection } from './commands/commands/utils/selection-utils';
23
+ export { getSelectionsService } from './commands/utils/selection-command-util';
23
24
  export { followSelectionOperation, getPrimaryForRange } from './commands/commands/utils/selection-utils';
24
25
  export { handleDeleteRangeMutation } from './commands/utils/handle-range-mutation';
25
26
  export { getInsertRangeMutations, getRemoveRangeMutations } from './commands/utils/handle-range-mutation';
@@ -30,7 +31,8 @@ export { BorderStyleManagerService, type IBorderInfo } from './services/border-s
30
31
  export * from './services/permission/permission-point';
31
32
  export { WorksheetPermissionService } from './services/permission/worksheet-permission/worksheet-permission.service';
32
33
  export { WorkbookPermissionService } from './services/permission/workbook-permission/workbook-permission.service';
33
- export { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService, SelectionMoveType, } from './services/selection-manager.service';
34
+ export { SheetsSelectionsService, WorkbookSelections, SelectionMoveType, DISABLE_NORMAL_SELECTIONS, } from './services/selections/selection-manager.service';
35
+ export { IRefSelectionsService } from './services/selections/ref-selections.service';
34
36
  export { getAddMergeMutationRangeByType } from './controllers/merge-cell.controller';
35
37
  export { NumfmtService } from './services/numfmt/numfmt.service';
36
38
  export type { INumfmtItem, INumfmtItemWithCache } from './services/numfmt/type';
@@ -0,0 +1,4 @@
1
+ import { default as zhCN } from './zh-CN';
2
+
3
+ declare const locale: typeof zhCN;
4
+ export default locale;
@@ -0,0 +1,4 @@
1
+ import { default as zhCN } from './zh-CN';
2
+
3
+ declare const locale: typeof zhCN;
4
+ export default locale;
@@ -1,6 +1,6 @@
1
1
  import { IMutationInfo, IRange, Nullable, Disposable, ICommandService, InterceptorManager, IUniverInstanceService } from '@univerjs/core';
2
2
  import { IDisposable } from '@wendellhu/redi';
3
- import { SelectionManagerService } from '../selection-manager.service';
3
+ import { SheetsSelectionsService } from '../selections/selection-manager.service';
4
4
  import { SheetInterceptorService } from '../sheet-interceptor/sheet-interceptor.service';
5
5
  import { EffectRefRangeParams } from './type';
6
6
 
@@ -24,7 +24,7 @@ export declare class RefRangeService extends Disposable {
24
24
  MERGE_UNDO: import('@univerjs/core').IInterceptor<IMutationInfo<object>[], null>;
25
25
  }>;
26
26
  private _watchRanges;
27
- constructor(_commandService: ICommandService, _sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _selectionManagerService: SelectionManagerService);
27
+ constructor(_commandService: ICommandService, _sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _selectionManagerService: SheetsSelectionsService);
28
28
  watchRange(unitId: string, subUnitId: string, range: IRange, callback: WatchRangeCallback, skipIntersects?: boolean): IDisposable;
29
29
  private _refRangeManagerMap;
30
30
  private _serializer;
@@ -3,26 +3,26 @@ import { IMoveColumnsMutationParams, IMoveRowsMutationParams } from '../../comma
3
3
  import { IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowsMutationParams, IRemoveSheetMutationParams } from '../../basics';
4
4
  import { IMoveRangeMutationParams } from '../../commands/mutations/move-range.mutation';
5
5
  import { ISheetCommandSharedParams } from '../../commands/utils/interface';
6
- import { SelectionManagerService } from '../selection-manager.service';
6
+ import { SheetsSelectionsService } from '../selections/selection-manager.service';
7
7
  import { EffectRefRangeParams, IDeleteRangeMoveLeftCommand, IDeleteRangeMoveUpCommand, IInsertColCommand, IInsertRangeMoveDownCommand, IInsertRangeMoveRightCommand, IInsertRowCommand, IMoveColsCommand, IMoveRangeCommand, IMoveRowsCommand, IOperator, IRemoveRowColCommand, IReorderRangeCommand } from './type';
8
8
 
9
9
  export declare const handleRangeTypeInput: (range: IRange) => {
10
- startColumn: number;
11
- endColumn: number;
12
10
  rangeType?: RANGE_TYPE;
13
11
  startAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
14
12
  endAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
15
13
  startRow: number;
16
14
  endRow: number;
17
- };
18
- export declare const handleRangeTypeOutput: (range: IRange, maxRow: number, maxCol: number) => {
19
15
  startColumn: number;
20
16
  endColumn: number;
17
+ };
18
+ export declare const handleRangeTypeOutput: (range: IRange, maxRow: number, maxCol: number) => {
21
19
  rangeType?: RANGE_TYPE;
22
20
  startAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
23
21
  endAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
24
22
  startRow: number;
25
23
  endRow: number;
24
+ startColumn: number;
25
+ endColumn: number;
26
26
  };
27
27
  export declare const rotateRange: (range: IRange) => IRange;
28
28
  interface ILine {
@@ -67,7 +67,7 @@ export declare const handleDeleteRangeMoveUpCommon: (param: IDeleteRangeMoveUpCo
67
67
  export declare const runRefRangeMutations: (operators: IOperator[], range: IRange) => IRange | null;
68
68
  export declare const handleDefaultRangeChangeWithEffectRefCommands: (range: IRange, commandInfo: ICommandInfo) => IRange | null;
69
69
  export declare const handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests: (range: IRange, commandInfo: ICommandInfo, deps: {
70
- selectionManagerService: SelectionManagerService;
70
+ selectionManagerService: SheetsSelectionsService;
71
71
  }) => IRange | null;
72
72
  type MutationsAffectRange = ISheetCommandSharedParams | IRemoveSheetMutationParams | IMoveRowsMutationParams | IMoveColumnsMutationParams | IRemoveRowsMutationParams | IRemoveColMutationParams | IInsertColMutationParams | IInsertRowMutationParams | IMoveRangeMutationParams;
73
73
  export declare const handleCommonDefaultRangeChangeWithEffectRefCommands: (range: IRange, commandInfo: ICommandInfo) => IRange | IRange[] | null;
@@ -81,7 +81,7 @@ export declare const handleCommonDefaultRangeChangeWithEffectRefCommands: (range
81
81
  */
82
82
  export declare function adjustRangeOnMutation(range: Readonly<IRange>, mutation: IMutationInfo<MutationsAffectRange>): Nullable<IRange>;
83
83
  export declare function getEffectedRangesOnCommand(command: EffectRefRangeParams, deps: {
84
- selectionManagerService: SelectionManagerService;
84
+ selectionManagerService: SheetsSelectionsService;
85
85
  }): IRange[];
86
86
  export declare function getEffectedRangesOnMutation(mutation: IMutationInfo<MutationsAffectRange>): IRange[] | undefined;
87
87
  export {};
@@ -0,0 +1,9 @@
1
+ import { SheetsSelectionsService } from '@univerjs/sheets';
2
+
3
+ /**
4
+ * Ref selections service reuses code of `SelectionManagerService`. And it only contains ref selections
5
+ * when user is editing formula.
6
+ *
7
+ * Its data should be cleared by the caller quit editing formula and reconstructed when user starts editing.
8
+ */
9
+ export declare const IRefSelectionsService: import('@wendellhu/redi').IdentifierDecorator<SheetsSelectionsService>;
@@ -0,0 +1,73 @@
1
+ import { ISelectionCell, Nullable, Workbook, Disposable, IUniverInstanceService, RxDisposable } from '@univerjs/core';
2
+ import { Observable } from 'rxjs';
3
+ import { ISelectionWithStyle } from '../../basics/selection';
4
+
5
+ export interface ISelectionManagerSearchParam {
6
+ unitId: string;
7
+ sheetId: string;
8
+ }
9
+ export declare enum SelectionMoveType {
10
+ MOVE_START = 0,
11
+ MOVING = 1,
12
+ MOVE_END = 2
13
+ }
14
+ export declare class SheetsSelectionsService extends RxDisposable {
15
+ private readonly _instanceSrv;
16
+ private get _currentSelectionPos();
17
+ readonly selectionMoveStart$: Observable<Nullable<ISelectionWithStyle[]>>;
18
+ readonly selectionMoving$: Observable<Nullable<ISelectionWithStyle[]>>;
19
+ readonly selectionMoveEnd$: Observable<ISelectionWithStyle[]>;
20
+ constructor(_instanceSrv: IUniverInstanceService);
21
+ /** Clear all selections in all workbooks. */
22
+ clear(): void;
23
+ getCurrentSelections(): Readonly<ISelectionWithStyle[]>;
24
+ getCurrentLastSelection(): Readonly<Nullable<ISelectionWithStyle & {
25
+ primary: ISelectionCell;
26
+ }>>;
27
+ addSelections(selectionsData: ISelectionWithStyle[]): void;
28
+ addSelections(unitId: string, worksheetId: string, selectionDatas: ISelectionWithStyle[]): void;
29
+ setSelections(selectionDatas: ISelectionWithStyle[], type?: SelectionMoveType): void;
30
+ setSelections(unitId: string, worksheetId: string, selectionDatas: ISelectionWithStyle[], type?: SelectionMoveType): void;
31
+ clearCurrentSelections(): void;
32
+ /**
33
+ * Determine whether multiple current selections overlap
34
+ *
35
+ * @deprecated this should be extracted to an pure function
36
+ */
37
+ isOverlapping(): boolean;
38
+ private _getCurrentSelections;
39
+ getWorkbookSelections(unitId: string): WorkbookSelections;
40
+ private _workbookSelections;
41
+ private _ensureWorkbookSelection;
42
+ }
43
+ /**
44
+ * This class manages selections in a single workbook.
45
+ */
46
+ export declare class WorkbookSelections extends Disposable {
47
+ private readonly _workbook;
48
+ private readonly _selectionMoveStart$;
49
+ readonly selectionMoveStart$: Observable<Nullable<ISelectionWithStyle[]>>;
50
+ private readonly _selectionMoving$;
51
+ readonly selectionMoving$: Observable<Nullable<ISelectionWithStyle[]>>;
52
+ private readonly _selectionMoveEnd$;
53
+ readonly selectionMoveEnd$: Observable<ISelectionWithStyle[]>;
54
+ private readonly _beforeSelectionMoveEnd$;
55
+ readonly beforeSelectionMoveEnd$: Observable<ISelectionWithStyle[]>;
56
+ constructor(_workbook: Workbook);
57
+ dispose(): void;
58
+ /** Clear all selections in this workbook. */
59
+ clear(): void;
60
+ addSelections(sheetId: string, selectionDatas: ISelectionWithStyle[]): void;
61
+ setSelections(sheetId: string, selectionDatas: ISelectionWithStyle[], type?: SelectionMoveType): void;
62
+ getCurrentSelections(): Readonly<ISelectionWithStyle[]>;
63
+ getSelectionOfWorksheet(sheetId: string): ISelectionWithStyle[];
64
+ private _getCurrentSelections;
65
+ getCurrentLastSelection(): Readonly<Nullable<ISelectionWithStyle & {
66
+ primary: ISelectionCell;
67
+ }>>;
68
+ private _worksheetSelections;
69
+ private _ensureSheetSelection;
70
+ private _emitOnEnd;
71
+ }
72
+ /** An context key to disable normal selections if its value is set to `true`. */
73
+ export declare const DISABLE_NORMAL_SELECTIONS = "DISABLE_NORMAL_SELECTIONS";