@univerjs/docs 1.0.0-alpha.1 → 1.0.0-alpha.3
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/facade.js +1156 -868
- package/lib/cjs/index.js +723 -18
- package/lib/es/facade.js +1154 -867
- package/lib/es/index.js +701 -19
- package/lib/facade.js +1154 -867
- package/lib/index.js +701 -19
- package/lib/types/commands/commands/create-header-footer.command.d.ts +45 -0
- package/lib/types/commands/commands/set-document-default-paragraph-style.command.d.ts +24 -0
- package/lib/types/commands/commands/set-section-header-footer-link.command.d.ts +26 -0
- package/lib/types/commands/commands/update-document-section.command.d.ts +38 -0
- package/lib/types/embed-host-anchor.d.ts +61 -0
- package/lib/types/facade/f-document-paragraph.d.ts +87 -100
- package/lib/types/facade/f-document-section.d.ts +281 -0
- package/lib/types/facade/f-document-text-range.d.ts +136 -0
- package/lib/types/facade/f-document.d.ts +316 -26
- package/lib/types/facade/f-enum.d.ts +32 -0
- package/lib/types/facade/f-types.d.ts +16 -0
- package/lib/types/facade/index.d.ts +11 -6
- package/lib/types/facade/utils.d.ts +15 -1
- package/lib/types/index.d.ts +15 -1
- package/lib/types/utils/paragraphs.d.ts +18 -0
- package/lib/types/utils/section-columns.d.ts +18 -0
- package/lib/types/utils/sections.d.ts +18 -0
- package/lib/types/utils/util.d.ts +19 -0
- package/lib/umd/facade.js +3 -1
- package/lib/umd/index.js +2 -1
- package/package.json +5 -5
- package/lib/types/facade/f-document-block-range.d.ts +0 -132
- package/lib/types/facade/f-document-body.d.ts +0 -276
- package/lib/types/facade/f-document-custom-block.d.ts +0 -57
- package/lib/types/facade/f-document-element.d.ts +0 -193
- package/lib/types/facade/f-document-table.d.ts +0 -57
|
@@ -1,276 +0,0 @@
|
|
|
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, IDocumentBody, Injector, ITextStyle } from '@univerjs/core';
|
|
17
|
-
import type { FDocumentBlockRange } from './f-document-block-range';
|
|
18
|
-
import type { FDocumentCustomBlock } from './f-document-custom-block';
|
|
19
|
-
import type { IFDocumentElementInfo } from './f-document-element';
|
|
20
|
-
import type { FDocumentTable } from './f-document-table';
|
|
21
|
-
import { UpdateDocsAttributeType } from '@univerjs/core';
|
|
22
|
-
import { FDocumentElement } from './f-document-element';
|
|
23
|
-
import { FDocumentParagraph } from './f-document-paragraph';
|
|
24
|
-
/**
|
|
25
|
-
* A text range in a document segment. Offsets are zero-based positions in the segment data stream.
|
|
26
|
-
*/
|
|
27
|
-
export interface IFDocumentTextRange {
|
|
28
|
-
/** The inclusive start offset of the range. */
|
|
29
|
-
startOffset: number;
|
|
30
|
-
/** The exclusive end offset of the range. */
|
|
31
|
-
endOffset: number;
|
|
32
|
-
/** The header/footer segment id. Omit or use an empty string for the main body. */
|
|
33
|
-
segmentId?: string;
|
|
34
|
-
}
|
|
35
|
-
export interface IFDocumentBodyEdit {
|
|
36
|
-
replaceRange: (range: IFDocumentTextRange, body: IDocumentBody) => boolean;
|
|
37
|
-
retainRange: (range: IFDocumentTextRange, body: IDocumentBody, coverType: UpdateDocsAttributeType) => boolean;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A Facade API object bounded to a document body or header/footer segment.
|
|
41
|
-
* It provides Google Docs-like element access and range editing methods.
|
|
42
|
-
*
|
|
43
|
-
* Paragraph elements use their persisted `paragraphId`. Tables, block ranges, and
|
|
44
|
-
* custom blocks use their persisted ids.
|
|
45
|
-
*
|
|
46
|
-
* @hideconstructor
|
|
47
|
-
*/
|
|
48
|
-
export declare class FDocumentBody {
|
|
49
|
-
private readonly _documentDataModel;
|
|
50
|
-
private readonly _injector;
|
|
51
|
-
private readonly _segmentId;
|
|
52
|
-
private readonly _bodyEdit;
|
|
53
|
-
constructor(_documentDataModel: DocumentDataModel, _injector: Injector, _segmentId?: string);
|
|
54
|
-
/**
|
|
55
|
-
* Get the segment id of this document body facade.
|
|
56
|
-
* The main body has an empty string segment id.
|
|
57
|
-
* The header and footer FDocumentBody instances have their respective segment ids.
|
|
58
|
-
* @returns {string} The segment id of this document body facade.
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
62
|
-
* const fDocumentBody = fDocument.getBody();
|
|
63
|
-
* console.log(fDocumentBody.getSegmentId());
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
getSegmentId(): string;
|
|
67
|
-
/**
|
|
68
|
-
* Get the underlying document body snapshot.
|
|
69
|
-
* @returns {IDocumentBody} The document body snapshot.
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
73
|
-
* const fDocumentBody = fDocument.getBody();
|
|
74
|
-
* console.log(fDocumentBody.getBody());
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
getBody(): IDocumentBody;
|
|
78
|
-
/**
|
|
79
|
-
* Get a list of top-level child elements in the body.
|
|
80
|
-
* @returns {FDocumentElement[]} The list of top-level document elements.
|
|
81
|
-
* @example
|
|
82
|
-
* ```ts
|
|
83
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
84
|
-
* const fDocumentBody = fDocument.getBody();
|
|
85
|
-
* const elements = fDocumentBody.getElements();
|
|
86
|
-
* console.log(elements);
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
getElements(): FDocumentElement[];
|
|
90
|
-
/**
|
|
91
|
-
* Get a top-level child element by child index.
|
|
92
|
-
* @param {number} index The zero-based child index.
|
|
93
|
-
* @returns {FDocumentElement} The top-level child element wrapper.
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
97
|
-
* const fDocumentBody = fDocument.getBody();
|
|
98
|
-
* const element = fDocumentBody.getElement(0);
|
|
99
|
-
* console.log(element);
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
getElement(index: number): FDocumentElement | null;
|
|
103
|
-
/**
|
|
104
|
-
* Get the current child index of an element handle.
|
|
105
|
-
* The index is resolved from the element key, so a paragraph handle keeps pointing
|
|
106
|
-
* to the same paragraph after facade edits insert content before it.
|
|
107
|
-
* @param {FDocumentElement} element The element handle to locate.
|
|
108
|
-
* @returns {number} The current zero-based child index.
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
112
|
-
* const fDocumentBody = fDocument.getBody();
|
|
113
|
-
* const element = fDocumentBody.getElement(0);
|
|
114
|
-
* console.log(fDocumentBody.getElementIndex(element));
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
getElementIndex(element: FDocumentElement): number;
|
|
118
|
-
/**
|
|
119
|
-
* Insert plain text at a document body offset.
|
|
120
|
-
* @param {number} index The zero-based insertion offset.
|
|
121
|
-
* @param {string} text The plain text to insert.
|
|
122
|
-
* @returns {boolean} `true` if the edit was applied.
|
|
123
|
-
* @example
|
|
124
|
-
* ```ts
|
|
125
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
126
|
-
* const fDocumentBody = fDocument.getBody();
|
|
127
|
-
* fDocumentBody.insertText(0, 'Hello ');
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
insertText(index: number, text: string): boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Apply text style to a body range.
|
|
133
|
-
* @param {IFDocumentTextRange} range The range to style.
|
|
134
|
-
* @param {ITextStyle} style The Univer text style patch.
|
|
135
|
-
* @returns {boolean} `true` if the style was applied.
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
139
|
-
* const fDocumentBody = fDocument.getBody();
|
|
140
|
-
* fDocumentBody.setTextStyle({ startOffset: 0, endOffset: 5 }, { bl: 1 });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
setTextStyle(range: IFDocumentTextRange, style: ITextStyle): boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Insert a plain-text paragraph before the paragraph at the given paragraph index.
|
|
146
|
-
* @param {number} index The zero-based paragraph insertion index.
|
|
147
|
-
* @param {string} text The paragraph text. Defaults to an empty paragraph.
|
|
148
|
-
* @returns {FDocumentParagraph} The inserted paragraph wrapper.
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
152
|
-
* const fDocumentBody = fDocument.getBody();
|
|
153
|
-
* const paragraph = fDocumentBody.insertParagraph(0, 'Document title');
|
|
154
|
-
* paragraph.appendText(' suffix');
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
insertParagraph(index: number, text?: string): FDocumentParagraph;
|
|
158
|
-
/**
|
|
159
|
-
* Append a plain-text paragraph at the end of the body.
|
|
160
|
-
* @param {string} text The paragraph text. Defaults to an empty paragraph.
|
|
161
|
-
* @returns {FDocumentParagraph} The appended paragraph wrapper.
|
|
162
|
-
* @example
|
|
163
|
-
* ```ts
|
|
164
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
165
|
-
* const fDocumentBody = fDocument.getBody();
|
|
166
|
-
* const paragraph = fDocumentBody.appendParagraph('Summary');
|
|
167
|
-
* console.log(paragraph.getText());
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
appendParagraph(text?: string): FDocumentParagraph;
|
|
171
|
-
/**
|
|
172
|
-
* Delete a range from the body.
|
|
173
|
-
* @param {IFDocumentTextRange} range The text range to delete.
|
|
174
|
-
* @returns {boolean} `true` if the range was deleted.
|
|
175
|
-
* @example
|
|
176
|
-
* ```ts
|
|
177
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
178
|
-
* const fDocumentBody = fDocument.getBody();
|
|
179
|
-
* fDocumentBody.deleteRange({ startOffset: 0, endOffset: 5 });
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
deleteRange(range: IFDocumentTextRange): boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Remove a paragraph by paragraph id.
|
|
185
|
-
* @param {FDocumentParagraph} paragraph The paragraph handle to remove.
|
|
186
|
-
* @returns {boolean} `true` if the paragraph was removed.
|
|
187
|
-
* @example
|
|
188
|
-
* ```ts
|
|
189
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
190
|
-
* const fDocumentBody = fDocument.getBody();
|
|
191
|
-
* const element = fDocumentBody.getElement(0);
|
|
192
|
-
*
|
|
193
|
-
* if (element?.isParagraph()) {
|
|
194
|
-
* const paragraph = element.asParagraph();
|
|
195
|
-
* const removed = fDocumentBody.removeParagraph(paragraph);
|
|
196
|
-
* console.log(removed ? 'Paragraph removed' : 'Failed to remove paragraph');
|
|
197
|
-
* }
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
removeParagraph(paragraph: FDocumentParagraph): boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Remove a callout, quote, or code block range and its content.
|
|
203
|
-
* @param {FDocumentBlockRange} blockRange The block range handle to remove.
|
|
204
|
-
* @returns {boolean} `true` if the block range content was removed.
|
|
205
|
-
* @example
|
|
206
|
-
* ```ts
|
|
207
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
208
|
-
* const fDocumentBody = fDocument.getBody();
|
|
209
|
-
* const element = fDocumentBody.getElement(0);
|
|
210
|
-
*
|
|
211
|
-
* if (element?.isBlockRange()) {
|
|
212
|
-
* const blockRange = element.asBlockRange();
|
|
213
|
-
* const removed = fDocumentBody.removeBlockRange(blockRange);
|
|
214
|
-
* console.log(removed ? 'Block range removed' : 'Failed to remove block range');
|
|
215
|
-
* }
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
removeBlockRange(blockRange: FDocumentBlockRange): boolean;
|
|
219
|
-
/**
|
|
220
|
-
* Remove a table marker and its content range.
|
|
221
|
-
* @returns {boolean} `true` if the table range was removed.
|
|
222
|
-
* @example
|
|
223
|
-
* ```ts
|
|
224
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
225
|
-
* const fDocumentBody = fDocument.getBody();
|
|
226
|
-
* const element = fDocumentBody.getElement(0);
|
|
227
|
-
*
|
|
228
|
-
* if (element?.isTable()) {
|
|
229
|
-
* const table = element.asTable();
|
|
230
|
-
* const removed = fDocumentBody.removeTable(table);
|
|
231
|
-
* console.log(removed ? 'Table removed' : 'Failed to remove table');
|
|
232
|
-
* }
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
removeTable(table: FDocumentTable): boolean;
|
|
236
|
-
/**
|
|
237
|
-
* Remove a custom block marker and its placeholder character.
|
|
238
|
-
* @param {FDocumentCustomBlock} customBlock The custom block handle to remove.
|
|
239
|
-
* @returns {boolean} `true` if the custom block placeholder was removed.
|
|
240
|
-
* @example
|
|
241
|
-
* ```ts
|
|
242
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
243
|
-
* const fDocumentBody = fDocument.getBody();
|
|
244
|
-
* const element = fDocumentBody.getElement(0);
|
|
245
|
-
*
|
|
246
|
-
* if (element?.isCustomBlock()) {
|
|
247
|
-
* const customBlock = element.asCustomBlock();
|
|
248
|
-
* const removed = fDocumentBody.removeCustomBlock(customBlock);
|
|
249
|
-
* console.log(removed ? 'Custom block removed' : 'Failed to remove custom block');
|
|
250
|
-
* }
|
|
251
|
-
* ```
|
|
252
|
-
*/
|
|
253
|
-
removeCustomBlock(customBlock: FDocumentCustomBlock): boolean;
|
|
254
|
-
/**
|
|
255
|
-
* Resolve an element key to its current child metadata.
|
|
256
|
-
* @param {FDocumentElement} element The element handle to resolve.
|
|
257
|
-
* @returns {IFDocumentElementInfo} The current child metadata used by the facade.
|
|
258
|
-
* @example
|
|
259
|
-
* ```ts
|
|
260
|
-
* const fDocument = univerAPI.getActiveDocument();
|
|
261
|
-
* const fDocumentBody = fDocument.getBody();
|
|
262
|
-
* const element = fDocumentBody.getElement(0);
|
|
263
|
-
* const resolved = fDocumentBody.resolveElement(element);
|
|
264
|
-
* console.log(resolved);
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
resolveElement(element: FDocumentElement): IFDocumentElementInfo;
|
|
268
|
-
private _getChildren;
|
|
269
|
-
private _resolveParagraphInfo;
|
|
270
|
-
private _getParagraphId;
|
|
271
|
-
private _getParagraphInsertOffset;
|
|
272
|
-
private _replaceBodyRange;
|
|
273
|
-
private _retainBodyRange;
|
|
274
|
-
private _ensureTextRuns;
|
|
275
|
-
private _executeTextX;
|
|
276
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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 { ICustomBlock, 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 IFDocumentCustomBlockMixin {
|
|
21
|
-
asCustomBlock(): FDocumentCustomBlock;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A facade wrapper for document top-level custom blocks.
|
|
25
|
-
* @hideconstructor
|
|
26
|
-
*/
|
|
27
|
-
export declare class FDocumentCustomBlock 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 custom block marker.
|
|
35
|
-
* @returns {ICustomBlock} The custom block 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?.isCustomBlock()) {
|
|
43
|
-
* const customBlock = element.asCustomBlock();
|
|
44
|
-
* console.log(customBlock.getCustomBlock());
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
getCustomBlock(): ICustomBlock;
|
|
49
|
-
}
|
|
50
|
-
export declare class FDocumentCustomBlockMixin extends FDocumentElement {
|
|
51
|
-
asCustomBlock(): FDocumentCustomBlock;
|
|
52
|
-
}
|
|
53
|
-
declare module '@univerjs/docs/facade' {
|
|
54
|
-
interface FDocumentElement extends IFDocumentCustomBlockMixin {
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export {};
|
|
@@ -1,193 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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 {};
|