@univerjs/core 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.
- package/lib/cjs/index.js +10 -10
- package/lib/es/index.js +8406 -7042
- package/lib/types/common/const.d.ts +1 -1
- package/lib/types/common/error.d.ts +18 -0
- package/lib/types/common/unit.d.ts +3 -0
- package/lib/types/docs/data-model/document-data-model.d.ts +4 -0
- package/lib/types/docs/data-model/json-x/json-x.d.ts +2 -1
- package/lib/types/docs/data-model/preset-list-type.d.ts +54 -4
- package/lib/types/docs/data-model/text-x/__tests__/transform-position.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/__tests__/transform.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +2 -2
- package/lib/types/docs/data-model/text-x/text-x.d.ts +31 -1
- package/lib/types/docs/data-model/text-x/transform-utils.d.ts +3 -0
- package/lib/types/docs/data-model/types.d.ts +12 -10
- package/lib/types/index.d.ts +2 -1
- package/lib/types/services/context/context.d.ts +3 -1
- package/lib/types/services/instance/instance.service.d.ts +18 -6
- package/lib/types/services/plugin/plugin.d.ts +1 -1
- package/lib/types/services/plugin/plugin.service.d.ts +1 -0
- package/lib/types/services/resource-manager/resource-manager.service.d.ts +4 -6
- package/lib/types/services/resource-manager/type.d.ts +8 -4
- package/lib/types/services/snapshot/snapshot-transform.d.ts +3 -0
- package/lib/types/services/snapshot/snapshot-utils.d.ts +2 -2
- package/lib/types/shared/shape.d.ts +6 -0
- package/lib/types/shared/tools.d.ts +11 -0
- package/lib/types/sheets/workbook.d.ts +1 -0
- package/lib/types/slides/slide-model.d.ts +24 -2
- package/lib/types/types/enum/text-style.d.ts +3 -1
- package/lib/types/types/interfaces/i-document-data-interceptor.d.ts +5 -1
- package/lib/types/types/interfaces/i-document-data.d.ts +166 -57
- package/lib/types/types/interfaces/i-workbook-data.d.ts +6 -5
- package/lib/umd/index.js +10 -10
- package/package.json +10 -7
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const DOCS_NORMAL_EDITOR_UNIT_ID_KEY = "__INTERNAL_EDITOR__DOCS_NORMAL";
|
|
17
17
|
export declare const DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY = "__INTERNAL_EDITOR__DOCS_FORMULA_BAR";
|
|
18
|
-
export declare const DOCS_ZEN_EDITOR_UNIT_ID_KEY = "
|
|
18
|
+
export declare const DOCS_ZEN_EDITOR_UNIT_ID_KEY = "__INTERNAL_EDITOR__ZEN_EDITOR";
|
|
19
19
|
export declare const DEFAULT_EMPTY_DOCUMENT_VALUE = "\r\n";
|
|
20
20
|
export declare function createInternalEditorID(id: string): string;
|
|
21
21
|
export declare function isInternalEditorID(id: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 declare class CustomCommandExecutionError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UniverType } from '@univerjs/protocol';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
2
3
|
import { Disposable } from '../shared';
|
|
3
4
|
|
|
4
5
|
export { UniverType as UniverInstanceType } from '@univerjs/protocol';
|
|
@@ -6,4 +7,6 @@ export type UnitType = UniverType | number;
|
|
|
6
7
|
export declare abstract class UnitModel<_D = object, T extends UnitType = UnitType> extends Disposable {
|
|
7
8
|
abstract readonly type: T;
|
|
8
9
|
abstract getUnitId(): string;
|
|
10
|
+
abstract name$: Observable<string>;
|
|
11
|
+
abstract setName(name: string): void;
|
|
9
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
1
2
|
import { Nullable } from '../../shared';
|
|
2
3
|
import { IDocumentBody, IDocumentData, IDocumentRenderConfig, IDocumentStyle, IDrawings } from '../../types/interfaces/i-document-data';
|
|
3
4
|
import { IPaddingData } from '../../types/interfaces/i-style-data';
|
|
@@ -18,8 +19,11 @@ interface IDrawingUpdateConfig {
|
|
|
18
19
|
declare class DocumentDataModelSimple extends UnitModel<IDocumentData, UniverInstanceType.UNIVER_DOC> {
|
|
19
20
|
type: UniverInstanceType.UNIVER_DOC;
|
|
20
21
|
getUnitId(): string;
|
|
22
|
+
protected readonly _name$: BehaviorSubject<string>;
|
|
23
|
+
name$: import('rxjs').Observable<string>;
|
|
21
24
|
protected snapshot: IDocumentData;
|
|
22
25
|
constructor(snapshot: Partial<IDocumentData>);
|
|
26
|
+
setName(name: string): void;
|
|
23
27
|
get drawings(): IDrawings | undefined;
|
|
24
28
|
get documentStyle(): IDocumentStyle;
|
|
25
29
|
get lists(): import('../../types/interfaces/i-document-data').ILists | undefined;
|
|
@@ -25,7 +25,8 @@ export declare class JSONX {
|
|
|
25
25
|
[k: string]: Doc;
|
|
26
26
|
} | null | undefined;
|
|
27
27
|
static compose(thisActions: JSONOp, otherActions: JSONOp): JSONOp;
|
|
28
|
-
static transform(
|
|
28
|
+
static transform(thisActions: JSONOp, otherActions: JSONOp, priority: TPriority): json1.JSONOpList | null | undefined;
|
|
29
|
+
static transformPosition(thisActions: JSONOp, index: number, priority?: TPriority): number;
|
|
29
30
|
static invertWithDoc(actions: JSONOp, doc: IDocumentData): JSONOp;
|
|
30
31
|
static isNoop(actions: JSONOp): boolean;
|
|
31
32
|
private static _instance;
|
|
@@ -1,10 +1,60 @@
|
|
|
1
1
|
import { IListData } from '../../types/interfaces/i-document-data';
|
|
2
2
|
|
|
3
|
+
export declare enum QuickListType {
|
|
4
|
+
ORDER_LIST_QUICK_1 = "1.",
|
|
5
|
+
ORDER_LIST_QUICK_2 = "a)",
|
|
6
|
+
ORDER_LIST_QUICK_3 = "a.",
|
|
7
|
+
ORDER_LIST_QUICK_4 = "i.",
|
|
8
|
+
ORDER_LIST_QUICK_5 = "A.",
|
|
9
|
+
ORDER_LIST_QUICK_6 = "I.",
|
|
10
|
+
ORDER_LIST_QUICK_7 = "01."
|
|
11
|
+
}
|
|
3
12
|
export declare enum PresetListType {
|
|
4
13
|
BULLET_LIST = "BULLET_LIST",
|
|
5
|
-
|
|
14
|
+
BULLET_LIST_1 = "BULLET_LIST_1",
|
|
15
|
+
BULLET_LIST_2 = "BULLET_LIST_2",
|
|
16
|
+
BULLET_LIST_3 = "BULLET_LIST_3",
|
|
17
|
+
BULLET_LIST_4 = "BULLET_LIST_4",
|
|
18
|
+
BULLET_LIST_5 = "BULLET_LIST_5",
|
|
19
|
+
/**
|
|
20
|
+
* 1 a i
|
|
21
|
+
*/
|
|
22
|
+
ORDER_LIST = "ORDER_LIST",
|
|
23
|
+
/**
|
|
24
|
+
* 1) a) i)
|
|
25
|
+
*/
|
|
26
|
+
ORDER_LIST_1 = "ORDER_LIST_1",
|
|
27
|
+
/**
|
|
28
|
+
* 1. 1.1. 1.1.1.
|
|
29
|
+
*/
|
|
30
|
+
ORDER_LIST_2 = "ORDER_LIST_2",
|
|
31
|
+
/**
|
|
32
|
+
* A a i
|
|
33
|
+
*/
|
|
34
|
+
ORDER_LIST_3 = "ORDER_LIST_3",
|
|
35
|
+
/**
|
|
36
|
+
* A 1 i
|
|
37
|
+
*/
|
|
38
|
+
ORDER_LIST_4 = "ORDER_LIST_4",
|
|
39
|
+
/**
|
|
40
|
+
* 01 a i
|
|
41
|
+
*/
|
|
42
|
+
ORDER_LIST_5 = "ORDER_LIST_5",
|
|
43
|
+
ORDER_LIST_QUICK_2 = "ORDER_LIST_QUICK_2",
|
|
44
|
+
ORDER_LIST_QUICK_3 = "ORDER_LIST_QUICK_3",
|
|
45
|
+
ORDER_LIST_QUICK_4 = "ORDER_LIST_QUICK_4",
|
|
46
|
+
ORDER_LIST_QUICK_5 = "ORDER_LIST_QUICK_5",
|
|
47
|
+
ORDER_LIST_QUICK_6 = "ORDER_LIST_QUICK_6",
|
|
48
|
+
CHECK_LIST = "CHECK_LIST",
|
|
49
|
+
CHECK_LIST_CHECKED = "CHECK_LIST_CHECKED"
|
|
6
50
|
}
|
|
7
|
-
export declare const PRESET_LIST_TYPE:
|
|
8
|
-
|
|
9
|
-
|
|
51
|
+
export declare const PRESET_LIST_TYPE: Record<string, IListData>;
|
|
52
|
+
export declare const QuickListTypeMap: {
|
|
53
|
+
"1.": PresetListType;
|
|
54
|
+
"a)": PresetListType;
|
|
55
|
+
"a.": PresetListType;
|
|
56
|
+
"i.": PresetListType;
|
|
57
|
+
"A.": PresetListType;
|
|
58
|
+
"I.": PresetListType;
|
|
59
|
+
"01.": PresetListType;
|
|
10
60
|
};
|
|
@@ -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,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 {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICustomBlock, ICustomDecoration, ICustomRange, IDocumentBody, IParagraph, ISectionBreak,
|
|
1
|
+
import { ICustomBlock, ICustomDecoration, ICustomRange, ICustomTable, IDocumentBody, IParagraph, ISectionBreak, ITextRun } from '../../../../types/interfaces';
|
|
2
2
|
|
|
3
3
|
export declare function normalizeTextRuns(textRuns: ITextRun[]): ITextRun[];
|
|
4
4
|
/**
|
|
@@ -28,6 +28,6 @@ export declare function deleteTextRuns(body: IDocumentBody, textLength: number,
|
|
|
28
28
|
export declare function deleteParagraphs(body: IDocumentBody, textLength: number, currentIndex: number): IParagraph[];
|
|
29
29
|
export declare function deleteSectionBreaks(body: IDocumentBody, textLength: number, currentIndex: number): ISectionBreak[];
|
|
30
30
|
export declare function deleteCustomBlocks(body: IDocumentBody, textLength: number, currentIndex: number): ICustomBlock[];
|
|
31
|
-
export declare function deleteTables(body: IDocumentBody, textLength: number, currentIndex: number):
|
|
31
|
+
export declare function deleteTables(body: IDocumentBody, textLength: number, currentIndex: number): ICustomTable[];
|
|
32
32
|
export declare function deleteCustomRanges(body: IDocumentBody, textLength: number, currentIndex: number): ICustomRange[];
|
|
33
33
|
export declare function deleteCustomDecorations(body: IDocumentBody, textLength: number, currentIndex: number, needOffset?: boolean): ICustomDecoration[];
|
|
@@ -8,7 +8,37 @@ export declare class TextX {
|
|
|
8
8
|
static uri: string;
|
|
9
9
|
static apply(doc: IDocumentBody, actions: TextXAction[]): IDocumentBody;
|
|
10
10
|
static compose(thisActions: TextXAction[], otherActions: TextXAction[]): TextXAction[];
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* |(this↓ \| other→) | **insert** | **retain** | **delete** |
|
|
13
|
+
* | ---------------- | ---------- | ---------- | ---------- |
|
|
14
|
+
* | **insert** | Case 1 | Case 2 | Case 2 |
|
|
15
|
+
* | **retain** | Case 1 | Case 5 | Case 4 |
|
|
16
|
+
* | **delete** | Case 1 | Case 3 | Case 3 |
|
|
17
|
+
*
|
|
18
|
+
* Case 1: When the other action type is an insert operation,
|
|
19
|
+
* the insert operation is retained regardless of the type of action this action
|
|
20
|
+
* Case 2: When this action type is an insert operation and the other action type is a
|
|
21
|
+
* non-insert operation, you need to retain the length of this action insert
|
|
22
|
+
* Case 3: When this action is a delete operation, there are two scenarios:
|
|
23
|
+
* 1) When other is a delete operation, since it is a delete operation, this has
|
|
24
|
+
* already been deleted, so the target does not need to be in delete, and it can
|
|
25
|
+
* be continued directly
|
|
26
|
+
* 2) When other is the retain operation, although this action delete occurs first,
|
|
27
|
+
* the delete priority is higher, so the delete operation is retained, and the origin
|
|
28
|
+
* delete has been applied, so it is directly continued
|
|
29
|
+
* Case 4: other is the delete operation, this is the retain operation, and the target delete operation
|
|
30
|
+
* is kept
|
|
31
|
+
* Case 5: When both other and this are retain operations
|
|
32
|
+
* 1) If the other body attribute does not exist, directly retain length
|
|
33
|
+
* 2) If the other body property exists, then execute the TransformBody logic to override it
|
|
34
|
+
*/
|
|
35
|
+
static transform(thisActions: TextXAction[], otherActions: TextXAction[], priority?: TPriority): TextXAction[];
|
|
36
|
+
static _transform(thisActions: TextXAction[], otherActions: TextXAction[], priority?: TPriority): TextXAction[];
|
|
37
|
+
/**
|
|
38
|
+
* Used to transform selection. Why not named transformSelection?
|
|
39
|
+
* Because Univer Doc supports multiple Selections in one document, user need to encapsulate transformSelections at the application layer.
|
|
40
|
+
*/
|
|
41
|
+
static transformPosition(thisActions: TextXAction[], index: number, priority?: boolean): number;
|
|
12
42
|
static isNoop(actions: TextXAction[]): boolean;
|
|
13
43
|
static invert(actions: TextXAction[]): TextXAction[];
|
|
14
44
|
static makeInvertible(actions: TextXAction[], doc: IDocumentBody): TextXAction[];
|
|
@@ -14,21 +14,21 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export declare enum DataStreamTreeNodeType {
|
|
17
|
-
PARAGRAPH =
|
|
18
|
-
SECTION_BREAK =
|
|
19
|
-
TABLE =
|
|
20
|
-
TABLE_ROW =
|
|
21
|
-
TABLE_CELL =
|
|
22
|
-
CUSTOM_BLOCK =
|
|
17
|
+
PARAGRAPH = "PARAGRAPH",// \r 段落
|
|
18
|
+
SECTION_BREAK = "SECTION_BREAK",// \n 章节
|
|
19
|
+
TABLE = "TABLE",
|
|
20
|
+
TABLE_ROW = "TABLE_ROW",
|
|
21
|
+
TABLE_CELL = "TABLE_CELL",
|
|
22
|
+
CUSTOM_BLOCK = "CUSTOM_BLOCK"
|
|
23
23
|
}
|
|
24
24
|
export declare enum DataStreamTreeTokenType {
|
|
25
25
|
PARAGRAPH = "\r",// 段落
|
|
26
26
|
SECTION_BREAK = "\n",// 章节
|
|
27
27
|
TABLE_START = "\u001A",// 表格开始
|
|
28
|
-
TABLE_ROW_START = "\u001B",//
|
|
29
|
-
TABLE_CELL_START = "\u001C",//
|
|
30
|
-
TABLE_CELL_END = "\u001D",//
|
|
31
|
-
TABLE_ROW_END = "\u000E",//
|
|
28
|
+
TABLE_ROW_START = "\u001B",// 表格行开始
|
|
29
|
+
TABLE_CELL_START = "\u001C",// 表格单元格开始
|
|
30
|
+
TABLE_CELL_END = "\u001D",// 表格单元格结束
|
|
31
|
+
TABLE_ROW_END = "\u000E",// 表格行结束
|
|
32
32
|
TABLE_END = "\u000F",// 表格结束
|
|
33
33
|
CUSTOM_RANGE_START = "\u001F",// 自定义范围开始
|
|
34
34
|
CUSTOM_RANGE_END = "\u001E",// 自定义范围结束
|
|
@@ -40,3 +40,5 @@ export declare enum DataStreamTreeTokenType {
|
|
|
40
40
|
LETTER = "",
|
|
41
41
|
SPACE = " "
|
|
42
42
|
}
|
|
43
|
+
/** Wrap your stream in a pair of custom range tokens. */
|
|
44
|
+
export declare function makeCustomRangeStream(stream: string): string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type { Serializable } from './common/json';
|
|
|
17
17
|
export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID } from './docs/data-model/subdocument';
|
|
18
18
|
export { type UnitType, UnitModel, UniverInstanceType } from './common/unit';
|
|
19
19
|
export { Registry, RegistryAsMap } from './common/registry';
|
|
20
|
+
export { CustomCommandExecutionError } from './common/error';
|
|
20
21
|
export { Univer } from './univer';
|
|
21
22
|
export { shallowEqual, isRangesEqual, isUnitRangesEqual } from './common/equal';
|
|
22
23
|
export { isNumeric, isSafeNumeric } from './common/number';
|
|
@@ -86,7 +87,7 @@ export * from './types/const';
|
|
|
86
87
|
export * from './types/enum';
|
|
87
88
|
export * from './types/interfaces';
|
|
88
89
|
export { ISnapshotServerService } from './services/snapshot/snapshot-server.service';
|
|
89
|
-
export { transformSnapshotToWorkbookData, transformWorkbookDataToSnapshot, transformDocumentDataToSnapshot, transformSnapshotToDocumentData, generateTemporarySnap, } from './services/snapshot/snapshot-transform';
|
|
90
|
+
export { transformSnapshotToWorkbookData, transformWorkbookDataToSnapshot, transformDocumentDataToSnapshot, transformSnapshotToDocumentData, generateTemporarySnap, generateTempDocumentSnapshot, } from './services/snapshot/snapshot-transform';
|
|
90
91
|
export { textEncoder, textDecoder } from './services/snapshot/snapshot-utils';
|
|
91
92
|
export { type ILogContext } from './services/log/context';
|
|
92
93
|
export { b64DecodeUnicode, b64EncodeUnicode } from './shared/coder';
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export declare const FOCUSING_UNIT = "FOCUSING_UNIT";
|
|
16
17
|
export declare const FOCUSING_SHEET = "FOCUSING_SHEET";
|
|
17
18
|
export declare const FOCUSING_DOC = "FOCUSING_DOC";
|
|
18
19
|
export declare const FOCUSING_SLIDE = "FOCUSING_SLIDE";
|
|
@@ -21,7 +22,7 @@ export declare const FOCUSING_EDITOR_BUT_HIDDEN = "FOCUSING_EDITOR_BUT_HIDDEN";
|
|
|
21
22
|
export declare const EDITOR_ACTIVATED = "EDITOR_ACTIVATED";
|
|
22
23
|
export declare const FOCUSING_EDITOR_INPUT_FORMULA = "FOCUSING_EDITOR_INPUT_FORMULA";
|
|
23
24
|
/** The focusing state of the formula editor (Fx bar). */
|
|
24
|
-
export declare const
|
|
25
|
+
export declare const FOCUSING_FX_BAR_EDITOR = "FOCUSING_FX_BAR_EDITOR";
|
|
25
26
|
export declare const FOCUSING_UNIVER_EDITOR = "FOCUSING_UNIVER_EDITOR";
|
|
26
27
|
export declare const FOCUSING_EDITOR_STANDALONE = "FOCUSING_EDITOR_INPUT_FORMULA";
|
|
27
28
|
export declare const FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE = "FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE";
|
|
@@ -29,3 +30,4 @@ export declare const FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE = "FOCUSING_U
|
|
|
29
30
|
* The focusing state of the common drawings.
|
|
30
31
|
*/
|
|
31
32
|
export declare const FOCUSING_COMMON_DRAWINGS = "FOCUSING_COMMON_DRAWINGS";
|
|
33
|
+
export declare const FORMULA_EDITOR_ACTIVATED = "FORMULA_EDITOR_ACTIVATED";
|
|
@@ -7,6 +7,15 @@ import { Workbook } from '../../sheets/workbook';
|
|
|
7
7
|
import { IContextService } from '../context/context.service';
|
|
8
8
|
import { UnitModel, UnitType, UniverInstanceType } from '../../common/unit';
|
|
9
9
|
|
|
10
|
+
export type UnitCtor = new (...args: any[]) => UnitModel;
|
|
11
|
+
export interface ICreateUnitOptions {
|
|
12
|
+
/**
|
|
13
|
+
* If Univer should make the new unit as current of its type.
|
|
14
|
+
*
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
makeCurrent?: boolean;
|
|
18
|
+
}
|
|
10
19
|
/**
|
|
11
20
|
* IUniverInstanceService holds all the current univer instances and provides a set of
|
|
12
21
|
* methods to add and remove univer instances.
|
|
@@ -24,14 +33,16 @@ export interface IUniverInstanceService {
|
|
|
24
33
|
unitDisposed$: Observable<UnitModel>;
|
|
25
34
|
/** Subscribe to curtain type of units' disposing. */
|
|
26
35
|
getTypeOfUnitDisposed$<T extends UnitModel>(type: UnitType): Observable<T>;
|
|
36
|
+
/** An observable value that emits the id of the focused unit. */
|
|
27
37
|
focused$: Observable<Nullable<string>>;
|
|
38
|
+
/** Focus a unit. */
|
|
28
39
|
focusUnit(unitId: string | null): void;
|
|
29
40
|
getFocusedUnit(): Nullable<UnitModel>;
|
|
30
41
|
getCurrentUnitForType<T extends UnitModel>(type: UnitType): Nullable<T>;
|
|
31
42
|
setCurrentUnitForType(unitId: string): void;
|
|
32
43
|
getCurrentTypeOfUnit$<T extends UnitModel>(type: UnitType): Observable<Nullable<T>>;
|
|
33
44
|
/** Create a unit with snapshot info. */
|
|
34
|
-
createUnit<T, U extends UnitModel>(type: UnitType, data: Partial<T
|
|
45
|
+
createUnit<T, U extends UnitModel>(type: UnitType, data: Partial<T>, options?: ICreateUnitOptions): U;
|
|
35
46
|
/** Dispose a unit */
|
|
36
47
|
disposeUnit(unitId: string): boolean;
|
|
37
48
|
registerCtorForType<T extends UnitModel>(type: UnitType, ctor: new (...args: any[]) => T): IDisposable;
|
|
@@ -55,17 +66,16 @@ export declare class UniverInstanceService extends Disposable implements IUniver
|
|
|
55
66
|
constructor(_injector: Injector, _contextService: IContextService);
|
|
56
67
|
dispose(): void;
|
|
57
68
|
private _createHandler;
|
|
58
|
-
__setCreateHandler(handler: (type: UnitType, data: unknown, ctor:
|
|
59
|
-
createUnit<T, U extends UnitModel>(type: UnitType, data: T): U;
|
|
69
|
+
__setCreateHandler(handler: (type: UnitType, data: unknown, ctor: UnitCtor, options?: ICreateUnitOptions) => UnitModel): void;
|
|
70
|
+
createUnit<T, U extends UnitModel>(type: UnitType, data: T, options?: ICreateUnitOptions): U;
|
|
60
71
|
private readonly _ctorByType;
|
|
61
72
|
registerCtorForType<T extends UnitModel>(type: UnitType, ctor: new () => T): IDisposable;
|
|
62
73
|
private _currentUnits;
|
|
63
74
|
private readonly _currentUnits$;
|
|
64
75
|
readonly currentUnits$: Observable<Map<number, Nullable<UnitModel<object, number>>>>;
|
|
65
76
|
getCurrentTypeOfUnit$<T>(type: number): Observable<Nullable<T>>;
|
|
66
|
-
getCurrentUnitForType<T>(type: UnitType): Nullable<T>;
|
|
77
|
+
getCurrentUnitForType<T extends UnitModel>(type: UnitType): Nullable<T>;
|
|
67
78
|
setCurrentUnitForType(unitId: string): void;
|
|
68
|
-
private _removeCurrentUnitForType;
|
|
69
79
|
private readonly _unitAdded$;
|
|
70
80
|
readonly unitAdded$: Observable<UnitModel<object, number>>;
|
|
71
81
|
getTypeOfUnitAdded$<T extends UnitModel<object, number>>(type: UnitType): Observable<T>;
|
|
@@ -76,7 +86,7 @@ export declare class UniverInstanceService extends Disposable implements IUniver
|
|
|
76
86
|
*
|
|
77
87
|
* @param unit The unit to be added.
|
|
78
88
|
*/
|
|
79
|
-
__addUnit(unit: UnitModel): void;
|
|
89
|
+
__addUnit(unit: UnitModel, options?: ICreateUnitOptions): void;
|
|
80
90
|
private _unitDisposed$;
|
|
81
91
|
readonly unitDisposed$: Observable<UnitModel<object, number>>;
|
|
82
92
|
getTypeOfUnitDisposed$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T>;
|
|
@@ -93,5 +103,7 @@ export declare class UniverInstanceService extends Disposable implements IUniver
|
|
|
93
103
|
getFocusedUnit(): Nullable<UnitModel>;
|
|
94
104
|
getUnitType(unitId: string): UniverInstanceType;
|
|
95
105
|
disposeUnit(unitId: string): boolean;
|
|
106
|
+
private _tryRemoveCurrentUnitForType;
|
|
107
|
+
private _tryBlurUnitOnRemoval;
|
|
96
108
|
private _getUnitById;
|
|
97
109
|
}
|
|
@@ -15,7 +15,7 @@ export declare abstract class Plugin extends Disposable {
|
|
|
15
15
|
static pluginName: string;
|
|
16
16
|
static type: UniverInstanceType;
|
|
17
17
|
protected abstract _injector: Injector;
|
|
18
|
-
onStarting(
|
|
18
|
+
onStarting(_injector?: Injector): void;
|
|
19
19
|
onReady(): void;
|
|
20
20
|
onRendered(): void;
|
|
21
21
|
onSteady(): void;
|
|
@@ -49,6 +49,7 @@ export declare class PluginHolder extends Disposable {
|
|
|
49
49
|
protected readonly _lifecycleInitializerService: LifecycleInitializerService;
|
|
50
50
|
protected _started: boolean;
|
|
51
51
|
get started(): boolean;
|
|
52
|
+
private _warnedAboutOnStartingDeprecation;
|
|
52
53
|
/** Plugin constructors waiting to be initialized. */
|
|
53
54
|
protected readonly _pluginRegistry: PluginRegistry;
|
|
54
55
|
/** Stores initialized plugin instances. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Disposable } from '../../shared/lifecycle';
|
|
2
|
-
import {
|
|
2
|
+
import { Resources } from '../../types/interfaces/i-workbook-data';
|
|
3
3
|
import { UniverInstanceType } from '../../common/unit';
|
|
4
4
|
import { IResourceHook, IResourceManagerService, IResourceName } from './type';
|
|
5
5
|
|
|
@@ -8,17 +8,15 @@ export declare class ResourceManagerService extends Disposable implements IResou
|
|
|
8
8
|
private _register$;
|
|
9
9
|
register$: import('rxjs').Observable<IResourceHook<any>>;
|
|
10
10
|
getAllResourceHooks(): IResourceHook<any>[];
|
|
11
|
-
getResources(unitId: string):
|
|
12
|
-
|
|
13
|
-
data: string;
|
|
14
|
-
}[];
|
|
11
|
+
getResources(unitId: string): Resources;
|
|
12
|
+
getResources(unitId: string, type: UniverInstanceType): Resources;
|
|
15
13
|
getResourcesByType(unitId: string, type: UniverInstanceType): {
|
|
16
14
|
name: `SHEET_${string}_PLUGIN` | `DOC_${string}_PLUGIN`;
|
|
17
15
|
data: string;
|
|
18
16
|
}[];
|
|
19
17
|
registerPluginResource<T = unknown>(hook: IResourceHook<T>): import('@wendellhu/redi').IDisposable;
|
|
20
18
|
disposePluginResource(pluginName: IResourceName): void;
|
|
21
|
-
loadResources(unitId: string, resources
|
|
19
|
+
loadResources(unitId: string, resources?: Resources): void;
|
|
22
20
|
unloadResources(unitId: string): void;
|
|
23
21
|
dispose(): void;
|
|
24
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { UniverInstanceType } from '@univerjs/core';
|
|
3
3
|
import { IDisposable } from '../../common/di';
|
|
4
|
-
import {
|
|
4
|
+
import { Resources } from '../../types/interfaces/i-workbook-data';
|
|
5
5
|
|
|
6
6
|
type IBusinessName = 'SHEET' | 'DOC';
|
|
7
7
|
export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;
|
|
@@ -18,9 +18,13 @@ export interface IResourceManagerService {
|
|
|
18
18
|
registerPluginResource: <T = any>(hook: IResourceHook<T>) => IDisposable;
|
|
19
19
|
disposePluginResource: (pluginName: IResourceName) => void;
|
|
20
20
|
getAllResourceHooks: () => IResourceHook[];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated You should get resource with type specified.
|
|
23
|
+
*/
|
|
24
|
+
getResources(unitId: string): Resources;
|
|
25
|
+
getResources(unitId: string, type: UniverInstanceType): Resources;
|
|
26
|
+
getResourcesByType: (unitId: string, type: UniverInstanceType) => Resources;
|
|
27
|
+
loadResources: (unitId: string, resources?: Resources) => void;
|
|
24
28
|
unloadResources(unitId: string): void;
|
|
25
29
|
}
|
|
26
30
|
export declare const IResourceManagerService: import('@univerjs/core').IdentifierDecorator<IResourceManagerService>;
|
|
@@ -4,6 +4,9 @@ import { IWorkbookData } from '../../types/interfaces/i-workbook-data';
|
|
|
4
4
|
import { IDocumentData } from '../../types/interfaces/i-document-data';
|
|
5
5
|
import { ISnapshotServerService } from './snapshot-server.service';
|
|
6
6
|
|
|
7
|
+
export declare function generateTempDocumentSnapshot(_context: ILogContext, document: IDocumentData, unitID: string, rev: number): Promise<{
|
|
8
|
+
snapshot: ISnapshot;
|
|
9
|
+
}>;
|
|
7
10
|
export declare function generateTemporarySnap(context: ILogContext, workbook: IWorkbookData, unitID: string, rev: number, snapshotService: ISnapshotServerService): Promise<{
|
|
8
11
|
snapshotRes: ISnapshot;
|
|
9
12
|
}>;
|
|
@@ -13,8 +13,8 @@ export declare const textDecoder: TextDecoder;
|
|
|
13
13
|
export declare function encodeWorksheetOtherMetas(worksheet: Partial<IWorksheetData>): Uint8Array;
|
|
14
14
|
export declare function encodeWorkbookOtherMetas(workbook: IWorkbookData): Uint8Array;
|
|
15
15
|
export declare function encodeDocOriginalMeta(document: IDocumentData): Uint8Array;
|
|
16
|
-
export declare function decodeWorksheetOtherMetas(buffer: Uint8Array): Partial<IWorksheetData>;
|
|
17
|
-
export declare function decodeWorkbookOtherMetas(buffer: Uint8Array): Partial<IWorkbookData>;
|
|
16
|
+
export declare function decodeWorksheetOtherMetas(buffer: Uint8Array | string): Partial<IWorksheetData>;
|
|
17
|
+
export declare function decodeWorkbookOtherMetas(buffer: Uint8Array | string): Partial<IWorkbookData>;
|
|
18
18
|
export declare function decodePartOfCellData(buffer: Uint8Array | string): IObjectMatrixPrimitiveType<ICellData>;
|
|
19
19
|
export declare function decodeDocOriginalMeta(buffer: Uint8Array | string): Partial<IDocumentData>;
|
|
20
20
|
export declare function splitCellDataToBlocks(cellData: IObjectMatrixPrimitiveType<ICellData>, maxColumn: number): ISheetBlock[];
|
|
@@ -113,5 +113,16 @@ export declare class Tools {
|
|
|
113
113
|
*/
|
|
114
114
|
static set(data: Record<string, any>, propertyPath: string, value: any): void;
|
|
115
115
|
static clamp(value: number, min: number, max: number): number;
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
*
|
|
119
|
+
* @static
|
|
120
|
+
* @param {unknown} object Modify the property while leaving the reference unchanged.
|
|
121
|
+
* @param {unknown} source The source being merged in object.
|
|
122
|
+
* @param {(value: unknown, originValue: unknown, key: string, object: unknown, source: unknown, stack: string[]) => {}} [customizer]
|
|
123
|
+
* @return {*}
|
|
124
|
+
* @memberof Tools
|
|
125
|
+
*/
|
|
126
|
+
static mergeWith(object: unknown, source: unknown, customizer?: (value: unknown, originValue: unknown, key: string, object: unknown, source: unknown, stack: string[]) => {}): any;
|
|
116
127
|
}
|
|
117
128
|
export declare function generateRandomId(n?: number, alphabet?: string): string;
|
|
@@ -45,6 +45,7 @@ export declare class Workbook extends UnitModel<IWorkbookData, UniverInstanceTyp
|
|
|
45
45
|
save(): IWorkbookData;
|
|
46
46
|
static isIRangeType(range: IRangeType | IRangeType[]): boolean;
|
|
47
47
|
getSnapshot(): IWorkbookData;
|
|
48
|
+
/** @deprecated use use name property instead */
|
|
48
49
|
getName(): string;
|
|
49
50
|
setName(name: string): void;
|
|
50
51
|
getUnitId(): string;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
1
2
|
import { UnitModel, UniverInstanceType } from '../common/unit';
|
|
2
|
-
import {
|
|
3
|
+
import { Nullable } from '../shared';
|
|
4
|
+
import { ISlideData, ISlidePage, PageType } from '../types/interfaces';
|
|
3
5
|
|
|
4
6
|
export declare class SlideDataModel extends UnitModel<ISlideData, UniverInstanceType.UNIVER_SLIDE> {
|
|
5
7
|
type: UniverInstanceType.UNIVER_SLIDE;
|
|
8
|
+
private readonly _activePage$;
|
|
9
|
+
private get _activePage();
|
|
10
|
+
readonly activePage$: Observable<Nullable<ISlidePage>>;
|
|
11
|
+
private readonly _name$;
|
|
12
|
+
name$: Observable<string>;
|
|
6
13
|
private _snapshot;
|
|
7
14
|
private _unitId;
|
|
8
15
|
constructor(snapshot: Partial<ISlideData>);
|
|
16
|
+
setName(name: string): void;
|
|
9
17
|
getContainer(): string | undefined;
|
|
10
18
|
getSnapshot(): ISlideData;
|
|
11
19
|
getUnitId(): string;
|
|
@@ -19,5 +27,19 @@ export declare class SlideDataModel extends UnitModel<ISlideData, UniverInstance
|
|
|
19
27
|
} | undefined;
|
|
20
28
|
getElement(pageId: string, elementId: string): import('../types/interfaces').IPageElement | undefined;
|
|
21
29
|
getPageSize(): import('../shared').ISize;
|
|
22
|
-
|
|
30
|
+
getBlankPage(): {
|
|
31
|
+
id: string;
|
|
32
|
+
pageType: PageType;
|
|
33
|
+
zIndex: number;
|
|
34
|
+
title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
pageBackgroundFill: {
|
|
37
|
+
rgb: string;
|
|
38
|
+
};
|
|
39
|
+
pageElements: {};
|
|
40
|
+
};
|
|
41
|
+
setActivePage(page: Nullable<ISlidePage>): void;
|
|
42
|
+
getActivePage(): Nullable<ISlidePage>;
|
|
43
|
+
updatePage(pageId: string, page: ISlidePage): void;
|
|
44
|
+
appendPage(page: ISlidePage): void;
|
|
23
45
|
}
|
|
@@ -49,7 +49,9 @@ export declare enum HorizontalAlign {
|
|
|
49
49
|
LEFT = 1,// The text is explicitly aligned to the left of the cell.
|
|
50
50
|
CENTER = 2,// The text is explicitly aligned to the center of the cell.
|
|
51
51
|
RIGHT = 3,// The text is explicitly aligned to the right of the cell.
|
|
52
|
-
JUSTIFIED = 4
|
|
52
|
+
JUSTIFIED = 4,// The paragraph is justified.
|
|
53
|
+
BOTH = 5,// The paragraph is justified.
|
|
54
|
+
DISTRIBUTED = 6
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* An enum that specifies the vertical alignment of text.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICustomDecoration, ICustomRange } from './i-document-data';
|
|
1
|
+
import { ICustomDecoration, ICustomRange, IParagraph } from './i-document-data';
|
|
2
2
|
|
|
3
3
|
export interface ICustomRangeForInterceptor extends ICustomRange {
|
|
4
4
|
active?: boolean;
|
|
@@ -8,3 +8,7 @@ export interface ICustomDecorationForInterceptor extends ICustomDecoration {
|
|
|
8
8
|
active?: boolean;
|
|
9
9
|
show?: boolean;
|
|
10
10
|
}
|
|
11
|
+
export interface IParagraphRange extends IParagraph {
|
|
12
|
+
paragraphStart: number;
|
|
13
|
+
paragraphEnd: number;
|
|
14
|
+
}
|