@univerjs/docs 1.0.0-alpha.0 → 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,193 @@
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 } from '@univerjs/core';
17
+ import type { FDocumentBody, IFDocumentBodyEdit } from './f-document-body';
18
+ import { DocumentBlockType } from '@univerjs/core';
19
+ import { FBase } from '@univerjs/core/facade';
20
+ export interface IFDocumentElementInfo {
21
+ type: DocumentBlockType;
22
+ key: string;
23
+ position: number;
24
+ priority: number;
25
+ }
26
+ /**
27
+ * A generic top-level document body element.
28
+ *
29
+ * Use this wrapper when you need to inspect an element type first, navigate to
30
+ * neighboring elements, or cast the element to a more specific facade wrapper.
31
+ *
32
+ * Paragraph keys are persisted `paragraphId` values. Tables, block ranges, and
33
+ * custom blocks use their persisted ids.
34
+ *
35
+ * @hideconstructor
36
+ */
37
+ export declare class FDocumentElement extends FBase {
38
+ protected readonly _body: FDocumentBody;
39
+ protected readonly _bodyEdit: IFDocumentBodyEdit;
40
+ protected readonly _info: IFDocumentElementInfo;
41
+ protected readonly _injector: Injector;
42
+ constructor(_body: FDocumentBody, _bodyEdit: IFDocumentBodyEdit, _info: IFDocumentElementInfo, _injector: Injector);
43
+ /**
44
+ * Get the document element type.
45
+ * @returns {DocumentBlockType} The element type, such as `paragraph`, `table`, `blockRange`, or `customBlock`.
46
+ * @example
47
+ * ```ts
48
+ * const fDocument = univerAPI.getActiveDocument();
49
+ * const fDocumentBody = fDocument.getBody();
50
+ * const element = fDocumentBody.getElement(0);
51
+ * console.log(element?.getType());
52
+ * ```
53
+ */
54
+ getType(): DocumentBlockType;
55
+ /**
56
+ * Whether this element is a paragraph.
57
+ * @returns {boolean} `true` if this element is a paragraph.
58
+ * @example
59
+ * ```ts
60
+ * const fDocument = univerAPI.getActiveDocument();
61
+ * const fDocumentBody = fDocument.getBody();
62
+ * const element = fDocumentBody.getElement(0);
63
+ * console.log(element?.isParagraph());
64
+ * ```
65
+ */
66
+ isParagraph(): boolean;
67
+ /**
68
+ * Whether this element is a table.
69
+ * @returns {boolean} `true` if this element is a table.
70
+ * @example
71
+ * ```ts
72
+ * const fDocument = univerAPI.getActiveDocument();
73
+ * const fDocumentBody = fDocument.getBody();
74
+ * const element = fDocumentBody.getElement(0);
75
+ * console.log(element?.isTable());
76
+ * ```
77
+ */
78
+ isTable(): boolean;
79
+ /**
80
+ * Whether this element is a block range, such as a callout, quote, or code block.
81
+ * @returns {boolean} `true` if this element is a block range.
82
+ * @example
83
+ * ```ts
84
+ * const fDocument = univerAPI.getActiveDocument();
85
+ * const fDocumentBody = fDocument.getBody();
86
+ * const element = fDocumentBody.getElement(0);
87
+ * console.log(element?.isBlockRange());
88
+ * ```
89
+ */
90
+ isBlockRange(): boolean;
91
+ /**
92
+ * Whether this element is a custom block.
93
+ * @returns {boolean} `true` if this element is a custom block.
94
+ * @example
95
+ * ```ts
96
+ * const fDocument = univerAPI.getActiveDocument();
97
+ * const fDocumentBody = fDocument.getBody();
98
+ * const element = fDocumentBody.getElement(0);
99
+ * console.log(element?.isCustomBlock());
100
+ * ```
101
+ */
102
+ isCustomBlock(): boolean;
103
+ /**
104
+ * Get the facade key used to resolve this element.
105
+ * @returns {string} The paragraph `paragraphId` or persisted table/block/custom block id.
106
+ * @example
107
+ * ```ts
108
+ * const fDocument = univerAPI.getActiveDocument();
109
+ * const fDocumentBody = fDocument.getBody();
110
+ * const element = fDocumentBody.getElement(0);
111
+ * console.log(element?.getKey());
112
+ * ```
113
+ */
114
+ getKey(): string;
115
+ /**
116
+ * Get the parent body facade that owns this element.
117
+ * @returns {FDocumentBody} The document body facade.
118
+ * @example
119
+ * ```ts
120
+ * const fDocument = univerAPI.getActiveDocument();
121
+ * const fDocumentBody = fDocument.getBody();
122
+ * const element = fDocumentBody.getElement(0);
123
+ * console.log(element?.getParent());
124
+ * ```
125
+ */
126
+ getParent(): FDocumentBody;
127
+ /**
128
+ * Get the resolved element info for this wrapper.
129
+ * @returns {IFDocumentElementInfo} The resolved element info, including type, key, position, and priority.
130
+ * @example
131
+ * ```ts
132
+ * const fDocument = univerAPI.getActiveDocument();
133
+ * const fDocumentBody = fDocument.getBody();
134
+ * const element = fDocumentBody.getElement(0);
135
+ * console.log(element?.getResolvedInfo());
136
+ * ```
137
+ */
138
+ getResolvedInfo(): IFDocumentElementInfo;
139
+ /**
140
+ * Get the next sibling element in the current body order.
141
+ * @returns {FDocumentElement | null} The next sibling wrapper, or `null` when this is the last child.
142
+ * @example
143
+ * ```ts
144
+ * const fDocument = univerAPI.getActiveDocument();
145
+ * const fDocumentBody = fDocument.getBody();
146
+ * const element = fDocumentBody.getElement(0);
147
+ * console.log(element?.getNextSibling());
148
+ * ```
149
+ */
150
+ getNextSibling(): FDocumentElement | null;
151
+ /**
152
+ * Get the previous sibling element in the current body order.
153
+ * @returns {FDocumentElement | null} The previous sibling wrapper, or `null` when this is the first child.
154
+ * @example
155
+ * ```ts
156
+ * const fDocument = univerAPI.getActiveDocument();
157
+ * const fDocumentBody = fDocument.getBody();
158
+ * const element = fDocumentBody.getElement(1);
159
+ * console.log(element?.getPreviousSibling());
160
+ * ```
161
+ */
162
+ getPreviousSibling(): FDocumentElement | null;
163
+ /**
164
+ * Get the sibling element at a relative offset from this element.
165
+ * @param {number} offset The relative offset from this element. Use `1` for the next sibling, `-1` for the previous sibling, and so on.
166
+ * @returns {FDocumentElement | null} The sibling wrapper at the specified offset, or `null` when the offset is out of range.
167
+ * @example
168
+ * ```ts
169
+ * const fDocument = univerAPI.getActiveDocument();
170
+ * const fDocumentBody = fDocument.getBody();
171
+ * const element = fDocumentBody.getElement(0);
172
+ *
173
+ * // Get the third sibling after this element
174
+ * const nextThirdSibling = element?.getSibling(3);
175
+ * console.log(nextThirdSibling?.getType());
176
+ * ```
177
+ */
178
+ getSibling(offset: number): FDocumentElement | null;
179
+ /**
180
+ * Remove this element from its parent body.
181
+ * @returns {boolean} `true` if the element content was removed.
182
+ * @example
183
+ * ```ts
184
+ * const fDocument = univerAPI.getActiveDocument();
185
+ * const fDocumentBody = fDocument.getBody();
186
+ * const element = fDocumentBody.getElement(0);
187
+ * const removed = element?.remove();
188
+ * console.log(removed);
189
+ * ```
190
+ */
191
+ remove(): boolean;
192
+ private _createSibling;
193
+ }
@@ -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 {};
@@ -16,13 +16,7 @@
16
16
  import type { DocumentDataModel, IDocumentData } from '@univerjs/core';
