@univerjs/core 0.1.0-beta.2 → 0.1.0-beta.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.
@@ -13,5 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IGridRangeName } from './reference';
17
- export declare function deserializeRangeForR1C1(refString: string, currentRow?: number, currentColumn?: number): IGridRangeName;
16
+ export declare function throttle<T extends (...args: any[]) => any>(fn: T, wait?: number): T;
@@ -15,8 +15,8 @@
15
15
  */
16
16
  import type { Nullable } from '../../shared';
17
17
  import type { IDocumentBody, IDocumentData, IDocumentRenderConfig } from '../../types/interfaces/i-document-data';
18
- import { type IPaddingData } from '../../types/interfaces/i-style-data';
19
- import { type DocMutationParams } from './mutation-types';
18
+ import type { IPaddingData } from '../../types/interfaces/i-style-data';
19
+ import type { TextXAction } from './mutation-types';
20
20
  export declare const DEFAULT_DOC: {
21
21
  id: string;
22
22
  documentStyle: {};
@@ -62,7 +62,7 @@ export declare class DocumentDataModel extends DocumentDataModelSimple {
62
62
  reset(snapshot: Partial<IDocumentData>): void;
63
63
  getSelfOrHeaderFooterModel(segmentId?: string): DocumentDataModel;
64
64
  getUnitId(): string;
65
- apply(mutations: DocMutationParams[]): DocMutationParams[];
65
+ apply(mutations: TextXAction[]): TextXAction[];
66
66
  sliceBody(startOffset: number, endOffset: number): Nullable<IDocumentBody>;
67
67
  private _updateApply;
68
68
  private _deleteApply;
@@ -18,7 +18,7 @@ import type { IDocumentBody } from '../../types/interfaces/i-document-data';
18
18
  /**
19
19
  * Retain mutation is used to move the cursor or to update properties of the text in the given range.
20
20
  */
21
- export interface IRetainMutationParams {
21
+ export interface IRetainAction {
22
22
  t: 'r';
23
23
  len: number;
24
24
  body?: IDocumentBody;
@@ -28,7 +28,7 @@ export interface IRetainMutationParams {
28
28
  /**
29
29
  * Insert mutation is used to insert text (maybe with rich text properties) at the given position.
30
30
  */
31
- export interface IInsertMutationParams {
31
+ export interface IInsertAction {
32
32
  t: 'i';
33
33
  body: IDocumentBody;
34
34
  len: number;
@@ -38,10 +38,10 @@ export interface IInsertMutationParams {
38
38
  /**
39
39
  * Delete mutation is used to delete text at the given position.
40
40
  */
41
- export interface IDeleteMutationParams {
41
+ export interface IDeleteAction {
42
42
  t: 'd';
43
- line: number;
44
43
  len: number;
44
+ line: number;
45
45
  segmentId?: string;
46
46
  }
47
- export type DocMutationParams = IRetainMutationParams | IInsertMutationParams | IDeleteMutationParams;
47
+ export type TextXAction = IRetainAction | IInsertAction | IDeleteAction;
@@ -0,0 +1,27 @@
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
+ import type { UpdateDocsAttributeType } from '../../../shared/command-enum';
17
+ import type { IDocumentBody } from '../../../types/interfaces/i-document-data';
18
+ import type { TextXAction } from '../mutation-types';
19
+ export declare class TextX {
20
+ static compose(thisActions: TextXAction[], otherActions: TextXAction[]): TextXAction[];
21
+ private _actions;
22
+ insert(len: number, body: IDocumentBody, segmentId: string): this;
23
+ retain(len: number, segmentId: string, body?: IDocumentBody, coverType?: UpdateDocsAttributeType): this;
24
+ delete(len: number, segmentId: string): this;
25
+ serialize(): TextXAction[];
26
+ push(...args: TextXAction[]): this;
27
+ }
@@ -35,7 +35,7 @@ export declare enum DataStreamTreeTokenType {
35
35
  PAGE_BREAK = "\f",// 换页
36
36
  DOCS_END = "\0",// 文档结尾
37
37
  TAB = "\t",// 制表符
38
- CUSTOM_BLOCK = "\b",// 图片 mention等不参与文档流的场景
38
+ CUSTOM_BLOCK = "\b",// 图片 mention 等不参与文档流的场景
39
39
  LETTER = "",
40
40
  SPACE = " "
41
41
  }
@@ -16,14 +16,16 @@
16
16
  export * from './basics';
17
17
  export { dedupe, remove } from './common/array';
18
18
  export { DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, } from './common/const';
19
+ export { throttle } from './common/function';
19
20
  export { MemoryCursor } from './common/memory-cursor';
20
21
  export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
21
22
  export { type ISequenceExecuteResult, sequence, sequenceAsync } from './common/sequence';
22
23
  export * from './docs/data-model';
23
- export { type DocMutationParams, type IDeleteMutationParams, type IInsertMutationParams, type IRetainMutationParams, } from './docs/data-model/mutation-types';
24
+ export { type TextXAction, type IDeleteAction, type IInsertAction, type IRetainAction, } from './docs/data-model/mutation-types';
25
+ export { TextX } from './docs/data-model/text-x/text-x';
24
26
  export * from './observer';
25
27
  export { Plugin, PluginType } from './plugin/plugin';
26
- export { type CommandListener, CommandService, CommandType, type ICommand, type ICommandInfo, ICommandService, type IExecutionOptions, type IMultiCommand, type IMutation, type IMutationCommonParams, type IMutationInfo, type IOperation, type IOperationInfo, sequenceExecute, sequenceExecuteAsync, } from './services/command/command.service';
28
+ export { type CommandListener, CommandService, CommandType, type ICommand, type ICommandInfo, ICommandService, type IExecutionOptions, type IMultiCommand, type IMutation, type IMutationCommonParams, type IMutationInfo, type IOperation, type IOperationInfo, NilCommand, sequenceExecute, sequenceExecuteAsync, } from './services/command/command.service';
27
29
  export { IConfigService } from './services/config/config.service';
28
30
  export * from './services/context/context';
29
31
  export { ContextService, IContextService } from './services/context/context.service';
@@ -43,13 +45,11 @@ export { IResourceManagerService, ISnapshotPersistenceService } from './services
43
45
  export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
44
46
  export { type IUndoRedoCommandInfos, type IUndoRedoItem, IUndoRedoService, type IUndoRedoStatus, LocalUndoRedoService, RedoCommand, UndoCommand, } from './services/undoredo/undoredo.service';
45
47
  export * from './shared';
46
- export { deserializeRangeForR1C1 } from './sheets/r1c1-reference';
47
48
  export type { IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
48
49
  export { composeInterceptors, createInterceptorKey, InterceptorManager } from './common/interceptor';
49
50
  export { normalizeTextRuns } from './docs/data-model/apply-utils/common';
50
51
  export type { PluginCtor } from './plugin/plugin';
51
52
  export { Range } from './sheets/range';
52
- export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, type IAbsoluteRefTypeForRange, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, UNIT_NAME_REGEX, } from './sheets/reference';
53
53
  export { Styles } from './sheets/styles';
54
54
  export { SheetViewModel } from './sheets/view-model';
55
55
  export { getWorksheetUID, Workbook } from './sheets/workbook';
@@ -150,3 +150,4 @@ export declare class CommandService implements ICommandService {
150
150
  }
151
151
  export declare function sequenceExecute(tasks: ICommandInfo[], commandService: ICommandService, options?: IExecutionOptions): import("../../common/sequence").ISequenceExecuteResult;
152
152
  export declare function sequenceExecuteAsync(tasks: ICommandInfo[], commandService: ICommandService, options?: IExecutionOptions): Promise<import("../../common/sequence").ISequenceExecuteResult>;
153
+ export declare const NilCommand: ICommand;
@@ -16,7 +16,9 @@
16
16
  export declare const FOCUSING_SHEET = "FOCUSING_SHEET";
17
17
  export declare const FOCUSING_DOC = "FOCUSING_DOC";
18
18
  export declare const FOCUSING_SLIDE = "FOCUSING_SLIDE";
19
+ /** @deprecated */
19
20
  export declare const FOCUSING_EDITOR_BUT_HIDDEN = "FOCUSING_EDITOR_BUT_HIDDEN";
20
- export declare const FOCUSING_EDITOR = "FOCUSING_EDITOR";
21
+ export declare const EDITOR_ACTIVATED = "EDITOR_ACTIVATED";
21
22
  export declare const FOCUSING_EDITOR_INPUT_FORMULA = "FOCUSING_EDITOR_INPUT_FORMULA";
22
23
  export declare const FOCUSING_FORMULA_EDITOR = "FOCUSING_FORMULA_EDITOR";
24
+ export declare const FOCUSING_UNIVER_EDITOR = "FOCUSING_UNIVER_EDITOR";
@@ -13,19 +13,25 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Observable } from 'rxjs';
16
+ import { Observable } from 'rxjs';
17
17
  import { Disposable } from '../../shared/lifecycle';
18
18
  export interface IContextService {
19
- readonly contextChanged$: Observable<void>;
19
+ readonly contextChanged$: Observable<{
20
+ [key: string]: boolean;
21
+ }>;
20
22
  getContextValue(key: string): boolean;
21
23
  setContextValue(key: string, value: boolean): void;
24
+ subscribeContextValue$(key: string): Observable<boolean>;
22
25
  }
23
26
  export declare const IContextService: import("@wendellhu/redi").IdentifierDecorator<IContextService>;
24
27
  export declare class ContextService extends Disposable implements IContextService {
25
28
  private _contextChanged$;
26
- contextChanged$: Observable<void>;
29
+ readonly contextChanged$: Observable<{
30
+ [key: string]: boolean;
31
+ }>;
27
32
  private readonly _contextMap;
28
33
  dispose(): void;
29
34
  getContextValue(key: string): boolean;
30
35
  setContextValue(key: string, value: boolean): void;
36
+ subscribeContextValue$(key: string): Observable<boolean>;
31
37
  }
@@ -21,8 +21,8 @@ import { LocaleType } from '../../types/enum/locale-type';
21
21
  * This service provides i18n and timezone / location features to other modules.
22
22
  */
23
23
  export declare class LocaleService extends Disposable {
24
- private currentLocale;
25
- private locales;
24
+ private _currentLocale;
25
+ private _locales;
26
26
  localeChanged$: Subject<void>;
27
27
  constructor();
28
28
  /**
@@ -13,9 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IKeyType } from './types';
17
- export declare const error: IKeyType<string>;
16
+ /**
17
+ * Determine whether it is a pure number, "12" and "12e+3" are both true
18
+ * @param val The number or string to be judged
19
+ * @returns Result
20
+ */
18
21
  export declare function isRealNum(val: string | number): boolean;
19
- export declare function datenum_local(v: Date, date1904?: number): number;
20
- export declare function generate(value: string): any;
21
- export declare const update: (a: any, b: any) => any;
@@ -26,7 +26,7 @@ export interface IObjectArrayPrimitiveType<T> {
26
26
  }
27
27
  export declare function getArrayLength<T>(o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): number;
28
28
  export declare function insertMatrixArray<T>(index: number, value: T, o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): void;
29
- export declare function spliceArray<T>(start: number, count: number, o: IObjectArrayPrimitiveType<T>): void;
29
+ export declare function spliceArray<T>(start: number, count: number, o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>, insert?: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>;
30
30
  export declare function concatMatrixArray<T>(source: IObjectArrayPrimitiveType<T>, target: IObjectArrayPrimitiveType<T>): IObjectArrayPrimitiveType<T>;
31
31
  export declare function sliceMatrixArray<T>(start: number, end: number, matrixArray: IObjectArrayPrimitiveType<T>): IObjectArrayPrimitiveType<T>;
32
32
  export declare function moveMatrixArray<T>(fromIndex: number, count: number, toIndex: number, o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): void;
@@ -60,6 +60,10 @@ export declare class ObjectMatrix<T> {
60
60
  setRow(rowNumber: number, row: IObjectArrayPrimitiveType<T>): void;
61
61
  moveRows(start: number, count: number, target: number): void;
62
62
  moveColumns(start: number, count: number, target: number): void;
63
+ insertRows(start: number, count: number): void;
64
+ insertColumns(start: number, count: number): void;
65
+ removeRows(start: number, count: number): void;
66
+ removeColumns(start: number, count: number): void;
63
67
  /**
64
68
  * Return a fragment of the original data matrix. Note that the returned matrix's row matrix would start from
65
69
  * 0 not `startRow`. Neither does its column matrix. If you want to get the original matrix, use `getSlice`.
@@ -29,7 +29,20 @@ export declare class ColumnManager {
29
29
  */
30
30
  getColumnData(): IObjectArrayPrimitiveType<Partial<IColumnData>>;
31
31
  getColVisible(colPos: number): boolean;
32
+ /**
33
+ * Get all hidden columns
34
+ * @param start Start index
35
+ * @param end End index
36
+ * @returns Hidden columns range list
37
+ */
32
38
  getHiddenCols(start?: number, end?: number): IRange[];
39
+ /**
40
+ * Get all visible columns
41
+ * @param start Start index
42
+ * @param end End index
43
+ * @returns Visible columns range list
44
+ */
45
+ getVisibleCols(start?: number, end?: number): IRange[];
33
46
  getColumnDatas(columnPos: number, numColumns: number): IObjectArrayPrimitiveType<Partial<IColumnData>>;
34
47
  /**
35
48
  * Get count of column in the sheet
@@ -45,7 +45,20 @@ export declare class RowManager {
45
45
  * @returns
46
46
  */
47
47
  getRowOrCreate(rowPos: number): Partial<IRowData>;
48
+ /**
49
+ * Get all hidden rows
50
+ * @param start Start index
51
+ * @param end End index
52
+ * @returns Hidden rows range list
53
+ */
48
54
  getHiddenRows(start?: number, end?: number): IRange[];
55
+ /**
56
+ * Get all visible rows
57
+ * @param start Start index
58
+ * @param end End index
59
+ * @returns Visible rows range list
60
+ */
61
+ getVisibleRows(start?: number, end?: number): IRange[];
49
62
  getRowVisible(rowPos: number): boolean;
50
63
  /**
51
64
  * Get count of row in the sheet
@@ -167,6 +167,16 @@ export declare class Worksheet {
167
167
  getHiddenRows(start?: number, end?: number): IRange[];
168
168
  getColVisible(col: number): boolean;
169
169
  getHiddenCols(start?: number, end?: number): IRange[];
170
+ /**
171
+ * Get all visible rows in the sheet.
172
+ * @returns Visible rows range list
173
+ */
174
+ getVisibleRows(): IRange[];
175
+ /**
176
+ * Get all visible columns in the sheet.
177
+ * @returns Visible columns range list
178
+ */
179
+ getVisibleCols(): IRange[];
170
180
  /**
171
181
  * Returns true if this sheet layout is right-to-left. Returns false if the sheet uses the default left-to-right layout.
172
182
  * @returns true if this sheet layout is right-to-left. Returns false if the sheet uses the default left-to-right layout.
@@ -67,29 +67,23 @@ export declare enum WrapStrategy {
67
67
  UNSPECIFIED = 0,
68
68
  /**
69
69
  * Lines that are longer than the cell width will be written in the next cell over, so long as that cell is empty. If the next cell over is non-empty, this behaves the same as CLIP . The text will never wrap to the next line unless the user manually inserts a new line. Example:
70
-
71
-
72
- | First sentence. |
73
- | Manual newline that is very long. <- Text continues into next cell
74
- | Next newline. |
70
+ * | First sentence. |
71
+ * | Manual newline that is very long. <- Text continues into next cell
72
+ * | Next newline. |
75
73
  */
76
74
  OVERFLOW = 1,
77
75
  /**
78
76
  * Lines that are longer than the cell width will be clipped. The text will never wrap to the next line unless the user manually inserts a new line. Example:
79
-
80
-
81
- | First sentence. |
82
- | Manual newline t| <- Text is clipped
83
- | Next newline. |
77
+ * | First sentence. |
78
+ * | Manual newline t| <- Text is clipped
79
+ * | Next newline. |
84
80
  */
85
81
  CLIP = 2,
86
82
  /**
87
83
  * Words that are longer than a line are wrapped at the character level rather than clipped. Example:
88
-
89
-
90
- | Cell has a |
91
- | loooooooooo| <- Word is broken.
92
- | ong word. |
84
+ * | Cell has a |
85
+ * | loooooooooo| <- Word is broken.
86
+ * | ong word. |
93
87
  */
94
88
  WRAP = 3
95
89
  }
@@ -20,7 +20,7 @@ import type { IStyleData } from './i-style-data';
20
20
  /**
21
21
  * Cell value type
22
22
  */
23
- export type ICellV = string | number | boolean;
23
+ export type CellValue = string | number | boolean;
24
24
  /**
25
25
  * Cell data
26
26
  */
@@ -35,7 +35,7 @@ export interface ICellData {
35
35
  /**
36
36
  * Origin value
37
37
  */
38
- v?: Nullable<ICellV>;
38
+ v?: Nullable<CellValue>;
39
39
  t?: Nullable<CellValueType>;
40
40
  f?: Nullable<string>;
41
41
  si?: Nullable<string>;
@@ -47,4 +47,4 @@ export interface ICellDataForSheetInterceptor extends ICellData {
47
47
  export declare function isICellData(value: any): value is ICellData;
48
48
  export declare function getCellValueType(cell: ICellData): CellValueType | null | undefined;
49
49
  export declare function isNullCell(cell: Nullable<ICellData>): boolean;
50
- export declare function isCellV(cell: Nullable<ICellData | ICellV>): boolean;
50
+ export declare function isCellV(cell: Nullable<ICellData | CellValue>): boolean;
@@ -25,7 +25,7 @@ export interface IRowData {
25
25
  /**
26
26
  * is current row self-adaptive to its content, use `ah` to set row height when true, else use `h`.
27
27
  */
28
- isAutoHeight?: boolean;
28
+ ia?: BooleanNumber;
29
29
  /**
30
30
  * auto height
31
31
  */