@univerjs/docs 0.25.1 → 1.0.0-alpha.1

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,231 @@
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 { Injector, IParagraph, IParagraphStyle } from '@univerjs/core';
17
+ import type { FDocumentBody, IFDocumentBodyEdit, IFDocumentTextRange } from './f-document-body';
18
+ import type { IFDocumentElementInfo } from './f-document-element';
19
+ import { FDocumentElement } from './f-document-element';
20
+ interface IFDocumentParagraphMixin {
21
+ asParagraph(): FDocumentParagraph;
22
+ }
23
+ /**
24
+ * Resolved paragraph metadata in the the document body.
25
+ */
26
+ export interface IFDocumentResolvedParagraph {
27
+ /** The underlying paragraph snapshot object. */
28
+ paragraph: IParagraph;
29
+ /** The current paragraph index in the body paragraph list. */
30
+ paragraphIndex: number;
31
+ /** The inclusive start offset of the paragraph text. */
32
+ startOffset: number;
33
+ /** The exclusive end offset of the paragraph text, before the paragraph break. */
34
+ endOffset: number;
35
+ }
36
+ /**
37
+ * A paragraph facade wrapper.
38
+ *
39
+ * Paragraph identity is backed by the persisted `paragraphId`. The id is
40
+ * re-resolved before each method call, so insertions before this paragraph do
41
+ * not break the wrapper.
42
+ *
43
+ * @hideconstructor
44
+ */
45
+ export declare class FDocumentParagraph extends FDocumentElement {
46
+ protected readonly body: FDocumentBody;
47
+ protected readonly bodyEdit: IFDocumentBodyEdit;
48
+ protected readonly info: IFDocumentElementInfo;
49
+ protected readonly injector: Injector;
50
+ constructor(body: FDocumentBody, bodyEdit: IFDocumentBodyEdit, info: IFDocumentElementInfo, injector: Injector);
51
+ /**
52
+ * Get the persisted paragraph id.
53
+ * @returns {string} The paragraph id.
54
+ * @example
55
+ * ```ts
56
+ * const fDocument = univerAPI.getActiveDocument();
57
+ * const fDocumentBody = fDocument.getBody();
58
+ * const element = fDocumentBody.getElement(0);
59
+ *
60
+ * if (element?.isParagraph()) {
61
+ * const paragraph = element.asParagraph();
62
+ * console.log(paragraph.getParagraphId());
63
+ * }
64
+ * ```
65
+ */
66
+ getParagraphId(): string;
67
+ /**
68
+ * Get the resolved paragraph info for this wrapper.
69
+ * @returns {IFDocumentResolvedParagraph} The resolved paragraph info, including the paragraph object, its index, and its text range.
70
+ * @example
71
+ * ```ts
72
+ * const fDocument = univerAPI.getActiveDocument();
73
+ * const fDocumentBody = fDocument.getBody();
74
+ * const element = fDocumentBody.getElement(0);
75
+ *
76
+ * if (element?.isParagraph()) {
77
+ * const paragraph = element.asParagraph();
78
+ * console.log(paragraph.getResolvedParagraphInfo());
79
+ * }
80
+ * ```
81
+ */
82
+ getResolvedParagraphInfo(): IFDocumentResolvedParagraph;
83
+ /**
84
+ * Get the current text range occupied by this paragraph.
85
+ * @returns {IFDocumentTextRange} The paragraph text range, excluding the trailing paragraph break.
86
+ * @example
87
+ * ```ts
88
+ * const fDocument = univerAPI.getActiveDocument();
89
+ * const fDocumentBody = fDocument.getBody();
90
+ * const element = fDocumentBody.getElement(0);
91
+ *
92
+ * if (element?.isParagraph()) {
93
+ * const paragraph = element.asParagraph();
94
+ * const range = paragraph.getRange();
95
+ * fDocumentBody.setTextStyle(range, { bl: 1 });
96
+ * }
97
+ * ```
98
+ */
99
+ getRange(): IFDocumentTextRange;
100
+ /**
101
+ * Get this paragraph's plain text.
102
+ * @returns {string} The paragraph text without the trailing paragraph break.
103
+ * @example
104
+ * ```ts
105
+ * const fDocument = univerAPI.getActiveDocument();
106
+ * const fDocumentBody = fDocument.getBody();
107
+ * const element = fDocumentBody.getElement(0);
108
+ *
109
+ * if (element?.isParagraph()) {
110
+ * const paragraph = element.asParagraph();
111
+ * console.log(paragraph.getText());
112
+ * }
113
+ * ```
114
+ */
115
+ getText(): string;
116
+ /**
117
+ * Replace this paragraph's plain text.
118
+ * @param {string} text The replacement text. Do not include the paragraph break.
119
+ * @returns {boolean} `true` if the paragraph text was replaced.
120
+ * @example
121
+ * ```ts
122
+ * const fDocument = univerAPI.getActiveDocument();
123
+ * const fDocumentBody = fDocument.getBody();
124
+ * const element = fDocumentBody.getElement(0);
125
+ *
126
+ * if (element?.isParagraph()) {
127
+ * const paragraph = element.asParagraph();
128
+ * const success = paragraph.setText('Updated title');
129
+ * console.log(success ? 'Text updated' : 'Failed to update text');
130
+ * }
131
+ * ```
132
+ */
133
+ setText(text: string): boolean;
134
+ /**
135
+ * Append plain text before this paragraph's trailing paragraph break.
136
+ * @param {string} text The plain text to append.
137
+ * @returns {boolean} `true` if the text was appended.
138
+ * @example
139
+ * ```ts
140
+ * const fDocument = univerAPI.getActiveDocument();
141
+ * const fDocumentBody = fDocument.getBody();
142
+ * const element = fDocumentBody.getElement(0);
143
+ *
144
+ * if (element?.isParagraph()) {
145
+ * const paragraph = element.asParagraph();
146
+ * const success = paragraph.appendText(' Appended text');
147
+ * console.log(success ? 'Text appended' : 'Failed to append text');
148
+ * }
149
+ * ```
150
+ */
151
+ appendText(text: string): boolean;
152
+ /**
153
+ * Apply paragraph style to a paragraph handle or text range.
154
+ * @param {IParagraphStyle} style The Univer paragraph style patch.
155
+ * @returns {boolean} `true` if the style was applied.
156
+ * @example
157
+ * ```ts
158
+ * const fDocument = univerAPI.getActiveDocument();
159
+ * const fDocumentBody = fDocument.getBody();
160
+ * const element = fDocumentBody.getElement(0);
161
+ *
162
+ * if (element?.isParagraph()) {
163
+ * const paragraph = element.asParagraph();
164
+ * paragraph.setStyle({ horizontalAlign: 2 });
165
+ * }
166
+ * ```
167
+ */
168
+ setStyle(style: IParagraphStyle): boolean;
169
+ /**
170
+ * Check whether this paragraph is a bullet, ordered, or checklist item.
171
+ * @returns {boolean} `true` if the paragraph has list metadata.
172
+ * @example
173
+ * ```ts
174
+ * const fDocument = univerAPI.getActiveDocument();
175
+ * const fDocumentBody = fDocument.getBody();
176
+ * const element = fDocumentBody.getElement(0);
177
+ *
178
+ * if (element?.isParagraph()) {
179
+ * const paragraph = element.asParagraph();
180
+ * console.log(paragraph.isListItem() ? 'This is a list item' : 'This is not a list item');
181
+ * }
182
+ * ```
183
+ */
184
+ isListItem(): boolean;
185
+ /**
186
+ * Check whether this paragraph is a task/checklist item.
187
+ * @returns {boolean} `true` if this paragraph is an unchecked or checked task item.
188
+ * @example
189
+ * ```ts
190
+ * const fDocument = univerAPI.getActiveDocument();
191
+ * const fDocumentBody = fDocument.getBody();
192
+ * const element = fDocumentBody.getElement(0);
193
+ *
194
+ * if (element?.isParagraph()) {
195
+ * const paragraph = element.asParagraph();
196
+ * console.log(paragraph.isTask() ? 'This is a task item' : 'This is not a task item');
197
+ * }
198
+ * ```
199
+ */
200
+ isTask(): boolean;
201
+ /**
202
+ * Set the checked state of this task/checklist paragraph.
203
+ * @param {boolean} checked Whether the task item should be checked.
204
+ * @returns {boolean} `true` if the task state was updated, or `false` if this paragraph is not a task item.
205
+ * @example
206
+ * ```ts
207
+ * const fDocument = univerAPI.getActiveDocument();
208
+ * const fDocumentBody = fDocument.getBody();
209
+ * const element = fDocumentBody.getElement(0);
210
+ *
211
+ * if (element?.isParagraph()) {
212
+ * const paragraph = element.asParagraph();
213
+ *
214
+ * if (paragraph.isTask()) {
215
+ * const success = paragraph.setTaskChecked(true);
216
+ * console.log(success ? 'Task checked' : 'Failed to check task');
217
+ * }
218
+ * }
219
+ * ```
220
+ */
221
+ setTaskChecked(checked: boolean): boolean;
222
+ private _preserveExplicitParagraphIds;
223
+ }
224
+ export declare class FDocumentParagraphMixin extends FDocumentElement {
225
+ asParagraph(): FDocumentParagraph;
226
+ }
227
+ declare module '@univerjs/docs/facade' {
228
+ interface FDocumentElement extends IFDocumentParagraphMixin {
229
+ }
230
+ }
231
+ export {};
@@ -0,0 +1,57 @@
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 { ICustomTable, Injector } from '@univerjs/core';
17
+ import type { FDocumentBody, IFDocumentBodyEdit } from './f-document-body';
18
+ import type { IFDocumentElementInfo } from './f-document-element';
19
+ import { FDocumentElement } from './f-document-element';
20
+ interface IFDocumentTableMixin {
21
+ asTable(): FDocumentTable;
22
+ }
23
+ /**
24
+ * A facade wrapper for document top-level tables.
25
+ * @hideconstructor
26
+ */
27
+ export declare class FDocumentTable extends FDocumentElement {
28
+ protected readonly body: FDocumentBody;
29
+ protected readonly bodyEdit: IFDocumentBodyEdit;
30
+ protected readonly info: IFDocumentElementInfo;
31
+ protected readonly injector: Injector;
32
+ constructor(body: FDocumentBody, bodyEdit: IFDocumentBodyEdit, info: IFDocumentElementInfo, injector: Injector);
33
+ /**
34
+ * Get the table marker.
35
+ * @returns {ICustomTable} The table marker.
36
+ * @example
37
+ * ```ts
38
+ * const fDocument = univerAPI.getActiveDocument();
39
+ * const fDocumentBody = fDocument.getBody();
40
+ * const element = fDocumentBody.getElement(0);
41
+ *
42
+ * if (element?.isTable()) {
43
+ * const table = element.asTable();
44
+ * console.log(table.getTable());
45
+ * }
46
+ * ```
47
+ */
48
+ getTable(): ICustomTable;
49
+ }
50
+ export declare class FDocumentTableMixin extends FDocumentElement {
51
+ asTable(): FDocumentTable;
52
+ }
53
+ declare module '@univerjs/docs/facade' {
54
+ interface FDocumentElement extends IFDocumentTableMixin {
55
+ }
56
+ }
57
+ export {};
@@ -0,0 +1,123 @@
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 { DocumentDataModel, IDocumentData } from '@univerjs/core';
17
+ import { ICommandService, Injector, IResourceLoaderService, IUniverInstanceService } from '@univerjs/core';
18
+ import { FBaseInitialable } from '@univerjs/core/facade';
19
+ import { FDocumentBody } from './f-document-body';
20
+ /**
21
+ * Facade API object bounded to a document. It provides a set of methods to interact with the document.
22
+ * @hideconstructor
23
+ */
24
+ export declare class FDocument extends FBaseInitialable {
25
+ private readonly _documentDataModel;
26
+ protected readonly _injector: Injector;
27
+ protected readonly _univerInstanceService: IUniverInstanceService;
28
+ protected readonly _resourceLoaderService: IResourceLoaderService;
29
+ private readonly _commandService;
30
+ readonly id: string;
31
+ constructor(_documentDataModel: DocumentDataModel, _injector: Injector, _univerInstanceService: IUniverInstanceService, _resourceLoaderService: IResourceLoaderService, _commandService: ICommandService);
32
+ /**
33
+ * Get the document data model of the document.
34
+ * @returns {DocumentDataModel} The document data model.
35
+ * @example
36
+ * ```typescript
37
+ * const fDocument = univerAPI.getActiveDocument();
38
+ * const documentDataModel = fDocument.getDocumentDataModel();
39
+ * console.log(documentDataModel);
40
+ * ```
41
+ */
42
+ getDocumentDataModel(): DocumentDataModel;
43
+ /**
44
+ * Get the document body facade.
45
+ *
46
+ * The returned body facade provides synchronous Google Docs-like element APIs
47
+ * for reading and editing top-level document body elements. Paragraph elements
48
+ * use their persisted `paragraphId` values. Persisted elements, such as tables
49
+ * and custom blocks, use their existing ids.
50
+ *
51
+ * @returns {FDocumentBody} The document body API instance.
52
+ * @example
53
+ * ```typescript
54
+ * const fDocument = univerAPI.getActiveDocument();
55
+ * const fDocumentBody = fDocument.getBody();
56
+ * console.log(fDocumentBody.getBody());
57
+ *
58
+ * const element = fDocumentBody.getElement(0);
59
+ * if (element.isParagraph()) {
60
+ * const paragraph = element.asParagraph();
61
+ * paragraph.appendText(' updated');
62
+ * console.log(paragraph.getText());
63
+ * }
64
+ * ```
65
+ */
66
+ getBody(): FDocumentBody;
67
+ dispose(): void;
68
+ /**
69
+ * Get the document id.
70
+ * @returns {string} The document id.
71
+ * @example
72
+ * ```typescript
73
+ * const fDocument = univerAPI.getActiveDocument();
74
+ * const unitId = fDocument.getId();
75
+ * console.log(unitId);
76
+ * ```
77
+ */
78
+ getId(): string;
79
+ /**
80
+ * Get the document name.
81
+ * @returns {string} The document name.
82
+ * @example
83
+ * ```typescript
84
+ * const fDocument = univerAPI.getActiveDocument();
85
+ * const name = fDocument.getName();
86
+ * console.log(name);
87
+ * ```
88
+ */
89
+ getName(): string;
90
+ /**
91
+ * Save the document snapshot data, including the document content and resource data, etc.
92
+ * @returns {IDocumentData} The document snapshot data.
93
+ * @example
94
+ * ```typescript
95
+ * const fDocument = univerAPI.getActiveDocument();
96
+ * const snapshot = fDocument.save();
97
+ * console.log(snapshot);
98
+ * ```
99
+ */
100
+ save(): IDocumentData;
101
+ /**
102
+ * Undo the last operation in the document.
103
+ * @returns {boolean} `true` if the undo operation was successful, or `false` if it failed.
104
+ * @example
105
+ * ```typescript
106
+ * const fDocument = univerAPI.getActiveDocument();
107
+ * const success = fDocument.undo();
108
+ * console.log(success);
109
+ * ```
110
+ */
111
+ undo(): boolean;
112
+ /**
113
+ * Redo the last undone operation in the document.
114
+ * @returns {boolean} `true` if the redo operation was successful, or `false` if it failed.
115
+ * @example
116
+ * ```typescript
117
+ * const fDocument = univerAPI.getActiveDocument();
118
+ * const success = fDocument.redo();
119
+ * console.log(success);
120
+ * ```
121
+ */
122
+ redo(): boolean;
123
+ }
@@ -0,0 +1,64 @@
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 { IDocumentData } from '@univerjs/core';
17
+ import { FUniver } from '@univerjs/core/facade';
18
+ import { FDocument } from './f-document';
19
+ /**
20
+ * @ignore
21
+ */
22
+ export interface IFUniverDocsMixin {
23
+ /**
24
+ * Create a new document and get the API handler of that document.
25
+ * @param {Partial<IDocumentData>} data The snapshot of the document.
26
+ * @returns {FDocument} The document API instance.
27
+ * @example
28
+ * ```typescript
29
+ * const fDocument = univerAPI.createUniverDoc({ id: 'document-01', title: 'Document1' });
30
+ * console.log(fDocument);
31
+ * ```
32
+ */
33
+ createDocument(data: Partial<IDocumentData>): FDocument;
34
+ /**
35
+ * Get the currently focused Univer document.
36
+ * @returns {FDocument | null} The currently focused Univer document API instance, or null if there is no focused Univer document.
37
+ * @example
38
+ * ```typescript
39
+ * const fDocument = univerAPI.getActiveDocument();
40
+ * console.log(fDocument);
41
+ * ```
42
+ */
43
+ getActiveDocument(): FDocument | null;
44
+ /**
45
+ * Get the document API handler by the document id.
46
+ * @param {string} id The document id.
47
+ * @returns {FDocument | null} The document API instance corresponding to the document id, or null if not found.
48
+ * @example
49
+ * ```typescript
50
+ * const fDocument = univerAPI.getDocument('document-01');
51
+ * console.log(fDocument);
52
+ * ```
53
+ */
54
+ getDocument(id: string): FDocument | null;
55
+ }
56
+ export declare class FUniverDocsMixin extends FUniver implements IFUniverDocsMixin {
57
+ createDocument(data: Partial<IDocumentData>): FDocument;
58
+ getActiveDocument(): FDocument | null;
59
+ getDocument(id: string): FDocument | null;
60
+ }
61
+ declare module '@univerjs/core/facade' {
62
+ interface FUniver extends IFUniverDocsMixin {
63
+ }
64
+ }
@@ -0,0 +1,23 @@
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 './f-univer';
17
+ export { FDocument } from './f-document';
18
+ export { FDocumentBlockRange } from './f-document-block-range';
19
+ export { FDocumentBody, type IFDocumentTextRange } from './f-document-body';
20
+ export { FDocumentCustomBlock } from './f-document-custom-block';
21
+ export { FDocumentElement } from './f-document-element';
22
+ export { FDocumentParagraph } from './f-document-paragraph';
23
+ export { FDocumentTable } from './f-document-table';
@@ -0,0 +1,24 @@
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 { IDocumentBody, IParagraphStyle } from '@univerjs/core';
17
+ export interface IBuildPlainTextInsertBodyOptions {
18
+ paragraphStyle?: IParagraphStyle;
19
+ removeLeadingParagraphBreak?: boolean;
20
+ }
21
+ export declare function getRemovedLeadingParagraphBreakLength(dataStream: string, removeLeadingParagraphBreak?: boolean): number;
22
+ export declare function getNormalizedPlainTextCursorOffset(dataStream: string, cursorOffset: number, removeLeadingParagraphBreak?: boolean): number;
23
+ export declare function getParagraphStyleAtOffset(body: IDocumentBody, offset: number): IParagraphStyle | undefined;
24
+ export declare function buildPlainTextInsertBody(dataStream: string, options?: IBuildPlainTextInsertBodyOptions): IDocumentBody;
@@ -13,15 +13,24 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { type IRichTextEditingMutationParams, RichTextEditingMutation } from './commands/mutations/core-editing.mutation';
17
- export { type ISetTextSelectionsOperationParams, SetTextSelectionsOperation } from './commands/operations/text-selection.operation';
16
+ export { DeleteTextCommand, InsertTextCommand, UpdateTextCommand } from './commands/commands/core-editing.command';
17
+ export type { IDeleteTextCommandParams, IInsertTextCommandParams, IUpdateTextCommandParams, } from './commands/commands/core-editing.command';
18
+ export { RichTextEditingMutation } from './commands/mutations/core-editing.mutation';
19
+ export type { IRichTextEditingMutationParams } from './commands/mutations/core-editing.mutation';
20
+ export { SetTextSelectionsOperation } from './commands/operations/text-selection.operation';
21
+ export type { ISetTextSelectionsOperationParams } from './commands/operations/text-selection.operation';
18
22
  export type { IUniverDocsConfig } from './config/config';
