Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
docs(facade): clarify API reference documentation (#7721)
白熱7c2fc05c1427
diff --git a/packages/core/src/facade/f-univer.ts b/packages/core/src/facade/f-univer.tsindex 643d9058b0..2319dc88ad 100644--- a/packages/core/src/facade/f-univer.ts+++ b/packages/core/src/facade/f-univer.ts@@ -122,6 +122,13 @@ export class FUniver extends Disposable {protected _eventRegistry = new FEventRegistry();+ /**+ * Registers a factory for the subscription that produces an event.+ * The factory starts when listeners exist and its subscription is disposed when the last listener is removed.+ * @param event The event name.+ * @param handler Creates the underlying event subscription.+ * @returns A disposable that unregisters the factory and disposes its active subscription.+ */registerEventHandler = (event: string, handler: () => IDisposable | Subscription): IDisposable => {return this._eventRegistry.registerEventHandler(event, handler);};diff --git a/packages/docs/src/facade/f-document.ts b/packages/docs/src/facade/f-document.tsindex 47a1d0914f..11924cd394 100644--- a/packages/docs/src/facade/f-document.ts+++ b/packages/docs/src/facade/f-document.ts@@ -84,6 +84,9 @@ export type IFDocumentInsertSectionBreakOptions = Partial<Omit<ISectionBreak, 's* @hideconstructor*/export class FDocument extends FBaseInitialable {+ /**+ * The document unit id used to identify this document in commands and snapshots.+ */readonly id: string;constructor(diff --git a/packages/sheets-data-validation/src/facade/f-data-validation.ts b/packages/sheets-data-validation/src/facade/f-data-validation.tsindex 65642484b3..52ed8436d5 100644--- a/packages/sheets-data-validation/src/facade/f-data-validation.ts+++ b/packages/sheets-data-validation/src/facade/f-data-validation.ts@@ -45,6 +45,9 @@ import { FDataValidationBuilder } from './f-data-validation-builder';* @hideconstructor*/export class FDataValidation {+ /**+ * The underlying validation rule data. Use the Facade setters to update a rule attached to a worksheet.+ */rule: IDataValidationRule;private _worksheet: Worksheet | undefined;private _injector: Injector | undefined;diff --git a/packages/sheets/src/facade/f-range.ts b/packages/sheets/src/facade/f-range.tsindex b1b7afbb53..f1d9693e3f 100644--- a/packages/sheets/src/facade/f-range.ts+++ b/packages/sheets/src/facade/f-range.ts@@ -966,6 +966,7 @@ export class FRange extends FBaseInitialable {* if (!fWorksheet) return;* const fRange = fWorksheet.getRange('A1:B2');* console.log(fRange.getWraps());+ * ```*/getWraps(): boolean[][] {const cells = this.getCellDatas();@@ -990,7 +991,8 @@ export class FRange extends FBaseInitialable {}/**- * Returns the horizontal alignment of the text (left/center/right) of the top-left cell in the range.+ * Returns the horizontal alignment of the top-left cell as `left`, `center`, or `normal` (right alignment).+ * Default and other core alignment values return `general`, which is not accepted by `setHorizontalAlignment()`.* @returns {string} The horizontal alignment of the text in the cell.* @example* ```ts@@ -1007,7 +1009,8 @@ export class FRange extends FBaseInitialable {}/**- * Returns the horizontal alignments of the cells in the range.+ * Returns a two-dimensional array of horizontal alignments: `left`, `center`, or `normal` (right alignment).+ * Default and other core alignment values return `general`, which is not accepted by `setHorizontalAlignment()`.* @returns {string[][]} A two-dimensional array of horizontal alignments of text associated with cells in the range.* @example* ```ts@@ -1024,7 +1027,8 @@ export class FRange extends FBaseInitialable {}/**- * Returns the vertical alignment (top/middle/bottom) of the top-left cell in the range.+ * Returns `top`, `middle`, or `bottom` for the top-left cell; unspecified alignment returns `general`.+ * `general` is a getter result and is not accepted by `setVerticalAlignment()`.* @returns {string} The vertical alignment of the text in the cell.* @example* ```ts@@ -1040,7 +1044,8 @@ export class FRange extends FBaseInitialable {}/**- * Returns the vertical alignments of the cells in the range.+ * Returns a two-dimensional array of `top`, `middle`, or `bottom` values; unspecified alignment returns `general`.+ * `general` is a getter result and is not accepted by `setVerticalAlignment()`.* @returns {string[][]} A two-dimensional array of vertical alignments of text associated with cells in the range.* @example* ```ts@@ -1123,7 +1128,7 @@ export class FRange extends FBaseInitialable {* Returns the custom meta data for the cell at the start of this range.* @returns {CustomData | null} The custom meta data* @example- * ```+ * ```ts* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorksheet = fWorkbook.getSheetByName('Sheet1');* if (!fWorksheet) return;@@ -1142,7 +1147,7 @@ export class FRange extends FBaseInitialable {* Returns the custom meta data for the cells in the range.* @returns {Nullable<CustomData>[][]} A two-dimensional array of custom metadata, with `null` for cells without metadata.* @example- * ```+ * ```ts* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorksheet = fWorkbook.getSheetByName('Sheet1');* if (!fWorksheet) return;@@ -1404,7 +1409,7 @@ export class FRange extends FBaseInitialable {* @param {RichTextValue | IDocumentData} value The rich text value* @returns {FRange} The range* @example- * ```+ * ```ts* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorksheet = fWorkbook.getSheetByName('Sheet1');* if (!fWorksheet) return;@@ -1572,8 +1577,9 @@ export class FRange extends FBaseInitialable {}/**- * Set the horizontal (left to right) alignment for the given range (left/center/right).- * @param {FHorizontalAlignment} alignment The horizontal alignment+ * Sets the horizontal alignment for the range using `left`, `center`, or `normal`.+ * These parameter names follow Google Apps Script. In Univer, `normal` means right alignment; `right` is not accepted.+ * @param {FHorizontalAlignment} alignment The horizontal alignment: `left`, `center`, or `normal` (right alignment).* @returns {FRange} this range, for chaining* @example* ```ts@@ -1581,7 +1587,7 @@ export class FRange extends FBaseInitialable {* const fWorksheet = fWorkbook.getSheetByName('Sheet1');* if (!fWorksheet) return;* const fRange = fWorksheet.getRange('A1:B2');- * fRange.setHorizontalAlignment('left');+ * fRange.setHorizontalAlignment('normal'); // Align right* ```*/setHorizontalAlignment(alignment: FHorizontalAlignment): FRange {diff --git a/packages/sheets/src/facade/f-workbook.ts b/packages/sheets/src/facade/f-workbook.tsindex a3aa4c757c..af907951ab 100644--- a/packages/sheets/src/facade/f-workbook.ts+++ b/packages/sheets/src/facade/f-workbook.ts@@ -73,6 +73,9 @@ import { FWorkbookPermission } from './permission/f-workbook-permission';* @hideconstructor*/export class FWorkbook extends FBaseInitialable {+ /**+ * The workbook unit id used to identify this workbook in commands and snapshots.+ */readonly id: string;constructor(diff --git a/packages/sheets/src/facade/permission/f-worksheet-permission.ts b/packages/sheets/src/facade/permission/f-worksheet-permission.tsindex d1ca434bbe..5b49956f8c 100644--- a/packages/sheets/src/facade/permission/f-worksheet-permission.ts+++ b/packages/sheets/src/facade/permission/f-worksheet-permission.ts@@ -449,6 +449,7 @@ export class FWorksheetPermission extends FBase {* if (fWorksheet.getWorksheetPermission().canView()) {* console.log('Worksheet is viewable');* }+ * ```*/canView(): boolean {return this.getPoint(WorksheetPermissionPoint.View);diff --git a/packages/sheets/src/facade/utils.ts b/packages/sheets/src/facade/utils.tsindex 3040f3a4a3..e7f326c65f 100644--- a/packages/sheets/src/facade/utils.ts+++ b/packages/sheets/src/facade/utils.ts@@ -22,6 +22,7 @@ import {} from '@univerjs/core';export type FDefaultAlignment = 'general';+/** Horizontal alignment accepted by the Facade API. `normal` means right alignment. */export type FHorizontalAlignment = 'left' | 'center' | 'normal';export type FVerticalAlignment = 'top' | 'middle' | 'bottom';diff --git a/packages/ui/src/facade/f-menu-builder.ts b/packages/ui/src/facade/f-menu-builder.tsindex 7236b5aa57..666021b127 100644--- a/packages/ui/src/facade/f-menu-builder.ts+++ b/packages/ui/src/facade/f-menu-builder.ts@@ -153,8 +153,17 @@ abstract class FMenuBase extends FBase {* @hideconstructor*/export class FMenu extends FMenuBase {+ /**+ * Built-in group identifiers for placing items on the Start ribbon tab.+ */static RibbonStartGroup = RibbonStartGroup;+ /**+ * Built-in ribbon tab identifiers for menu placement.+ */static RibbonPosition = RibbonPosition;+ /**+ * Top-level menu placement identifiers for the ribbon and context menu.+ */static MenuManagerPosition = MenuManagerPosition;private _commandToRegister = new Map<string, (accessor: IAccessor) => void>();