@univerjs/core 1.0.0-alpha.2 → 1.0.0-alpha.4

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.
Files changed (77) hide show
  1. package/lib/cjs/facade.js +85 -27
  2. package/lib/cjs/index.js +16381 -10924
  3. package/lib/es/facade.js +86 -28
  4. package/lib/es/index.js +16321 -10901
  5. package/lib/facade.js +86 -28
  6. package/lib/index.js +16321 -10901
  7. package/lib/types/bases/base-data-model.d.ts +4 -0
  8. package/lib/types/bases/empty-snapshot.d.ts +2 -1
  9. package/lib/types/bases/index.d.ts +3 -2
  10. package/lib/types/bases/typedef.d.ts +80 -67
  11. package/lib/types/common/regexp/charset.d.ts +63 -0
  12. package/lib/types/common/regexp/escape.d.ts +30 -0
  13. package/lib/types/common/regexp/factory.d.ts +16 -0
  14. package/lib/types/common/regexp/index.d.ts +37 -0
  15. package/lib/types/common/regexp/or.d.ts +57 -0
  16. package/lib/types/docs/data-model/empty-snapshot.d.ts +2 -1
  17. package/lib/types/docs/data-model/index.d.ts +21 -0
  18. package/lib/types/docs/data-model/paragraph-style.d.ts +22 -0
  19. package/lib/types/docs/data-model/preset-list-type.d.ts +19 -6
  20. package/lib/types/docs/data-model/rich-text-builder.d.ts +455 -1
  21. package/lib/types/docs/data-model/text-x/action-types.d.ts +1 -0
  22. package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +4 -1
  23. package/lib/types/docs/data-model/text-x/build-utils/data-stream-change.d.ts +28 -0
  24. package/lib/types/docs/data-model/text-x/build-utils/drawings.d.ts +2 -2
  25. package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +6 -0
  26. package/lib/types/docs/data-model/text-x/build-utils/paragraph.d.ts +4 -1
  27. package/lib/types/docs/data-model/text-x/build-utils/range-interval.d.ts +74 -0
  28. package/lib/types/docs/data-model/text-x/structure-validator.d.ts +31 -0
  29. package/lib/types/docs/data-model/text-x/utils.d.ts +12 -4
  30. package/lib/types/docs/index.d.ts +5 -0
  31. package/lib/types/docs/section-break-id.d.ts +19 -0
  32. package/lib/types/docs/section-header-footer.d.ts +32 -0
  33. package/lib/types/facade/f-enum.d.ts +40 -1
  34. package/lib/types/facade/f-hooks.d.ts +8 -0
  35. package/lib/types/facade/f-univer.d.ts +28 -27
  36. package/lib/types/index.d.ts +3 -32
  37. package/lib/types/services/authz-io/authz-io-local.service.d.ts +1 -1
  38. package/lib/types/services/instance/instance.service.d.ts +26 -0
  39. package/lib/types/services/resource-manager/type.d.ts +1 -1
  40. package/lib/types/shared/date-kit.d.ts +1 -0
  41. package/lib/types/shared/numfmt/api.d.ts +82 -0
  42. package/lib/types/shared/numfmt/clamp.d.ts +16 -0
  43. package/lib/types/shared/numfmt/code-to-locale.d.ts +16 -0
  44. package/lib/types/shared/numfmt/constants.d.ts +68 -0
  45. package/lib/types/shared/numfmt/dec-to-frac.d.ts +26 -0
  46. package/lib/types/shared/numfmt/decimal.d.ts +37 -0
  47. package/lib/types/shared/numfmt/format-info.d.ts +21 -0
  48. package/lib/types/shared/numfmt/format-number.d.ts +18 -0
  49. package/lib/types/shared/numfmt/general.d.ts +18 -0
  50. package/lib/types/shared/numfmt/index.d.ts +18 -0
  51. package/lib/types/shared/numfmt/locale.d.ts +89 -0
  52. package/lib/types/shared/numfmt/num-dec.d.ts +17 -0
  53. package/lib/types/shared/numfmt/number-props.d.ts +17 -0
  54. package/lib/types/shared/numfmt/options.d.ts +17 -0
  55. package/lib/types/shared/numfmt/pad.d.ts +22 -0
  56. package/lib/types/shared/numfmt/parse-format-section.d.ts +17 -0
  57. package/lib/types/shared/numfmt/parse-pattern.d.ts +18 -0
  58. package/lib/types/shared/numfmt/parse-value.d.ts +30 -0
  59. package/lib/types/shared/numfmt/round.d.ts +26 -0
  60. package/lib/types/shared/numfmt/run-part.d.ts +18 -0
  61. package/lib/types/shared/numfmt/serial-date.d.ts +32 -0
  62. package/lib/types/shared/numfmt/to-ymd.d.ts +20 -0
  63. package/lib/types/shared/numfmt/tokenize.d.ts +20 -0
  64. package/lib/types/shared/numfmt/types.d.ts +193 -0
  65. package/lib/types/shared/{numfmt.d.ts → numfmt/utils.d.ts} +3 -4
  66. package/lib/types/shared/tools.d.ts +0 -11
  67. package/lib/types/sheets/index.d.ts +26 -0
  68. package/lib/types/sheets/typedef.d.ts +2 -0
  69. package/lib/types/types/const/const.d.ts +0 -1
  70. package/lib/types/types/enum/locale-type.d.ts +9 -0
  71. package/lib/types/types/interfaces/i-document-data-interceptor.d.ts +1 -0
  72. package/lib/types/types/interfaces/i-document-data.d.ts +39 -2
  73. package/lib/types/types/interfaces/i-drawing.d.ts +25 -1
  74. package/lib/types/types/interfaces/i-style-data.d.ts +4 -6
  75. package/lib/umd/facade.js +1 -1
  76. package/lib/umd/index.js +21 -11
  77. package/package.json +5 -6
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IDocumentBody, IDocumentData } from '../../../types/interfaces/i-document-data';
17
+ export type DocStructureIssueCode = 'missing-root-paragraph' | 'missing-root-section-break' | 'paragraph-token-mismatch' | 'duplicate-paragraph-metadata' | 'section-break-token-mismatch' | 'duplicate-section-break-metadata' | 'missing-section-id' | 'duplicate-section-id' | 'table-start-token-mismatch' | 'table-end-token-mismatch' | 'missing-table-metadata' | 'overlapping-table' | 'block-range-token-mismatch' | 'missing-block-range-metadata' | 'overlapping-block-range' | 'unbalanced-block' | 'column-group-range-token-mismatch' | 'missing-column-group-metadata' | 'overlapping-column-group' | 'column-group-column-count-mismatch' | 'custom-block-token-mismatch' | 'missing-custom-block-metadata' | 'duplicate-custom-block-metadata' | 'empty-column' | 'empty-table-cell' | 'unbalanced-column-group' | 'unbalanced-table';
18
+ export interface IDocStructureIssue {
19
+ code: DocStructureIssueCode;
20
+ segmentType: 'body' | 'header' | 'footer';
21
+ segmentId?: string;
22
+ index?: number;
23
+ message: string;
24
+ }
25
+ interface IValidationContext {
26
+ segmentType: IDocStructureIssue['segmentType'];
27
+ segmentId?: string;
28
+ }
29
+ export declare function validateDocBodyStructure(body: IDocumentBody, context?: IValidationContext): IDocStructureIssue[];
30
+ export declare function validateDocumentStructure(snapshot: Pick<IDocumentData, 'body' | 'headers' | 'footers'>): IDocStructureIssue[];
31
+ export {};
@@ -21,14 +21,19 @@ export declare enum SliceBodyType {
21
21
  copy = 0,
22
22
  cut = 1
23
23
  }
