@univerjs/core 0.1.0-beta.3 → 0.1.0-beta.4
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 +4 -4
- package/lib/es/index.js +1501 -1376
- package/lib/types/docs/data-model/__tests__/common.spec.d.ts +16 -0
- package/lib/types/docs/data-model/{mutation-types.d.ts → action-types.d.ts} +8 -3
- package/lib/types/docs/data-model/document-data-model.d.ts +2 -2
- package/lib/types/docs/data-model/text-x/__tests__/action-iterator.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/__tests__/compose.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/__tests__/utils.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/action-iterator.d.ts +29 -0
- package/lib/types/docs/data-model/text-x/text-x.d.ts +2 -1
- package/lib/types/docs/data-model/text-x/utils.d.ts +21 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/umd/index.js +4 -4
- package/package.json +2 -2
|
@@ -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 {};
|
|
@@ -15,11 +15,16 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { UpdateDocsAttributeType } from '../../shared/command-enum';
|
|
17
17
|
import type { IDocumentBody } from '../../types/interfaces/i-document-data';
|
|
18
|
+
export declare enum TextXActionType {
|
|
19
|
+
RETAIN = "r",
|
|
20
|
+
INSERT = "i",
|
|
21
|
+
DELETE = "d"
|
|
22
|
+
}
|
|
18
23
|
/**
|
|
19
24
|
* Retain mutation is used to move the cursor or to update properties of the text in the given range.
|
|
20
25
|
*/
|
|
21
26
|
export interface IRetainAction {
|
|
22
|
-
t:
|
|
27
|
+
t: TextXActionType.RETAIN;
|
|
23
28
|
len: number;
|
|
24
29
|
body?: IDocumentBody;
|
|
25
30
|
coverType?: UpdateDocsAttributeType;
|
|
@@ -29,7 +34,7 @@ export interface IRetainAction {
|
|
|
29
34
|
* Insert mutation is used to insert text (maybe with rich text properties) at the given position.
|
|
30
35
|
*/
|
|
31
36
|
export interface IInsertAction {
|
|
32
|
-
t:
|
|
37
|
+
t: TextXActionType.INSERT;
|
|
33
38
|
body: IDocumentBody;
|
|
34
39
|
len: number;
|
|
35
40
|
line: number;
|
|
@@ -39,7 +44,7 @@ export interface IInsertAction {
|
|
|
39
44
|
* Delete mutation is used to delete text at the given position.
|
|
40
45
|
*/
|
|
41
46
|
export interface IDeleteAction {
|
|
42
|
-
t:
|
|
47
|
+
t: TextXActionType.DELETE;
|
|
43
48
|
len: number;
|
|
44
49
|
line: number;
|
|
45
50
|
segmentId?: string;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { Nullable } from '../../shared';
|
|
17
17
|
import type { IDocumentBody, IDocumentData, IDocumentRenderConfig } from '../../types/interfaces/i-document-data';
|
|
18
18
|
import type { IPaddingData } from '../../types/interfaces/i-style-data';
|
|
19
|
-
import type
|
|
19
|
+
import { type TextXAction } from './action-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(
|
|
65
|
+
apply(actions: TextXAction[]): TextXAction[];
|
|
66
66
|
sliceBody(startOffset: number, endOffset: number): Nullable<IDocumentBody>;
|
|
67
67
|
private _updateApply;
|
|
68
68
|
private _deleteApply;
|
|
@@ -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 {};
|
|
@@ -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,29 @@
|
|
|
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 { TextXAction } from '../action-types';
|
|
17
|
+
import { TextXActionType } from '../action-types';
|
|
18
|
+
export declare class ActionIterator {
|
|
19
|
+
private _actions;
|
|
20
|
+
private _index;
|
|
21
|
+
private _offset;
|
|
22
|
+
constructor(_actions: TextXAction[]);
|
|
23
|
+
hasNext(): boolean;
|
|
24
|
+
next(length?: number): TextXAction;
|
|
25
|
+
peek(): TextXAction;
|
|
26
|
+
peekLength(): number;
|
|
27
|
+
peekType(): TextXActionType;
|
|
28
|
+
rest(): TextXAction[];
|
|
29
|
+
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { UpdateDocsAttributeType } from '../../../shared/command-enum';
|
|
17
17
|
import type { IDocumentBody } from '../../../types/interfaces/i-document-data';
|
|
18
|
-
import type
|
|
18
|
+
import { type TextXAction } from '../action-types';
|
|
19
19
|
export declare class TextX {
|
|
20
20
|
static compose(thisActions: TextXAction[], otherActions: TextXAction[]): TextXAction[];
|
|
21
21
|
private _actions;
|
|
@@ -24,4 +24,5 @@ export declare class TextX {
|
|
|
24
24
|
delete(len: number, segmentId: string): this;
|
|
25
25
|
serialize(): TextXAction[];
|
|
26
26
|
push(...args: TextXAction[]): this;
|
|
27
|
+
trimEndUselessRetainAction(): this;
|
|
27
28
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { UpdateDocsAttributeType } from '../../../shared/command-enum';
|
|
17
|
+
import type { IDocumentBody } from '../../../types/interfaces/i-document-data';
|
|
18
|
+
import type { IRetainAction } from '../action-types';
|
|
19
|
+
export declare function getBodySlice(body: IDocumentBody, startOffset: number, endOffset: number): IDocumentBody;
|
|
20
|
+
export declare function composeBody(thisBody: IDocumentBody, otherBody: IDocumentBody, coverType?: UpdateDocsAttributeType): IDocumentBody;
|
|
21
|
+
export declare function isUselessRetainAction(action: IRetainAction): boolean;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -21,7 +21,9 @@ export { MemoryCursor } from './common/memory-cursor';
|
|
|
21
21
|
export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
|
|
22
22
|
export { type ISequenceExecuteResult, sequence, sequenceAsync } from './common/sequence';
|
|
23
23
|
export * from './docs/data-model';
|
|
24
|
-
export { type TextXAction, type IDeleteAction, type IInsertAction, type IRetainAction, } from './docs/data-model/
|
|
24
|
+
export { TextXActionType, type TextXAction, type IDeleteAction, type IInsertAction, type IRetainAction, } from './docs/data-model/action-types';
|
|
25
|
+
export { ActionIterator } from './docs/data-model/text-x/action-iterator';
|
|
26
|
+
export { getBodySlice, composeBody } from './docs/data-model/text-x/utils';
|
|
25
27
|
export { TextX } from './docs/data-model/text-x/text-x';
|
|
26
28
|
export * from './observer';
|
|
27
29
|
export { Plugin, PluginType } from './plugin/plugin';
|