@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,193 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export type ConditionOperator = '<' | '<=' | '=' | '>=' | '>' | '<>';
17
+ export type FormatCondition = [ConditionOperator, number];
18
+ export interface LocaleToken {
19
+ lang: string;
20
+ language: string;
21
+ territory: string;
22
+ }
23
+ export interface LocaleData {
24
+ group: string;
25
+ decimal: string;
26
+ positive: string;
27
+ negative: string;
28
+ percent: string;
29
+ exponent: string;
30
+ nan: string;
31
+ infinity: string;
32
+ ampm: string[];
33
+ mmmm6: string[];
34
+ mmm6: string[];
35
+ mmmm: string[];
36
+ mmm: string[];
37
+ dddd: string[];
38
+ ddd: string[];
39
+ bool: string[];
40
+ preferMDY: boolean;
41
+ isDefault?: boolean;
42
+ }
43
+ export type LocaleSettings = Partial<Omit<LocaleData, 'isDefault'>>;
44
+ export interface ParseData<T extends number | boolean = number | boolean> {
45
+ v: T;
46
+ z?: string;
47
+ }
48
+ export interface NumberDigits {
49
+ total: number;
50
+ digits?: number;
51
+ sign: number;
52
+ period: number;
53
+ int: number;
54
+ frac: number;
55
+ }
56
+ export interface FormatOptions {
57
+ overflow?: string;
58
+ dateErrorThrows?: boolean;
59
+ dateErrorNumber?: boolean;
60
+ bigintErrorNumber?: boolean;
61
+ dateSpanLarge?: boolean;
62
+ leap1900?: boolean;
63
+ nbsp?: boolean;
64
+ throws?: boolean;
65
+ invalid?: string;
66
+ locale?: string;
67
+ ignoreTimezone?: boolean;
68
+ grouping?: readonly [number, number?];
69
+ indexColors?: boolean;
70
+ skipChar?: string | boolean;
71
+ fillChar?: string | boolean;
72
+ }
73
+ export interface ResolvedFormatOptions {
74
+ overflow: string;
75
+ dateErrorThrows: boolean;
76
+ dateErrorNumber: boolean;
77
+ bigintErrorNumber: boolean;
78
+ dateSpanLarge: boolean;
79
+ leap1900: boolean;
80
+ nbsp: boolean;
81
+ throws: boolean;
82
+ invalid: string;
83
+ locale: string;
84
+ ignoreTimezone: boolean;
85
+ grouping: readonly [number, number?];
86
+ indexColors: boolean;
87
+ skipChar: string | boolean;
88
+ fillChar: string | boolean;
89
+ }
90
+ export interface FormatToken {
91
+ raw: string;
92
+ type: string;
93
+ value: any;
94
+ short?: boolean;
95
+ }
96
+ export interface RenderToken {
97
+ type: string;
98
+ raw?: string;
99
+ value?: string | string[];
100
+ num?: string;
101
+ rule?: 'num' | 'num+int' | 'den';
102
+ volatile?: boolean;
103
+ plus?: boolean;
104
+ size?: number;
105
+ date?: 1;
106
+ pad?: boolean | number;
107
+ decimals?: number;
108
+ short?: boolean;
109
+ }
110
+ export interface ParsedFormatSection {
111
+ scale: number;
112
+ scaleExponent: number;
113
+ percent: boolean;
114
+ text: boolean;
115
+ date: number;
116
+ date_eval: boolean;
117
+ date_system: number;
118
+ sec_decimals: number;
119
+ general: boolean;
120
+ clock: 12 | 24;
121
+ int_pattern: string[];
122
+ frac_pattern: string[];
123
+ man_pattern: string[];
124
+ den_pattern: string[];
125
+ num_pattern: string[];
126
+ tokens: RenderToken[];
127
+ tokensUsed: number;
128
+ pattern: string;
129
+ int_max: number;
130
+ int_min: number;
131
+ frac_max: number;
132
+ frac_min: number;
133
+ man_max: number;
134
+ man_min: number;
135
+ num_max: number;
136
+ num_min: number;
137
+ den_max: number;
138
+ den_min: number;
139
+ int_p: string;
140
+ man_p: string;
141
+ num_p: string;
142
+ den_p: string;
143
+ integer: boolean;
144
+ parens?: boolean;
145
+ fractions?: boolean;
146
+ grouping?: boolean;
147
+ condition?: FormatCondition | null;
148
+ locale?: string;
149
+ color?: string | number;
150
+ dec_fractions?: boolean;
151
+ exponential?: boolean;
152
+ exp_plus?: boolean;
153
+ denominator?: number;
154
+ }
155
+ export interface ErrorFormatSection {
156
+ tokens: RenderToken[];
157
+ error: string;
158
+ }
159
+ export type FormatSection = ParsedFormatSection | ErrorFormatSection;
160
+ export interface ParsedPattern {
161
+ pattern: string;
162
+ partitions: Array<FormatSection | undefined>;
163
+ locale?: string | null;
164
+ error?: string;
165
+ info?: FormatInfo;
166
+ dateInfo?: FormatDateInfo;
167
+ }
168
+ export interface FormatDateInfo {
169
+ year: boolean;
170
+ month: boolean;
171
+ day: boolean;
172
+ hours: boolean;
173
+ minutes: boolean;
174
+ seconds: boolean;
175
+ clockType: 12 | 24;
176
+ }
177
+ export type FormatInfoType = 'currency' | 'date' | 'datetime' | 'error' | 'fraction' | 'general' | 'grouped' | 'number' | 'percent' | 'scientific' | 'text' | 'time';
178
+ export interface FormatInfo {
179
+ type: FormatInfoType;
180
+ isDate: boolean;
181
+ isText: boolean;
182
+ isPercent: boolean;
183
+ maxDecimals: number;
184
+ color: 0 | 1;
185
+ parentheses: 0 | 1;
186
+ grouped: 0 | 1;
187
+ code: string;
188
+ scale: number;
189
+ level: number;
190
+ }
191
+ export type DateParts = [number, number, number];
192
+ export type DateTimeParts = [number, number, number, number, number, number];
193
+ export type FormatColor = string | number | null;
@@ -13,12 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import * as numfmt from 'numfmt';
17
- export * as numfmt from 'numfmt';
16
+ import type { ParseData } from './api';
18
17
  export declare const DEFAULT_TEXT_FORMAT = "@@@";