24
+ export declare enum SliceStructuralRangeMode {
25
+ intersect = 0,
26
+ contained = 1,
27
+ ending = 2
28
+ }
24
29
  export declare function getTextRunSlice(body: IDocumentBody, startOffset: number, endOffset: number, returnEmptyTextRuns?: boolean): ITextRun[] | undefined;
25
- export declare function getTableSlice(body: IDocumentBody, startOffset: number, endOffset: number): {
30
+ export declare function getTableSlice(body: IDocumentBody, startOffset: number, endOffset: number, mode?: SliceStructuralRangeMode): {
26
31
  startIndex: number;
27
32
  endIndex: number;
28
33
  tableId: string;
29
34
  }[];
30
- export declare function getBlockRangeSlice(body: IDocumentBody, startOffset: number, endOffset: number): IDocumentBlockRange[];
31
- export declare function getColumnGroupSlice(body: IDocumentBody, startOffset: number, endOffset: number): ICustomColumnGroup[];
35
+ export declare function getBlockRangeSlice(body: IDocumentBody, startOffset: number, endOffset: number, mode?: SliceStructuralRangeMode): IDocumentBlockRange[];
36
+ export declare function getColumnGroupSlice(body: IDocumentBody, startOffset: number, endOffset: number, mode?: SliceStructuralRangeMode): ICustomColumnGroup[];
32
37
  export declare function getParagraphsSlice(body: IDocumentBody, startOffset: number, endOffset: number, type?: SliceBodyType): {
33
38
  startIndex: number;
34
39
  paragraphId: string;
@@ -37,6 +42,7 @@ export declare function getParagraphsSlice(body: IDocumentBody, startOffset: num
37
42
  }[] | undefined;
38
43
  export declare function getSectionBreakSlice(body: IDocumentBody, startOffset: number, endOffset: number): {
39
44
  startIndex: number;
45
+ sectionId: string;
40
46
  pageNumberStart?: number;
41
47
  pageSize?: import("../../..").ISize;
42
48
  pageOrient?: import("../../..").PageOrientType;
@@ -71,7 +77,9 @@ export declare function getCustomBlockSlice(body: IDocumentBody, startOffset: nu
71
77
  blockType?: import("../../..").BlockType;
72
78
  blockId: string;
73
79
  }[] | undefined;
74
- export declare function getBodySlice(body: IDocumentBody, startOffset: number, endOffset: number, returnEmptyArray?: boolean, type?: SliceBodyType): IDocumentBody;
80
+ export declare function getBodySlice(body: IDocumentBody, startOffset: number, endOffset: number, returnEmptyArray?: boolean, type?: SliceBodyType, structuralRangeMode?: SliceStructuralRangeMode): IDocumentBody;
81
+ export declare function getBodySliceForTextXAction(body: IDocumentBody, startOffset: number, endOffset: number, returnEmptyArray?: boolean, type?: SliceBodyType): IDocumentBody;
82
+ export declare function getBodySliceForSplitTextXAction(body: IDocumentBody, startOffset: number, endOffset: number, returnEmptyArray?: boolean, type?: SliceBodyType): IDocumentBody;
75
83
  export declare function normalizeBody(body: IDocumentBody): IDocumentBody;
76
84
  export declare function getCustomRangeSlice(body: IDocumentBody, startOffset: number, endOffset: number): {
77
85
  customRanges?: undefined;
@@ -14,3 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export * from './data-model';
17
+ export { cloneBodyWithFreshParagraphIds, cloneParagraphWithId, createParagraphId, PARAGRAPH_ID_PREFIX, } from './paragraph-id';
18
+ export type { IParagraphIdScope } from './paragraph-id';
19
+ export { cloneSectionBreakWithId, createSectionId, SECTION_ID_PREFIX, } from './section-break-id';
20
+ export { getSectionHeaderFooterReferenceKey, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, } from './section-header-footer';
21
+ export type { IResolvedSectionHeaderFooterReference, SectionHeaderFooterKind, SectionHeaderFooterReferenceKey, SectionHeaderFooterVariant, } from './section-header-footer';
@@ -0,0 +1,19 @@
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 { ISectionBreak } from '../types/interfaces/i-document-data';
17
+ export declare const SECTION_ID_PREFIX = "section_";
18
+ export declare function createSectionId(existingIds: Set<string>): string;
19
+ export declare function cloneSectionBreakWithId(sectionBreak: ISectionBreak, existingIds: Set<string>, preserveId?: boolean): ISectionBreak;
@@ -0,0 +1,32 @@
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 { IDocumentStyle, ISectionBreak } from '../types/interfaces/i-document-data';
17
+ export type SectionHeaderFooterKind = 'header' | 'footer';
18
+ export type SectionHeaderFooterVariant = 'default' | 'first' | 'even';
19
+ export type SectionHeaderFooterReferenceKey = 'defaultHeaderId' | 'defaultFooterId' | 'firstPageHeaderId' | 'firstPageFooterId' | 'evenPageHeaderId' | 'evenPageFooterId';
20
+ export interface IResolvedSectionHeaderFooterReference {
21
+ segmentId?: string;
22
+ linkedToPrevious: boolean;
23
+ sourceSectionId?: string;
24
+ }
25
+ export declare function getSectionHeaderFooterReferenceKey(kind: SectionHeaderFooterKind, variant: SectionHeaderFooterVariant): SectionHeaderFooterReferenceKey;
26
+ /**
27
+ * Resolves one OOXML header/footer reference for a document section.
28
+ * A missing reference after the first section inherits the previous section.
29
+ * Document-level references are defaults for the first section only.
30
+ */
31
+ export declare function resolveSectionHeaderFooterReference(documentStyle: IDocumentStyle, sections: Readonly<ISectionBreak[]>, sectionIndex: number, key: SectionHeaderFooterReferenceKey): IResolvedSectionHeaderFooterReference;
32
+ export declare function resolveSectionHeaderFooterReferences(documentStyle: IDocumentStyle, sections: Readonly<ISectionBreak[]>, sectionIndex: number): Pick<ISectionBreak, SectionHeaderFooterReferenceKey>;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { AbsoluteRefType, AutoFillSeries, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, ColorType, CommandType, CommonHideTypes, CopyPasteType, DataValidationErrorStyle, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DeveloperMetadataVisibility, Dimension, Direction, HorizontalAlign, InterpolationPointType, LifecycleStages, LocaleType, MentionType, ProtectionType, RelativeDate, SheetTypes, TextDecoration, TextDirection, ThemeColorType, UniverInstanceType, VerticalAlign, WrapStrategy } from '@univerjs/core';
16
+ import { AbsoluteRefType, AutoFillSeries, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, ColorType, CommandType, CommonHideTypes, CopyPasteType, DataValidationErrorStyle, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DeveloperMetadataVisibility, Dimension, Direction, HorizontalAlign, ImageSourceType, InterpolationPointType, LifecycleStages, LocaleType, MentionType, NumberUnitType, PresetListType, ProtectionType, RelativeDate, SheetTypes, SpacingRule, TextDecoration, TextDirection, ThemeColorType, UniverInstanceType, VerticalAlign, WrapStrategy } from '@univerjs/core';
17
17
  /**
18
18
  * @hideconstructor
19
19
  */
@@ -136,6 +136,36 @@ export declare class FEnum {
136
136
  * ```
137
137
  */
138
138
  get HorizontalAlign(): typeof HorizontalAlign;
139
+ /**
140
+ * Paragraph line-height interpretation modes
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * console.log(univerAPI.Enum.SpacingRule.EXACT);
145
+ * ```
146
+ */
147
+ get SpacingRule(): typeof SpacingRule;
148
+ /**
149
+ * Units accepted by document lengths such as paragraph indentation and spacing
150
+ *
151
+ * Agent-facing rich-text helpers accept plain numbers as document points, so this enum is only needed when an
152
+ * explicit alternative unit is required.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * console.log(univerAPI.Enum.NumberUnitType.POINT);
157
+ * ```
158
+ */
159
+ get NumberUnitType(): typeof NumberUnitType;
160
+ /**
161
+ * Preset ordered, unordered, and checklist styles used by rich-text list items
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * console.log(univerAPI.Enum.PresetListType.BULLET_LIST);
166
+ * ```
167
+ */
168
+ get PresetListType(): typeof PresetListType;
139
169
  /**
140
170
  * Different text decoration styles
141
171
  *
@@ -325,4 +355,13 @@ export declare class FEnum {
325
355
  * ```
326
356
  */
327
357
  get ThemeColorType(): typeof ThemeColorType;
358
+ /**
359
+ * Image source types
360
+ *
361
+ * @example
362
+ * ```ts
363
+ * console.log(univerAPI.Enum.ImageSourceType.URL);
364
+ * ```
365
+ */
366
+ get ImageSourceType(): typeof ImageSourceType;
328
367
  }
@@ -25,41 +25,49 @@ export declare class FHooks extends FBase {
25
25
  constructor(_injector: Injector, _lifecycleService: LifecycleService);
26
26
  /**
27
27
  * @param callback
28
+ * @returns {IDisposable} A disposable used to remove the listener.
28
29
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
29
30
  */
30
31
  onStarting(callback: () => void): IDisposable;
31
32
  /**
32
33
  * @param callback
34
+ * @returns {IDisposable} A disposable used to remove the listener.
33
35
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
34
36
  */
35
37
  onReady(callback: () => void): IDisposable;
36
38
  /**
37
39
  * @param callback
40
+ * @returns {IDisposable} A disposable used to remove the listener.
38
41
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
39
42
  */
40
43
  onRendered(callback: () => void): IDisposable;
41
44
  /**
42
45
  * @param callback
46
+ * @returns {IDisposable} A disposable used to remove the listener.
43
47
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
44
48
  */
45
49
  onSteady(callback: () => void): IDisposable;
46
50
  /**
47
51
  * @param callback
52
+ * @returns {IDisposable} A disposable used to remove the listener.
48
53
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {})` as instead
49
54
  */
50
55
  onBeforeUndo(callback: (action: IUndoRedoItem) => void): IDisposable;
51
56
  /**
52
57
  * @param callback
58
+ * @returns {IDisposable} A disposable used to remove the listener.
53
59
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.Undo, (event) => {})` as instead
54
60
  */
55
61
  onUndo(callback: (action: IUndoRedoItem) => void): IDisposable;
56
62
  /**
57
63
  * @param callback
64
+ * @returns {IDisposable} A disposable used to remove the listener.
58
65
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {})` as instead
59
66
  */
60
67
  onBeforeRedo(callback: (action: IUndoRedoItem) => void): IDisposable;
61
68
  /**
62
69
  * @param callback
70
+ * @returns {IDisposable} A disposable used to remove the listener.
63
71
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.Redo, (event) => {})` as instead
64
72
  */
65
73
  onRedo(callback: (action: IUndoRedoItem) => void): IDisposable;
@@ -259,46 +259,47 @@ export declare class FUniver extends Disposable {
259
259
  newBlob(): FBlob;
260
260
  /**
261
261
  * Create a new rich text.
262
- * @param {IDocumentData} data
263
262
  * @returns {RichTextBuilder} The new rich text instance
264
263
  * @example
265
264
  * ```ts
266
- * const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
267
- * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
268
- * if (!fWorksheet) return;
269
- * const range = fWorksheet.getRange('A1');
270
- * range.setRichTextValueForCell(richText);
265
+ * const richText = univerAPI.newRichText()
266
+ * .align({ horizontal: univerAPI.Enum.HorizontalAlign.CENTER })
267
+ * .text('Status: ')
268
+ * .span('Ready', { bold: true, color: '#16a34a' });
271
269
  * ```
272
270
  */
273
- newRichText(data?: IDocumentData): RichTextBuilder;
271
+ newRichText(): RichTextBuilder;
272
+ /**
273
+ * Create a rich-text builder from raw Univer document data.
274
+ *
275
+ * This is an advanced integration escape hatch for importers and adapters. Application and agent code should use
276
+ * the fluent builder returned by `newRichText()`.
277
+ *
278
+ * @param data Raw Univer document data.
279
+ * @returns A rich-text builder initialized with the supplied document data.
280
+ * @advanced
281
+ */
282
+ newRichTextFromDocumentData(data: IDocumentData): RichTextBuilder;
274
283
  /**
275
284
  * Create a new rich text value.
276
- * @param {IDocumentData} data - The rich text data
285
+ *
286
+ * This is an advanced integration escape hatch for callers that already own Univer document data. Application and
287
+ * agent code should prefer the fluent value returned by `newRichText()`.
288
+ *
289
+ * @param {IDocumentData} data The raw Univer document data.
277
290
  * @returns {RichTextValue} The new rich text value instance
278
- * @example
279
- * ```ts
280
- * const richTextValue = univerAPI.newRichTextValue({ body: { dataStream: 'Hello World\r\n' } });
281
- * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
282
- * if (!fWorksheet) return;
283
- * const range = fWorksheet.getRange('A1');
284
- * range.setRichTextValueForCell(richTextValue);
285
- * ```
291
+ * @advanced
286
292
  */
287
293
  newRichTextValue(data: IDocumentData): RichTextValue;
288
294
  /**
289
295
  * Create a new paragraph style.
290
- * @param {IParagraphStyle} style - The paragraph style
296
+ *
297
+ * This is an advanced document-model API. Application and agent code should normally use
298
+ * `newRichText().paragraph({ ... })`.
299
+ *
300
+ * @param {IParagraphStyle} style The paragraph style
291
301
  * @returns {ParagraphStyleBuilder} The new paragraph style instance
292
- * @example
293
- * ```ts
294
- * const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
295
- * const paragraphStyle = univerAPI.newParagraphStyle({ textStyle: { ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE } });
296
- * richText.insertParagraph(paragraphStyle);
297
- * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
298
- * if (!fWorksheet) return;
299
- * const range = fWorksheet.getRange('A1');
300
- * range.setRichTextValueForCell(richText);
301
- * ```
302
+ * @advanced
302
303
  */
303
304
  newParagraphStyle(style?: IParagraphStyle): ParagraphStyleBuilder;
304
305
  /**
@@ -32,6 +32,7 @@ export * from './common/lodash';
32
32
  export { MemoryCursor } from './common/memory-cursor';
33
33
  export { mixinClass } from './common/mixin';
34
34
  export { isNumeric, isSafeNumeric, willLoseNumericPrecision } from './common/number';
35
+ export { regexp } from './common/regexp';
35
36
  export { Registry, RegistryAsMap } from './common/registry';
36
37
  export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
37
38
  export { sequence, sequenceAsync } from './common/sequence';
@@ -39,24 +40,7 @@ export type { ISequenceExecuteResult } from './common/sequence';
39
40
  export { mergeSets } from './common/set';
40
41
  export { UnitModel, UniverInstanceType } from './common/unit';
41
42
  export { isSafeUrl, normalizeUrl, resolveWithBasePath } from './common/url';
42
- export * from './docs/data-model';
43
- export { JSON1, JSONX } from './docs/data-model/json-x/json-x';
44
- export type { JSONXActions, JSONXPath } from './docs/data-model/json-x/json-x';
45
- export { replaceInDocumentBody } from './docs/data-model/replacement';
46
- export { ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, } from './docs/data-model/rich-text-builder';
47
- export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID } from './docs/data-model/subdocument';
48
- export { ActionIterator } from './docs/data-model/text-x/action-iterator';
49
- export { TextXActionType } from './docs/data-model/text-x/action-types';
50
- export type { IDeleteAction, IInsertAction, IRetainAction, TextXAction } from './docs/data-model/text-x/action-types';
51
- export { normalizeTextRuns, RESTORE_INSERTED_PARAGRAPH_IDS } from './docs/data-model/text-x/apply-utils/common';
52
- export { updateAttributeByDelete } from './docs/data-model/text-x/apply-utils/delete-apply';
53
- export { updateAttributeByInsert } from './docs/data-model/text-x/apply-utils/insert-apply';
54
- export { getPlainText } from './docs/data-model/text-x/build-utils/parse';
55
- export { TextX } from './docs/data-model/text-x/text-x';
56
- export type { TPriority } from './docs/data-model/text-x/text-x';
57
- export { composeBody, getBodySlice, getCustomBlockSlice, getCustomDecorationSlice, getCustomRangeSlice, getParagraphsSlice, getRichTextEditPath, getSectionBreakSlice, getTableSlice, getTextRunSlice, normalizeBody, SliceBodyType, } from './docs/data-model/text-x/utils';
58
- export { cloneBodyWithFreshParagraphIds, cloneParagraphWithId, createParagraphId, PARAGRAPH_ID_PREFIX, } from './docs/paragraph-id';
59
- export type { IParagraphIdScope } from './docs/paragraph-id';
43
+ export * from './docs';
60
44
  export { EventState, EventSubject, fromEventSubject } from './observer/observable';
61
45
  export type { IEventObserver } from './observer/observable';
62
46
  export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';
@@ -114,20 +98,7 @@ export { getIntersectRange } from './shared/range';
114
98
  export { afterTime, bufferDebounceTime, convertObservableToBehaviorSubject, fromCallback, takeAfter, } from './shared/rxjs';
115
99
  export { awaitTime, delayAnimationFrame } from './shared/timer';
116
100
  export { isNodeEnv } from './shared/tools';
117
- export * from './sheets/clone';
118
- export { Range } from './sheets/range';
119
- export { getCellCoordByIndexSimple, getCellWithCoordByIndexCore, SheetSkeleton } from './sheets/sheet-skeleton';
120
- export type { IGetRowColByPosOptions } from './sheets/sheet-skeleton';
121
- export * from './sheets/sheet-skeleton';
122
- export { DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, mergeWorksheetSnapshotWithDefault, } from './sheets/sheet-snapshot-utils';
123
- export { Styles } from './sheets/styles';
124
- export * from './sheets/typedef';
125
- export type { IPosition } from './sheets/typedef';
126
- export { addLinkToDocumentModel, getEmptyCell, isNotNullOrUndefined, isRangesEqual, isUnitRangesEqual, } from './sheets/util';
127
- export { createDocumentModelWithStyle } from './sheets/util';
128
- export { SheetViewModel } from './sheets/view-model';
129
- export { getWorksheetUID, Workbook } from './sheets/workbook';
130
- export { extractPureTextFromCell, getDisplayValueFromCell, getOriginCellValue, Worksheet } from './sheets/worksheet';
101
+ export * from './sheets';
131
102
  export { Skeleton } from './skeleton';
132
103
  export * from './types/const';
133
104
  export { skipParseTagNames } from './types/const/clipboard';
@@ -66,7 +66,7 @@ export declare class AuthzIoLocalService implements IAuthzIoService {
66
66
  clearAllOverrides(objectID: string): void;
67
67
  updateCollaborator(): Promise<void>;
68
68
  createCollaborator(): Promise<void>;
69
- putCollaborators(config: IPutCollaboratorsRequest): Promise<void>;
69
+ putCollaborators(_config: IPutCollaboratorsRequest): Promise<void>;
70
70
  setCfgEnableObjInherit(enabled: boolean): void;
71
71
  getCfgEnableObjInherit(): boolean;
72
72
  }
@@ -32,6 +32,28 @@ export interface ICreateUnitOptions {
32
32
  * @default true
33
33
  */
34
34
  makeCurrent?: boolean;
35
+ /**
36
+ * If product UI render services should skip their default main-canvas render
37
+ * creation. Embedded units create their render explicitly into a host-owned
38
+ * container instead.
39
+ *
40
+ * @default false
41
+ */
42
+ skipAutoRender?: boolean;
43
+ /**
44
+ * If render services should create the render unit as an embedded/non-main
45
+ * render. Embedded renders are mounted explicitly by a host container and
46
+ * must not mutate global workbench state while resolving their local view.
47
+ *
48
+ * @default false
49
+ */
50
+ embeddedRender?: boolean;
51
+ /**
52
+ * Optional parent injector for an embedded render unit. Render modules will
53
+ * resolve their dependencies from this injector before falling back to the
54
+ * root injector.
55
+ */
56
+ renderParentInjector?: Injector;
35
57
  }
36
58
  interface ICreateUnitEvent<T extends UnitModel = UnitModel> {
37
59
  unit: T;
@@ -71,6 +93,8 @@ export interface IUniverInstanceService {
71
93
  getCurrentTypeOfUnit$<T extends UnitModel>(type: UniverInstanceType): Observable<Nullable<T>>;
72
94
  /** Create a unit with snapshot info. */
73
95
  createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: Partial<T>, options?: ICreateUnitOptions): U;
96
+ /** Get the options originally used to create a unit. */
97
+ getUnitCreateOptions(unitId: string): Nullable<ICreateUnitOptions>;
74
98
  /** Dispose a unit */
75
99
  disposeUnit(unitId: string): boolean;
76
100
  registerCtorForType<T extends UnitModel>(type: UniverInstanceType, ctor: new (...args: any[]) => T): IDisposable;
@@ -88,6 +112,7 @@ export declare class UniverInstanceService extends Disposable implements IUniver
88
112
  private readonly _contextService;
89
113
  private readonly _logService;
90
114
  private readonly _unitsByType;
115
+ private readonly _unitCreateOptions;
91
116
  constructor(_injector: Injector, _contextService: IContextService, _logService: ILogService);
92
117
  dispose(): void;
93
118
  private _createHandler;
@@ -117,6 +142,7 @@ export declare class UniverInstanceService extends Disposable implements IUniver
117
142
  readonly unitDisposed$: Observable<UnitModel<object, UniverInstanceType>>;
118
143
  getTypeOfUnitDisposed$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T>;
119
144
  getUnit<T extends UnitModel = UnitModel>(id: string, type?: UniverInstanceType): Nullable<T>;
145
+ getUnitCreateOptions(unitId: string): Nullable<ICreateUnitOptions>;
120
146
  getUniverSheetInstance(unitId: string): Nullable<Workbook>;
121
147
  getAllUnitsForType<T>(type: UniverInstanceType): T[];
122
148
  changeDoc(unitId: string, doc: DocumentDataModel): void;
@@ -21,7 +21,7 @@ export type IResources = Array<{
21
21
  name: string;
22
22
  data: string;
23
23
  }>;
24
- type IBusinessName = 'SHEET' | 'DOC' | 'SLIDE';
24
+ type IBusinessName = 'SHEET' | 'DOC' | 'SLIDE' | 'BASE' | 'UNIVER';
25
25
  export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;
26
26
  export interface IResourceHook<T = any> {
27
27
  pluginName: IResourceName;
@@ -19,6 +19,7 @@ export type DateKitInput = Date | number | string | IDateKit | null | undefined;
19
19
  export interface IDateKit {
20
20
  isValid(): boolean;
21
21
  format(template?: string): string;
22
+ formatIntl(locale?: string | string[], options?: Intl.DateTimeFormatOptions): string;
22
23
  valueOf(): number;
23
24
  toDate(): Date;
24
25
  add(value: number, unit?: DateKitUnitType): IDateKit;
@@ -0,0 +1,82 @@
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 { FormatColor, FormatDateInfo, FormatInfo, FormatOptions } from './types';
17
+ export { dec2frac } from './dec-to-frac';
18
+ export { addLocale, getLocale, parseLocale } from './locale';
19
+ export { parseBool, parseDate, parseNumber, parseTime, parseValue } from './parse-value';
20
+ export { round } from './round';
21
+ export { dateFromSerial, dateToSerial } from './serial-date';
22
+ export { tokenize } from './tokenize';
23
+ export type { FormatDateInfo, FormatInfo, FormatToken, LocaleData, LocaleToken, ParseData, } from './types';
24
+ /**
25
+ * Formats a value as a string and returns the result.
26
+ */
27
+ export declare function format(pattern: string, value: unknown, options?: FormatOptions): string;
28
+ /**
29
+ * Find the color appropriate to a value as dictated by a format pattern.
30
+ */
31
+ export declare function formatColor(pattern: string, value: unknown, options?: FormatOptions): FormatColor;
32
+ /** Determine if a given format pattern is a date pattern. */
33
+ export declare function isDateFormat(pattern: string): boolean;
34
+ /** Determine if a given format pattern is a percentage pattern. */
35
+ export declare function isPercentFormat(pattern: string): boolean;
36
+ /** Determine if a given format pattern is a text only pattern. */
37
+ export declare function isTextFormat(pattern: string): boolean;
38
+ /** Determine if a given format pattern is valid. */
39
+ export declare function isValidFormat(pattern: string): boolean;
40
+ /** Returns metadata describing a parsed format pattern. */
41
+ export declare function getFormatInfo(pattern: string, options?: {
42
+ currency?: string;
43
+ }): FormatInfo;
44
+ /** Gets information about date codes used in a format string. */
45
+ export declare function getFormatDateInfo(pattern: string): FormatDateInfo;
46
+ /** A dictionary of the types used to identify token variants. */
47
+ export declare const tokenTypes: Readonly<{
48
+ AMPM: "ampm";
49
+ BREAK: "break";
50
+ CALENDAR: "calendar";
51
+ CHAR: "char";
52
+ COLOR: "color";
53
+ COMMA: "comma";
54
+ CONDITION: "condition";
55
+ DATETIME: "datetime";
56
+ DBNUM: "dbnum";
57
+ DIGIT: "digit";
58
+ DURATION: "duration";
59
+ ERROR: "error";
60
+ ESCAPED: "escaped";
61
+ EXP: "exp";
62
+ FILL: "fill";
63
+ GENERAL: "general";
64
+ GROUP: "group";
65
+ HASH: "hash";
66
+ LOCALE: "locale";
67
+ MINUS: "minus";
68
+ MODIFIER: "modifier";
69
+ NATNUM: "natnum";
70
+ PAREN: "paren";
71
+ PERCENT: "percent";
72
+ PLUS: "plus";
73
+ POINT: "point";
74
+ QMARK: "qmark";
75
+ SCALE: "scale";
76
+ SKIP: "skip";
77
+ SLASH: "slash";
78
+ SPACE: "space";
79
+ STRING: "string";
80
+ TEXT: "text";
81
+ ZERO: "zero";
82
+ }>;
@@ -0,0 +1,16 @@
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
+ export declare function clamp(number: number): number;
@@ -0,0 +1,16 @@
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
+ export declare const codeToLocale: Readonly<Record<number, string>>;
@@ -0,0 +1,68 @@
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
+ export declare const u_YEAR = 2;
17
+ export declare const u_MONTH: number;
18
+ export declare const u_DAY: number;
19
+ export declare const u_HOUR: number;
20
+ export declare const u_MIN: number;
21
+ export declare const u_SEC: number;
22
+ export declare const u_DSEC: number;
23
+ export declare const u_CSEC: number;
24
+ export declare const u_MSEC: number;
25
+ export declare const MIN_S_DATE = 0;
26
+ export declare const MAX_S_DATE = 2958466;
27
+ export declare const MIN_L_DATE = -694324;
28
+ export declare const MAX_L_DATE = 35830291;
29
+ export declare const EPOCH_1904 = -1;
30
+ export declare const EPOCH_1900 = 1;
31
+ export declare const EPOCH_1317 = 6;
32
+ export declare const TOKEN_GENERAL = "general";
33
+ export declare const TOKEN_HASH = "hash";
34
+ export declare const TOKEN_ZERO = "zero";
35
+ export declare const TOKEN_QMARK = "qmark";
36
+ export declare const TOKEN_SLASH = "slash";
37
+ export declare const TOKEN_GROUP = "group";
38
+ export declare const TOKEN_SCALE = "scale";
39
+ export declare const TOKEN_COMMA = "comma";
40
+ export declare const TOKEN_BREAK = "break";
41
+ export declare const TOKEN_TEXT = "text";
42
+ export declare const TOKEN_PLUS = "plus";
43
+ export declare const TOKEN_MINUS = "minus";
44
+ export declare const TOKEN_POINT = "point";
45
+ export declare const TOKEN_SPACE = "space";
46
+ export declare const TOKEN_PERCENT = "percent";
47
+ export declare const TOKEN_DIGIT = "digit";
48
+ export declare const TOKEN_CALENDAR = "calendar";
49
+ export declare const TOKEN_ERROR = "error";
50
+ export declare const TOKEN_DATETIME = "datetime";
51
+ export declare const TOKEN_DURATION = "duration";
52
+ export declare const TOKEN_CONDITION = "condition";
53
+ export declare const TOKEN_DBNUM = "dbnum";
54
+ export declare const TOKEN_NATNUM = "natnum";
55
+ export declare const TOKEN_LOCALE = "locale";
56
+ export declare const TOKEN_COLOR = "color";
57
+ export declare const TOKEN_MODIFIER = "modifier";
58
+ export declare const TOKEN_AMPM = "ampm";
59
+ export declare const TOKEN_ESCAPED = "escaped";
60
+ export declare const TOKEN_STRING = "string";
61
+ export declare const TOKEN_SKIP = "skip";
62
+ export declare const TOKEN_EXP = "exp";
63
+ export declare const TOKEN_FILL = "fill";
64
+ export declare const TOKEN_PAREN = "paren";
65
+ export declare const TOKEN_CHAR = "char";
66
+ export declare const indexColors: string[];
67
+ export declare const currencySymbols: string[];
68
+ export declare const reCurrencySymbols: RegExp;