19
23
  export { UniverDocsPlugin } from './plugin';
24
+ export { DocBlockMoveValidatorService } from './services/doc-block-move-validator.service';
25
+ export type { DocBlockMoveTransformer, DocBlockMoveValidator, IDocBlockMoveResult, IDocBlockMoveTransformContext, IDocBlockMoveValidationContext } from './services/doc-block-move-validator.service';
26
+ export { DocContentInsertService } from './services/doc-content-insert.service';
27
+ export type { IDocContentInsertRange } from './services/doc-content-insert.service';
20
28
  export { DocInterceptorService } from './services/doc-interceptor/doc-interceptor.service';
21
29
  export { DOC_INTERCEPTOR_POINT } from './services/doc-interceptor/interceptor-const';
22
30
  export { DocSelectionManagerService } from './services/doc-selection-manager.service';
23
31
  export { DocSkeletonManagerService } from './services/doc-skeleton-manager.service';
32
+ export { DocStateChangeManagerService, IDocStateChangeInterceptorService, } from './services/doc-state-change-manager.service';
24
33
  export type { IDocStateChangeInfo, IDocStateChangeParams } from './services/doc-state-emit.service';
25
34
  export { DocStateEmitService } from './services/doc-state-emit.service';
26
- export { addCustomRangeBySelectionFactory, addCustomRangeFactory, deleteCustomRangeFactory } from './utils/custom-range-factory';
35
+ export { addCustomRangeBySelectionFactory, addCustomRangeFactory, deleteCustomRangeFactory, } from './utils/custom-range-factory';
27
36
  export { replaceSelectionFactory } from './utils/replace-selection-factory';