17
17
  import { ICommandService, Injector, IResourceLoaderService, IUniverInstanceService } from '@univerjs/core';
18
18
  import { FBaseInitialable } from '@univerjs/core/facade';
19
- import { FDocBody } from './f-doc-body';
20
- export interface IDocumentInsertTextFacadeOptions {
21
- startOffset?: number;
22
- endOffset?: number;
23
- segmentId?: string;
24
- cursorOffset?: number;
25
- }
19
+ import { FDocumentBody } from './f-document-body';
26
20
  /**
27
21
  * Facade API object bounded to a document. It provides a set of methods to interact with the document.
28
22
  * @hideconstructor
@@ -34,7 +28,6 @@ export declare class FDocument extends FBaseInitialable {
34
28
  protected readonly _resourceLoaderService: IResourceLoaderService;
35
29
  private readonly _commandService;
36
30
  readonly id: string;
37
- private readonly _docElementRegistry;
38
31
  constructor(_documentDataModel: DocumentDataModel, _injector: Injector, _univerInstanceService: IUniverInstanceService, _resourceLoaderService: IResourceLoaderService, _commandService: ICommandService);
39
32
  /**
40
33
  * Get the document data model of the document.
@@ -55,18 +48,22 @@ export declare class FDocument extends FBaseInitialable {
55
48
  * use their persisted `paragraphId` values. Persisted elements, such as tables
56
49
  * and custom blocks, use their existing ids.
57
50
  *
58
- * @returns {FDocBody} The document body API instance.
51
+ * @returns {FDocumentBody} The document body API instance.
59
52
  * @example
60
53
  * ```typescript
61
- * const doc = univerAPI.getActiveDocument();
62
- * if (!doc) throw new Error('No active document');
54
+ * const fDocument = univerAPI.getActiveDocument();
55
+ * const fDocumentBody = fDocument.getBody();
56
+ * console.log(fDocumentBody.getBody());
63
57
  *
64
- * const body = doc.getBody();
65
- * const paragraph = body.getChild(0).asParagraph();
66
- * paragraph.appendText(' updated');
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
+ * }
67
64
  * ```
68
65
  */