19
18
  export declare const DEFAULT_TEXT_FORMAT_EXCEL = "@";
20
19
  export declare const DEFAULT_NUMBER_FORMAT = "General";
21
- export declare function isTextFormat(pattern: string | undefined): pattern is "@@@" | "@";
20
+ export declare function isTextFormat(pattern: string | undefined): pattern is "@" | "@@@";
22
21
  export declare function isDefaultFormat(pattern?: string | null): pattern is "General" | null | undefined;
23
22
  export type INumfmtLocaleTag = 'zh-CN' | 'zh-TW' | 'zh-HK' | 'ar' | 'cs' | 'da' | 'nl' | 'en' | 'fi' | 'fr' | 'de' | 'el' | 'hu' | 'is' | 'id' | 'it' | 'ja' | 'ko' | 'nb' | 'pl' | 'pt' | 'ru' | 'sk' | 'es' | 'sv' | 'th' | 'tr' | 'vi';
24
23
  /**
@@ -31,4 +30,4 @@ export declare const currencySymbols: string[];
31
30
  /**
32
31
  * Get the numfmt parse value, and filter out the parse error.
33
32
  */
34
- export declare const getNumfmtParseValueFilter: (value: string) => numfmt.ParseData | null;
33
+ export declare const getNumfmtParseValueFilter: (value: string) => ParseData | null;
@@ -85,14 +85,3 @@ export declare class Tools {
85
85
  */
86
86
  export declare function composeStyles(...styles: Nullable<IStyleData>[]): IStyleData;
87
87
  export declare const isNodeEnv: () => boolean;
88
- /**
89
- * Converts a wildcard pattern with ? and * to a regular expression.
90
- * @param {string} wildChar - The wildcard string containing ? and *
91
- * @returns {RegExp} The generated regular expression
92
- */
93
- export declare function createREGEXFromWildChar(wildChar: string): RegExp;
94
- /**
95
- * Escapes characters that have special meaning in a regular expression so the
96
- * returned string can be safely embedded in a RegExp pattern as literal text.
97
- */
98
- export declare function escapeRegExp(str: string): string;
@@ -0,0 +1,26 @@
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 * from './clone';
17
+ export { getEmptySnapshot as getSheetsEmptySnapshot } from './empty-snapshot';
18
+ export { Range } from './range';
19
+ export * from './sheet-skeleton';
20
+ 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 './sheet-snapshot-utils';
21
+ export { Styles } from './styles';
22
+ export * from './typedef';
23
+ export { addLinkToDocumentModel, createDocumentModelWithStyle, getEmptyCell, isNotNullOrUndefined, isRangesEqual, isUnitRangesEqual, } from './util';
24
+ export { SheetViewModel } from './view-model';
25
+ export { getWorksheetUID, Workbook } from './workbook';
26
+ export { extractPureTextFromCell, getDisplayValueFromCell, getOriginCellValue, Worksheet } from './worksheet';
@@ -562,6 +562,7 @@ export interface ISelection {
562
562
  primary: Nullable<ISelectionCell>;
563
563
  }
564
564
  export interface ITextRangeStart {
565
+ /** Inclusive insertion offset at the start of the selection. */
565
566
  startOffset: number;
566
567
  }
567
568
  export declare enum RANGE_DIRECTION {
@@ -570,6 +571,7 @@ export declare enum RANGE_DIRECTION {
570
571
  FORWARD = "forward"
571
572
  }
572
573
  export interface ITextRange extends ITextRangeStart {
574
+ /** Exclusive insertion offset at the end of a non-collapsed selection. */
573
575
  endOffset: number;
574
576
  collapsed: boolean;
575
577
  direction?: RANGE_DIRECTION;
@@ -161,5 +161,4 @@ export declare const DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING = 1.5;
161
161
  export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE = 0;
162
162
  export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW = 12;
163
163
  export declare const NAMED_STYLE_SPACE_MAP: Record<NamedStyleType, Nullable<IParagraphStyle>>;
164
- export declare const PRINT_CHART_COMPONENT_KEY = "univer-sheets-chart-print-chart";
165
164
  export declare const DOC_DRAWING_PRINTING_COMPONENT_KEY = "univer-docs-drawing-printing";
@@ -37,3 +37,12 @@ export declare enum LocaleType {
37
37
  PL_PL = "plPL",
38
38
  AR_SA = "arSA"
39
39
  }
40
+ type LocaleDirection = 'ltr' | 'rtl';
41
+ interface ILocaleMeta {
42
+ name: string;
43
+ tag: string;
44
+ direction: LocaleDirection;
45
+ numberingSystem?: string;
46
+ }
47
+ export declare const LOCALE_META: Record<LocaleType, ILocaleMeta>;
48
+ export {};
@@ -16,6 +16,7 @@
16
16
  import type { ICustomDecoration, ICustomRange, IParagraph } from './i-document-data';
17
17
  export interface ICustomRangeForInterceptor extends ICustomRange {
18
18
  active?: boolean;
19
+ glyphWidthEm?: number;
19
20
  show?: boolean;
20
21
  }
21
22
  export interface ICustomDecorationForInterceptor extends ICustomDecoration {
@@ -286,7 +286,9 @@ export interface IHyperlink {
286
286
  * A ParagraphElement that represents a run of text that all has the same styling.
287
287
  */
288
288
  export interface ITextRun {
289
+ /** Inclusive character index of the first styled character. */
289
290
  st: number;
291
+ /** Exclusive character boundary after the last styled character. */
290
292
  ed: number;
291
293
  sId?: string;
292
294
  ts?: ITextStyle;
@@ -295,7 +297,9 @@ export interface ITextRun {
295
297
  * Block element, link like, disabled to self nested
296
298
  */
297
299
  export interface ICustomRange<T extends Record<string, any> = Record<string, any>> {
300
+ /** Inclusive index of the first character covered by this annotation. */
298
301
  startIndex: number;
302
+ /** Inclusive index of the last character covered by this annotation. */
299
303
  endIndex: number;
300
304
  rangeId: string;
301
305
  rangeType: CustomRangeType | number;
@@ -319,7 +323,9 @@ export declare enum DocumentBlockRangeType {
319
323
  CODE = "code"
320
324
  }
321
325
  export interface IDocumentBlockRange {
326
+ /** Inclusive index that must point at a `BLOCK_START` sentinel. */
322
327
  startIndex: number;
328
+ /** Inclusive index that must point at the matching `BLOCK_END` sentinel. */
323
329
  endIndex: number;
324
330
  blockId: string;
325
331
  blockType: DocumentBlockRangeType;
@@ -339,6 +345,7 @@ export declare enum CustomRangeType {
339
345
  * Custom Block
340
346
  */
341
347
  export interface ICustomBlock {
348
+ /** Index that must point at exactly one `CUSTOM_BLOCK` sentinel. */
342
349
  startIndex: number;
343
350
  blockType?: BlockType;
344
351
  blockId: string;
@@ -348,7 +355,9 @@ export declare enum CustomDecorationType {
348
355
  DELETED = 9999
349
356
  }
350
357
  export interface ICustomDecoration {
358
+ /** Inclusive index of the first decorated character. */
351
359
  startIndex: number;
360
+ /** Inclusive index of the last decorated character. */
352
361
  endIndex: number;
353
362
  id: string;
354
363
  type: CustomDecorationType;
@@ -383,7 +392,9 @@ export interface IDocStyleBase extends IMargin {
383
392
  pageSize?: ISize;
384
393
  pageOrient?: PageOrientType;
385
394
  documentFlavor?: DocumentFlavor;
395
+ /** Distance from the page edge to the header, in points (pt). */
386
396
  marginHeader?: number;
397
+ /** Distance from the page edge to the footer, in points (pt). */
387
398
  marginFooter?: number;
388
399
  renderConfig?: IDocumentRenderConfig;
389
400
  }
@@ -405,6 +416,7 @@ export declare enum GridType {
405
416
  }
406
417
  export interface IDocumentStyle extends IDocStyleBase, IDocumentLayout, IHeaderAndFooterBase {
407
418
  textStyle?: ITextStyle;
419
+ defaultParagraphStyle?: IDocumentDefaultParagraphStyle;
408
420
  background?: IDocumentBackground;
409
421
  }
410
422
  export interface IDocumentBackground {
@@ -452,6 +464,8 @@ export interface ISectionBreakBase {
452
464
  * Properties of section break
453
465
  */
454
466
  export interface ISectionBreak extends IDocStyleBase, ISectionBreakBase, IHeaderAndFooterBase {
467
+ /** Stable identity of the section-break metadata entry. */
468
+ sectionId: string;
455
469
  startIndex: number;
456
470
  }
457
471
  /**
@@ -484,7 +498,9 @@ export declare enum TextDirectionType {
484
498
  * Properties of section column
485
499
  */
486
500
  export interface ISectionColumnProperties {
501
+ /** Column width in points (pt). */
487
502
  width: number;
503
+ /** Trailing space after the column in points (pt). */
488
504
  paddingEnd: number;
489
505
  }
490
506
  export interface IParagraph {
@@ -526,8 +542,8 @@ export interface IBullet {
526
542
  */
527
543
  export interface IDocDrawingBase extends IDrawingParam {
528
544
  drawingId: string;
529
- title: string;
530
- description: string;
545
+ title?: string;
546
+ description?: string;
531
547
  docTransform: IDocDrawingPosition;
532
548
  layoutType: PositionedObjectLayoutType;
533
549
  behindDoc?: BooleanNumber;
@@ -568,6 +584,10 @@ export interface IDocDrawingPosition {
568
584
  positionH: IObjectPositionH;
569
585
  positionV: IObjectPositionV;
570
586
  angle: number;
587
+ /** Horizontal flip persisted with the document drawing transform. */
588
+ flipX?: boolean;
589
+ /** Vertical flip persisted with the document drawing transform. */
590
+ flipY?: boolean;
571
591
  }
572
592
  /**
573
593
  * ChartProperties
@@ -632,6 +652,11 @@ export interface IIndentStart {
632
652
  export interface IParagraphStyle extends IParagraphProperties {
633
653
  textStyle?: ITextStyle;
634
654
  }
655
+ /**
656
+ * Paragraph properties that may be inherited from the document defaults.
657
+ * Paragraph identity and named/text styles have their own inheritance mechanisms.
658
+ */
659
+ export type IDocumentDefaultParagraphStyle = Omit<IParagraphStyle, 'headingId' | 'namedStyleType' | 'textStyle'>;
635
660
  export interface IParagraphProperties extends IIndentStart {
636
661
  headingId?: string;
637
662
  namedStyleType?: NamedStyleType;
@@ -759,12 +784,16 @@ export declare enum TableTextWrapType {
759
784
  WRAP = 1
760
785
  }
761
786
  export interface ICustomTable {
787
+ /** Inclusive index that must point at a `TABLE_START` sentinel. */
762
788
  startIndex: number;
789
+ /** Exclusive boundary immediately after the matching `TABLE_END` sentinel. */
763
790
  endIndex: number;
764
791
  tableId: string;
765
792
  }
766
793
  export interface ICustomColumnGroup {
794
+ /** Inclusive index that must point at a `COLUMN_GROUP_START` sentinel. */
767
795
  startIndex: number;
796
+ /** Inclusive index that must point at the matching `COLUMN_GROUP_END` sentinel. */
768
797
  endIndex: number;
769
798
  columnGroupId: string;
770
799
  columns?: IColumn[];
@@ -828,6 +857,10 @@ export interface ITableRowSize {
828
857
  * Properties of row of table
829
858
  */
830
859
  export interface ITableRow {
860
+ /**
861
+ * Rows do not persist stream offsets. Their ordinal position must match the
862
+ * corresponding `TABLE_ROW_START`/`TABLE_ROW_END` pair in `dataStream`.
863
+ */
831
864
  tableCells: ITableCell[];
832
865
  trHeight: ITableRowSize;
833
866
  cantSplit?: BooleanNumber;
@@ -838,6 +871,10 @@ export interface ITableRow {
838
871
  * Properties of table cell
839
872
  */
840
873
  export interface ITableCell {
874
+ /**
875
+ * Cells do not persist stream offsets. Their ordinal position must match the
876
+ * corresponding `TABLE_CELL_START`/`TABLE_CELL_END` pair in the row stream.
877
+ */
841
878
  margin?: ITableCellMargin;
842
879
  rowSpan?: number;
843
880
  columnSpan?: number;
@@ -80,7 +80,11 @@ export declare enum DrawingTypeEnum {
80
80
  /**
81
81
  * Dom element, allows inserting HTML elements as floating objects into the document
82
82
  */
83
- DRAWING_DOM = 8
83
+ DRAWING_DOM = 8,
84
+ /**
85
+ * Block element, allows host products to place embeddable unit-backed blocks as drawing objects.
86
+ */
87
+ DRAWING_BLOCK = 9
84
88
  }
85
89
  export type DrawingType = DrawingTypeEnum | number;
86
90
  export interface IDrawingSpace {
@@ -104,6 +108,18 @@ export interface ITransformStateDisableOption {
104
108
  }
105
109
  export interface ITransformState extends IAbsoluteTransform, IRotationSkewFlipTransform, ITransformStateDisableOption {
106
110
  }
111
+ export interface IDrawingObjectLocks {
112
+ /**
113
+ * Prevent selecting the drawing directly from the canvas. Layer/object panels may still select it for management.
114
+ */
115
+ noSelect?: boolean;
116
+ noMove?: boolean;
117
+ noResize?: boolean;
118
+ noRotate?: boolean;
119
+ noTextEdit?: boolean;
120
+ noEditPoints?: boolean;
121
+ noChangeAspect?: boolean;
122
+ }
107
123
  export interface IDrawingParam extends IDrawingSearch {
108
124
  drawingType: DrawingType;
109
125
  transform?: Nullable<ITransformState>;
@@ -120,6 +136,14 @@ export interface IDrawingParam extends IDrawingSearch {
120
136
  * The drawing element is hidden when render
121
137
  */
122
138
  hidden?: boolean;
139
+ name?: string;
140
+ description?: string;
141
+ /**
142
+ * Compatibility shortcut for whether the drawing can be selected from the canvas.
143
+ * Prefer locks.noSelect for fine-grained behavior when available.
144
+ */
145
+ selectable?: boolean;
146
+ locks?: IDrawingObjectLocks;
123
147
  }
124
148
  /**
125
149
  * Describes a single group node's direct children in a group hierarchy.
@@ -170,11 +170,7 @@ export interface IStyleBase {
170
170
  * fontFamily
171
171
  */
172
172
  ff?: Nullable<string>;
173
- /**
174
- * fontSize
175
- *
176
- * pt
177
- */
173
+ /** Font size in points (pt), where 1 pt is 1/72 inch. */
178
174
  fs?: number;
179
175
  /**
180
176
  * italic
@@ -231,6 +227,8 @@ export interface IStyleBase {
231
227
  * Properties of cell style
232
228
  */
233
229
  export interface IStyleData extends IStyleBase {
230
+ /** Whether the font size should shrink to fit the cell width. */
231
+ stf?: BooleanNumber;
234
232
  /**
235
233
  * textRotation
236
234
  */
@@ -260,7 +258,7 @@ export interface IStyleData extends IStyleBase {
260
258
  /**
261
259
  * Exact keys of {@link IStyleData}.
262
260
  */
263
- export declare const STYLE_KEYS: readonly ["ff", "fs", "it", "bl", "ul", "bbl", "st", "ol", "bg", "bd", "cl", "va", "n", "tr", "td", "ht", "vt", "tb", "pd"];
261
+ export declare const STYLE_KEYS: readonly ["ff", "fs", "it", "bl", "ul", "bbl", "st", "ol", "bg", "bd", "cl", "va", "n", "stf", "tr", "td", "ht", "vt", "tb", "pd"];
264
262
  /**
265
263
  * Key union of {@link IStyleData}.
266
264
  */
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=t),t.push(e.prototype._initialize)}else if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):this.prototype[t]=e.prototype[t]}}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t==null?`text/plain`:t});return this._blob=n,this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}};m(h,`_instance`,void 0);var g=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get DocCreated(){return`DocCreated`}get DocDisposed(){return`DocDisposed`}get LifeCycleChanged(){return`LifeCycleChanged`}get Redo(){return`Redo`}get Undo(){return`Undo`}get BeforeRedo(){return`BeforeRedo`}get BeforeUndo(){return`BeforeUndo`}get CommandExecuted(){return`CommandExecuted`}get BeforeCommandExecute(){return`BeforeCommandExecute`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,m(this,`_eventRegistry`,new y),m(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[C];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(v,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,"FHooks",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return w}}),e.FUtil=x});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=t),t.push(e.prototype._initialize)}else if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):this.prototype[t]=e.prototype[t]}}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t==null?`text/plain`:t});return this._blob=n,this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get SpacingRule(){return t.SpacingRule}get NumberUnitType(){return t.NumberUnitType}get PresetListType(){return t.PresetListType}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}get ImageSourceType(){return t.ImageSourceType}};m(h,`_instance`,void 0);var g=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get DocCreated(){return`DocCreated`}get DocDisposed(){return`DocDisposed`}get LifeCycleChanged(){return`LifeCycleChanged`}get Redo(){return`Redo`}get Undo(){return`Undo`}get BeforeRedo(){return`BeforeRedo`}get BeforeUndo(){return`BeforeUndo`}get CommandExecuted(){return`CommandExecuted`}get BeforeCommandExecute(){return`BeforeCommandExecute`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,m(this,`_eventRegistry`,new y),m(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[C];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(v,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(){return t.RichTextBuilder.create()}newRichTextFromDocumentData(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,"FHooks",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return w}}),e.FUtil=x});