@@ -0,0 +1,46 @@
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 { IDisposable, IDocumentData } from '@univerjs/core';
17
+ import { Disposable } from '@univerjs/core';
18
+ export interface IDocBlockMoveValidationContext {
19
+ unitId: string;
20
+ sourceRange: {
21
+ startOffset: number;
22
+ endOffset: number;
23
+ };
24
+ targetOffset: number;
25
+ }
26
+ export type DocBlockMoveValidator = (context: IDocBlockMoveValidationContext) => boolean;
27
+ export interface IDocBlockMoveResult {
28
+ nextDocumentData: IDocumentData;
29
+ movedRange: {
30
+ startOffset: number;
31
+ endOffset: number;
32
+ };
33
+ }
34
+ export interface IDocBlockMoveTransformContext extends IDocBlockMoveValidationContext {
35
+ previousDocumentData: IDocumentData;
36
+ result: IDocBlockMoveResult;
37
+ }
38
+ export type DocBlockMoveTransformer = (context: IDocBlockMoveTransformContext) => IDocBlockMoveResult;
39
+ export declare class DocBlockMoveValidatorService extends Disposable {
40
+ private readonly _validators;
41
+ private readonly _transformers;
42
+ registerValidator(validator: DocBlockMoveValidator): IDisposable;
43
+ registerTransformer(transformer: DocBlockMoveTransformer): IDisposable;
44
+ canMoveBlock(context: IDocBlockMoveValidationContext): boolean;
45
+ transformMoveResult(context: IDocBlockMoveTransformContext): IDocBlockMoveResult;
46
+ }
@@ -0,0 +1,28 @@
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 { Disposable } from '@univerjs/core';
17
+ export interface IDocContentInsertRange {
18
+ unitId: string;
19
+ startOffset: number;
20
+ endOffset: number;
21
+ segmentId?: string;
22
+ }
23
+ export declare class DocContentInsertService extends Disposable {
24
+ private _range;
25
+ setInsertRange(range: IDocContentInsertRange): void;
26
+ consumeInsertRange(unitId?: string): IDocContentInsertRange | null;
27
+ clearInsertRange(): void;
28
+ }