@univerjs/core 1.0.0-alpha.1 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/lib/cjs/facade.js +90 -28
  2. package/lib/cjs/index.js +12527 -10884
  3. package/lib/es/facade.js +91 -29
  4. package/lib/es/index.js +12493 -10889
  5. package/lib/facade.js +91 -29
  6. package/lib/index.js +12493 -10889
  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/document-data-model.d.ts +1 -1
  17. package/lib/types/docs/data-model/empty-snapshot.d.ts +2 -1
  18. package/lib/types/docs/data-model/index.d.ts +20 -0
  19. package/lib/types/docs/data-model/paragraph-style.d.ts +22 -0
  20. package/lib/types/docs/data-model/preset-list-type.d.ts +19 -6
  21. package/lib/types/docs/data-model/rich-text-builder.d.ts +269 -1
  22. package/lib/types/docs/data-model/text-x/action-types.d.ts +1 -0
  23. package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +4 -1
  24. package/lib/types/docs/data-model/text-x/build-utils/data-stream-change.d.ts +28 -0
  25. package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +5 -0
  26. package/lib/types/docs/data-model/text-x/build-utils/paragraph.d.ts +5 -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 -6
  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/tools.d.ts +0 -11
  42. package/lib/types/sheets/index.d.ts +26 -0
  43. package/lib/types/sheets/typedef.d.ts +2 -0
  44. package/lib/types/types/const/const.d.ts +0 -1
  45. package/lib/types/types/enum/locale-type.d.ts +9 -0
  46. package/lib/types/types/interfaces/i-document-data-interceptor.d.ts +1 -0
  47. package/lib/types/types/interfaces/i-document-data.d.ts +35 -2
  48. package/lib/types/types/interfaces/i-drawing.d.ts +25 -1
  49. package/lib/types/types/interfaces/i-style-data.d.ts +1 -5
  50. package/lib/umd/facade.js +1 -1
  51. package/lib/umd/index.js +19 -11
  52. package/package.json +5 -5
package/lib/es/facade.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AbsoluteRefType, AutoFillSeries, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, CanceledError, ColorType, CommandType, CommonHideTypes, CopyPasteType, DataValidationErrorStyle, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DeveloperMetadataVisibility, Dimension, Direction, Disposable, HorizontalAlign, ICommandService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterpolationPointType, LifecycleService, LifecycleStages, LocaleService, LocaleType, MentionType, ParagraphStyleBuilder, ParagraphStyleValue, ProtectionType, Rectangle, RedoCommand, Registry, RelativeDate, RichTextBuilder, RichTextValue, SheetTypes, TextDecoration, TextDecorationBuilder, TextDirection, TextStyleBuilder, TextStyleValue, ThemeColorType, ThemeService, Tools, UndoCommand, Univer, UniverInstanceType, UserManagerService, VerticalAlign, WrapStrategy, numfmt, toDisposable } from "@univerjs/core";
1
+ import { AbsoluteRefType, AutoFillSeries, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, CanceledError, ColorType, CommandType, CommonHideTypes, CopyPasteType, DataValidationErrorStyle, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DeveloperMetadataVisibility, Dimension, Direction, Disposable, HorizontalAlign, ICommandService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterpolationPointType, LifecycleService, LifecycleStages, LocaleService, LocaleType, MentionType, NumberUnitType, ParagraphStyleBuilder, ParagraphStyleValue, PresetListType, ProtectionType, Rectangle, RedoCommand, Registry, RelativeDate, RichTextBuilder, RichTextValue, SheetTypes, SpacingRule, TextDecoration, TextDecorationBuilder, TextDirection, TextStyleBuilder, TextStyleValue, ThemeColorType, ThemeService, Tools, UndoCommand, Univer, UniverInstanceType, UserManagerService, VerticalAlign, WrapStrategy, numfmt, toDisposable } from "@univerjs/core";
2
2
  import { filter } from "rxjs";
3
3
 
4
4
  //#region src/facade/f-base.ts
@@ -68,7 +68,11 @@ var FBaseInitialable = class extends Disposable {
68
68
  this.prototype[InitializerSymbol$1] = initializers;
69
69
  }
70
70
  initializers.push(source.prototype._initialize);
