@univerjs/core 1.0.0-rc.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/lib/cjs/facade.js +96 -40
  2. package/lib/cjs/index.js +985 -362
  3. package/lib/es/facade.js +97 -41
  4. package/lib/es/index.js +979 -362
  5. package/lib/facade.js +97 -41
  6. package/lib/index.js +979 -362
  7. package/lib/types/docs/data-model/text-x/action-types.d.ts +19 -1
  8. package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +1 -1
  9. package/lib/types/docs/data-model/text-x/apply-utils/delete-apply.d.ts +1 -1
  10. package/lib/types/docs/data-model/text-x/apply-utils/insert-apply.d.ts +1 -1
  11. package/lib/types/docs/data-model/text-x/apply.d.ts +1 -1
  12. package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +2 -1
  13. package/lib/types/docs/data-model/text-x/custom-range-update.d.ts +30 -0
  14. package/lib/types/docs/data-model/text-x/structure-validator.d.ts +1 -1
  15. package/lib/types/docs/data-model/text-x/text-x.d.ts +7 -3
  16. package/lib/types/docs/data-model/text-x/utils.d.ts +7 -1
  17. package/lib/types/docs/sdt-binding.d.ts +19 -0
  18. package/lib/types/facade/f-blob.d.ts +11 -11
  19. package/lib/types/facade/f-enum.d.ts +9 -1
  20. package/lib/types/facade/f-event-registry.d.ts +18 -6
  21. package/lib/types/facade/f-event.d.ts +4 -0
  22. package/lib/types/facade/f-univer.d.ts +43 -19
  23. package/lib/types/index.d.ts +2 -0
  24. package/lib/types/sheets/typedef.d.ts +38 -7
  25. package/lib/types/sheets/workbook.d.ts +1 -1
  26. package/lib/types/sheets/worksheet.d.ts +8 -7
  27. package/lib/types/types/enum/record-filter.d.ts +30 -0
  28. package/lib/types/types/interfaces/i-document-data.d.ts +256 -9
  29. package/lib/types/types/interfaces/i-drawing.d.ts +9 -1
  30. package/lib/umd/facade.js +1 -1
  31. package/lib/umd/index.js +26 -26
  32. package/package.json +7 -7
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import type { ImageSourceType } from '../services/image-io/image-io.service';
16
17
  import type { IResources } from '../services/resource-manager/type';
17
18
  import type { IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, Nullable } from '../shared';
18
19
  import type { BooleanNumber } from '../types/enum';
@@ -77,6 +78,24 @@ export interface IWorkbookData {
77
78
  */
78
79
  custom?: CustomData;
79
80
  }
81
+ /** Worksheet-only hiding states; row/column and cell flags still use BooleanNumber. */
82
+ export declare enum WorksheetHiddenState {
83
+ /** Visible in the sheet bar. Preserves the existing hidden: 0 value. */
84
+ VISIBLE = 0,
85
+ /** Hidden, and listed in the UI's Unhide dialog. Preserves hidden: 1. */
86
+ HIDDEN = 1,
87
+ /** Omitted from Unhide UI; can be revealed through the API. Not an access permission. */
88
+ VERY_HIDDEN = 2
89
+ }
90
+ /** Image displayed behind the worksheet grid. */
91
+ export interface IWorksheetBackgroundImage {
92
+ source: string;
93
+ imageSourceType: ImageSourceType;
94
+ /** Horizontal scale from source pixels to 96-DPI worksheet layout pixels. */
95
+ scaleX?: number;
96
+ /** Vertical scale from source pixels to 96-DPI worksheet layout pixels. */
97
+ scaleY?: number;
98
+ }
80
99
  /**
81
100
  * Snapshot of a worksheet.
82
101
  */