69
- getBody(): FDocBody;
66
+ getBody(): FDocumentBody;
70
67
  dispose(): void;
71
68
  /**
72
69
  * Get the document id.
@@ -123,83 +120,4 @@ export declare class FDocument extends FBaseInitialable {
123
120
  * ```
124
121
  */
125
122
  redo(): boolean;
126
- /**
127
- * Adds the specified text to the end of this text region.
128
- * @param {string} text - The text to be added to the end of this text region.
129
- * @return {boolean} `true` if the text was successfully appended, or `false` if it failed.
130
- * @example
131
- * ```typescript
132
- * const fDocument = univerAPI.getActiveDocument();
133
- * const success = fDocument.appendText('Hello, world!');
134
- * console.log(success);
135
- * ```
136
- */
137
- appendText(text: string): boolean;
138
- /**
139
- * Inserts text at the provided document range. Defaults to appending before the final section break.
140
- * @param {string} text - The text to insert.
141
- * @param {IDocumentInsertTextFacadeOptions} options - Optional target range, segment id, and cursor offset.
142
- * @returns {boolean} `true` if the text was successfully inserted, or `false` if it failed.
143
- * @example
144
- *
145
- * // Insert text at a specific range in the document body
146
- * ```typescript
147
- * const fDocument = univerAPI.getActiveDocument();
148
- * const success = fDocument.insertText('Hello, world!', {
149
- * startOffset: 5,
150
- * endOffset: 5,
151
- * segmentId: '',
152
- * cursorOffset: 13,
153
- * });
154
- * console.log(success);
155
- * ```
156
- *
157
- * // Insert text at the beginning of a header or footer segment
158
- * ```typescript
159
- * const fDocument = univerAPI.getActiveDocument();
160
- * const snapshot = fDocument.save();
161
- * const { headers, footers } = snapshot;
162
- *
163
- * if (headers) {
164
- * for (const headerId in headers) {
165
- * if (headerId === 'target-header-id') {
166
- * fDocument.insertText('Hello, header!', {
167
- * startOffset: 0,
168
- * endOffset: 0,
169
- * segmentId: headerId,
170
- * });
171
- * }
172
- * }
173
- * }
174
- *
175
- * if (footers) {
176
- * for (const footerId in footers) {
177
- * if (footerId === 'target-footer-id') {
178
- * fDocument.insertText('Hello, footer!', {
179
- * startOffset: 0,
180
- * endOffset: 0,
181
- * segmentId: footerId,
182
- * });
183
- * }
184
- * }
185
- * }
186
- * ```
187
- */
188
- insertText(text: string, options?: IDocumentInsertTextFacadeOptions): boolean;
189
- /**
190
- * Inserts one or more plain-text paragraphs at the provided document range.
191
- * @param {string} text - The paragraph text to insert. Newlines are normalized to document paragraph separators.
192
- * @param {IDocumentInsertTextFacadeOptions} options - Optional target range, segment id, and cursor offset.
193
- * @returns {boolean} `true` if the paragraphs were successfully inserted, or `false` if it failed.
194
- * @example
195
- * ```typescript
196
- * const fDocument = univerAPI.getActiveDocument();
197
- * const success = fDocument.insertParagraph('Hello, world! This is a new paragraph.', {
198
- * startOffset: 5,
199
- * endOffset: 5,
200
- * });
201
- * console.log(success);
202
- * ```
203
- */
204
- insertParagraph(text?: string, options?: IDocumentInsertTextFacadeOptions): boolean;
205
123
  }