71
- } else if (name !== "constructor") this.prototype[name] = source.prototype[name];
71
+ } else if (name !== "constructor") {
72
+ const descriptor = Object.getOwnPropertyDescriptor(source.prototype, name);
73
+ if (descriptor) Object.defineProperty(this.prototype, name, descriptor);
74
+ else this.prototype[name] = source.prototype[name];
75
+ }
72
76
  });
73
77
  Object.getOwnPropertyNames(source).forEach((name) => {
74
78
  if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
@@ -424,6 +428,42 @@ var FEnum = class FEnum {
424
428
  return HorizontalAlign;
425
429
  }
426
430
  /**
431
+ * Paragraph line-height interpretation modes
432
+ *
433
+ * @example
434
+ * ```ts
435
+ * console.log(univerAPI.Enum.SpacingRule.EXACT);
436
+ * ```
437
+ */
438
+ get SpacingRule() {
439
+ return SpacingRule;
440
+ }
441
+ /**
442
+ * Units accepted by document lengths such as paragraph indentation and spacing
443
+ *
444
+ * Agent-facing rich-text helpers accept plain numbers as document points, so this enum is only needed when an
445
+ * explicit alternative unit is required.
446
+ *
447
+ * @example
448
+ * ```ts
449
+ * console.log(univerAPI.Enum.NumberUnitType.POINT);
450
+ * ```
451
+ */
452
+ get NumberUnitType() {
453
+ return NumberUnitType;
454
+ }
455
+ /**
456
+ * Preset ordered, unordered, and checklist styles used by rich-text list items
457
+ *
458
+ * @example
459
+ * ```ts
460
+ * console.log(univerAPI.Enum.PresetListType.BULLET_LIST);
461
+ * ```
462
+ */
463
+ get PresetListType() {
464
+ return PresetListType;
465
+ }
466
+ /**
427
467
  * Different text decoration styles
428
468
  *
429
469
  * @example
@@ -654,6 +694,17 @@ var FEnum = class FEnum {
654
694
  get ThemeColorType() {
655
695
  return ThemeColorType;
656
696
  }
697
+ /**
698
+ * Image source types
699
+ *
700
+ * @example
701
+ * ```ts
702
+ * console.log(univerAPI.Enum.ImageSourceType.URL);
703
+ * ```
704
+ */
705
+ get ImageSourceType() {
706
+ return ImageSourceType;
707
+ }
657
708
  };
658
709
  _defineProperty(FEnum, "_instance", void 0);
659
710
 
@@ -849,6 +900,7 @@ let FHooks = class FHooks extends FBase {
849
900
  }
850
901
  /**
851
902
  * @param callback
903
+ * @returns {IDisposable} A disposable used to remove the listener.
852
904
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
853
905
  */
854
906
  onStarting(callback) {
@@ -856,6 +908,7 @@ let FHooks = class FHooks extends FBase {
856
908
  }
857
909
  /**
858
910
  * @param callback
911
+ * @returns {IDisposable} A disposable used to remove the listener.
859
912
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
860
913
  */
861
914
  onReady(callback) {
@@ -863,6 +916,7 @@ let FHooks = class FHooks extends FBase {
863
916
  }
864
917
  /**
865
918
  * @param callback
919
+ * @returns {IDisposable} A disposable used to remove the listener.
866
920
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
867
921
  */
868
922
  onRendered(callback) {
@@ -870,6 +924,7 @@ let FHooks = class FHooks extends FBase {
870
924
  }
871
925
  /**
872
926
  * @param callback
927
+ * @returns {IDisposable} A disposable used to remove the listener.
873
928
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
874
929
  */
875
930
  onSteady(callback) {
@@ -877,6 +932,7 @@ let FHooks = class FHooks extends FBase {
877
932
  }
878
933
  /**
879
934
  * @param callback
935
+ * @returns {IDisposable} A disposable used to remove the listener.
880
936
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {})` as instead
881
937
  */
882
938
  onBeforeUndo(callback) {
@@ -889,6 +945,7 @@ let FHooks = class FHooks extends FBase {
889
945
  }
890
946
  /**
891
947
  * @param callback
948
+ * @returns {IDisposable} A disposable used to remove the listener.
892
949
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.Undo, (event) => {})` as instead
893
950
  */
894
951
  onUndo(callback) {
@@ -901,6 +958,7 @@ let FHooks = class FHooks extends FBase {
901
958
  }
902
959
  /**
903
960
  * @param callback
961
+ * @returns {IDisposable} A disposable used to remove the listener.
904
962
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {})` as instead
905
963
  */
906
964
  onBeforeRedo(callback) {
@@ -913,6 +971,7 @@ let FHooks = class FHooks extends FBase {
913
971
  }
914
972
  /**
915
973
  * @param callback
974
+ * @returns {IDisposable} A disposable used to remove the listener.
916
975
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.Redo, (event) => {})` as instead
917
976
  */
918
977
  onRedo(callback) {
@@ -1532,50 +1591,53 @@ let FUniver = _FUniver = class FUniver extends Disposable {
1532
1591
  }
1533
1592
  /**
1534
1593
  * Create a new rich text.
1535
- * @param {IDocumentData} data
1536
1594
  * @returns {RichTextBuilder} The new rich text instance
1537
1595
  * @example
1538
1596
  * ```ts
1539
- * const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
1540
- * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
1541
- * if (!fWorksheet) return;
1542
- * const range = fWorksheet.getRange('A1');
1543
- * range.setRichTextValueForCell(richText);
1597
+ * const richText = univerAPI.newRichText()
1598
+ * .align({ horizontal: univerAPI.Enum.HorizontalAlign.CENTER })
1599
+ * .text('Status: ')
1600
+ * .span('Ready', { bold: true, color: '#16a34a' });
1544
1601
  * ```
1545
1602
  */
1546
- newRichText(data) {
1603
+ newRichText() {
1604
+ return RichTextBuilder.create();
1605
+ }
1606
+ /**
1607
+ * Create a rich-text builder from raw Univer document data.
1608
+ *
1609
+ * This is an advanced integration escape hatch for importers and adapters. Application and agent code should use
1610
+ * the fluent builder returned by `newRichText()`.
1611
+ *
1612
+ * @param data Raw Univer document data.
1613
+ * @returns A rich-text builder initialized with the supplied document data.
1614
+ * @advanced
1615
+ */
1616
+ newRichTextFromDocumentData(data) {
1547
1617
  return RichTextBuilder.create(data);
1548
1618
  }
1549
1619
  /**
1550
1620
  * Create a new rich text value.
1551
- * @param {IDocumentData} data - The rich text data
1621
+ *
1622
+ * This is an advanced integration escape hatch for callers that already own Univer document data. Application and
1623
+ * agent code should prefer the fluent value returned by `newRichText()`.
1624
+ *
1625
+ * @param {IDocumentData} data The raw Univer document data.
1552
1626
  * @returns {RichTextValue} The new rich text value instance
1553
- * @example
1554
- * ```ts
1555
- * const richTextValue = univerAPI.newRichTextValue({ body: { dataStream: 'Hello World\r\n' } });
1556
- * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
1557
- * if (!fWorksheet) return;
1558
- * const range = fWorksheet.getRange('A1');
1559
- * range.setRichTextValueForCell(richTextValue);
1560
- * ```
1627
+ * @advanced
1561
1628
  */
1562
1629
  newRichTextValue(data) {
1563
1630
  return RichTextValue.create(data);
1564
1631
  }
1565
1632
  /**
1566
1633
  * Create a new paragraph style.
1567
- * @param {IParagraphStyle} style - The paragraph style
1634
+ *
1635
+ * This is an advanced document-model API. Application and agent code should normally use
1636
+ * `newRichText().paragraph({ ... })`.
1637
+ *
1638
+ * @param {IParagraphStyle} style The paragraph style
1568
1639
  * @returns {ParagraphStyleBuilder} The new paragraph style instance
1569
- * @example
1570
- * ```ts
1571
- * const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
1572
- * const paragraphStyle = univerAPI.newParagraphStyle({ textStyle: { ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE } });
1573
- * richText.insertParagraph(paragraphStyle);
1574
- * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
1575
- * if (!fWorksheet) return;
1576
- * const range = fWorksheet.getRange('A1');
1577
- * range.setRichTextValueForCell(richText);
1578
- * ```
1640
+ * @advanced
1579
1641
  */
1580
1642
  newParagraphStyle(style) {
1581
1643
  return ParagraphStyleBuilder.create(style);