@univerjs/docs 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.
package/lib/facade.js CHANGED
@@ -303,7 +303,7 @@ function stripBlockTokens(text) {
303
303
  }
304
304
 
305
305
  //#endregion
306
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
306
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
307
307
  function __decorateParam(paramIndex, decorator) {
308
308
  return function(target, key) {
309
309
  decorator(target, key, paramIndex);
@@ -311,7 +311,7 @@ function __decorateParam(paramIndex, decorator) {
311
311
  }
312
312
 
313
313
  //#endregion
314
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
314
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
315
315
  function __decorate(decorators, target, key, desc) {
316
316
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
317
317
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -420,6 +420,8 @@ let FDocumentTextRange = class FDocumentTextRange extends FBaseInitialable {
420
420
  * Existing text-run splitting, merging, and normalization are handled by
421
421
  * the document mutation pipeline.
422
422
  * `style.fs` is a font size in points (pt), not CSS pixels.
423
+ * @param {ITextStyle} style Text-style properties to merge into the range.
424
+ * @returns {boolean} Whether the style update succeeded; `false` for an empty range.
423
425
  * @example
424
426
  * ```ts
425
427
  * const fDocument = univerAPI.getActiveDocument();
@@ -440,6 +442,8 @@ let FDocumentTextRange = class FDocumentTextRange extends FBaseInitialable {
440
442
  }
441
443
  /**
442
444
  * Replaces the range with plain text while preserving document mutation semantics.
445
+ * @param {string} text Replacement plain text. An empty string deletes the range.
446
+ * @returns {boolean} Whether the replacement succeeded.
443
447
  * @example
444
448
  * ```ts
445
449
  * const fDocument = univerAPI.getActiveDocument();
@@ -999,6 +1003,10 @@ let FDocumentSection = class FDocumentSection {
999
1003
  * Sets equal or explicitly sized columns for this traditional section.
1000
1004
  * Use `columnCount = 1` to restore normal single-column layout.
1001
1005
  * `gap` and `widths` are in 96-DPI layout pixels.
1006
+ * @param {number} columnCount Positive integer column count.
1007
+ * @param {IFDocumentSectionColumnOptions} [options] Column widths, gap (default 18 pixels), and separator (default none).
1008
+ * @returns {boolean} Whether the section update succeeded.
1009
+ * @throws {RangeError} If column dimensions or the separator are invalid, or columns exceed the available width.
1002
1010
  * @example
1003
1011
  * ```ts
1004
1012
  * const fDocument = univerAPI.getActiveDocument();
@@ -1024,6 +1032,10 @@ let FDocumentSection = class FDocumentSection {
1024
1032
  }
1025
1033
  /**
1026
1034
  * Sets explicit OOXML-compatible column width and trailing-space values in 96-DPI layout pixels.
1035
+ * @param {ISectionColumnProperties[]} columns Explicit widths and trailing spaces; an empty array restores a single column.
1036
+ * @param {ColumnSeparatorType} [separator] Column separator style. Defaults to `ColumnSeparatorType.NONE`.
1037
+ * @returns {boolean} Whether the section update succeeded.
1038
+ * @throws {RangeError} If column dimensions or the separator are invalid, or columns exceed the available width.
1027
1039
  * @example
1028
1040
  * ```ts
1029
1041
  * const fDocument = univerAPI.getActiveDocument();
@@ -1190,6 +1202,8 @@ let FDocumentSection = class FDocumentSection {
1190
1202
  }
1191
1203
  /**
1192
1204
  * Ensures a header segment linked specifically to this section.
1205
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1206
+ * @returns {string} The existing or newly created section-specific segment ID.
1193
1207
  * @example
1194
1208
  * ```ts
1195
1209
  * const fDocument = univerAPI.getActiveDocument();
@@ -1206,6 +1220,8 @@ let FDocumentSection = class FDocumentSection {
1206
1220
  }
1207
1221
  /**
1208
1222
  * Ensures a footer segment linked specifically to this section.
1223
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1224
+ * @returns {string} The existing or newly created section-specific segment ID.
1209
1225
  * @example
1210
1226
  * ```ts
1211
1227
  * const fDocument = univerAPI.getActiveDocument();
@@ -1222,6 +1238,8 @@ let FDocumentSection = class FDocumentSection {
1222
1238
  }
1223
1239
  /**
1224
1240
  * Returns the effective header id after resolving links to previous sections.
1241
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1242
+ * @returns {string | null} The effective segment ID, or `null` if no segment is available.
1225
1243
  * @example
1226
1244
  * ```ts
1227
1245
  * const fDocument = univerAPI.getActiveDocument();
@@ -1233,6 +1251,8 @@ let FDocumentSection = class FDocumentSection {
1233
1251
  }
1234
1252
  /**
1235
1253
  * Returns the effective footer id after resolving links to previous sections.
1254
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1255
+ * @returns {string | null} The effective segment ID, or `null` if no segment is available.
1236
1256
  * @example
1237
1257
  * ```ts
1238
1258
  * const fDocument = univerAPI.getActiveDocument();
@@ -1244,6 +1264,8 @@ let FDocumentSection = class FDocumentSection {
1244
1264
  }
1245
1265
  /**
1246
1266
  * Whether this header variant inherits the previous section's reference.
1267
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1268
+ * @returns {boolean} Whether this variant inherits from the previous section.
1247
1269
  * @example
1248
1270
  * ```ts
1249
1271
  * const fDocument = univerAPI.getActiveDocument();
@@ -1255,6 +1277,8 @@ let FDocumentSection = class FDocumentSection {
1255
1277
  }
1256
1278
  /**
1257
1279
  * Whether this footer variant inherits the previous section's reference.
1280
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1281
+ * @returns {boolean} Whether this variant inherits from the previous section.
1258
1282
  * @example
1259
1283
  * ```ts
1260
1284
  * const fDocument = univerAPI.getActiveDocument();
@@ -1266,6 +1290,9 @@ let FDocumentSection = class FDocumentSection {
1266
1290
  }
1267
1291
  /**
1268
1292
  * Links or unlinks this header variant. Unlinking clones the inherited header.
1293
+ * @param {boolean} linkedToPrevious Whether to inherit the previous section's header/footer.
1294
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1295
+ * @returns {boolean} Whether the link update succeeded.
1269
1296
  * @example
1270
1297
  * ```ts
1271
1298
  * const fDocument = univerAPI.getActiveDocument();
@@ -1279,6 +1306,9 @@ let FDocumentSection = class FDocumentSection {
1279
1306
  }
1280
1307
  /**
1281
1308
  * Links or unlinks this footer variant. Unlinking clones the inherited footer.
1309
+ * @param {boolean} linkedToPrevious Whether to inherit the previous section's header/footer.
1310
+ * @param {SectionHeaderFooterVariant} [variant] The `'default'`, `'first'`, or `'even'` variant. Defaults to `'default'`.
1311
+ * @returns {boolean} Whether the link update succeeded.
1282
1312
  * @example
1283
1313
  * ```ts
1284
1314
  * const fDocument = univerAPI.getActiveDocument();
@@ -1293,6 +1323,8 @@ let FDocumentSection = class FDocumentSection {
1293
1323
  /**
1294
1324
  * Updates header/footer switches and margins on this section break.
1295
1325
  * `marginHeader` and `marginFooter` are in 96-DPI layout pixels.
1326
+ * @param {IHeaderFooterProps} options Header/footer switches and margins to update. Omitted properties are preserved.
1327
+ * @returns {boolean} Whether the update command succeeded.
1296
1328
  * @example
1297
1329
  * ```ts
1298
1330
  * const fDocument = univerAPI.getActiveDocument();
@@ -1372,7 +1404,8 @@ let FDocumentSection = class FDocumentSection {
1372
1404
  }
1373
1405
  _getHeaderFooterReference(kind, variant) {
1374
1406
  const { index } = this._resolve();
1375
- return resolveSectionHeaderFooterReference(this._document.getDocumentDataModel().getSnapshot().documentStyle, getTopLevelSectionBreaks(this._document.getBody()), index, getSectionHeaderFooterReferenceKey(kind, variant));
1407
+ const snapshot = this._document.getDocumentDataModel().getSnapshot();
1408
+ return resolveSectionHeaderFooterReference(snapshot.documentStyle, getTopLevelSectionBreaks(this._document.getBody()), index, getSectionHeaderFooterReferenceKey(kind, variant));
1376
1409
  }
1377
1410
  _describeHeaderFooterReference(kind, variant) {
1378
1411
  const reference = this._getHeaderFooterReference(kind, variant);
@@ -1420,7 +1453,7 @@ let FDocumentSection = class FDocumentSection {
1420
1453
  FDocumentSection = __decorate([__decorateParam(2, ICommandService), __decorateParam(3, IPermissionService)], FDocumentSection);
1421
1454
 
1422
1455
  //#endregion
1423
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
1456
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
1424
1457
  function _typeof(o) {
1425
1458
  "@babel/helpers - typeof";
1426
1459
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -1431,7 +1464,7 @@ function _typeof(o) {
1431
1464
  }
1432
1465
 
1433
1466
  //#endregion
1434
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
1467
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
1435
1468
  function toPrimitive(t, r) {
1436
1469
  if ("object" != _typeof(t) || !t) return t;
1437
1470
  var e = t[Symbol.toPrimitive];
@@ -1444,14 +1477,14 @@ function toPrimitive(t, r) {
1444
1477
  }
1445
1478
 
1446
1479
  //#endregion
1447
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
1480
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
1448
1481
  function toPropertyKey(t) {
1449
1482
  var i = toPrimitive(t, "string");
1450
1483
  return "symbol" == _typeof(i) ? i : i + "";
1451
1484
  }
1452
1485
 
1453
1486
  //#endregion
1454
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
1487
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
1455
1488
  function _defineProperty(e, r, t) {
1456
1489
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1457
1490
  value: t,
@@ -1477,7 +1510,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1477
1510
  }
1478
1511
  /**
1479
1512
  * Get the document data model of the document.
1480
- * @param {string} segmentId The segment id used to get the header/footer data model. Defaults to an empty string for the document data model of the document.
1513
+ * @param {string} [segmentId] The segment id used to get the header/footer data model. Defaults to an empty string for the document data model of the document.
1481
1514
  * @returns {DocumentDataModel} The document data model.
1482
1515
  * @example
1483
1516
  * ```typescript
@@ -1519,7 +1552,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1519
1552
  * Get the document body or header/footer body by the segment id.
1520
1553
  * The main body has an empty segment id.
1521
1554
  * The header and footer body have their respective segment ids.
1522
- * @param {string} segmentId The segment id of the body. Defaults to an empty string for the main body.
1555
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
1523
1556
  * @returns {IDocumentBody} The document body.
1524
1557
  * @example
1525
1558
  * ```typescript
@@ -1536,6 +1569,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1536
1569
  if (!body) throw new Error(segmentId === "" ? "Body is not found in the document." : `Body is not found in the segment: ${segmentId}`);
1537
1570
  return body;
1538
1571
  }
1572
+ /** Releases this facade's resources. Use `univerAPI.disposeUnit()` to unload the owning unit. */
1539
1573
  dispose() {
1540
1574
  super.dispose();
1541
1575
  }
@@ -1726,7 +1760,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1726
1760
  }
1727
1761
  /**
1728
1762
  * Ensure the page header segment exists and return its segment id.
1729
- * @param {number} pageIndex The zero-based page index. Defaults to the first page.
1763
+ * @param {number} [pageIndex] The zero-based page index. Defaults to the first page.
1730
1764
  * @returns {string} The header segment id.
1731
1765
  * @example
1732
1766
  * ```ts
@@ -1740,7 +1774,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1740
1774
  }
1741
1775
  /**
1742
1776
  * Ensure the page footer segment exists and return its segment id.
1743
- * @param {number} pageIndex The zero-based page index. Defaults to the first page.
1777
+ * @param {number} [pageIndex] The zero-based page index. Defaults to the first page.
1744
1778
  * @returns {string} The footer segment id.
1745
1779
  * @example
1746
1780
  * ```ts
@@ -1756,7 +1790,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1756
1790
  * Insert plain text at a document body offset.
1757
1791
  * @param {number} index The zero-based insertion offset.
1758
1792
  * @param {string} text The plain text to insert.
1759
- * @param {string} segmentId The segment id of the body. Defaults to an empty string for the main body.
1793
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
1760
1794
  * @returns {boolean} `true` if the edit was applied.
1761
1795
  * @example
1762
1796
  * ```ts
@@ -1797,6 +1831,8 @@ let FDocument = class FDocument extends FBaseInitialable {
1797
1831
  * Traditional and Unspecified documents keep the legacy header/footer
1798
1832
  * behavior. Modern documents reject this API. `marginHeader` and
1799
1833
  * `marginFooter` use 96-DPI layout pixels.
1834
+ * @param {IHeaderFooterProps} options Header/footer switches and margins to update. Omitted properties are preserved.
1835
+ * @returns {boolean} Whether the update command succeeded.
1800
1836
  * @example
1801
1837
  * ```ts
1802
1838
  * const fDocument = univerAPI.getActiveDocument();
@@ -1820,7 +1856,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1820
1856
  * The end offset is exclusive, and offsets are scoped to the selected body segment.
1821
1857
  * @param {number} startOffset The inclusive start offset.
1822
1858
  * @param {number} endOffset The exclusive end offset.
1823
- * @param {string} segmentId The header/footer segment id, or an empty string for the main body.
1859
+ * @param {string} [segmentId] The header/footer segment id, or an empty string for the main body.
1824
1860
  * @returns {FDocumentTextRange} A fixed text-range facade.
1825
1861
  * @example
1826
1862
  * ```ts
@@ -1848,6 +1884,8 @@ let FDocument = class FDocument extends FBaseInitialable {
1848
1884
  }
1849
1885
  /**
1850
1886
  * Returns a traditional section by zero-based index, or `null` in modern documents.
1887
+ * @param {number} index Zero-based section index.
1888
+ * @returns {FDocumentSection | null} The matching section, or `null` if none exists or the document is not Traditional.
1851
1889
  * @example
1852
1890
  * ```ts
1853
1891
  * const fDocument = univerAPI.getActiveDocument();
@@ -1860,6 +1898,8 @@ let FDocument = class FDocument extends FBaseInitialable {
1860
1898
  }
1861
1899
  /**
1862
1900
  * Returns the traditional section containing a data-stream offset, or `null` in modern documents.
1901
+ * @param {number} offset Zero-based data-stream offset in the main document body.
1902
+ * @returns {FDocumentSection | null} The matching section, or `null` if none exists or the document is not Traditional.
1863
1903
  * @example
1864
1904
  * ```ts
1865
1905
  * const fDocument = univerAPI.getActiveDocument();
@@ -1944,6 +1984,8 @@ let FDocument = class FDocument extends FBaseInitialable {
1944
1984
  * In a single-column section, the traditional renderer advances to the next physical page.
1945
1985
  * Modern documents must use ColumnGroup. Unspecified documents must resolve
1946
1986
  * their flavor first. Both throw `DocsSectionUnsupportedDocumentFlavorError`.
1987
+ * @param {number} offset Zero-based data-stream offset at which to insert the column break.
1988
+ * @returns {boolean} Whether the insertion succeeded.
1947
1989
  * @example
1948
1990
  * ```ts
1949
1991
  * const fDocument = univerAPI.getActiveDocument();
@@ -1967,6 +2009,10 @@ let FDocument = class FDocument extends FBaseInitialable {
1967
2009
  * Inserts a horizontal rule using the existing paragraph `borderBottom` mechanism.
1968
2010
  * The returned paragraph can be inspected or removed with normal paragraph APIs.
1969
2011
  * Border width and padding are in points (pt).
2012
+ * @param {number} offset Zero-based insertion offset in the selected body segment.
2013
+ * @param {IParagraphBorder} [border] Bottom border appearance. Defaults to a solid gray 1 pt line with 5 pt padding.
2014
+ * @param {string} [segmentId] Header/footer segment ID, or an empty string for the main body (default).
2015
+ * @returns {FDocumentParagraph | null} The inserted paragraph, or `null` if insertion fails.
1970
2016
  * @example
1971
2017
  * ```ts
1972
2018
  * const fDocument = univerAPI.getActiveDocument();
@@ -1997,7 +2043,7 @@ let FDocument = class FDocument extends FBaseInitialable {
1997
2043
  }
1998
2044
  /**
1999
2045
  * Get all paragraphs in the document body or header/footer body by the segment id.
2000
- * @param {string} segmentId The segment id of the body. Defaults to an empty string for the main body.
2046
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
2001
2047
  * @returns {FDocumentParagraph[]} An array of paragraph facade instances.
2002
2048
  * @example
2003
2049
  * ```ts
@@ -2017,7 +2063,7 @@ let FDocument = class FDocument extends FBaseInitialable {
2017
2063
  /**
2018
2064
  * Get a paragraph by its paragraph id and segment id.
2019
2065
  * @param {string} paragraphId The paragraph id.
2020
- * @param {string} segmentId The segment id of the body. Defaults to an empty string for the main body.
2066
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
2021
2067
  * @returns {FDocumentParagraph | null} The paragraph facade instance, or `null` if the paragraph is not found.
2022
2068
  * @example
2023
2069
  * ```ts
@@ -2038,7 +2084,7 @@ let FDocument = class FDocument extends FBaseInitialable {
2038
2084
  /**
2039
2085
  * Find a paragraph by its text content and segment id.
2040
2086
  * @param {string} text The text content to search for.
2041
- * @param {string} segmentId The segment id of the body. Defaults to an empty string for the main body.
2087
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
2042
2088
  * @returns {FDocumentParagraph | null} The paragraph facade instance, or `null` if the paragraph is not found.
2043
2089
  * @example
2044
2090
  * ```ts
@@ -2086,8 +2132,8 @@ let FDocument = class FDocument extends FBaseInitialable {
2086
2132
  /**
2087
2133
  * Insert a plain-text paragraph before the paragraph at the given paragraph index.
2088
2134
  * @param {number} index The zero-based paragraph insertion index.
2089
- * @param {string} text The paragraph text. Defaults to an empty paragraph.
2090
- * @param {string} segmentId The segment id of the body. Defaults to an empty string for the main body.
2135
+ * @param {string} [text] The paragraph text. Defaults to an empty paragraph.
2136
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
2091
2137
  * @returns {FDocumentParagraph} The inserted paragraph facade instance.
2092
2138
  * @example
2093
2139
  * ```ts
@@ -2114,8 +2160,8 @@ let FDocument = class FDocument extends FBaseInitialable {
2114
2160
  }
2115
2161
  /**
2116
2162
  * Append a plain-text paragraph at the end of the body.
2117
- * @param {string} text The paragraph text. Defaults to an empty paragraph.
2118
- * @param {string} segmentId The segment id of the body. Defaults to an empty string for the main body.
2163
+ * @param {string} [text] The paragraph text. Defaults to an empty paragraph.
2164
+ * @param {string} [segmentId] The segment id of the body. Defaults to an empty string for the main body.
2119
2165
  * @returns {FDocumentParagraph} The appended paragraph wrapper.
2120
2166
  * @example
2121
2167
  * ```ts