@@ -89,14 +108,12 @@ export interface IWorksheetData {
89
108
  name: string;
90
109
  tabColor: string;
91
110
  /**
92
- * Determine whether the sheet is hidden.
93
- *
94
- * @remarks
95
- * See {@link BooleanNumber| the BooleanNumber enum} for more details.
96
- *
97
- * @defaultValue `BooleanNumber.FALSE`
111
+ * Sheet hiding state: 0 = visible, 1 = hidden, 2 = very hidden.
112
+ * BooleanNumber remains accepted for existing 0/1 snapshots and integrations.
113
+ * Use WorksheetHiddenState for new code; do not interpret this as a boolean flag.
114
+ * @defaultValue WorksheetHiddenState.VISIBLE
98
115
  */
99
- hidden: BooleanNumber;
116
+ hidden: WorksheetHiddenState | BooleanNumber;
100
117
  freeze: IFreeze;
101
118
  rowCount: number;
102
119
  columnCount: number;
@@ -128,6 +145,8 @@ export interface IWorksheetData {
128
145
  * Color of the gridlines.
129
146
  */
130
147
  gridlinesColor?: string;
148
+ /** Image tiled behind the worksheet grid. It is not included when printing. */
149
+ backgroundImage?: IWorksheetBackgroundImage;
131
150
  rightToLeft: BooleanNumber;
132
151
  /**
133
152
  * User stored custom fields.
@@ -206,6 +225,14 @@ export interface IColAutoWidthInfo {
206
225
  * Cell value type
207
226
  */
208
227
  export type CellValue = string | number | boolean;
228
+ /** Formula kinds from SpreadsheetML ST_CellFormulaType. */
229
+ export declare enum FormulaType {
230
+ NORMAL = 0,
231
+ SHARED = 1,
232
+ ARRAY = 2,
233
+ /** What-if analysis data table, not a structured table. */
234
+ DATA_TABLE = 3
235
+ }
209
236
  /**
210
237
  * Cell data
211
238
  */
@@ -226,6 +253,10 @@ export interface ICellData {
226
253
  * Raw formula string. For example `=SUM(A1:B4)`.
227
254
  */
228
255
  f?: Nullable<string>;
256
+ /** Formula type, mapped from OOXML f@t. Omission preserves existing runtime behavior. */
257
+ ft?: Nullable<FormulaType>;
258
+ /** Dynamic array flag, mapped from the referenced dynamicArrayProperties@fDynamic metadata. */
259
+ fd?: Nullable<BooleanNumber>;
229
260
  /**
230
261
  * If the formula is a formula array, this field is used to store the referencing range.
231
262
  * @ignore
@@ -118,7 +118,7 @@ export declare class Workbook extends UnitModel<IWorkbookData, UniverInstanceTyp
118
118
  getSheetBySheetName(name: string): Nullable<Worksheet>;
119
119
  getSheetBySheetId(sheetId: string): Nullable<Worksheet>;
120
120
  getSheetByIndex(index: number): Nullable<Worksheet>;
121
- getHiddenWorksheets(): string[];
121
+ getHiddenWorksheets(includeVeryHidden?: boolean): string[];
122
122
  getUnhiddenWorksheets(): string[];
123
123
  load(config: IWorkbookData): void;
124
124
  /**
@@ -15,18 +15,18 @@
15
15
  */
16
16
  import type { IInterceptor } from '../common/interceptor';
17
17
  import type { Nullable } from '../shared';
18
- import type { BooleanNumber, HorizontalAlign, TextDirection, VerticalAlign, WrapStrategy } from '../types/enum';
18
+ import type { HorizontalAlign, TextDirection, VerticalAlign, WrapStrategy } from '../types/enum';
19
19
  import type { IPaddingData, IStyleData, ITextRotation } from '../types/interfaces';
20
20
  import type { Styles } from './styles';
21
21
  import type { CustomData, ICellData, ICellDataForSheetInterceptor, ICellDataWithSpanAndDisplay, IFreeze, IRange, ISelectionCell, IWorksheetData } from './typedef';
22
22
  import { DocumentDataModel } from '../docs';
23
23
  import { ObjectMatrix } from '../shared';
24
- import { CellValueType } from '../types/enum';
24
+ import { BooleanNumber, CellValueType } from '../types/enum';
25
25
  import { ColumnManager } from './column-manager';
26
26
  import { Range } from './range';
27
27
  import { RowManager } from './row-manager';
28
28
  import { SpanModel } from './span-model';
29
- import { CellModeEnum } from './typedef';
29
+ import { CellModeEnum, WorksheetHiddenState } from './typedef';
30
30
  import { SheetViewModel } from './view-model';
31
31
  export interface IDocumentLayoutObject {
32
32
  documentModel: Nullable<DocumentDataModel>;
@@ -323,11 +323,12 @@ export declare class Worksheet {
323
323
  setRowCount(count: number): void;
324
324
  getColumnCount(): number;
325
325
  setColumnCount(count: number): void;
326
- /**
327
- * isSheetHidden
328
- * @returns hidden status of sheet
329
- */
326
+ /** Returns 0 for visible, 1 for either hidden state, preserving the existing predicate API. */
330
327
  isSheetHidden(): BooleanNumber;
328
+ /** Returns the complete persisted state, including VERY_HIDDEN (2). */
329
+ getHiddenState(): WorksheetHiddenState;
330
+ /** Model mutation primitive. User-facing changes must go through worksheet hide/show commands. */
331
+ setHiddenState(hidden: WorksheetHiddenState | BooleanNumber): void;
331
332
  /**
332
333
  * Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default.
333
334
  * @returns {boolean} Gridlines Hidden Status.
@@ -0,0 +1,30 @@
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
+ /** Typed record identities shared by compact Table and external report filters. */
17
+ export declare enum RecordValueType {
18
+ Blank = "blank",
19
+ String = "string",
20
+ Number = "number",
21
+ Date = "date",
22
+ Boolean = "boolean",
23
+ Error = "error"
24
+ }
25
+ /** Values are wire identifiers; an absent native Table filter represents All. */
26
+ export declare enum FilterSelectionMode {
27
+ All = "all",
28
+ Include = "include",
29
+ Exclude = "exclude"
30
+ }
@@ -45,6 +45,8 @@ export interface IReferenceSource {
45
45
  tableSource?: ITables;
46
46
  footers?: IFooters;
47
47
  headers?: IHeaders;
48
+ footnotes?: Record<string, IDocxNoteStory>;
49
+ endnotes?: Record<string, IDocxNoteStory>;
48
50
  lists?: ILists;
49
51
  drawings?: IDrawings;
50
52
  drawingsOrder?: string[];
@@ -99,10 +101,19 @@ export interface IDocumentNote {
99
101
  customMark?: string;
100
102
  /** Style of the generated note marker; it does not affect text inserted at body offset zero. */
101
103
  referenceTextStyle?: ITextStyle;
104
+ /** False preserves an imported note body without a reference marker; the main-story anchor is unaffected. */
105
+ showBodyReference?: boolean;
102
106
  }
103
107
  export type IFootnoteCustomRange = ICustomRange<{
104
108
  noteId: string;
105
109
  }>;
110
+ /** A note story keyed by its OOXML id, independently of its displayed number. */
111
+ export interface IDocxNoteStory {
112
+ noteId: string;
113
+ type: 'normal' | 'separator' | 'continuationSeparator' | 'continuationNotice';
114
+ body: IDocumentBody;
115
+ tableSource?: ITables;
116
+ }
106
117
  /**
107
118
  * Set of headers
108
119
  */
@@ -358,6 +369,8 @@ export interface IHyperlink {
358
369
  url?: string;
359
370
  bookmarkId?: string;
360
371
  headingId?: string;
372
+ /** Use authored text formatting instead of the default link color and underline. */
373
+ textStyleMode?: 'link' | 'text';
361
374
  }
362
375
  /**
363
376
  * A ParagraphElement that represents a run of text that all has the same styling.
@@ -390,9 +403,133 @@ export interface ICustomRange<T extends Record<string, any> = Record<string, any
390
403
  */
391
404
  properties?: T;
392
405
  }
393
- export type IHyperLinkCustomRange = ICustomRange<{
394
- url: string;
395
- }>;
406
+ export type IHyperLinkCustomRange = ICustomRange<IHyperlink>;
407
+ /** Legacy Word form field settings. Macro names are retained as data, never executed by the SDK. */
408
+ export interface IFormFieldData {
409
+ name?: string;
410
+ enabled?: BooleanNumber;
411
+ calcOnExit?: BooleanNumber;
412
+ entryMacro?: string;
413
+ exitMacro?: string;
414
+ helpText?: {
415
+ type?: 'text' | 'autoText';
416
+ value?: string;
417
+ };
418
+ statusText?: {
419
+ type?: 'text' | 'autoText';
420
+ value?: string;
421
+ };
422
+ tabIndex?: number;
423
+ textInput?: {
424
+ type?: string;
425
+ default?: string;
426
+ maxLength?: number;
427
+ format?: string;
428
+ };
429
+ checkBox?: {
430
+ size?: number;
431
+ sizeAuto?: BooleanNumber;
432
+ default?: BooleanNumber;
433
+ checked?: BooleanNumber;
434
+ };
435
+ ddList?: {
436
+ default?: number;
437
+ result?: number;
438
+ entries?: string[];
439
+ };
440
+ }
441
+ export interface IFieldRangeProperties {
442
+ /** Original OOXML field instruction. This is the round-trip source of truth. */
443
+ instruction: string;
444
+ /** Upper-case first token of `instruction`, used only for field dispatch. */
445
+ fieldType: string;
446
+ sourceKind?: 'complex' | 'simple';
447
+ dirty?: BooleanNumber;
448
+ locked?: BooleanNumber;
449
+ formData?: IFormFieldData;
450
+ cachedResult?: string;
451
+ }
452
+ /** A field range includes its CUSTOM_RANGE_START/END sentinels and may contain nested fields. */
453
+ export type IFieldCustomRange = ICustomRange<IFieldRangeProperties> & {
454
+ rangeType: CustomRangeType.FIELD;
455
+ wholeEntity?: false;
456
+ };
457
+ export type SdtKind = 'richText' | 'text' | 'checkbox' | 'date' | 'dropDownList' | 'comboBox' | 'picture' | 'group' | 'repeatingSection' | 'repeatingSectionItem' | 'docPartObj';
458
+ export type SdtLock = 'unlocked' | 'sdtLocked' | 'contentLocked' | 'sdtContentLocked';
459
+ export type SdtPlacement = 'inline' | 'block' | 'table' | 'row' | 'cell' | 'header' | 'footer';
460
+ export interface ISdtListItem {
461
+ displayText?: string;
462
+ value: string;
463
+ }
464
+ export interface ISdtRangeProperties {
465
+ kind: SdtKind;
466
+ placement: SdtPlacement;
467
+ alias?: string;
468
+ tag?: string;
469
+ ooxmlId?: string;
470
+ lock?: SdtLock;
471
+ appearance?: string;
472
+ color?: string;
473
+ showingPlaceholder?: boolean;
474
+ temporary?: boolean;
475
+ placeholder?: string;
476
+ /** Imported OOXML placeholder reference and its original display text; not user-facing configuration. */
477
+ placeholderDocPart?: {
478
+ name?: string;
479
+ text?: string;
480
+ };
481
+ checkbox?: {
482
+ checked: boolean;
483
+ checkedState?: {
484
+ value?: string;
485
+ font?: string;
486
+ };
487
+ uncheckedState?: {
488
+ value?: string;
489
+ font?: string;
490
+ };
491
+ };
492
+ text?: {
493
+ /** Whether a plain-text content control accepts paragraph breaks. */
494
+ multiLine?: boolean;
495
+ };
496
+ date?: {
497
+ fullDate?: string;
498
+ format?: string;
499
+ locale?: string;
500
+ calendar?: string;
501
+ storage?: string;
502
+ };
503
+ listItems?: ISdtListItem[];
504
+ repeatingSection?: {
505
+ sectionTitle?: string;
506
+ doNotAllowInsertDelete?: boolean;
507
+ };
508
+ docPart?: {
509
+ gallery?: string;
510
+ category?: string;
511
+ unique?: boolean;
512
+ };
513
+ dataBinding?: {
514
+ prefixMappings?: string;
515
+ xpath?: string;
516
+ storeItemID?: string;
517
+ /** Visible result captured during import, used to detect direct text edits. */
518
+ cachedResult?: string;
519
+ /** Set after a content-control interaction so export updates the bound custom XML node. */
520
+ dirty?: boolean;
521
+ };
522
+ /** Original property XML retained for lossless OOXML round-trip. */
523
+ rawSdtPr?: string;
524
+ /** Original end-run properties retained for lossless OOXML round-trip. */
525
+ rawSdtEndPr?: string;
526
+ }
527
+ /** A Word structured document tag. SDTs may nest and span structural table tokens. */
528
+ export type ISdtCustomRange = ICustomRange<ISdtRangeProperties> & {
529
+ rangeType: CustomRangeType.SDT;
530
+ wholeEntity?: false;
531
+ properties: ISdtRangeProperties;
532
+ };
396
533
  export type IMentionCustomRange = ICustomRange<IMention>;
397
534
  export declare enum DocumentBlockRangeType {
398
535
  CALLOUT = "callout",
@@ -432,6 +569,9 @@ export interface ICustomBlock {
432
569
  startIndex: number;
433
570
  blockType?: BlockType;
434
571
  blockId: string;
572
+ /** A note reference in the body, or the matching number/rule inside a note story. */
573
+ noteType?: 'footnote' | 'endnote' | 'separator' | 'continuationSeparator';
574
+ noteId?: string;
435
575
  /** Original DOCX run XML retained by the exchange layer for lossless round-trip. */
436
576
  docxRawXml?: string;
437
577
  /** Original DOCX text style retained by the exchange layer for lossless round-trip. */
@@ -477,12 +617,30 @@ export interface IHeaderAndFooterBase {
477
617
  export declare enum DocumentFlavor {
478
618
  UNSPECIFIED = 0,
479
619
  TRADITIONAL = 1,
480
- MODERN = 2
481
- }
482
- /**
483
- * Basics properties of doc style
484
- */
620
+ MODERN = 2,
621
+ /** DrawingML text semantics for host-prepared shape and slide text models. */
622
+ DRAWINGML = 3
623
+ }
624
+ /** Page border geometry is expressed in 96-DPI layout pixels. */
625
+ export interface IPageBorder {
626
+ /** Word line/art border style name; separate from table dash patterns. */
627
+ style?: string;
628
+ width?: number;
629
+ padding?: number;
630
+ color?: IColorStyle;
631
+ }
632
+ export interface IPageBorders {
633
+ offsetFrom?: 'page' | 'text';
634
+ display?: 'allPages' | 'firstPage' | 'notFirstPage';
635
+ zOrder?: 'front' | 'back';
636
+ top?: IPageBorder;
637
+ left?: IPageBorder;
638
+ bottom?: IPageBorder;
639
+ right?: IPageBorder;
640
+ }
641
+ /** Basics properties of doc style. */
485
642
  export interface IDocStyleBase extends IMargin {
643
+ pageBorders?: IPageBorders;
486
644
  pageNumberStart?: number;
487
645
  /** Page size in 96-DPI layout pixels. */
488
646
  pageSize?: ISize;
@@ -501,6 +659,8 @@ export interface IDocumentLayout {
501
659
  useFELayout?: BooleanNumber;
502
660
  /** OOXML `splitPgBreakAndParaMark`: move a trailing paragraph mark after a manual page break. */
503
661
  splitPageBreakAndParagraphMark?: BooleanNumber;
662
+ /** Preserve the OOXML half/full-width space compatibility switch. */
663
+ balanceSingleByteDoubleByteWidth?: BooleanNumber;
504
664
  /** Align automatic line height inside tables to the active document line grid. */
505
665
  adjustLineHeightInTable?: BooleanNumber;
506
666
  paragraphLineGapDefault?: number;
@@ -517,7 +677,13 @@ export declare enum GridType {
517
677
  SNAP_TO_CHARS = 3
518
678
  }
519
679
  export interface IDocumentStyle extends IDocStyleBase, IDocumentLayout, IHeaderAndFooterBase {
680
+ /** Imported Word on/off compatibility flags, keyed by their OOXML local names. */
681
+ compatibilityFlags?: Record<string, BooleanNumber>;
682
+ /** Imported OOXML compatSetting values, including the Word compatibilityMode. */
683
+ compatibilitySettings?: Record<string, string>;
520
684
  textStyle?: ITextStyle;
685
+ /** Document-declared alternate families, tried only after the authored font is unavailable. */
686
+ fontFamilyFallbacks?: Record<string, string>;
521
687
  defaultParagraphStyle?: IDocumentDefaultParagraphStyle;
522
688
  background?: IDocumentBackground;
523
689
  }
@@ -550,6 +716,7 @@ export interface IDocumentRenderConfig {
550
716
  isRenderStyle?: BooleanNumber;
551
717
  zeroWidthParagraphBreak?: BooleanNumber;
552
718
  shapeTextOpticalVerticalAlign?: BooleanNumber;
719
+ lineWrapTolerance?: number;
553
720
  }
554
721
  export interface ISectionBreakBase {
555
722
  noteProperties?: INoteProperties;
@@ -616,6 +783,10 @@ export interface IParagraph {
616
783
  styleId?: string;
617
784
  paragraphStyle?: IParagraphStyle;
618
785
  bullet?: IBullet;
786
+ /** Imported resolved numbering, used to distinguish later edits from unchanged inheritance. */
787
+ sourceBullet?: IBullet | null;
788
+ /** Imported direct numbering. Absent inherits from the style; null explicitly disables numbering. */
789
+ directBullet?: IBullet | null;
619
790
  }
620
791
  export declare enum ParagraphElementType {
621
792
  TEXT_RUN = 0,
@@ -672,6 +843,18 @@ export interface IDocDrawingBase extends IDrawingParam {
672
843
  distR?: number;
673
844
  distT?: number;
674
845
  distB?: number;
846
+ /** Effect bounds outside the drawing box, in layout pixels (OOXML wp:effectExtent). */
847
+ effectExtent?: {
848
+ left?: number;
849
+ top?: number;
850
+ right?: number;
851
+ bottom?: number;
852
+ };
853
+ /** Picture-local DrawingML size / layout size; retained on resize without changing the layout box. */
854
+ drawingMLSizeScale?: {
855
+ width: number;
856
+ height: number;
857
+ };
675
858
  }
676
859
  /**
677
860
  * Types of wrap text
@@ -766,6 +949,31 @@ export interface IDocTextOutline {
766
949
  width?: number;
767
950
  }
768
951
  export interface ITextStyle extends IStyleBase {
952
+ /** Retain text in the document without painting it or reserving layout space (OOXML vanish). Absent inherits. */
953
+ hidden?: boolean;
954
+ /** Word font-type hint for characters shared by Latin, East Asian and complex scripts. */
955
+ fontHint?: 'default' | 'eastAsia' | 'cs';
956
+ /** Alignment tab anchored to the page margins or paragraph indents. Applies only to a tab character. */
957
+ positionedTab?: {
958
+ alignment: TabStopAlignment;
959
+ relativeTo: 'margin' | 'indent';
960
+ leader?: TabStopLeader;
961
+ };
962
+ /** Original font-specific OOXML symbol; only applies to the matching character. */
963
+ symbol?: {
964
+ font: string;
965
+ code: number;
966
+ };
967
+ /** Authored text language (BCP 47), used by language-sensitive text layout. Absent inherits. */
968
+ lang?: string;
969
+ /** Alternate language from the authored text properties (BCP 47). Absent inherits. */
970
+ altLang?: string;
971
+ /** Minimum font size for pair kerning, in the same units as fs. Zero disables it; absent inherits. */
972
+ kerning?: number;
973
+ /** Display capital letters without changing the source text. Absent inherits. */
974
+ caps?: boolean;
975
+ /** Display lowercase letters as smaller capitals without changing source text. Absent inherits. */
976
+ smallCaps?: boolean;
769
977
  sc?: number;
770
978
  pos?: number;
771
979
  sa?: number;
@@ -803,20 +1011,26 @@ export type ParagraphFontAlign = 'auto' | 'top' | 'center' | 'baseline' | 'botto
803
1011
  */
804
1012
  export interface IParagraphStyle extends IParagraphProperties {
805
1013
  textStyle?: ITextStyle;
1014
+ /** Formatting of the paragraph terminator only, not inherited by body text. */
1015
+ paragraphMarkTextStyle?: ITextStyle;
806
1016
  }
807
1017
  /**
808
1018
  * Paragraph properties that may be inherited from the document defaults.
809
1019
  * Paragraph identity and named/text styles have their own inheritance mechanisms.
810
1020
  */
811
- export type IDocumentDefaultParagraphStyle = Omit<IParagraphStyle, 'headingId' | 'namedStyleType' | 'textStyle'>;
1021
+ export type IDocumentDefaultParagraphStyle = Omit<IParagraphStyle, 'headingId' | 'namedStyleType' | 'outlineLevel' | 'textStyle' | 'paragraphMarkTextStyle'>;
812
1022
  export interface IParagraphProperties extends IIndentStart {
813
1023
  headingId?: string;
814
1024
  namedStyleType?: NamedStyleType;
1025
+ /** Zero-based OOXML outline level used by TOC generation; 9 denotes body text. */
1026
+ outlineLevel?: number;
815
1027
  defaultTabStop?: number;
816
1028
  /** Whether East Asian kinsoku line-breaking rules apply to this paragraph. */
817
1029
  eastAsianLineBreak?: BooleanNumber;
818
1030
  /** Whether punctuation may hang outside the paragraph text bounds. */
819
1031
  hangingPunctuation?: BooleanNumber;
1032
+ /** Whether full-width punctuation at a line start may be compressed (OOXML topLinePunct). */
1033
+ topLinePunct?: BooleanNumber;
820
1034
  fontAlign?: ParagraphFontAlign;
821
1035
  horizontalAlign?: HorizontalAlign;
822
1036
  lineSpacing?: number;
@@ -884,6 +1098,17 @@ export interface IParagraphProperties extends IIndentStart {
884
1098
  widowControl?: BooleanNumber;
885
1099
  shading?: IShading;
886
1100
  suppressHyphenation?: BooleanNumber;
1101
+ /** Positioned Word frame metadata; legacy snapshots may contain only a presence flag. */
1102
+ paragraphFrame?: BooleanNumber | {
1103
+ horizontalSpace?: number;
1104
+ wrap?: string;
1105
+ verticalAnchor?: string;
1106
+ horizontalAnchor?: string;
1107
+ x?: string;
1108
+ y?: string;
1109
+ xAlign?: string;
1110
+ yAlign?: string;
1111
+ };
887
1112
  }
888
1113
  /**
889
1114
  * Types of name style
@@ -943,6 +1168,7 @@ export interface ITabStop {
943
1168
  offset: number;
944
1169
  alignment: TabStopAlignment;
945
1170
  leader?: TabStopLeader;
1171
+ clear?: boolean;
946
1172
  }
947
1173
  /**
948
1174
  * The alignment of the tab stop.
@@ -1047,6 +1273,8 @@ export interface ITable {
1047
1273
  tableColumns: ITableColumn[];
1048
1274
  align: TableAlignmentType;
1049
1275
  indent: INumberUnit;
1276
+ /** Imported pre-2013 Word text-to-frame indent correction for top-level tables. */
1277
+ legacyIndentAdjustment?: INumberUnit;
1050
1278
  textWrap: TableTextWrapType;
1051
1279
  position: ITableAnchor;
1052
1280
  dist: IDistFromText;
@@ -1073,6 +1301,8 @@ export interface ITableRowSize {
1073
1301
  * Properties of row of table
1074
1302
  */
1075
1303
  export interface ITableRow {
1304
+ /** Authored row-level default margins (OOXML tblPrEx); imported cells contain resolved margins. */
1305
+ cellMargin?: ITableCellMargin;
1076
1306
  /**
1077
1307
  * Rows do not persist stream offsets. Their ordinal position must match the
1078
1308
  * corresponding `TABLE_ROW_START`/`TABLE_ROW_END` pair in `dataStream`.
@@ -1082,6 +1312,10 @@ export interface ITableRow {
1082
1312
  gridBefore?: number;
1083
1313
  /** Number of table-grid columns omitted after the last cell in this row. */
1084
1314
  gridAfter?: number;
1315
+ /** Preferred width of the omitted leading grid columns (OOXML wBefore). */
1316
+ widthBefore?: IWidthInTableSize;
1317
+ /** Preferred width of the omitted trailing grid columns (OOXML wAfter). */
1318
+ widthAfter?: IWidthInTableSize;
1085
1319
  trHeight: ITableRowSize;
1086
1320
  cantSplit?: BooleanNumber;
1087
1321
  isFirstRow?: BooleanNumber;
@@ -1105,6 +1339,10 @@ export interface ITableCell {
1105
1339
  borderBottom?: ITableCellBorder;
1106
1340
  size?: IWidthInTableSize;
1107
1341
  tcFitText?: BooleanNumber;
1342
+ /** Exclude the cell's final paragraph mark from content height (OOXML w:hideMark). */
1343
+ tcHideMark?: BooleanNumber;
1344
+ /** OOXML table-cell writing direction; independent of paragraph bidirectional ordering. */
1345
+ textDirection?: 'lrTb' | 'tbRl' | 'btLr' | 'lrTbV' | 'tbRlV' | 'tbLrV';
1108
1346
  vAlign?: VerticalAlignmentType;
1109
1347
  }
1110
1348
  export interface ITableCellMargin {
@@ -1120,6 +1358,15 @@ export interface ITableCellBorder {
1120
1358
  color: IColorStyle;
1121
1359
  width?: INumberUnit;
1122
1360
  dashStyle?: DashStyleType;
1361
+ /**
1362
+ * Resolved outer table top when borderTop inherits the table's insideH edge.
1363
+ * At the top of a traditional table page fragment, use this instead of the
1364
+ * internal edge. Absent for explicit cell borders and legacy snapshots.
1365
+ * Replacing or editing the cell border must discard this inheritance.
1366
+ */
1367
+ tableTopBorder?: ITableCellBorder;
1368
+ /** Resolved outer bottom for an inherited insideH edge; follows the same editing rules as tableTopBorder. */
1369
+ tableBottomBorder?: ITableCellBorder;
1123
1370
  }
1124
1371
  /**
1125
1372
  * The content alignments for a Shape or TableCell. The supported alignments correspond to predefined text anchoring types from the ECMA-376 standard.
@@ -84,7 +84,15 @@ export declare enum DrawingTypeEnum {
84
84
  /**
85
85
  * Block element, allows host products to place embeddable unit-backed blocks as drawing objects.
86
86
  */
87
- DRAWING_BLOCK = 9
87
+ DRAWING_BLOCK = 9,
88
+ /**
89
+ * Spreadsheet Slicer control.
90
+ */
91
+ DRAWING_SLICER = 10,
92
+ /**
93
+ * Spreadsheet Timeline control.
94
+ */
95
+ DRAWING_TIMELINE = 11
88
96
  }
89
97
  export type DrawingType = DrawingTypeEnum | number;
90
98
  export interface IDrawingSpace {
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=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 r=Symbol(`initializers`),i=Symbol(`manualInit`);var a=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[i])return;let t=this,n=Object.getPrototypeOf(this)[r];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[r];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[i]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[r];t||(t=[],this.prototype[r]=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 o(e,t){return function(n,r){t(n,r,e)}}function s(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 c;let l=c=class extends n{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(c,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??`text/plain`});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}};l=c=s([o(1,(0,t.Inject)(t.Injector))],l);function u(e){"@babel/helpers - typeof";return u=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},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=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 NamedStyleType(){return t.NamedStyleType}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}};p(m,`_instance`,void 0);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 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`}};p(h,`_instance`,void 0);let g=class extends a{constructor(e,t){super(t),this.doc=e}};g=s([o(1,(0,t.Inject)(t.Injector))],g);var _=class{constructor(){p(this,`_eventRegistry`,new Map),p(this,`_eventHandlerMap`,new Map),p(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 v=class extends n{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};v=s([o(0,(0,t.Inject)(t.Injector)),o(1,(0,t.Inject)(t.UserManagerService))],v);var y=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}};p(y,`_instance`,void 0);var b;let x=Symbol(`initializers`),S=b=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(b)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let n=this.prototype[x];n||(n=[],this.prototype[x]=n),n.push(Reflect.get(e.prototype,t))}else t!==`constructor`&&Reflect.set(this.prototype,t,Reflect.get(e.prototype,t))}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&Reflect.set(this,t,Reflect.get(e,t))})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,p(this,`_eventRegistry`,new _),p(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)[x];a&&a.forEach(e=>{e.call(this,this._injector)})}_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(g,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)}setTheme(e){this._injector.get(t.ThemeService).setTheme(e)}getCurrentTheme(){return this._injector.get(t.ThemeService).getCurrentTheme()}isDarkMode(){return this._injector.get(t.ThemeService).darkMode}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)}setRegion(e){this._injector.get(t.RegionService).setRegion(e)}getCurrentRegion(){return this._injector.get(t.RegionService).getCurrentRegion()}setDirection(e){this._injector.get(t.LocaleService).setDirection(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}get Enum(){return m.get()}get Event(){return h.get()}get Util(){return y.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(v)}newBlob(){return this._injector.createInstance(l,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)}};S=b=s([o(0,(0,t.Inject)(t.Injector)),o(1,t.ICommandService),o(2,t.IUniverInstanceService),o(3,(0,t.Inject)(t.LifecycleService))],S),e.FBase=n,e.FBaseInitialable=a,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return l}}),e.FEnum=m,e.FEventName=h,Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return S}}),e.FUtil=y});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=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 r=Symbol(`initializers`),i=Symbol(`manualInit`);var a=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[i])return;let t=this,n=Object.getPrototypeOf(this)[r];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[r];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[i]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[r];t||(t=[],this.prototype[r]=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 o(e,t){return function(n,r){t(n,r,e)}}function s(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 c;let l=c=class extends n{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(c,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??`text/plain`});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}};l=c=s([o(1,(0,t.Inject)(t.Injector))],l);function u(e){"@babel/helpers - typeof";return u=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},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=class e{get FormulaType(){return t.FormulaType}get WorksheetHiddenState(){return t.WorksheetHiddenState}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 NamedStyleType(){return t.NamedStyleType}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}};p(m,`_instance`,void 0);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 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`}};p(h,`_instance`,void 0);let g=class extends a{constructor(e,t){super(t),this.doc=e}};g=s([o(1,(0,t.Inject)(t.Injector))],g);var _=class{constructor(){p(this,`_eventRegistry`,new Map),p(this,`_eventHandlerMap`,new Map),p(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 v=class extends n{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};v=s([o(0,(0,t.Inject)(t.Injector)),o(1,(0,t.Inject)(t.UserManagerService))],v);var y=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}};p(y,`_instance`,void 0);var b;let x=Symbol(`initializers`),S=b=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(b)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let n=this.prototype[x];n||(n=[],this.prototype[x]=n),n.push(Reflect.get(e.prototype,t))}else t!==`constructor`&&Reflect.set(this.prototype,t,Reflect.get(e.prototype,t))}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&Reflect.set(this,t,Reflect.get(e,t))})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,p(this,`_eventRegistry`,new _),p(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)[x];a&&a.forEach(e=>{e.call(this,this._injector)})}_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(g,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)}setTheme(e){this._injector.get(t.ThemeService).setTheme(e)}getCurrentTheme(){return this._injector.get(t.ThemeService).getCurrentTheme()}isDarkMode(){return this._injector.get(t.ThemeService).darkMode}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)}setRegion(e){this._injector.get(t.RegionService).setRegion(e)}getCurrentRegion(){return this._injector.get(t.RegionService).getCurrentRegion()}setDirection(e){this._injector.get(t.LocaleService).setDirection(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}get Enum(){return m.get()}get Event(){return h.get()}get Util(){return y.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(v)}newBlob(){return this._injector.createInstance(l,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)}};S=b=s([o(0,(0,t.Inject)(t.Injector)),o(1,t.ICommandService),o(2,t.IUniverInstanceService),o(3,(0,t.Inject)(t.LifecycleService))],S),e.FBase=n,e.FBaseInitialable=a,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return l}}),e.FEnum=m,e.FEventName=h,Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return S}}),e.FUtil=y});