@univerjs/docs 0.25.0 → 1.0.0-alpha.0

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,139 @@
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 { DocumentBlockRangeType } from '@univerjs/core';
17
+ import type { FDocBody } from './f-doc-body';
18
+ /**
19
+ * A facade wrapper for document block ranges, such as callout, quote, and code blocks.
20
+ *
21
+ * Block range identity is backed by the persisted `IDocumentBlockRange.blockId`,
22
+ * so wrappers can be re-resolved after text is inserted before the block range.
23
+ *
24
+ * @hideconstructor
25
+ */
26
+ export declare class FDocBlockRange {
27
+ protected readonly _body: FDocBody;
28
+ protected readonly _key: string;
29
+ constructor(_body: FDocBody, _key: string);
30
+ /**
31
+ * Get the document element type.
32
+ * @returns {'blockRange'} The literal block range element type.
33
+ * @example
34
+ * ```ts
35
+ * const doc = univerAPI.getActiveDocument();
36
+ * if (!doc) throw new Error('No active document');
37
+ *
38
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
39
+ * console.log(blockRange.getType());
40
+ * ```
41
+ */
42
+ getType(): 'blockRange';
43
+ /**
44
+ * Get the block range key.
45
+ * @returns {string} The persisted `blockId` for this block range.
46
+ * @example
47
+ * ```ts
48
+ * const doc = univerAPI.getActiveDocument();
49
+ * if (!doc) throw new Error('No active document');
50
+ *
51
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
52
+ * console.log(blockRange.getKey());
53
+ * ```
54
+ */
55
+ getKey(): string;
56
+ /**
57
+ * Get the parent body facade that owns this block range.
58
+ * @returns {FDocBody} The document body facade.
59
+ * @example
60
+ * ```ts
61
+ * const doc = univerAPI.getActiveDocument();
62
+ * if (!doc) throw new Error('No active document');
63
+ *
64
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
65
+ * console.log(blockRange.getParent().getChildIndex(blockRange));
66
+ * ```
67
+ */
68
+ getParent(): FDocBody;
69
+ /**
70
+ * Remove this block range and its content from the parent body.
71
+ * @returns {boolean} `true` if the block range content was removed.
72
+ * @example
73
+ * ```ts
74
+ * const doc = univerAPI.getActiveDocument();
75
+ * if (!doc) throw new Error('No active document');
76
+ *
77
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
78
+ * blockRange.removeFromParent();
79
+ * ```
80
+ */
81
+ removeFromParent(): boolean;
82
+ /**
83
+ * Get the block range type.
84
+ * @returns {DocumentBlockRangeType} The block type, such as callout, quote, or code.
85
+ * @example
86
+ * ```ts
87
+ * const doc = univerAPI.getActiveDocument();
88
+ * if (!doc) throw new Error('No active document');
89
+ *
90
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
91
+ * console.log(blockRange.getBlockType());
92
+ * ```
93
+ */
94
+ getBlockType(): DocumentBlockRangeType;
95
+ /**
96
+ * Get the plain text inside this block range.
97
+ * @returns {string} The block range text.
98
+ * @example
99
+ * ```ts
100
+ * const doc = univerAPI.getActiveDocument();
101
+ * if (!doc) throw new Error('No active document');
102
+ *
103
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
104
+ * console.log(blockRange.getText());
105
+ * ```
106
+ */
107
+ getText(): string;
108
+ /**
109
+ * Replace the plain text inside this block range.
110
+ * @param {string} text The replacement text.
111
+ * @returns {boolean} `true` if the block range text was replaced.
112
+ * @example
113
+ * ```ts
114
+ * const doc = univerAPI.getActiveDocument();
115
+ * if (!doc) throw new Error('No active document');
116
+ *
117
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
118
+ * blockRange.setText('Updated block text');
119
+ * ```
120
+ */
121
+ setText(text: string): boolean;
122
+ /**
123
+ * Remove this block range wrapper from the body.
124
+ *
125
+ * This currently removes the block range and its content, matching
126
+ * `removeFromParent()`.
127
+ *
128
+ * @returns {boolean} `true` if the block range content was removed.
129
+ * @example
130
+ * ```ts
131
+ * const doc = univerAPI.getActiveDocument();
132
+ * if (!doc) throw new Error('No active document');
133
+ *
134
+ * const blockRange = doc.getBody().getChild(0).asBlockRange();
135
+ * blockRange.unwrap();
136
+ * ```
137
+ */
138
+ unwrap(): boolean;
139
+ }
@@ -0,0 +1,535 @@
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, ICommandService, ICustomBlock, ICustomTable, IDocumentBlockRange, IDocumentBody, IParagraph, IParagraphStyle, ITextStyle } from '@univerjs/core';
17
+ import type { DocElementRegistry, FDocElementType } from './doc-element-registry';
18
+ import { FDocElement } from './f-doc-element';
19
+ import { FDocParagraph } from './f-doc-paragraph';
20
+ /**
21
+ * A text range in a document segment. Offsets are zero-based positions in the segment data stream.
22
+ */
23
+ export interface IFDocTextRange {
24
+ /** The inclusive start offset of the range. */
25
+ startOffset: number;
26
+ /** The exclusive end offset of the range. */
27
+ endOffset: number;
28
+ /** The header/footer segment id. Omit or use an empty string for the main body. */
29
+ segmentId?: string;
30
+ }
31
+ /**
32
+ * Resolved paragraph metadata in the current document body.
33
+ */
34
+ export interface IFDocResolvedParagraph {
35
+ /** The underlying paragraph snapshot object. */
36
+ paragraph: IParagraph;
37
+ /** The current paragraph index in the body paragraph list. */
38
+ paragraphIndex: number;
39
+ /** The inclusive start offset of the paragraph text. */
40
+ startOffset: number;
41
+ /** The exclusive end offset of the paragraph text, before the paragraph break. */
42
+ endOffset: number;
43
+ }
44
+ /**
45
+ * A stable facade element handle that can be resolved by type and key.
46
+ */
47
+ export interface IFDocElementHandle {
48
+ /**
49
+ * Get the element type.
50
+ * @returns {FDocElementType} The element type used by the facade resolver.
51
+ */
52
+ getType(): FDocElementType;
53
+ /**
54
+ * Get the persisted key used by the facade to resolve the element.
55
+ * @returns {string} The facade key.
56
+ */
57
+ getKey(): string;
58
+ }
59
+ /**
60
+ * A rich-text-like object, such as `RichTextValue` or `RichTextBuilder`, that can provide document body data.
61
+ */
62
+ export interface IFDocRichTextLike {
63
+ /**
64
+ * Get rich text data that contains document body data.
65
+ * @returns {{ body?: IDocumentBody }} The rich text data object.
66
+ */
67
+ getData(): {
68
+ body?: IDocumentBody;
69
+ };
70
+ }
71
+ interface IFDocChildInfo {
72
+ type: FDocElementType;
73
+ key: string;
74
+ position: number;
75
+ priority: number;
76
+ }
77
+ /**
78
+ * A Facade API object bounded to a document body or header/footer segment.
79
+ * It provides Google Docs-like element access and range editing methods.
80
+ *
81
+ * Paragraph elements use their persisted `paragraphId`. Tables, block ranges, and
82
+ * custom blocks use their persisted ids.
83
+ *
84
+ * @hideconstructor
85
+ */
86
+ export declare class FDocBody {
87
+ private readonly _documentDataModel;
88
+ private readonly _commandService;
89
+ private readonly _segmentId;
90
+ constructor(_documentDataModel: DocumentDataModel, _commandService: ICommandService, _registry: DocElementRegistry, _segmentId?: string);
91
+ /**
92
+ * Get the number of top-level child elements in the body.
93
+ * @returns {number} The number of child elements.
94
+ * @example
95
+ * ```ts
96
+ * const doc = univerAPI.getActiveDocument();
97
+ * if (!doc) throw new Error('No active document');
98
+ *
99
+ * const body = doc.getBody();
100
+ * console.log(body.getNumChildren());
101
+ * ```
102
+ */
103
+ getNumChildren(): number;
104
+ /**
105
+ * Get a top-level child element by child index.
106
+ * @param {number} index The zero-based child index.
107
+ * @returns {FDocElement} The child element wrapper.
108
+ * @example
109
+ * ```ts
110
+ * const doc = univerAPI.getActiveDocument();
111
+ * if (!doc) throw new Error('No active document');
112
+ *
113
+ * const body = doc.getBody();
114
+ * const firstChild = body.getChild(0);
115
+ * console.log(firstChild.getType());
116
+ * ```
117
+ */
118
+ getChild(index: number): FDocElement;
119
+ /**
120
+ * Get the current child index of an element handle.
121
+ * The index is resolved from the element key, so a paragraph handle keeps pointing
122
+ * to the same paragraph after facade edits insert content before it.
123
+ * @param {IFDocElementHandle} element The element handle to locate.
124
+ * @returns {number} The current zero-based child index.
125
+ * @example
126
+ * ```ts
127
+ * const doc = univerAPI.getActiveDocument();
128
+ * if (!doc) throw new Error('No active document');
129
+ *
130
+ * const body = doc.getBody();
131
+ * const paragraph = body.getChild(1).asParagraph();
132
+ * body.insertParagraph(0, 'Intro');
133
+ * console.log(body.getChildIndex(paragraph));
134
+ * ```
135
+ */
136
+ getChildIndex(element: IFDocElementHandle): number;
137
+ /**
138
+ * Insert plain text at a document body offset.
139
+ * @param {number} index The zero-based insertion offset.
140
+ * @param {string} text The plain text to insert.
141
+ * @returns {boolean} `true` if the edit was applied.
142
+ * @example
143
+ * ```ts
144
+ * const doc = univerAPI.getActiveDocument();
145
+ * if (!doc) throw new Error('No active document');
146
+ *
147
+ * const body = doc.getBody();
148
+ * body.insertText(0, 'Hello ');
149
+ * ```
150
+ */
151
+ insertText(index: number, text: string): boolean;
152
+ /**
153
+ * Insert a plain-text paragraph before the paragraph at the given paragraph index.
154
+ * @param {number} index The zero-based paragraph insertion index.
155
+ * @param {string} text The paragraph text. Defaults to an empty paragraph.
156
+ * @returns {FDocParagraph} The inserted paragraph wrapper.
157
+ * @example
158
+ * ```ts
159
+ * const doc = univerAPI.getActiveDocument();
160
+ * if (!doc) throw new Error('No active document');
161
+ *
162
+ * const body = doc.getBody();
163
+ * const paragraph = body.insertParagraph(0, 'Document title');
164
+ * paragraph.appendText(' suffix');
165
+ * ```
166
+ */
167
+ insertParagraph(index: number, text?: string): FDocParagraph;
168
+ /**
169
+ * Append a plain-text paragraph at the end of the body.
170
+ * @param {string} text The paragraph text. Defaults to an empty paragraph.
171
+ * @returns {FDocParagraph} The appended paragraph wrapper.
172
+ * @example
173
+ * ```ts
174
+ * const doc = univerAPI.getActiveDocument();
175
+ * if (!doc) throw new Error('No active document');
176
+ *
177
+ * const body = doc.getBody();
178
+ * const paragraph = body.appendParagraph('Summary');
179
+ * console.log(paragraph.getText());
180
+ * ```
181
+ */
182
+ appendParagraph(text?: string): FDocParagraph;
183
+ /**
184
+ * Delete a range from the body.
185
+ * @param {IFDocTextRange} range The text range to delete.
186
+ * @returns {boolean} `true` if the range was deleted.
187
+ * @example
188
+ * ```ts
189
+ * const doc = univerAPI.getActiveDocument();
190
+ * if (!doc) throw new Error('No active document');
191
+ *
192
+ * const body = doc.getBody();
193
+ * body.deleteRange({ startOffset: 0, endOffset: 5 });
194
+ * ```
195
+ */
196
+ deleteRange(range: IFDocTextRange): boolean;
197
+ /**
198
+ * Replace a range with plain text or rich text body data.
199
+ * @param {IFDocTextRange} range The text range to replace.
200
+ * @param {string | IFDocRichTextLike | { body?: IDocumentBody }} value The replacement text or rich-text-like value.
201
+ * @returns {boolean} `true` if the replacement was applied.
202
+ * @example
203
+ * ```ts
204
+ * const doc = univerAPI.getActiveDocument();
205
+ * if (!doc) throw new Error('No active document');
206
+ *
207
+ * const body = doc.getBody();
208
+ * body.replaceRange({ startOffset: 0, endOffset: 5 }, 'Hello');
209
+ * ```
210
+ */
211
+ replaceRange(range: IFDocTextRange, value: string | IFDocRichTextLike | {
212
+ body?: IDocumentBody;
213
+ }): boolean;
214
+ /**
215
+ * Apply text style to a body range.
216
+ * @param {IFDocTextRange} range The range to style.
217
+ * @param {ITextStyle} style The Univer text style patch.
218
+ * @returns {boolean} `true` if the style was applied.
219
+ * @example
220
+ * ```ts
221
+ * const doc = univerAPI.getActiveDocument();
222
+ * if (!doc) throw new Error('No active document');
223
+ *
224
+ * const body = doc.getBody();
225
+ * body.setTextStyle({ startOffset: 0, endOffset: 5 }, { bl: 1 });
226
+ * ```
227
+ */
228
+ setTextStyle(range: IFDocTextRange, style: ITextStyle): boolean;
229
+ /**
230
+ * Apply paragraph style to a paragraph handle or text range.
231
+ * @param {FDocElement | FDocParagraph | IFDocTextRange} paragraph The paragraph handle or a range inside the paragraph.
232
+ * @param {IParagraphStyle} style The Univer paragraph style patch.
233
+ * @returns {boolean} `true` if the style was applied.
234
+ * @example
235
+ * ```ts
236
+ * const doc = univerAPI.getActiveDocument();
237
+ * if (!doc) throw new Error('No active document');
238
+ *
239
+ * const body = doc.getBody();
240
+ * const paragraph = body.getChild(0).asParagraph();
241
+ * body.setParagraphStyle(paragraph, { horizontalAlign: 2 });
242
+ * ```
243
+ */
244
+ setParagraphStyle(paragraph: FDocElement | FDocParagraph | IFDocTextRange, style: IParagraphStyle): boolean;
245
+ /**
246
+ * Get the text content of a paragraph by paragraph id.
247
+ * @param {string} key The paragraph id.
248
+ * @returns {string} The paragraph text without the trailing paragraph break.
249
+ * @example
250
+ * ```ts
251
+ * const doc = univerAPI.getActiveDocument();
252
+ * if (!doc) throw new Error('No active document');
253
+ *
254
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
255
+ * console.log(doc.getBody().getParagraphText(paragraph.getKey()));
256
+ * ```
257
+ */
258
+ getParagraphText(key: string): string;
259
+ /**
260
+ * Replace the text content of a paragraph by paragraph id.
261
+ * @param {string} key The paragraph id.
262
+ * @param {string} text The replacement paragraph text.
263
+ * @returns {boolean} `true` if the paragraph text was replaced.
264
+ * @example
265
+ * ```ts
266
+ * const doc = univerAPI.getActiveDocument();
267
+ * if (!doc) throw new Error('No active document');
268
+ *
269
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
270
+ * doc.getBody().setParagraphText(paragraph.getKey(), 'Updated text');
271
+ * ```
272
+ */
273
+ setParagraphText(key: string, text: string): boolean;
274
+ /**
275
+ * Append text to a paragraph by paragraph id.
276
+ * @param {string} key The paragraph id.
277
+ * @param {string} text The text to append before the paragraph break.
278
+ * @returns {boolean} `true` if the text was appended.
279
+ * @example
280
+ * ```ts
281
+ * const doc = univerAPI.getActiveDocument();
282
+ * if (!doc) throw new Error('No active document');
283
+ *
284
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
285
+ * doc.getBody().appendParagraphText(paragraph.getKey(), ' suffix');
286
+ * ```
287
+ */
288
+ appendParagraphText(key: string, text: string): boolean;
289
+ /**
290
+ * Remove a paragraph by paragraph id.
291
+ * @param {string} key The paragraph id.
292
+ * @returns {boolean} `true` if the paragraph was removed.
293
+ * @example
294
+ * ```ts
295
+ * const doc = univerAPI.getActiveDocument();
296
+ * if (!doc) throw new Error('No active document');
297
+ *
298
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
299
+ * doc.getBody().removeParagraph(paragraph.getKey());
300
+ * ```
301
+ */
302
+ removeParagraph(key: string): boolean;
303
+ /**
304
+ * Get a paragraph text range by paragraph id.
305
+ * @param {string} key The paragraph id.
306
+ * @returns {IFDocTextRange} The paragraph range excluding the trailing paragraph break.
307
+ * @example
308
+ * ```ts
309
+ * const doc = univerAPI.getActiveDocument();
310
+ * if (!doc) throw new Error('No active document');
311
+ *
312
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
313
+ * const range = doc.getBody().getParagraphRange(paragraph.getKey());
314
+ * console.log(range.startOffset, range.endOffset);
315
+ * ```
316
+ */
317
+ getParagraphRange(key: string): IFDocTextRange;
318
+ /**
319
+ * Check whether a paragraph has list metadata.
320
+ * @param {string} key The paragraph id.
321
+ * @returns {boolean} `true` if the paragraph is a list item.
322
+ * @example
323
+ * ```ts
324
+ * const doc = univerAPI.getActiveDocument();
325
+ * if (!doc) throw new Error('No active document');
326
+ *
327
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
328
+ * console.log(doc.getBody().isListParagraph(paragraph.getKey()));
329
+ * ```
330
+ */
331
+ isListParagraph(key: string): boolean;
332
+ /**
333
+ * Check whether a paragraph is a task/checklist item.
334
+ * @param {string} key The paragraph id.
335
+ * @returns {boolean} `true` if the paragraph is an unchecked or checked task item.
336
+ * @example
337
+ * ```ts
338
+ * const doc = univerAPI.getActiveDocument();
339
+ * if (!doc) throw new Error('No active document');
340
+ *
341
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
342
+ * console.log(doc.getBody().isTaskParagraph(paragraph.getKey()));
343
+ * ```
344
+ */
345
+ isTaskParagraph(key: string): boolean;
346
+ /**
347
+ * Set the checked state of a task/checklist paragraph.
348
+ * @param {string} key The paragraph id.
349
+ * @param {boolean} checked Whether the task should be checked.
350
+ * @returns {boolean} `true` if the task state was updated, or `false` if the paragraph is not a task item.
351
+ * @example
352
+ * ```ts
353
+ * const doc = univerAPI.getActiveDocument();
354
+ * if (!doc) throw new Error('No active document');
355
+ *
356
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
357
+ * doc.getBody().setTaskChecked(paragraph.getKey(), true);
358
+ * ```
359
+ */
360
+ setTaskChecked(key: string, checked: boolean): boolean;
361
+ /**
362
+ * Resolve a paragraph id to its current paragraph metadata.
363
+ * @param {string} key The paragraph id.
364
+ * @returns {IFDocResolvedParagraph} The current paragraph metadata.
365
+ * @example
366
+ * ```ts
367
+ * const doc = univerAPI.getActiveDocument();
368
+ * if (!doc) throw new Error('No active document');
369
+ *
370
+ * const paragraph = doc.getBody().getChild(0).asParagraph();
371
+ * const resolved = doc.getBody().resolveParagraph(paragraph.getKey());
372
+ * console.log(resolved.paragraphIndex);
373
+ * ```
374
+ */
375
+ resolveParagraph(key: string): IFDocResolvedParagraph;
376
+ /**
377
+ * Resolve an element key to its current child metadata.
378
+ * @param {FDocElementType} type The element type.
379
+ * @param {string} key The persisted element key.
380
+ * @returns {object} The current child metadata used by the facade.
381
+ * @example
382
+ * ```ts
383
+ * const doc = univerAPI.getActiveDocument();
384
+ * if (!doc) throw new Error('No active document');
385
+ *
386
+ * const element = doc.getBody().getChild(0);
387
+ * const resolved = doc.getBody().resolveElement(element.getType(), element.getKey());
388
+ * console.log(resolved.position);
389
+ * ```
390
+ */
391
+ resolveElement(type: FDocElementType, key: string): IFDocChildInfo;
392
+ /**
393
+ * Get a callout, quote, or code block range by block id.
394
+ * @param {string} key The persisted block range id.
395
+ * @returns {IDocumentBlockRange} The matching block range snapshot.
396
+ * @example
397
+ * ```ts
398
+ * const doc = univerAPI.getActiveDocument();
399
+ * if (!doc) throw new Error('No active document');
400
+ *
401
+ * const block = doc.getBody().getChild(0).asBlockRange();
402
+ * console.log(doc.getBody().getBlockRange(block.getKey()).blockType);
403
+ * ```
404
+ */
405
+ getBlockRange(key: string): IDocumentBlockRange;
406
+ /**
407
+ * Get the text inside a callout, quote, or code block range.
408
+ * @param {string} key The persisted block range id.
409
+ * @returns {string} The block range text.
410
+ * @example
411
+ * ```ts
412
+ * const doc = univerAPI.getActiveDocument();
413
+ * if (!doc) throw new Error('No active document');
414
+ *
415
+ * const block = doc.getBody().getChild(0).asBlockRange();
416
+ * console.log(doc.getBody().getBlockRangeText(block.getKey()));
417
+ * ```
418
+ */
419
+ getBlockRangeText(key: string): string;
420
+ /**
421
+ * Replace the text inside a callout, quote, or code block range.
422
+ * @param {string} key The persisted block range id.
423
+ * @param {string} text The replacement text.
424
+ * @returns {boolean} `true` if the text was replaced.
425
+ * @example
426
+ * ```ts
427
+ * const doc = univerAPI.getActiveDocument();
428
+ * if (!doc) throw new Error('No active document');
429
+ *
430
+ * const block = doc.getBody().getChild(0).asBlockRange();
431
+ * doc.getBody().setBlockRangeText(block.getKey(), 'Updated block');
432
+ * ```
433
+ */
434
+ setBlockRangeText(key: string, text: string): boolean;
435
+ /**
436
+ * Remove a callout, quote, or code block range and its content.
437
+ * @param {string} key The persisted block range id.
438
+ * @returns {boolean} `true` if the block range content was removed.
439
+ * @example
440
+ * ```ts
441
+ * const doc = univerAPI.getActiveDocument();
442
+ * if (!doc) throw new Error('No active document');
443
+ *
444
+ * const block = doc.getBody().getChild(0).asBlockRange();
445
+ * doc.getBody().removeBlockRange(block.getKey());
446
+ * ```
447
+ */
448
+ removeBlockRange(key: string): boolean;
449
+ /**
450
+ * Get a table marker by table id.
451
+ * @param {string} key The persisted table id.
452
+ * @returns {ICustomTable} The matching table marker.
453
+ * @example
454
+ * ```ts
455
+ * const doc = univerAPI.getActiveDocument();
456
+ * if (!doc) throw new Error('No active document');
457
+ *
458
+ * const table = doc.getBody().getChild(0).asTable();
459
+ * console.log(doc.getBody().getTable(table.getTableId()));
460
+ * ```
461
+ */
462
+ getTable(key: string): ICustomTable;
463
+ /**
464
+ * Remove a table marker and its content range.
465
+ * @param {string} key The persisted table id.
466
+ * @returns {boolean} `true` if the table range was removed.
467
+ * @example
468
+ * ```ts
469
+ * const doc = univerAPI.getActiveDocument();
470
+ * if (!doc) throw new Error('No active document');
471
+ *
472
+ * const table = doc.getBody().getChild(0).asTable();
473
+ * doc.getBody().removeTable(table.getTableId());
474
+ * ```
475
+ */
476
+ removeTable(key: string): boolean;
477
+ /**
478
+ * Get a custom block marker by block id.
479
+ * @param {string} key The persisted custom block id.
480
+ * @returns {ICustomBlock} The matching custom block marker.
481
+ * @example
482
+ * ```ts
483
+ * const doc = univerAPI.getActiveDocument();
484
+ * if (!doc) throw new Error('No active document');
485
+ *
486
+ * const customBlock = doc.getBody().getChild(0).asCustomBlock();
487
+ * console.log(doc.getBody().getCustomBlock(customBlock.getBlockId()));
488
+ * ```
489
+ */
490
+ getCustomBlock(key: string): ICustomBlock;
491
+ /**
492
+ * Remove a custom block marker and its placeholder character.
493
+ * @param {string} key The persisted custom block id.
494
+ * @returns {boolean} `true` if the custom block placeholder was removed.
495
+ * @example
496
+ * ```ts
497
+ * const doc = univerAPI.getActiveDocument();
498
+ * if (!doc) throw new Error('No active document');
499
+ *
500
+ * const customBlock = doc.getBody().getChild(0).asCustomBlock();
501
+ * doc.getBody().removeCustomBlock(customBlock.getBlockId());
502
+ * ```
503
+ */
504
+ removeCustomBlock(key: string): boolean;
505
+ /**
506
+ * Create a sibling element wrapper relative to the current element key.
507
+ * @param {FDocElementType} type The current element type.
508
+ * @param {string} key The current element key.
509
+ * @param {-1 | 1} direction `-1` for previous sibling, `1` for next sibling.
510
+ * @returns {FDocElement | null} The sibling wrapper, or `null` if none exists.
511
+ * @example
512
+ * ```ts
513
+ * const doc = univerAPI.getActiveDocument();
514
+ * if (!doc) throw new Error('No active document');
515
+ *
516
+ * const element = doc.getBody().getChild(0);
517
+ * const next = doc.getBody().createSibling(element.getType(), element.getKey(), 1);
518
+ * console.log(next?.getType());
519
+ * ```
520
+ */
521
+ createSibling(type: FDocElementType, key: string, direction: -1 | 1): FDocElement | null;
522
+ private _getChildren;
523
+ private _createElement;
524
+ private _getBody;
525
+ private _getParagraphInsertOffset;
526
+ private _normalizeInsertedParagraphIndex;
527
+ private _getParagraphId;
528
+ private _preserveExplicitParagraphIds;
529
+ private _findParagraphByRange;
530
+ private _replaceBodyRange;
531
+ private _retainBodyRange;
532
+ private _ensureTextRuns;
533
+ private _executeTextX;
534
+ }
535
+ export {};