@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
|
@@ -0,0 +1,281 @@
|
|
|
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, ISectionBreak, ISectionColumnProperties, SectionHeaderFooterKind, SectionHeaderFooterVariant } from '@univerjs/core';
|
|
17
|
+
import type { IHeaderFooterProps } from '@univerjs/docs';
|
|
18
|
+
import type { FDocument } from './f-document';
|
|
19
|
+
import type { IFDocumentTextRange } from './utils';
|
|
20
|
+
import { ColumnSeparatorType, SectionType } from '@univerjs/core';
|
|
21
|
+
export interface IFDocumentSectionColumnOptions {
|
|
22
|
+
/** Gap after each column except the last, in points (pt). */
|
|
23
|
+
gap?: number;
|
|
24
|
+
/** Optional explicit column widths in points (pt). Length must equal `columnCount`. */
|
|
25
|
+
widths?: number[];
|
|
26
|
+
/** Whether to draw separators, or the exact separator enum value. */
|
|
27
|
+
separator?: boolean | ColumnSeparatorType;
|
|
28
|
+
/** How the following section starts. */
|
|
29
|
+
sectionType?: SectionType;
|
|
30
|
+
}
|
|
31
|
+
export interface IFDocumentSectionDescription {
|
|
32
|
+
sectionId: string;
|
|
33
|
+
index: number;
|
|
34
|
+
range: IFDocumentTextRange;
|
|
35
|
+
columnCount: number;
|
|
36
|
+
columns: ISectionColumnProperties[];
|
|
37
|
+
columnSeparatorType: ColumnSeparatorType;
|
|
38
|
+
sectionType: SectionType;
|
|
39
|
+
headerFooter: Record<`${SectionHeaderFooterVariant}${Capitalize<SectionHeaderFooterKind>}`, {
|
|
40
|
+
segmentId: string | null;
|
|
41
|
+
linkedToPrevious: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
config: ISectionBreak;
|
|
44
|
+
}
|
|
45
|
+
/** Error thrown when traditional section APIs are used to mutate a modern document. */
|
|
46
|
+
export declare class DocsSectionUnsupportedDocumentFlavorError extends Error {
|
|
47
|
+
constructor();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Facade wrapper for an OOXML-compatible traditional document section.
|
|
51
|
+
* Modern documents use ColumnGroup APIs and cannot mutate this facade.
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
55
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
56
|
+
* console.log(fDocument.getSection(0)?.describe());
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class FDocumentSection {
|
|
61
|
+
private readonly _document;
|
|
62
|
+
private readonly _sectionId;
|
|
63
|
+
private readonly _injector;
|
|
64
|
+
constructor(_document: FDocument, _sectionId: string, _injector: Injector);
|
|
65
|
+
/**
|
|
66
|
+
* Returns the persisted section id.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
70
|
+
* console.log(fDocument?.getSection(0)?.getId());
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
getId(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the current zero-based section index.
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
79
|
+
* console.log(fDocument?.getSection(0)?.getIndex());
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
getIndex(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the section break snapshot that terminates this section.
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
88
|
+
* console.log(fDocument?.getSection(0)?.getConfig());
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
getConfig(): ISectionBreak;
|
|
92
|
+
/**
|
|
93
|
+
* Returns the section content range, excluding its terminating section-break token.
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
97
|
+
* console.log(fDocument?.getSection(0)?.getRange());
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
getRange(): IFDocumentTextRange;
|
|
101
|
+
/**
|
|
102
|
+
* Returns the explicit columns. An empty array means the normal single-column layout.
|
|
103
|
+
* Column widths and trailing spaces are in points (pt).
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
107
|
+
* console.log(fDocument?.getSection(0)?.getColumns());
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
getColumns(): ISectionColumnProperties[];
|
|
111
|
+
/**
|
|
112
|
+
* Returns a compact serializable section summary.
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
116
|
+
* console.log(fDocument?.getSection(0)?.describe());
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
describe(): IFDocumentSectionDescription;
|
|
120
|
+
/**
|
|
121
|
+
* Sets equal or explicitly sized columns for this traditional section.
|
|
122
|
+
* Use `columnCount = 1` to restore normal single-column layout.
|
|
123
|
+
* `gap` and `widths` are in points (pt).
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
127
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
128
|
+
* fDocument.getSection(0)?.setColumns(2, { gap: 18, separator: true });
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
setColumns(columnCount: number, options?: IFDocumentSectionColumnOptions): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Sets explicit OOXML-compatible column width and trailing-space values in points (pt).
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
138
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
139
|
+
* fDocument.getSection(0)?.setColumnProperties([
|
|
140
|
+
* { width: 240, paddingEnd: 18 },
|
|
141
|
+
* { width: 240, paddingEnd: 0 },
|
|
142
|
+
* ], univerAPI.Enum.ColumnSeparatorType.BETWEEN_EACH_COLUMN);
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
setColumnProperties(columns: ISectionColumnProperties[], separator?: ColumnSeparatorType): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Sets how the next section begins.
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
152
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
153
|
+
* fDocument.getSection(0)?.setSectionType(univerAPI.Enum.SectionType.NEXT_PAGE);
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
setSectionType(sectionType: SectionType): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Ensures a header segment linked specifically to this section.
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
163
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
164
|
+
* const segmentId = fDocument.getSection(0)?.ensureHeader();
|
|
165
|
+
* if (segmentId) {
|
|
166
|
+
* fDocument.insertText(0, 'Quarterly report', segmentId);
|
|
167
|
+
* }
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
ensureHeader(variant?: SectionHeaderFooterVariant): string;
|
|
172
|
+
/**
|
|
173
|
+
* Ensures a footer segment linked specifically to this section.
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
177
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
178
|
+
* const segmentId = fDocument.getSection(0)?.ensureFooter('first');
|
|
179
|
+
* if (segmentId) {
|
|
180
|
+
* fDocument.insertText(0, 'Confidential', segmentId);
|
|
181
|
+
* }
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
ensureFooter(variant?: SectionHeaderFooterVariant): string;
|
|
186
|
+
/**
|
|
187
|
+
* Returns the effective header id after resolving links to previous sections.
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
191
|
+
* console.log(fDocument?.getSection(0)?.getHeaderId('default'));
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
getHeaderId(variant?: SectionHeaderFooterVariant): string | null;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the effective footer id after resolving links to previous sections.
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
200
|
+
* console.log(fDocument?.getSection(0)?.getFooterId('first'));
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
getFooterId(variant?: SectionHeaderFooterVariant): string | null;
|
|
204
|
+
/**
|
|
205
|
+
* Whether this header variant inherits the previous section's reference.
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
209
|
+
* console.log(fDocument?.getSection(1)?.isHeaderLinkedToPrevious());
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
isHeaderLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Whether this footer variant inherits the previous section's reference.
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
218
|
+
* console.log(fDocument?.getSection(1)?.isFooterLinkedToPrevious('even'));
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
isFooterLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Links or unlinks this header variant. Unlinking clones the inherited header.
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
227
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
228
|
+
* fDocument.getSection(1)?.setHeaderLinkedToPrevious(false, 'default');
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
setHeaderLinkedToPrevious(linkedToPrevious: boolean, variant?: SectionHeaderFooterVariant): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Links or unlinks this footer variant. Unlinking clones the inherited footer.
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
238
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
239
|
+
* fDocument.getSection(1)?.setFooterLinkedToPrevious(true, 'even');
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
setFooterLinkedToPrevious(linkedToPrevious: boolean, variant?: SectionHeaderFooterVariant): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Updates header/footer switches and margins on this section break.
|
|
246
|
+
* `marginHeader` and `marginFooter` are in points (pt).
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
250
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
251
|
+
* fDocument.getSection(0)?.setHeaderFooterOptions({
|
|
252
|
+
* marginHeader: 36,
|
|
253
|
+
* marginFooter: 36,
|
|
254
|
+
* useFirstPageHeaderFooter: univerAPI.Enum.BooleanNumber.TRUE,
|
|
255
|
+
* });
|
|
256
|
+
* }
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
setHeaderFooterOptions(options: IHeaderFooterProps): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Deletes this section break. The final top-level section break cannot be removed.
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
265
|
+
* if (fDocument && !fDocument.isModern()) {
|
|
266
|
+
* const sections = fDocument.getSections();
|
|
267
|
+
* if (sections.length > 1) {
|
|
268
|
+
* sections[0].remove();
|
|
269
|
+
* }
|
|
270
|
+
* }
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
remove(): boolean;
|
|
274
|
+
private _update;
|
|
275
|
+
private _ensureHeaderFooter;
|
|
276
|
+
private _getHeaderFooterReference;
|
|
277
|
+
private _describeHeaderFooterReference;
|
|
278
|
+
private _setHeaderFooterLinkedToPrevious;
|
|
279
|
+
private _assertTraditionalDocument;
|
|
280
|
+
private _resolve;
|
|
281
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
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, ITextStyle } from '@univerjs/core';
|
|
17
|
+
import type { FDocument } from './f-document';
|
|
18
|
+
import type { IFDocumentTextRange } from './utils';
|
|
19
|
+
/** A clipped text-style run in document offsets. */
|
|
20
|
+
export interface IFDocumentTextStyleRun {
|
|
21
|
+
/** Inclusive start offset in the document segment. */
|
|
22
|
+
startOffset: number;
|
|
23
|
+
/** Exclusive end offset in the document segment. */
|
|
24
|
+
endOffset: number;
|
|
25
|
+
/** Explicit text style stored on this run. */
|
|
26
|
+
textStyle: ITextStyle;
|
|
27
|
+
}
|
|
28
|
+
/** Agent-friendly summary of a document text range. */
|
|
29
|
+
export interface IFDocumentTextRangeDescription extends IFDocumentTextRange {
|
|
30
|
+
text: string;
|
|
31
|
+
length: number;
|
|
32
|
+
/** Explicit styles stored directly in text runs. */
|
|
33
|
+
explicitTextStyleRuns: IFDocumentTextStyleRun[];
|
|
34
|
+
/** Top-level explicit style properties common to the complete range. */
|
|
35
|
+
commonExplicitTextStyle: ITextStyle;
|
|
36
|
+
/** @deprecated Use `explicitTextStyleRuns`. */
|
|
37
|
+
textStyleRuns: IFDocumentTextStyleRun[];
|
|
38
|
+
/** @deprecated Use `commonExplicitTextStyle`. */
|
|
39
|
+
commonTextStyle: ITextStyle;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Facade wrapper for reading and styling a fixed document text range.
|
|
43
|
+
*
|
|
44
|
+
* Offsets are fixed when the wrapper is created. Create a new range after edits
|
|
45
|
+
* that insert or remove content before it.
|
|
46
|
+
* @hideconstructor
|
|
47
|
+
*/
|
|
48
|
+
export declare class FDocumentTextRange {
|
|
49
|
+
private readonly _document;
|
|
50
|
+
private readonly _startOffset;
|
|
51
|
+
private readonly _endOffset;
|
|
52
|
+
private readonly _segmentId;
|
|
53
|
+
private readonly _injector;
|
|
54
|
+
constructor(_document: FDocument, _startOffset: number, _endOffset: number, _segmentId: string, _injector: Injector);
|
|
55
|
+
/**
|
|
56
|
+
* Returns the serializable document range.
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
60
|
+
* const range = fDocument?.findParagraphByText('Launch')?.getTextRange();
|
|
61
|
+
* console.log(range?.getRange());
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
getRange(): IFDocumentTextRange;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the plain data-stream text in this range.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
70
|
+
* const range = fDocument?.findParagraphByText('Launch')?.getTextRange();
|
|
71
|
+
* console.log(range?.getText());
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
getText(): string;
|
|
75
|
+
/**
|
|
76
|
+
* Returns explicit text-style runs intersecting this range.
|
|
77
|
+
* Returned offsets are clipped to the range and remain document-relative.
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
81
|
+
* const range = fDocument?.findParagraphByText('Launch')?.getTextRange();
|
|
82
|
+
* console.log(range?.getExplicitTextStyleRuns());
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
getExplicitTextStyleRuns(): IFDocumentTextStyleRun[];
|
|
86
|
+
/** @deprecated Use `getExplicitTextStyleRuns()` to distinguish stored styles from effective styles. */
|
|
87
|
+
getTextStyleRuns(): IFDocumentTextStyleRun[];
|
|
88
|
+
/**
|
|
89
|
+
* Returns top-level style properties that have the same explicit value
|
|
90
|
+
* across the complete range. Unstyled gaps make a property non-common.
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
94
|
+
* const range = fDocument?.findParagraphByText('Launch')?.getTextRange();
|
|
95
|
+
* console.log(range?.getCommonExplicitTextStyle());
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
getCommonExplicitTextStyle(): ITextStyle;
|
|
99
|
+
/** @deprecated Use `getCommonExplicitTextStyle()` to distinguish stored styles from effective styles. */
|
|
100
|
+
getCommonTextStyle(): ITextStyle;
|
|
101
|
+
/**
|
|
102
|
+
* Returns a serializable summary suitable for an agent/tool response.
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
106
|
+
* const range = fDocument?.findParagraphByText('Launch')?.getTextRange();
|
|
107
|
+
* console.log(range?.describe());
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
describe(): IFDocumentTextRangeDescription;
|
|
111
|
+
/**
|
|
112
|
+
* Merges a text-style patch into every character in the range.
|
|
113
|
+
* Existing text-run splitting, merging, and normalization are handled by
|
|
114
|
+
* the document mutation pipeline.
|
|
115
|
+
* `style.fs` is a font size in points (pt), not CSS pixels.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
119
|
+
* const range = fDocument?.findParagraphByText('Launch')?.getTextRange();
|
|
120
|
+
* range?.setTextStyle({ fs: 10.5, bl: univerAPI.Enum.BooleanNumber.TRUE });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
setTextStyle(style: ITextStyle): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Replaces the range with plain text while preserving document mutation semantics.
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
129
|
+
* const range = fDocument?.findParagraphByText('Draft')?.getTextRange();
|
|
130
|
+
* range?.setText('Final');
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
setText(text: string): boolean;
|
|
134
|
+
private _validateRange;
|
|
135
|
+
private _getStyleSegments;
|
|
136
|
+
}
|