@@ -14,12 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import './f-univer';
17
- export { DocElementRegistry, DocElementStaleError, type FDocElementType } from './doc-element-registry';
18
- export { FDocBlockRange } from './f-doc-block-range';
19
- export { FDocBody, type IFDocElementHandle, type IFDocResolvedParagraph, type IFDocRichTextLike, type IFDocTextRange } from './f-doc-body';
20
- export { FDocCustomBlock } from './f-doc-custom-block';
21
- export { FDocElement } from './f-doc-element';
22
- export { FDocParagraph } from './f-doc-paragraph';
23
- export { FDocTable } from './f-doc-table';
24
17
  export { FDocument } from './f-document';
25
- export type * from './f-univer';
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';
@@ -13,14 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IDocumentBody } from '@univerjs/core';
17
- type IParagraphStyle = NonNullable<IDocumentBody['paragraphs']>[number]['paragraphStyle'];
16
+ import type { IDocumentBody, IParagraphStyle } from '@univerjs/core';
18
17
  export interface IBuildPlainTextInsertBodyOptions {
19
18
  paragraphStyle?: IParagraphStyle;
20
19
  removeLeadingParagraphBreak?: boolean;
21
20
  }
22
21
  export declare function getRemovedLeadingParagraphBreakLength(dataStream: string, removeLeadingParagraphBreak?: boolean): number;
23
22
  export declare function getNormalizedPlainTextCursorOffset(dataStream: string, cursorOffset: number, removeLeadingParagraphBreak?: boolean): number;
24
- export declare function getParagraphStyleAtOffset(body: IDocumentBody, offset: number): IParagraphStyle;
23
+ export declare function getParagraphStyleAtOffset(body: IDocumentBody, offset: number): IParagraphStyle | undefined;
25
24
  export declare function buildPlainTextInsertBody(dataStream: string, options?: IBuildPlainTextInsertBodyOptions): IDocumentBody;
26
- export {};
@@ -21,6 +21,8 @@ export { SetTextSelectionsOperation } from './commands/operations/text-selection
21
21
  export type { ISetTextSelectionsOperationParams } from './commands/operations/text-selection.operation';
22
22
  export type { IUniverDocsConfig } from './config/config';
23
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';
24
26
  export { DocContentInsertService } from './services/doc-content-insert.service';
25
27
  export type { IDocContentInsertRange } from './services/doc-content-insert.service';
26
28
  export { DocInterceptorService } from './services/doc-interceptor/doc-interceptor.service';