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
fix: better facade comment (#4402)
lumix59a1774a6f76
diff --git a/.vscode/settings.json b/.vscode/settings.jsonindex 0878774491..6e45915aeb 100644--- a/.vscode/settings.json+++ b/.vscode/settings.json@@ -157,7 +157,9 @@"source.fixAll.eslint": "explicit","source.organizeImports": "never"},-+ "eslint.workingDirectories": [+ { "mode": "auto" }+ ],// Enable the ESlint flat config support"eslint.useFlatConfig": true,// Silent the stylistic rules in you IDE, but still auto fix themdiff --git a/common/shared/eslint/index.js b/common/shared/eslint/index.jsindex 2ad60afe49..2ef4db4673 100644--- a/common/shared/eslint/index.js+++ b/common/shared/eslint/index.js@@ -1,3 +1,4 @@+const jsdoc = require('eslint-plugin-jsdoc');const eslintPluginReadableTailwind = require('eslint-plugin-readable-tailwind');const noExternalImportsInFacade = require('./plugins/no-external-imports-in-facade');const noSelfPackageImports = require('./plugins/no-self-package-imports');@@ -213,3 +214,12 @@ exports.specPreset = () => {},};};++exports.jsdocPreset = () => {+ return {+ files: ['**/*.{ts,tsx}'],+ rules: {+ ...jsdoc.configs.recommended.rules,+ },+ };+};diff --git a/eslint.config.js b/eslint.config.jsindex 6c18da9ec8..f1ab152014 100644--- a/eslint.config.js+++ b/eslint.config.js@@ -1,5 +1,5 @@import antfu from '@antfu/eslint-config';-import { baseRules, facadePreset, specPreset, tailwindcssPreset, typescriptPreset, univerSourcePreset } from '@univerjs-infra/shared/eslint';+import { baseRules, facadePreset, jsdocPreset, specPreset, tailwindcssPreset, typescriptPreset, univerSourcePreset } from '@univerjs-infra/shared/eslint';import header from 'eslint-plugin-header';import barrel from 'eslint-plugin-no-barrel-import';import penetrating from 'eslint-plugin-no-penetrating-import';@@ -102,5 +102,6 @@ export default antfu(univerSourcePreset(),facadePreset(),tailwindcssPreset(),- specPreset()+ specPreset(),+ jsdocPreset());diff --git a/package.json b/package.jsonindex ca14972a16..e46eda6963 100644--- a/package.json+++ b/package.json@@ -60,6 +60,7 @@"eslint": "9.17.0","eslint-plugin-format": "^0.1.3","eslint-plugin-header": "^3.1.1",+ "eslint-plugin-jsdoc": "^50.6.1","eslint-plugin-no-barrel-import": "^0.0.2","eslint-plugin-no-penetrating-import": "^0.0.1","eslint-plugin-react": "^7.37.3",diff --git a/packages/core/src/facade/f-blob.ts b/packages/core/src/facade/f-blob.tsindex 31aa642e40..e84a2c4040 100644--- a/packages/core/src/facade/f-blob.ts+++ b/packages/core/src/facade/f-blob.ts@@ -44,7 +44,7 @@ export class FBlob extends FBase {* @returns a new blob by copying the current blob* @example* ```ts- * const blob = UniverApi.newBlob(blob);+ * const blob = univerAPI.newBlob(blob);* const newBlob = blob.copyBlob();* console.log(newBlob);* ```@@ -59,7 +59,7 @@ export class FBlob extends FBase {* @returns a new blob by converting the current blob to the specified content type* @example* ```ts- * const blob = UniverApi.newBlob(blob);+ * const blob = univerAPI.newBlob(blob);* const newBlob = blob.getBlob();* ```*/@@ -70,23 +70,23 @@ export class FBlob extends FBase {}/**- * get the blob as a string+ * Get the blob as a string.* @returns* @example* ```ts- * const blob = UniverApi.newBlob(blob);+ * const blob = univerAPI.newBlob(blob);* const newBlob = blob.getDataAsString();* console.log(newBlob);* ```*/getDataAsString(): Promise<string>;/**- * get the blob as a string+ * Get the blob as a string.* @param charset the charset* @returns the blob content as a string* @example* ```ts- * const blob = UniverApi.newBlob(blob);+ * const blob = univerAPI.newBlob(blob);* const newBlob = blob.getDataAsString('iso-8859-1');* console.log(newBlob);* ```@@ -115,7 +115,7 @@ export class FBlob extends FBase {* @returns the blob content as a byte array* @example* ```ts- * const blob = UniverApi.newBlob(blob);+ * const blob = univerAPI.newBlob(blob);* const newBlob = blob.getBytes();* console.log(newBlob);* ```@@ -133,7 +133,7 @@ export class FBlob extends FBase {* @returns the blob object* @example* ```ts- * const blob = UniverApi.newBlob();+ * const blob = univerAPI.newBlob();* const bytes = new Uint8Array(10);* blob.setBytes(bytes);* ```@@ -149,7 +149,7 @@ export class FBlob extends FBase {* @returns the blob object* @example* ```ts- * const blob = UniverApi.newBlob();+ * const blob = univerAPI.newBlob();* blob.setDataFromString('Hello, World!');* ```*/@@ -161,7 +161,7 @@ export class FBlob extends FBase {* @returns the blob object* @example* ```ts- * const blob = UniverApi.newBlob();+ * const blob = univerAPI.newBlob();* blob.setDataFromString('Hello, World!', 'text/plain');* ```*/@@ -178,7 +178,7 @@ export class FBlob extends FBase {* @returns the content type* @example* ```ts- * const blob = UniverApi.newBlob(blob);+ * const blob = univerAPI.newBlob(blob);* const newBlob = blob.getContentType();* console.log(newBlob);* ```@@ -193,7 +193,7 @@ export class FBlob extends FBase {* @returns the blob object* @example* ```ts- * const blob = UniverApi.newBlob(blob);+ * const blob = univerAPI.newBlob(blob);* const newBlob = blob.setContentType('text/plain');* console.log(newBlob);* ```diff --git a/packages/core/src/facade/f-univer.ts b/packages/core/src/facade/f-univer.tsindex ad6e26e098..91a7946f12 100644--- a/packages/core/src/facade/f-univer.ts+++ b/packages/core/src/facade/f-univer.ts@@ -36,9 +36,7 @@ import { FUserManager } from './f-usermanager';export class FUniver extends FBaseInitialable {/*** Create an FUniver instance, if the injector is not provided, it will create a new Univer instance.- ** @static- ** @param {Univer | Injector} wrapped - The Univer instance or injector instance.* @returns {FUniver} - The FUniver instance.*/@@ -78,7 +76,6 @@ export class FUniver extends FBaseInitialable {/*** Dispose the UniverSheet by the `unitId`. The UniverSheet would be unload from the application.- ** @param unitId The unit id of the UniverSheet.* @returns Whether the Univer instance is disposed successfully.*/@@ -88,7 +85,6 @@ export class FUniver extends FBaseInitialable {/*** Get the current lifecycle stage.- ** @returns {LifecycleStages} - The current lifecycle stage.*/getCurrentLifecycleStage(): LifecycleStages {@@ -98,7 +94,6 @@ export class FUniver extends FBaseInitialable {/*** Undo an editing on the currently focused document.- ** @returns {Promise<boolean>} undo result*/undo(): Promise<boolean> {@@ -107,7 +102,6 @@ export class FUniver extends FBaseInitialable {/*** Redo an editing on the currently focused document.- ** @returns {Promise<boolean>} redo result*/redo(): Promise<boolean> {@@ -179,11 +173,10 @@ export class FUniver extends FBaseInitialable {/*** Create a new blob.- ** @returns {FBlob} The new blob instance* @example* ```ts- * const blob = UniverApi.newBlob();+ * const blob = univerAPI.newBlob();* ```*/newBlob(): FBlob {@@ -250,4 +243,3 @@ export class FUniver extends FBaseInitialable {return this._injector.createInstance(FUserManager);}}-diff --git a/packages/core/src/facade/f-usermanager.ts b/packages/core/src/facade/f-usermanager.tsindex 40e29f3341..151aa423cc 100644--- a/packages/core/src/facade/f-usermanager.ts+++ b/packages/core/src/facade/f-usermanager.ts@@ -28,10 +28,11 @@ export class FUserManager extends FBase {}/**- * Get current user info+ * Get current user info.+ * @returns {IUser} Current user info.* @example- * ```- * univerAPI.getUserManager().getCurrentUser()+ * ```typescript+ * univerAPI.getUserManager().getCurrentUser();* ```*/getCurrentUser(): IUser {diff --git a/packages/docs-ui/src/facade/f-document.ts b/packages/docs-ui/src/facade/f-document.tsindex 430b244346..d3f5ae1371 100644--- a/packages/docs-ui/src/facade/f-document.ts+++ b/packages/docs-ui/src/facade/f-document.ts@@ -68,7 +68,7 @@ export class FDocument {/*** Adds the specified text to the end of this text region.- * @param text+ * @param text - The text to be added to the end of this text region.*/appendText(text: string): Promise<boolean> {const unitId = this.id;@@ -102,10 +102,8 @@ export class FDocument {/*** Sets the selection to a specified text range in the document.- ** @param startOffset - The starting offset of the selection in the document.* @param endOffset - The ending offset of the selection in the document.- ** @example* ```typescript* document.setSelection(10, 20);diff --git a/packages/sheets-conditional-formatting/src/facade/conditional-formatting-builder.ts b/packages/sheets-conditional-formatting/src/facade/conditional-formatting-builder.tsindex 6d71be99b2..d3ce209acf 100644--- a/packages/sheets-conditional-formatting/src/facade/conditional-formatting-builder.ts+++ b/packages/sheets-conditional-formatting/src/facade/conditional-formatting-builder.ts@@ -110,9 +110,8 @@ class ConditionalFormatRuleBaseBuilder {}/**- * deep clone a current builder.- *- * @return {*}+ * Deep clone a current builder.+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/copy() {@@ -121,7 +120,7 @@ class ConditionalFormatRuleBaseBuilder {/*** Gets the scope of the current conditional format- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/getRanges() {@@ -136,8 +135,8 @@ class ConditionalFormatRuleBaseBuilder {}/**- * create a conditional format ID.- * @return {*}+ * Create a conditional format ID.+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/createCfId() {@@ -147,7 +146,7 @@ class ConditionalFormatRuleBaseBuilder {/*** Sets the scope for conditional formatting* @param {IRange[]} ranges- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setRanges(ranges: IRange[]) {@@ -168,7 +167,6 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set average rule- ** @param {IAverageHighlightCell['operator']} operator* @memberof ConditionalFormatHighlightRuleBuilder*/@@ -182,7 +180,6 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set uniqueValues rule- ** @memberof ConditionalFormatHighlightRuleBuilder*/setUniqueValues() {@@ -194,7 +191,6 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set duplicateValues rule- ** @memberof ConditionalFormatHighlightRuleBuilder*/setDuplicateValues() {@@ -206,8 +202,10 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set rank rule- ** @param {{ isBottom: boolean, isPercent: boolean, value: number }} config+ * @param config.isBottom+ * @param config.isPercent+ * @param config.value* @memberof ConditionalFormatHighlightRuleBuilder*/setRank(config: { isBottom: boolean; isPercent: boolean; value: number }) {@@ -223,7 +221,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Sets the background color* @param {string} [color]- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setBackground(color?: string) {@@ -242,7 +240,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set Bold* @param {boolean} isBold- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setBold(isBold: boolean) {@@ -257,7 +255,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Sets the font color* @param {string} [color]- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setFontColor(color?: string) {@@ -276,7 +274,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set the text to italic* @param {boolean} isItalic- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setItalic(isItalic: boolean) {@@ -290,7 +288,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set the strikethrough* @param {boolean} isStrikethrough- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setStrikethrough(isStrikethrough: boolean) {@@ -304,7 +302,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Set the underscore* @param {boolean} isUnderline- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setUnderline(isUnderline: boolean) {@@ -329,7 +327,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Sets the conditional formatting rule to fire when the cell is not empty- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/whenCellNotEmpty() {@@ -343,9 +341,8 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Highlight when the date is in a time period, custom time is not supported.- ** @param {CFTimePeriodOperator} date- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/whenDate(date: CFTimePeriodOperator) {@@ -388,7 +385,6 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Sets the conditional formatting rule to fire when the number equals the given value- ** @param {number} value* @memberof ConditionalFormatRuleBuilder*/@@ -476,6 +472,7 @@ class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBui/*** Sets the conditional formatting rule to fire when a number does not equal a given value.+ * @param value* @memberof ConditionalFormatRuleBuilder*/whenNumberNotEqualTo(value: number) {@@ -564,7 +561,6 @@ class ConditionalFormatDataBarRuleBuilder extends ConditionalFormatRuleBaseBuild/*** Data bar settings- ** @param {{* min: IValueConfig;* max: IValueConfig;@@ -573,6 +569,12 @@ class ConditionalFormatDataBarRuleBuilder extends ConditionalFormatRuleBaseBuild* nativeColor: string;* isShowValue?: boolean;* }} config+ * @param config.min+ * @param config.max+ * @param config.isGradient+ * @param config.positiveColor+ * @param config.nativeColor+ * @param config.isShowValue* @memberof ConditionalFormatRuleBuilder*/setDataBar(config: {@@ -624,6 +626,8 @@ class ConditionalFormatIconSetRuleBuilder extends ConditionalFormatRuleBaseBuild** Icon Set* @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config+ * @param config.iconConfigs+ * @param config.isShowValue* @memberof ConditionalFormatRuleBuilder*/setIconSet(config: { iconConfigs: IIconSet['config']; isShowValue: boolean }) {@@ -646,7 +650,6 @@ export class FConditionalFormattingBuilder {/*** Set average rule- ** @param {IAverageHighlightCell['operator']} operator* @memberof ConditionalFormatHighlightRuleBuilder*/@@ -656,7 +659,6 @@ export class FConditionalFormattingBuilder {/*** Set uniqueValues rule- ** @memberof ConditionalFormatHighlightRuleBuilder*/setUniqueValues() {@@ -665,7 +667,6 @@ export class FConditionalFormattingBuilder {/*** Set duplicateValues rule- ** @memberof ConditionalFormatHighlightRuleBuilder*/setDuplicateValues() {@@ -674,8 +675,10 @@ export class FConditionalFormattingBuilder {/*** Set rank rule- ** @param {{ isBottom: boolean, isPercent: boolean, value: number }} config+ * @param config.isBottom+ * @param config.isPercent+ * @param config.value* @memberof ConditionalFormatHighlightRuleBuilder*/setRank(config: { isBottom: boolean; isPercent: boolean; value: number }) {@@ -686,6 +689,8 @@ export class FConditionalFormattingBuilder {** Set iconSet rule* @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config+ * @param config.iconConfigs+ * @param config.isShowValue* @memberof ConditionalFormatRuleBuilder*/setIconSet(config: { iconConfigs: IIconSet['config']; isShowValue: boolean }) {@@ -703,7 +708,6 @@ export class FConditionalFormattingBuilder {/*** Set dataBar rule- ** @param {{* min: IValueConfig;* max: IValueConfig;@@ -712,6 +716,12 @@ export class FConditionalFormattingBuilder {* nativeColor: string;* isShowValue?: boolean;* }} config+ * @param config.min+ * @param config.max+ * @param config.isGradient+ * @param config.positiveColor+ * @param config.nativeColor+ * @param config.isShowValue* @memberof ConditionalFormatRuleBuilder*/setDataBar(config: {@@ -728,7 +738,7 @@ export class FConditionalFormattingBuilder {/*** Sets the background color* @param {string} [color]- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setBackground(color?: string) {@@ -738,7 +748,7 @@ export class FConditionalFormattingBuilder {/*** Set Bold* @param {boolean} isBold- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setBold(isBold: boolean) {@@ -748,7 +758,7 @@ export class FConditionalFormattingBuilder {/*** Sets the font color* @param {string} [color]- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setFontColor(color?: string) {@@ -758,7 +768,7 @@ export class FConditionalFormattingBuilder {/*** Set the text to italic* @param {boolean} isItalic- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setItalic(isItalic: boolean) {@@ -768,7 +778,7 @@ export class FConditionalFormattingBuilder {/*** Set the strikethrough* @param {boolean} isStrikethrough- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setStrikethrough(isStrikethrough: boolean) {@@ -778,7 +788,7 @@ export class FConditionalFormattingBuilder {/*** Set the underscore* @param {boolean} isUnderline- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/setUnderline(isUnderline: boolean) {@@ -794,7 +804,7 @@ export class FConditionalFormattingBuilder {/*** Sets the conditional formatting rule to fire when the cell is not empty- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/whenCellNotEmpty() {@@ -803,9 +813,8 @@ export class FConditionalFormattingBuilder {/*** Highlight when the date is in a time period, custom time is not supported.- ** @param {CFTimePeriodOperator} date- * @return {*}+ * @returns {*}* @memberof ConditionalFormatRuleBuilder*/whenDate(date: CFTimePeriodOperator) {@@ -833,7 +842,6 @@ export class FConditionalFormattingBuilder {/*** Sets the conditional formatting rule to fire when the number equals the given value- ** @param {number} value* @memberof ConditionalFormatRuleBuilder*/@@ -889,6 +897,7 @@ export class FConditionalFormattingBuilder {/*** Sets the conditional formatting rule to fire when a number does not equal a given value.+ * @param value* @memberof ConditionalFormatRuleBuilder*/whenNumberNotEqualTo(value: number) {diff --git a/packages/sheets-conditional-formatting/src/facade/f-worksheet.ts b/packages/sheets-conditional-formatting/src/facade/f-worksheet.tsindex f204a9e2cc..d90c9c5db0 100644--- a/packages/sheets-conditional-formatting/src/facade/f-worksheet.ts+++ b/packages/sheets-conditional-formatting/src/facade/f-worksheet.ts@@ -36,7 +36,7 @@ export interface IFWorksheetConditionalFormattingMixin {/*** Gets all the conditional formatting for the current sheet- * @return {*} {IConditionFormattingRule[]}+ * @returns {*} {IConditionFormattingRule[]}* @memberof IFWorksheetConditionalFormattingMixin* @example* ```ts@@ -44,9 +44,11 @@ export interface IFWorksheetConditionalFormattingMixin {* ```*/getConditionalFormattingRules(): IConditionFormattingRule[];+/**+ * @deprecated use newConditionalFormattingRule instead.* Creates a constructor for conditional formatting- * @return {*} {ConditionalFormatRuleBuilder}+ * @returns {ConditionalFormatRuleBuilder}* @memberof IFWorksheetConditionalFormattingMixin* @example* ```ts@@ -64,6 +66,26 @@ export interface IFWorksheetConditionalFormattingMixin {*/createConditionalFormattingRule(): FConditionalFormattingBuilder;+ /**+ * Creates a constructor for conditional formatting+ * @returns {ConditionalFormatRuleBuilder}@example+ * @memberof IFWorksheetConditionalFormattingMixin+ * @example+ * ```ts+ * const workbook = univerAPI.getActiveWorkbook();+ * const worksheet = workbook?.getActiveSheet();+ * const rule = worksheet?.createConditionalFormattingRule()+ * .whenCellNotEmpty()+ * .setRanges([{ startRow: 0, endRow: 100, startColumn: 0, endColumn: 100 }])+ * .setItalic(true)+ * .setItalic(true)+ * .setBackground('red')+ * .setFontColor('green')+ * .build();+ * ```+ */+ newConditionalFormattingRule(): FConditionalFormattingBuilder;+/*** Add a new conditional format* @param {IConditionFormattingRule} rule@@ -88,7 +110,6 @@ export interface IFWorksheetConditionalFormattingMixin {/*** Delete conditional format according to `cfId`- ** @param {string} cfId* @returns {FWorksheet} Returns the current worksheet instance for method chaining* @memberof IFWorksheetConditionalFormattingMixin@@ -153,6 +174,10 @@ export class FWorksheetConditionalFormattingMixin extends FWorksheet implementsreturn new FConditionalFormattingBuilder();}+ override newConditionalFormattingRule(): FConditionalFormattingBuilder {+ return new FConditionalFormattingBuilder();+ }+override addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet {const params: IAddConditionalRuleMutationParams = {rule, unitId: this._workbook.getUnitId(), subUnitId: this._worksheet.getSheetId(),diff --git a/packages/sheets-data-validation/src/facade/f-range.ts b/packages/sheets-data-validation/src/facade/f-range.tsindex 0058831385..f05927f354 100644--- a/packages/sheets-data-validation/src/facade/f-range.ts+++ b/packages/sheets-data-validation/src/facade/f-range.ts@@ -22,19 +22,19 @@ import { FDataValidation } from './f-data-validation';export interface IFRangeDataValidationMixin {/**- * set a data validation rule to current range+ * Set a data validation rule to current range.* @param rule data validation rule, build by `FUniver.newDataValidation`* @returns current range*/setDataValidation(this: FRange, rule: Nullable<FDataValidation>): FRange;/**- * get first data validation rule in current range+ * Get first data validation rule in current range.* @returns data validation rule*/getDataValidation(this: FRange): Nullable<FDataValidation>;/**- * get all data validation rules in current range+ * Get all data validation rules in current range.* @returns all data validation rules*/getDataValidations(this: FRange): FDataValidation[];diff --git a/packages/sheets-data-validation/src/facade/f-workbook.ts b/packages/sheets-data-validation/src/facade/f-workbook.tsindex 7bce5229da..5f8a52b814 100644--- a/packages/sheets-data-validation/src/facade/f-workbook.ts+++ b/packages/sheets-data-validation/src/facade/f-workbook.ts@@ -15,16 +15,19 @@*/import type { IRuleChange } from '@univerjs/data-validation';-import type { IAddSheetDataValidationCommandParams,+import type {+ IAddSheetDataValidationCommandParams,IRemoveSheetAllDataValidationCommandParams,IRemoveSheetDataValidationCommandParams,IUpdateSheetDataValidationOptionsCommandParams,IUpdateSheetDataValidationRangeCommandParams,IUpdateSheetDataValidationSettingCommandParams,- IValidStatusChange } from '@univerjs/sheets-data-validation';+ IValidStatusChange,+} from '@univerjs/sheets-data-validation';import { type DataValidationStatus, type IDisposable, type IExecutionOptions, type Nullable, type ObjectMatrix, toDisposable } from '@univerjs/core';-import { AddSheetDataValidationCommand,+import {+ AddSheetDataValidationCommand,RemoveSheetAllDataValidationCommand,RemoveSheetDataValidationCommand,SheetDataValidationModel,@@ -38,15 +41,19 @@ import { filter } from 'rxjs';export interface IFWorkbookDataValidationMixin {/**- * get data validation validator status for current workbook- * @returns matrix of validator status+ * Get data validation validator status for current workbook.+ * @returns A promise that resolves to a matrix of validator status.+ * @example+ * ```ts+ * univerAPI.getActiveWorkbook().getValidatorStatus().then((status) => { console.log(status) })+ * ```*/getValidatorStatus(this: FWorkbook): Promise<Record<string, ObjectMatrix<Nullable<DataValidationStatus>>>>;/*** The onDataValidationChange event is fired when the data validation rule of this sheet is changed.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {function(IRuleChange): void} callback - Callback function that will be called when the event is fired+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event*/onDataValidationChange(callback: (ruleChange: IRuleChange) => void@@ -54,8 +61,8 @@ export interface IFWorkbookDataValidationMixin {/*** The onDataValidationStatusChange event is fired when the data validation status of this sheet is changed.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {function(IValidStatusChange): void} callback - Callback function that will be called when the event is fired+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event*/onDataValidationStatusChange(callback: (statusChange: IValidStatusChange) => void@@ -63,8 +70,8 @@ export interface IFWorkbookDataValidationMixin {/*** The onBeforeAddDataValidation event is fired before the data validation rule is added.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {function(IAddSheetDataValidationCommandParams, IExecutionOptions | undefined): void | false} callback - Callback function that will be called when the event is fired+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event*/onBeforeAddDataValidation(this: FWorkbook,@@ -73,7 +80,7 @@ export interface IFWorkbookDataValidationMixin {/*** The onBeforeUpdateDataValidationCriteria event is fired before the data validation rule is updated.- * @param callback Callback function that will be called when the event is fired+ * @param callback - Callback function that will be called when the event is fired* @returns A disposable object that can be used to unsubscribe from the event*/onBeforeUpdateDataValidationCriteria(@@ -83,7 +90,7 @@ export interface IFWorkbookDataValidationMixin {/*** The onBeforeUpdateDataValidationRange event is fired before the data validation rule is updated.- * @param callback Callback function that will be called when the event is fired+ * @param callback - Callback function that will be called when the event is fired* @returns A disposable object that can be used to unsubscribe from the event*/onBeforeUpdateDataValidationRange(@@ -92,7 +99,7 @@ export interface IFWorkbookDataValidationMixin {): IDisposable;/*** The onBeforeUpdateDataValidationOptions event is fired before the data validation rule is updated.- * @param callback Callback function that will be called when the event is fired+ * @param callback - Callback function that will be called when the event is fired* @returns A disposable object that can be used to unsubscribe from the event*/onBeforeUpdateDataValidationOptions(@@ -102,7 +109,7 @@ export interface IFWorkbookDataValidationMixin {/*** The onBeforeDeleteDataValidation event is fired before the data validation rule is deleted.- * @param callback Callback function that will be called when the event is fired+ * @param callback - Callback function that will be called when the event is fired* @returns A disposable object that can be used to unsubscribe from the event*/onBeforeDeleteDataValidation(@@ -112,7 +119,7 @@ export interface IFWorkbookDataValidationMixin {/*** The onBeforeDeleteAllDataValidation event is fired before delete all data validation rules.- * @param callback Callback function that will be called when the event is fired+ * @param callback - Callback function that will be called when the event is fired* @returns A disposable object that can be used to unsubscribe from the event*/onBeforeDeleteAllDataValidation(@@ -132,21 +139,12 @@ export class FWorkbookDataValidationMixin extends FWorkbook implements IFWorkboo});}- /**- * get data validation validator status for current workbook- * @returns matrix of validator status- */override getValidatorStatus(): Promise<Record<string, ObjectMatrix<Nullable<DataValidationStatus>>>> {const validatorService = this._injector.get(SheetsDataValidationValidatorService);return validatorService.validatorWorkbook(this._workbook.getUnitId());}// region DataValidationHooks- /**- * The onDataValidationChange event is fired when the data validation rule of this sheet is changed.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event- */override onDataValidationChange(callback: (ruleChange: IRuleChange) => void): IDisposable {@@ -156,11 +154,6 @@ export class FWorkbookDataValidationMixin extends FWorkbook implements IFWorkboo.subscribe(callback));}- /**- * The onDataValidationStatusChange event is fired when the data validation status of this sheet is changed.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event- */override onDataValidationStatusChange(callback: (statusChange: IValidStatusChange) => void): IDisposable {@@ -169,11 +162,6 @@ export class FWorkbookDataValidationMixin extends FWorkbook implements IFWorkboo.subscribe(callback));}- /**- * The onBeforeAddDataValidation event is fired before the data validation rule is added.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event- */override onBeforeAddDataValidation(callback: (params: IAddSheetDataValidationCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable {diff --git a/packages/sheets-data-validation/src/facade/f-worksheet.ts b/packages/sheets-data-validation/src/facade/f-worksheet.tsindex d418fb4a93..2075e25d05 100644--- a/packages/sheets-data-validation/src/facade/f-worksheet.ts+++ b/packages/sheets-data-validation/src/facade/f-worksheet.ts@@ -22,12 +22,12 @@ import { FDataValidation } from './f-data-validation';export interface IFWorksheetDataValidationMixin {/**- * get all data validation rules in current sheet+ * Get all data validation rules in current sheet.* @returns all data validation rules*/getDataValidations(): FDataValidation[];/**- * get data validation validator status for current sheet+ * Get data validation validator status for current sheet.* @returns matrix of validator status*/getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;diff --git a/packages/sheets-drawing-ui/src/facade/f-worksheet.ts b/packages/sheets-drawing-ui/src/facade/f-worksheet.tsindex ab43965a60..c961527ac8 100644--- a/packages/sheets-drawing-ui/src/facade/f-worksheet.ts+++ b/packages/sheets-drawing-ui/src/facade/f-worksheet.ts@@ -14,7 +14,8 @@* limitations under the License.*/-import { type IFBlobSource, ImageSourceType, type Nullable } from '@univerjs/core';+import type { IDisposable, IFBlobSource, Nullable } from '@univerjs/core';+import { ImageSourceType, toDisposable } from '@univerjs/core';import { ISheetDrawingService, type ISheetImage } from '@univerjs/sheets-drawing';import { type ICanvasFloatDom, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetSheetDrawingCommand, SheetCanvasFloatDomManagerService } from '@univerjs/sheets-drawing-ui';import { type IFComponentKey, transformComponentKey } from '@univerjs/sheets-ui/facade';@@ -26,7 +27,7 @@ export interface IFICanvasFloatDom extends Omit<ICanvasFloatDom, 'componentKey'export interface IFWorksheetLegacy {/**- * add a float dom to position+ * Add a float dom to position.* @param layer float dom config* @param id float dom id, if not given will be auto generated* @returns float dom id and dispose function@@ -70,24 +71,38 @@ export interface IFWorksheetLegacy {* const imageBuilder = activeSheet.newOverGridImage();* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setWidth(500).setHeight(300).build();* activeSheet.insertImages([param]);- *- ** const image = activeSheet.getImageById(param.drawingId);* console.log(image);-* setTimeout(async ()=>{* const builder = image.toBuilder();* const param = await builder.setHeight(50).setWidth(100).build();* activeSheet.updateImages([param]);* }, 4000);*/- insertImages(sheetImages: ISheetImage[]): void;+ insertImages(sheetImages: ISheetImage[]): FWorksheet;+ /**+ * Get all images in current sheet.+ * @returns FOverGridImage[]+ * @example+ * ```ts+ * univerAPI.getActiveWorkbook().getActiveSheet().getImages();+ * ```+ */getImages(): FOverGridImage[];+ /**+ * Get image by drawing id+ * @param id - The drawing id of the image+ * @returns FOverGridImage | null+ * @example+ * ```ts+ * univerAPI.getActiveWorkbook().getActiveSheet().getImageById('xxxx');+ * ```+ */getImageById(id: string): FOverGridImage | null;- deleteImages(sheetImages: FOverGridImage[]): void;+ deleteImages(sheetImages: FOverGridImage[]): FWorksheet;/*** Update images to the sheet@@ -100,34 +115,51 @@ export interface IFWorksheetLegacy {* const imageBuilder = activeSheet.newOverGridImage();* const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setWidth(500).setHeight(300).build();* activeSheet.insertImages([param]);- *- ** const image = activeSheet.getImageById(param.drawingId);* console.log(image);-* setTimeout(async ()=>{* const builder = image.toBuilder();* const param = await builder.setHeight(50).setWidth(100).build();* activeSheet.updateImages([param]);* }, 4000);*/- updateImages(sheetImages: ISheetImage[]): void;+ updateImages(sheetImages: ISheetImage[]): FWorksheet;+ /**+ * Get all images in current sheet.+ * @returns FOverGridImage[]+ * @example+ * ```ts+ * univerAPI.getActiveWorkbook().getActiveSheet().getImages();+ * ```+ */getActiveImages(): FOverGridImage[];- onImageInserted(callback: (images: FOverGridImage[]) => void): void;+ /**+ * Hook when a image is inserted.+ * @param {function(FOverGridImage[]: void)} callback - The callback function when a image is inserted.+ */+ onImageInserted(callback: (images: FOverGridImage[]) => void): IDisposable;- onImageDeleted(callback: (images: FOverGridImage[]) => void): void;+ /**+ * Hook when a image is deleted.+ * @param {function(FOverGridImage[]: void)} callback - The callback function when a image is deleted.+ */+ onImageDeleted(callback: (images: FOverGridImage[]) => void): IDisposable;- onImageChanged(callback: (images: FOverGridImage[]) => void): void;+ /**+ * Hook when a image is changed.+ * @param {function(FOverGridImage[]: void)} callback - The callback function when a image is changed.+ */+ onImageChanged(callback: (images: FOverGridImage[]) => void): IDisposable;/*** Create a new over grid image builder.- * @returns The builder+ * @returns {FOverGridImageBuilder} The builder* @example* ```ts* // create a new over grid image builder.- * const builder = UniverApi.newOverGridImage();+ * const builder = univerAPI.newOverGridImage();* ```*/newOverGridImage(): FOverGridImageBuilder;@@ -198,7 +230,7 @@ export class FWorksheetLegacy extends FWorksheet implements IFWorksheetLegacy {return this._commandService.syncExecuteCommand(InsertSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings: [param] });}- override insertImages(sheetImages: ISheetImage[]): void {+ override insertImages(sheetImages: ISheetImage[]): FWorksheet {const param = sheetImages.map((image) => {image.unitId = this._fWorkbook.getId();image.subUnitId = this.getSheetId();@@ -206,9 +238,10 @@ export class FWorksheetLegacy extends FWorksheet implements IFWorksheetLegacy {});this._commandService.syncExecuteCommand(InsertSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings: param });+ return this;}- override deleteImages(sheetImages: FOverGridImage[]): void {+ override deleteImages(sheetImages: FOverGridImage[]): FWorksheet {const drawings = sheetImages.map((image) => {return {unitId: this._fWorkbook.getId(),@@ -218,6 +251,8 @@ export class FWorksheetLegacy extends FWorksheet implements IFWorksheetLegacy {};});this._commandService.syncExecuteCommand(RemoveSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings });++ return this;}override getImages(): FOverGridImage[] {@@ -251,38 +286,39 @@ export class FWorksheetLegacy extends FWorksheet implements IFWorksheetLegacy {return images;}- override updateImages(sheetImages: ISheetImage[]): void {+ override updateImages(sheetImages: ISheetImage[]): FWorksheet {this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, { unitId: this._fWorkbook.getId(), drawings: sheetImages });+ return this;}- override onImageInserted(callback: (images: FOverGridImage[]) => void): void {+ override onImageInserted(callback: (images: FOverGridImage[]) => void): IDisposable {const sheetDrawingService = this._injector.get(ISheetDrawingService);- sheetDrawingService.add$.subscribe((drawingSearches) => {+ return toDisposable(sheetDrawingService.add$.subscribe((drawingSearches) => {const drawings = drawingSearches.map((drawingSearch) => this._injector.createInstance(FOverGridImage, sheetDrawingService.getDrawingByParam(drawingSearch) as ISheetImage));callback(drawings);- });+ }));}- override onImageDeleted(callback: (images: FOverGridImage[]) => void): void {+ override onImageDeleted(callback: (images: FOverGridImage[]) => void): IDisposable {const sheetDrawingService = this._injector.get(ISheetDrawingService);- sheetDrawingService.remove$.subscribe((drawingSearches) => {+ return toDisposable(sheetDrawingService.remove$.subscribe((drawingSearches) => {const drawings = drawingSearches.map((drawingSearch) => this._injector.createInstance(FOverGridImage, sheetDrawingService.getDrawingByParam(drawingSearch) as ISheetImage));callback(drawings);- });+ }));}- override onImageChanged(callback: (images: FOverGridImage[]) => void): void {+ override onImageChanged(callback: (images: FOverGridImage[]) => void): IDisposable {const sheetDrawingService = this._injector.get(ISheetDrawingService);- sheetDrawingService.update$.subscribe((drawingSearches) => {+ return toDisposable(sheetDrawingService.update$.subscribe((drawingSearches) => {const drawings = drawingSearches.map((drawingSearch) => this._injector.createInstance(FOverGridImage, sheetDrawingService.getDrawingByParam(drawingSearch) as ISheetImage));callback(drawings);- });+ }));}override newOverGridImage(): FOverGridImageBuilder {diff --git a/packages/sheets-formula/src/facade/f-formula.ts b/packages/sheets-formula/src/facade/f-formula.tsindex 1a33410d8e..a79ceb39ef 100644--- a/packages/sheets-formula/src/facade/f-formula.ts+++ b/packages/sheets-formula/src/facade/f-formula.ts@@ -32,7 +32,6 @@ export interface IFFormulaSheetsMixin {/*** Register a custom synchronous formula function.- ** @param name - The name of the function to register. This will be used in formulas (e.g., =MYFUNC())* @param func - The implementation of the function* @param description - A string describing the function's purpose and usage@@ -64,12 +63,10 @@ export interface IFFormulaSheetsMixin {/*** Register a custom synchronous formula function with localization support.- ** @param name - The name of the function to register. This will be used in formulas (e.g., =MYFUNC())* @param func - The implementation of the function* @param options - Object containing locales and description* @returns A disposable object that will unregister the function when disposed- ** @example* ```js* univerAPI.getFormula().registerFunction('HELLO',@@ -106,11 +103,9 @@ export interface IFFormulaSheetsMixin {/*** Register a custom asynchronous formula function.- ** @param name - The name of the function to register. This will be used in formulas (e.g., =ASYNCFUNC())* @param func - The async implementation of the function* @returns A disposable object that will unregister the function when disposed- ** @example* ```js* univerAPI.getFormula().registerAsyncFunction('RANDOM_DELAYED',@@ -129,12 +124,10 @@ export interface IFFormulaSheetsMixin {registerAsyncFunction(name: string, func: IRegisterAsyncFunction, description?: string): IDisposable;/*** Register a custom asynchronous formula function with description.- ** @param name - The name of the function to register. This will be used in formulas (e.g., =ASYNCFUNC())* @param func - The async implementation of the function* @param description - A string describing the function's purpose and usage* @returns A disposable object that will unregister the function when disposed- ** @example* ```js* // Mock a user score fetching function@@ -175,13 +168,12 @@ export interface IFFormulaSheetsMixin {export class FFormulaSheetsMixin extends FFormula implements IFFormulaSheetsMixin {/**- * registerFunction may be executed multiple times, triggering multiple formula forced refreshes+ * RegisterFunction may be executed multiple times, triggering multiple formula forced refreshes.*/declare private _debouncedFormulaCalculation: () => void;/*** Initialize the FUniver instance.- ** @private*/override _initialize(): void {diff --git a/packages/sheets-formula/src/facade/f-univer.ts b/packages/sheets-formula/src/facade/f-univer.tsindex 08181a2bc5..648382fb87 100644--- a/packages/sheets-formula/src/facade/f-univer.ts+++ b/packages/sheets-formula/src/facade/f-univer.ts@@ -33,13 +33,12 @@ export interface IFUniverSheetsFormulaMixin {export class FUniverSheetsFormulaMixin extends FUniver implements IFUniverSheetsFormulaMixin {/**- * registerFunction may be executed multiple times, triggering multiple formula forced refreshes+ * RegisterFunction may be executed multiple times, triggering multiple formula forced refreshes.*/declare private _debouncedFormulaCalculation: () => void;/*** Initialize the FUniver instance.- ** @private*/override _initialize(): void {diff --git a/packages/sheets-hyper-link-ui/src/facade/f-workbook.ts b/packages/sheets-hyper-link-ui/src/facade/f-workbook.tsindex d9fe18195e..8b6f444fab 100644--- a/packages/sheets-hyper-link-ui/src/facade/f-workbook.ts+++ b/packages/sheets-hyper-link-ui/src/facade/f-workbook.ts@@ -21,8 +21,12 @@ import { FWorkbook } from '@univerjs/sheets/facade';interface IFWorkbookHyperlinkUIMixin {/**- * navigate to the sheet hyperlink+ * Navigate to the sheet hyperlink.* @param hyperlink the hyperlink string+ * @example+ * ``` ts+ * univerAPI.getActiveWorkbook().navigateToSheetHyperlink('#gid=sheet_Id&range=F6')+ * ```*/navigateToSheetHyperlink(this: FWorkbook, hyperlink: string): void;}diff --git a/packages/sheets-hyper-link/src/facade/f-workbook.ts b/packages/sheets-hyper-link/src/facade/f-workbook.tsindex 680b70a5cc..d4ffb2d1a4 100644--- a/packages/sheets-hyper-link/src/facade/f-workbook.ts+++ b/packages/sheets-hyper-link/src/facade/f-workbook.ts@@ -21,16 +21,27 @@ import { FWorkbook } from '@univerjs/sheets/facade';export interface IFWorkbookHyperlinkMixin {/**- * create a hyperlink for the sheet+ * Create a hyperlink for the sheet.* @param sheetId the sheet id to link* @param range the range to link, or define-name id* @returns the hyperlink string+ * @example+ * ```ts+ * let range = univerAPI.getActiveWorkbook().getActiveSheet().getRange(5, 5);+ * // return something like '#gid=sheet_Id&range=F6'+ * univerAPI.getActiveWorkbook().createSheetHyperlink('sheet_Id', r.getRange());+ * ```*/createSheetHyperlink(this: FWorkbook, sheetId: string, range?: string | IRange): string;+/**- * parse the hyperlink string to get the hyperlink info+ * Parse the hyperlink string to get the hyperlink info.* @param hyperlink the hyperlink string* @returns the hyperlink info+ * @example+ * ``` ts+ * univerAPI.getActiveWorkbook().parseSheetHyperlink('#gid=sheet_Id&range=F6')+ * ```*/parseSheetHyperlink(this: FWorkbook, hyperlink: string): ISheetHyperLinkInfo;}@@ -42,9 +53,9 @@ export class FWorkbookHyperLinkMixin extends FWorkbook implements IFWorkbookHype}/**- * parse the hyperlink string to get the hyperlink info- * @param hyperlink the hyperlink string- * @returns the hyperlink info+ * Parse the hyperlink string to get the hyperlink info.+ * @param {string} hyperlink the hyperlink string+ * @returns {ISheetHyperLinkInfo} the hyperlink info*/override parseSheetHyperlink(hyperlink: string): ISheetHyperLinkInfo {const resolverService = this._injector.get(SheetsHyperLinkParserService);diff --git a/packages/sheets-thread-comment/src/facade/f-worksheet.ts b/packages/sheets-thread-comment/src/facade/f-worksheet.tsindex 59d9e7de88..682027bf63 100644--- a/packages/sheets-thread-comment/src/facade/f-worksheet.ts+++ b/packages/sheets-thread-comment/src/facade/f-worksheet.ts@@ -28,6 +28,16 @@ export interface IFWorksheetCommentMixin {* @returns all comments in the current sheet*/getComments(): FThreadComment[];++ /**+ * Subscribe to comment events.+ * @param callback (cellPos: Nullable<IHoverCellPosition>) => void Callback function, param contains comment info and target cell.+ * @example+ * ```ts+ * univerAPI.getActiveWorkbook().getActiveSheet().onCommented((params) => {...})+ * ```+ */+ onCommented(callback: (params: IAddCommentCommandParams) => void): IDisposable;}export class FWorksheetCommentMixin extends FWorksheet implements IFWorksheetCommentMixin {@@ -37,11 +47,7 @@ export class FWorksheetCommentMixin extends FWorksheet implements IFWorksheetComreturn comments.map((comment) => this._injector.createInstance(FThreadComment, comment));}- /**- * Subscribe to comment events.- * @param callback Callback function, param contains comment info and target cell.- */- onCommented(callback: (params: IAddCommentCommandParams) => void): IDisposable {+ override onCommented(callback: (params: IAddCommentCommandParams) => void): IDisposable {const commandService = this._injector.get(ICommandService);return commandService.onCommandExecuted((command) => {if (command.id === AddCommentCommand.id) {diff --git a/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.tsindex 873641012a..3cbda7bb85 100644--- a/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.ts+++ b/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.ts@@ -281,14 +281,16 @@ export class SheetsScrollRenderController extends Disposable implements IRenderM}/**- * Scroll spreadsheet to cell position. Based on the limitations of viewport and the number of rows and columns, you can only scroll to the maximum scrollable range.- * @param row- * @param column- * @returns+ * Scroll spreadsheet(viewMain) to cell position. Based on the limitations of viewport and the number of rows and columns, you can only scroll to the maximum scrollable range.+ *+ * if column A ~ B is frozen. set second param to 0 would make viewMain start at column C.+ * set second param to 2 would make viewMain start at column E.+ * @param {number} row - Cell row+ * @param {number} column - Cell column+ * @returns {boolean} - true if scroll is successful*/scrollToCell(row: number, column: number) {const worksheet = this._context.unit.getActiveSheet();- // if (!worksheet) return false;const {ySplit: freezeYSplit,xSplit: freezeXSplit,diff --git a/packages/sheets-ui/src/facade/f-permission.ts b/packages/sheets-ui/src/facade/f-permission.tsindex bfde3b2951..dc44be1ca6 100644--- a/packages/sheets-ui/src/facade/f-permission.ts+++ b/packages/sheets-ui/src/facade/f-permission.ts@@ -19,8 +19,11 @@ import { FPermission } from '@univerjs/sheets/facade';export interface IFPermissionSheetsUIMixin {/*** Set visibility of unauthorized pop-up window- ** @param {boolean} visible+ * @example+ * ```ts+ * univerAPI.getPermission().setPermissionDialogVisible(false);+ * ```*/setPermissionDialogVisible(visible: boolean): void;}diff --git a/packages/sheets-ui/src/facade/f-range.ts b/packages/sheets-ui/src/facade/f-range.tsindex 0475afdb2d..85a2f02044 100644--- a/packages/sheets-ui/src/facade/f-range.ts+++ b/packages/sheets-ui/src/facade/f-range.ts@@ -19,9 +19,9 @@ import type { ISelectionStyle, ISheetLocation } from '@univerjs/sheets';import type { ComponentType } from '@univerjs/ui';import { DisposableCollection, generateRandomId, toDisposable } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';-import { FRange } from '@univerjs/sheets/facade';import { CellAlertManagerService, type ICanvasPopup, type ICellAlert, IMarkSelectionService, SheetCanvasPopManagerService } from '@univerjs/sheets-ui';import { ISheetClipboardService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import { FRange } from '@univerjs/sheets/facade';import { ComponentManager } from '@univerjs/ui';export interface IFComponentKey {@@ -42,35 +42,77 @@ export interface IFCanvasPopup extends Omit<ICanvasPopup, 'componentKey'>, IFCominterface IFRangeSheetsUIMixin {/*** Return this cell information, including whether it is merged and cell coordinates- * @returns The cell information+ * @returns {ICellWithCoord} cell location and coordinate.+ * @example+ * ``` ts+ * let sheet = univerAPI.getActiveWorkbook().getActiveSheet();+ * sheet.getRange(5, 7).getCell();+ * ```*/- getCell(): ICellWithCoord;+ getCell(this: FRange): ICellWithCoord;+/*** Returns the coordinates of this cell,does not include units* @returns coordinates of the cell, top, right, bottom, left+ * @example+ * ``` ts+ * let sheet = univerAPI.getActiveWorkbook().getActiveSheet();+ * sheet.getRange(5, 7).getCellRect();+ * ```*/- getCellRect(): DOMRect;+ getCellRect(this: FRange): DOMRect;+/*** Generate HTML content for the range.+ * @example+ * ``` ts+ * let sheet = univerAPI.getActiveWorkbook().getActiveSheet();+ * sheet.getRange(5, 7).generateHTML();+ * ```*/generateHTML(this: FRange): string;+/*** Attach a popup to the start cell of current range.* If current worksheet is not active, the popup will not be shown.* Be careful to manager the detach disposable object, if not dispose correctly, it might memory leaks.* @param popup The popup to attach* @returns The disposable object to detach the popup, if the popup is not attached, return `null`.+ * @example+ ```+ let sheet = univerAPI.getActiveWorkbook().getActiveSheet();+ let range = sheet.getRange(2, 2, 3, 3);+ let disposable = range.attachPopup({+ componentKey: 'univer.sheet.cell-alert',+ extraProps: { alert: { type: 0, title: 'This is an Info', message: 'This is an info message' } },+ });+ ```*/attachPopup(popup: IFCanvasPopup): Nullable<IDisposable>;+/*** Attach an alert popup to the start cell of current range.* @param alert The alert to attach* @returns The disposable object to detach the alert.+ * @example+ * ```ts+ * let sheet = univerAPI.getActiveWorkbook().getActiveSheet();+ * let range = sheet.getRange(2, 2, 3, 3);+ * range.attachAlertPopup({ message: 'This is an alert', type: 'warning' });+ * ```*/attachAlertPopup(alert: Omit<ICellAlert, 'location'>): IDisposable;/**- * Highlight this range.+ * Highlight the range with the specified style and primary cell.+ * @param style - style for highlight range.+ * @param primary - primary cell for highlight range.+ * @example+ * ```ts+ * let sheet = univerAPI.getActiveWorkbook().getActiveSheet();+ * let range = sheet.getRange(2, 2, 3, 3);+ * range.highlight({ stroke: 'red' }, { startRow: 2, startColumn: 2 });+ * ```*/highlight(style?: Nullable<Partial<ISelectionStyle>>, primary?: Nullable<ISelectionCell>): IDisposable;}@@ -103,6 +145,10 @@ class FRangeSheetsUIMixin extends FRange implements IFRangeSheetsUIMixin {}override attachPopup(popup: IFCanvasPopup): Nullable<IDisposable> {+ popup.direction = popup.direction ?? 'horizontal';+ popup.extraProps = popup.extraProps ?? {};+ popup.offset = popup.offset ?? [0, 0];+const { key, disposableCollection } = transformComponentKey(popup, this._injector.get(ComponentManager));const sheetsPopupService = this._injector.get(SheetCanvasPopManagerService);const disposePopup = sheetsPopupService.attachPopupToCell(@@ -162,6 +208,11 @@ declare module '@univerjs/sheets/facade' {interface FRange extends IFRangeSheetsUIMixin {}}+/**+ * Transform component key+ * @param {IFComponentKey} component - The component key to transform.+ * @param {ComponentManager} componentManager - The component manager to use for registration.+ */export function transformComponentKey(component: IFComponentKey, componentManager: ComponentManager): { key: string; disposableCollection: DisposableCollection } {const { componentKey, isVue3 } = component;let key: string;diff --git a/packages/sheets-ui/src/facade/f-sheet-hooks.ts b/packages/sheets-ui/src/facade/f-sheet-hooks.tsindex a7418959af..3d92f0051c 100644--- a/packages/sheets-ui/src/facade/f-sheet-hooks.ts+++ b/packages/sheets-ui/src/facade/f-sheet-hooks.ts@@ -24,38 +24,68 @@ import { FSheetHooks } from '@univerjs/sheets/facade';export interface IFSheetHooksUIMixin {/*** The onCellPointerMove event is fired when a pointer changes coordinates.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {function(Nullable<IHoverCellPosition>): void} callback - function that will be called when the event is fired+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event+ * @example+ * ```ts+ * univerAPI.getSheetHooks().onCellPointerMove((cellPos) => { console.log(cellPos)});+ * ```*/onCellPointerMove(callback: (cellPos: Nullable<IHoverCellPosition>) => void): IDisposable;/*** The onCellPointerOver event is fired when a pointer is moved into a cell's hit test boundaries.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {function(Nullable<IHoverCellPosition>): void} callback - function that will be called when the event is fired+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event+ * @example+ * ```ts+ * univerAPI.getSheetHooks().onCellPointerOver((cellPos) => { console.log(cellPos)});+ * ```*/onCellPointerOver(callback: (cellPos: Nullable<IHoverCellPosition>) => void): IDisposable;/*** The onCellDragOver event is fired when an element or text selection is being dragged into a cell's hit test boundaries.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {function (Nullable<IDragCellPosition>): void} callback Callback function that will be called when the event is fired+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event+ * @example+ * ```ts+ * univerAPI.getSheetHooks().onCellDragOver((cellPos) => { console.log(cellPos)});+ * ```*/onCellDragOver(callback: (cellPos: Nullable<IDragCellPosition>) => void): IDisposable;/*** The onCellDrop event is fired when an element or text selection is being dropped on the cell.- * @param callback Callback function that will be called when the event is fired- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {function(Nullable<IDragCellPosition>): void} callback Callback function that will be called when the event is fired+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event+ * @example+ * ```ts+ * univerAPI.getSheetHooks().onCellDrop((cellPos) => { console.log(cellPos)});+ * ```*/onCellDrop(callback: (cellPos: Nullable<IDragCellPosition>) => void): IDisposable;/*** The onCellRender event is fired when a cell is rendered.- * @param customRender Custom render function- * @param effect The effect of the interceptor- * @param priority The priority of the interceptor- * @returns A disposable object that can be used to unsubscribe from the event+ * @param {Nullable<ICellCustomRender[]>} customRender Custom render function+ * @param {InterceptorEffectEnum} [effect] The effect of the interceptor+ * @param {number} priority The priority of the interceptor+ * @returns {IDisposable} A disposable object that can be used to unsubscribe from the event+ * @example+ * ```ts+ univerAPI.getSheetHooks().onCellRender([{+ drawWith: (ctx, info) => {+ const { row, col } = info;+ // Update to any cell location you want+ if (row === 1 && col === 2) {+ const { primaryWithCoord } = info;+ const { startX, startY } = primaryWithCoord;+ ctx.fillText('Univer', startX, startY + 10);+ }+ },+ }])+ * ```*/onCellRender(customRender: Nullable<ICellCustomRender[]>, effect?: InterceptorEffectEnum, priority?: number): IDisposable;@@ -63,6 +93,10 @@ export interface IFSheetHooksUIMixin {* The onBeforeCellEdit event is fired before a cell is edited.* @param callback Callback function that will be called when the event is fired* @returns A disposable object that can be used to unsubscribe from the event+ * @example+ * ```ts+ * univerAPI.getSheetHooks().onBeforeCellEdit((params) => {console.log(params)})+ * ```*/onBeforeCellEdit(callback: (params: IEditorBridgeServiceVisibleParam) => void): IDisposable;@@ -70,6 +104,10 @@ export interface IFSheetHooksUIMixin {* The onAfterCellEdit event is fired after a cell is edited.* @param callback Callback function that will be called when the event is fired* @returns A disposable object that can be used to unsubscribe from the event+ * @example+ * ```ts+ * univerAPI.getSheetHooks().onAfterCellEdit((params) => {console.log(params)})+ * ```*/onAfterCellEdit(callback: (params: IEditorBridgeServiceVisibleParam) => void): IDisposable;}diff --git a/packages/sheets-ui/src/facade/f-univer.ts b/packages/sheets-ui/src/facade/f-univer.tsindex cfe3439eb0..a18cace2b5 100644--- a/packages/sheets-ui/src/facade/f-univer.ts+++ b/packages/sheets-ui/src/facade/f-univer.ts@@ -35,29 +35,24 @@ import { CopyCommand, CutCommand, HTML_CLIPBOARD_MIME_TYPE, IClipboardInterfaceSexport interface IFUniverSheetsUIMixin {/*** Customize the column header of the spreadsheet.- ** @param {IColumnsHeaderCfgParam} cfg The configuration of the column header.- ** @example* ```typescript- * customizeColumnHeader({ headerStyle: { backgroundColor: 'pink', fontSize: 9 }, columnsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });+ * univerAPI.customizeColumnHeader({ headerStyle: { backgroundColor: 'pink', fontSize: 9 }, columnsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });* ```*/customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void;/*** Customize the row header of the spreadsheet.- ** @param {IRowsHeaderCfgParam} cfg The configuration of the row header.- ** @example* ```typescript- * customizeRowHeader({ headerStyle: { backgroundColor: 'pink', fontSize: 9 }, rowsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });+ * univerAPI.customizeRowHeader({ headerStyle: { backgroundColor: 'pink', fontSize: 9 }, rowsCfg: ['MokaII', undefined, null, { text: 'Size', textAlign: 'left' }] });* ```*/customizeRowHeader(cfg: IRowsHeaderCfgParam): void;/*** Register sheet row header render extensions.- ** @param {string} unitId The unit id of the spreadsheet.* @param {SheetExtension[]} extensions The extensions to register.* @returns {IDisposable} The disposable instance.@@ -65,7 +60,6 @@ export interface IFUniverSheetsUIMixin {registerSheetRowHeaderExtension(unitId: string, ...extensions: SheetExtension[]): IDisposable;/*** Register sheet column header render extensions.- ** @param {string} unitId The unit id of the spreadsheet.* @param {SheetExtension[]} extensions The extensions to register.* @returns {IDisposable} The disposable instance.@@ -73,7 +67,6 @@ export interface IFUniverSheetsUIMixin {registerSheetColumnHeaderExtension(unitId: string, ...extensions: SheetExtension[]): IDisposable;/*** Register sheet main render extensions.- ** @param {string} unitId The unit id of the spreadsheet.* @param {SheetExtension[]} extensions The extensions to register.* @returns {IDisposable} The disposable instance.@@ -82,8 +75,11 @@ export interface IFUniverSheetsUIMixin {/*** Get sheet hooks.- *- * @returns {FSheetHooks} FSheetHooks instance+ * @returns {FSheetHooks} FSheetHooks instance.+ * @example+ * ``` ts+ * univerAPI.getSheetHooks();+ * ```*/getSheetHooks(): FSheetHooks;}@@ -338,9 +334,7 @@ export class FUniverSheetsUIMixin extends FUniver implements IFUniverSheetsUIMix/*** Get sheet render component from render by unitId and view key.- ** @private- ** @param {string} unitId The unit id of the spreadsheet.* @param {SHEET_VIEW_KEY} viewKey The view key of the spreadsheet.* @returns {Nullable<RenderComponentType>} The render component.@@ -364,7 +358,6 @@ export class FUniverSheetsUIMixin extends FUniver implements IFUniverSheetsUIMix/*** Get sheet hooks.- ** @returns {FSheetHooks} FSheetHooks instance*/override getSheetHooks(): FSheetHooks {diff --git a/packages/sheets-ui/src/facade/f-workbook.ts b/packages/sheets-ui/src/facade/f-workbook.tsindex a32955b964..a992eedd5c 100644--- a/packages/sheets-ui/src/facade/f-workbook.ts+++ b/packages/sheets-ui/src/facade/f-workbook.ts@@ -27,9 +27,7 @@ import { filter } from 'rxjs';export interface IFWorkbookSheetsUIMixin {/*** Open a sidebar.- ** @deprecated- ** @param params the sidebar options* @returns the disposable object*/@@ -37,9 +35,7 @@ export interface IFWorkbookSheetsUIMixin {/*** Open a dialog.- ** @deprecated- ** @param dialog the dialog options* @returns the disposable object*/@@ -47,7 +43,6 @@ export interface IFWorkbookSheetsUIMixin {/*** Subscribe to cell click events- ** @param callback - The callback function to be called when a cell is clicked* @returns A disposable object that can be used to unsubscribe from the event*/@@ -55,7 +50,6 @@ export interface IFWorkbookSheetsUIMixin {/*** Subscribe cell hover events- ** @param callback - The callback function to be called when a cell is hovered* @returns A disposable object that can be used to unsubscribe from the event*/@@ -80,20 +74,31 @@ export interface IFWorkbookSheetsUIMixin {/*** Start the editing process* @returns A boolean value+ * @example+ * ```ts+ * univerAPI.getActiveWorkbook().startEditing();+ * ```*/startEditing(): boolean;/*** Use endEditingAsync as instead* @deprecated+ * End the editing process+ * @async+ * @param save - Whether to save the changes+ * @returns A promise that resolves to a boolean value+ * @example+ * ``` ts+ * univerAPI.getActiveWorkbook().endEditing(true);+ * ```*/endEditing(save?: boolean): Promise<boolean>;/*** @async- * @param save - Whether to save the changes, default is true- * @returns A promise that resolves to a boolean value- * @param save+ * @param {boolean} save - Whether to save the changes, default is true+ * @returns {Promise<boolean>} A promise that resolves to a boolean value*/endEditingAsync(save?: boolean): Promise<boolean>;/*@@ -108,39 +113,40 @@ export interface IFWorkbookSheetsUIMixin {/*** Disable selection. After disabled, there would be no response for selection.+ * @returns {FWorkbook} FWorkbook instance* @example- * ```+ * ```ts* univerAPI.getActiveWorkbook().disableSelection();* ```*/- disableSelection(): void;+ disableSelection(): FWorkbook;/*** Enable selection. After this you can select range.* @example- * ```+ * ```ts* univerAPI.getActiveWorkbook().enableSelection();* ```*/- enableSelection(): void;+ enableSelection(): FWorkbook;/*** Set selection invisible, Unlike disableSelection, selection still works, you just can not see them.* @example- * ```+ * ```ts* univerAPI.getActiveWorkbook().transparentSelection();* ```*/- transparentSelection(): void;+ transparentSelection(): FWorkbook;/*** Set selection visible.* @example- * ```+ * ```ts* univerAPI.getActiveWorkbook().showSelection();* ```*/- showSelection(): void;+ showSelection(): FWorkbook;}export class FWorkbookSheetsUIMixin extends FWorkbook implements IFWorkbookSheetsUIMixin {@@ -243,6 +249,7 @@ export class FWorkbookSheetsUIMixin extends FWorkbook implements IFWorkbookSheet/*** Get scroll state of specified sheet.+ * @param {string} sheetId - sheet id* @returns {IScrollState} scroll state* @example* ``` ts@@ -258,40 +265,44 @@ export class FWorkbookSheetsUIMixin extends FWorkbook implements IFWorkbookSheetreturn scm.getScrollStateByParam({ unitId, sheetId });}- override disableSelection(): void {+ override disableSelection(): FWorkbook {const unitId = this._workbook.getUnitId();const renderManagerService = this._injector.get(IRenderManagerService) as RenderManagerService;const render = renderManagerService.getRenderById(unitId);if (render) {(render.with(ISheetSelectionRenderService) as SheetSelectionRenderService).disableSelection();}+ return this;}- override enableSelection(): void {+ override enableSelection(): FWorkbook {const unitId = this._workbook.getUnitId();const renderManagerService = this._injector.get(IRenderManagerService) as RenderManagerService;const render = renderManagerService.getRenderById(unitId);if (render) {(render.with(ISheetSelectionRenderService) as SheetSelectionRenderService).enableSelection();}+ return this;}- override transparentSelection(): void {+ override transparentSelection(): FWorkbook {const unitId = this._workbook.getUnitId();const renderManagerService = this._injector.get(IRenderManagerService) as RenderManagerService;const render = renderManagerService.getRenderById(unitId);if (render) {(render.with(ISheetSelectionRenderService) as SheetSelectionRenderService).transparentSelection();}+ return this;}- override showSelection(): void {+ override showSelection(): FWorkbook {const unitId = this._workbook.getUnitId();const renderManagerService = this._injector.get(IRenderManagerService) as RenderManagerService;const render = renderManagerService.getRenderById(unitId);if (render) {(render.with(ISheetSelectionRenderService) as SheetSelectionRenderService).showSelection();}+ return this;}}diff --git a/packages/sheets-ui/src/facade/f-worksheet.ts b/packages/sheets-ui/src/facade/f-worksheet.tsindex 699bb95f2f..85dea554e5 100644--- a/packages/sheets-ui/src/facade/f-worksheet.ts+++ b/packages/sheets-ui/src/facade/f-worksheet.ts@@ -26,7 +26,7 @@ export interface IFWorksheetSkeletonMixin {/*** Refresh the canvas.*/- refreshCanvas(): void;+ refreshCanvas(): FWorksheet;/*** Set zoom ratio of the worksheet.* @param {number} zoomRatio The zoom ratio to set.It should be in the range of 10 to 400.@@ -56,16 +56,28 @@ export interface IFWorksheetSkeletonMixin {/*** Return visible range, sum view range of 4 viewports.- * @returns IRange+ * @returns {IRange} - visible range+ * @example+ * ``` ts+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * const fWorksheet = fWorkbook.getActiveSheet();+ * const visibleRange = fWorksheet.getVisibleRange();+ * ```*/getVisibleRange(): IRange;/**- * Scroll spreadsheet to cell position. Based on the limitations of viewport and the number of rows and columns, you can only scroll to the maximum scrollable range.- * @param row- * @param column+ * Scroll spreadsheet(viewMain) to cell position. Make the cell at topleft of current viewport.+ * Based on the limitations of viewport and the number of rows and columns, you can only scroll to the maximum scrollable range.+ * @param {number} row - Cell row index+ * @param {number} column - Cell column index+ * @returns {FWorksheet} - Current worksheet+ * @example+ * ``` ts+ * univerAPI.getActiveWorkbook().getActiveSheet().scrollToCell(1, 1);+ * ```*/- scrollToCell(row: number, column: number): void;+ scrollToCell(row: number, column: number): FWorksheet;/*** Get scroll state of current sheet.@@ -75,11 +87,12 @@ export interface IFWorksheetSkeletonMixin {* univerAPI.getActiveWorkbook().getActiveSheet().getScrollState()* ```*/- getScrollState(): Nullable<IScrollState>;+ getScrollState(): IScrollState;/*** Invoked when scrolling the sheet.- * @param {function(params: Nullable<IViewportScrollState>): void} callback The scrolling callback function.+ * @param {function(Nullable<IViewportScrollState>): void} callback The scrolling callback function.+ * @returns {IDisposable} The disposable object to remove the event listener.* @example* ``` ts* univerAPI.getActiveWorkbook().getActiveSheet().onScroll((params) => {...})@@ -90,7 +103,7 @@ export interface IFWorksheetSkeletonMixin {}export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSkeletonMixin {- override refreshCanvas(): void {+ override refreshCanvas(): FWorksheet {const renderManagerService = this._injector.get(IRenderManagerService);const unitId = this._fWorkbook.id;const render = renderManagerService.getRenderById(unitId);@@ -108,6 +121,8 @@ export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSk}mainComponent.makeDirty();++ return this;}override zoom(zoomRatio: number): FWorksheet {@@ -117,7 +132,6 @@ export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSksubUnitId: this._worksheet.getSheetId(),zoomRatio,});-return this;}@@ -154,7 +168,7 @@ export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSkreturn range;}- override scrollToCell(row: number, column: number): void {+ override scrollToCell(row: number, column: number): FWorksheet {const unitId = this._workbook.getUnitId();const renderManagerService = this._injector.get(IRenderManagerService);const render = renderManagerService.getRenderById(unitId);@@ -162,16 +176,24 @@ export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSkconst scrollRenderController = render?.with(SheetsScrollRenderController);scrollRenderController.scrollToCell(row, column);}+ return this;}- override getScrollState(): Nullable<IScrollState> {+ override getScrollState(): IScrollState {+ const emptyScrollState: IScrollState = {+ offsetX: 0,+ offsetY: 0,+ sheetViewStartColumn: 0,+ sheetViewStartRow: 0,+ };const unitId = this._workbook.getUnitId();const sheetId = this._worksheet.getSheetId();const renderManagerService = this._injector.get(IRenderManagerService);const render = renderManagerService.getRenderById(unitId);- if (!render) return null;- const scm = render.with(SheetScrollManagerService);- return scm.getScrollStateByParam({ unitId, sheetId });+ if (!render) return emptyScrollState;+ const sheetScrollManagerService = render.with(SheetScrollManagerService);+ const scrollState = sheetScrollManagerService.getScrollStateByParam({ unitId, sheetId });+ return scrollState || emptyScrollState;}override onScroll(callback: (params: Nullable<IViewportScrollState>) => void): IDisposable {diff --git a/packages/sheets-ui/src/services/scroll-manager.service.ts b/packages/sheets-ui/src/services/scroll-manager.service.tsindex 6a25941210..2d667ab851 100644--- a/packages/sheets-ui/src/services/scroll-manager.service.ts+++ b/packages/sheets-ui/src/services/scroll-manager.service.ts@@ -30,11 +30,19 @@ export interface IScrollState {*/offsetY: number;/**- * current start row in viewport visible area+ * Current start row in viewportMain in canvas, NOT the first row of visible area of current viewport after freeze.+ * e.g. If no freeze, it's the same as startRow in current viewport.+ * If freeze, this value is smaller than the first row of visible area. Just pretend that viewMainTop does not exist.+ *+ * e.g. If row 1 ~ 2 is frozen, the first row if viewMain is 3, but sheetViewStartRow still 0.*/sheetViewStartRow: number;/**- * current start column in viewport visible area+ * Current start column in viewportMain in canvas, NOT the first column of visible area of current viewport after freeze.+ * e.g. If no freeze, it's the same as startColumn in current viewport.+ * If freeze, this value is smaller than the first column of visible area. Just pretend that viewMainLeft does not exist.+ *+ * e.g. If column A ~ C is frozen, the first column of viewMain is D, but sheetViewStartColumn still 0.*/sheetViewStartColumn: number;}diff --git a/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsx b/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsxindex b974498a9e..0719a553fd 100644--- a/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsx+++ b/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsx@@ -14,12 +14,12 @@* limitations under the License.*/-import React from 'react';+import type { ICanvasPopup } from '../../services/canvas-pop-manager.service';+import type { ICellAlert } from '../../services/cell-alert-manager.service';import { ErrorSingle, WarningSingle } from '@univerjs/icons';import cs from 'clsx';-import type { ICellAlert } from '../../services/cell-alert-manager.service';+import React from 'react';import { CellAlertType } from '../../services/cell-alert-manager.service';-import type { ICanvasPopup } from '../../services/canvas-pop-manager.service';import styles from './index.module.less';export function CellAlert({ popup }: { popup: ICanvasPopup }) {diff --git a/packages/sheets/src/facade/f-defined-name.ts b/packages/sheets/src/facade/f-defined-name.tsindex 5305e11d93..75b59a8b1b 100644--- a/packages/sheets/src/facade/f-defined-name.ts+++ b/packages/sheets/src/facade/f-defined-name.ts@@ -19,6 +19,13 @@ import { FBase, generateRandomId, IAuthzIoService, ICommandService, Inject, Injeimport { IDefinedNamesService, type ISetDefinedNameMutationParam, serializeRange } from '@univerjs/engine-formula';import { RangeProtectionRuleModel, RemoveDefinedNameCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetDefinedNameCommand, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';+/**+ * Get defined name field name+ * @param {string} unitId - unit id+ * @param {LocaleService} localeService - locale service+ * @param {DefinedNamesService} definedNamesService - defined names service+ * @returns {string} field name+ */function getDefinedNameFieldName(unitId: string, localeService: LocaleService, definedNamesService: IDefinedNamesService): string {const definedNameMap = definedNamesService.getDefinedNameMap(unitId);if (definedNameMap == null) {@@ -54,12 +61,12 @@ export class FDefinedNameBuilder {/*** Sets the name of the defined name builder.- * @param name The name of the defined name.- * @returns The defined name builder.+ * @param {string} name The name of the defined name.+ * @returns {FDefinedNameBuilder} The defined name builder.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();- * const definedNameBuilder = UniverAPI.newDefinedName()+ * const workbook = univerAPI.getActiveWorkbook();+ * const definedNameBuilder = univerAPI.newDefinedName()* .setName('MyDefinedName')* .build();* workbook.insertDefinedNameBuilder(definedNameBuilder);@@ -72,12 +79,12 @@ export class FDefinedNameBuilder {/*** Sets the formula of the defined name builder.- * @param formula The formula of the defined name.- * @returns The defined name builder.+ * @param {string }formula The formula of the defined name.+ * @returns {FDefinedNameBuilder} The defined name builder.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();- * const definedNameBuilder = UniverAPI.newDefinedName()+ * const workbook = univerAPI.getActiveWorkbook();+ * const definedNameBuilder = univerAPI.newDefinedName()* .setFormula('SUM(Sheet1!$A$1)')* .setName('MyDefinedName')* .build();@@ -91,12 +98,12 @@ export class FDefinedNameBuilder {/*** Sets the reference of the defined name builder.- * @param refString The reference of the defined name.- * @returns The defined name builder.+ * @param {string} a1Notation The reference of the defined name.+ * @returns {FDefinedNameBuilder} The defined name builder.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();- * const definedNameBuilder = UniverAPI.newDefinedName()+ * const workbook = univerAPI.getActiveWorkbook();+ * const definedNameBuilder = univerAPI.newDefinedName()* .setRef('Sheet1!$A$1')* .build();* workbook.insertDefinedNameBuilder(definedNameBuilder);@@ -109,15 +116,15 @@ export class FDefinedNameBuilder {/*** Sets the reference of the defined name builder by range .- * @param row The start row of the range.- * @param column The start column of the range.- * @param numRows The number of rows in the range.- * @param numColumns The number of columns in the range.- * @returns The defined name builder.+ * @param {number} row The start row of the range.+ * @param {number} column The start column of the range.+ * @param {number} numRows The number of rows in the range.+ * @param {number} numColumns The number of columns in the range.+ * @returns {FDefinedNameBuilder} The defined name builder.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();- * const definedNameBuilder = UniverAPI.newDefinedName()+ * const workbook = univerAPI.getActiveWorkbook();+ * const definedNameBuilder = univerAPI.newDefinedName()* .setRefByRange(1, 3, 2, 5)* .build();* workbook.insertDefinedNameBuilder(definedNameBuilder);@@ -135,12 +142,12 @@ export class FDefinedNameBuilder {/*** Sets the comment of the defined name builder.- * @param comment The comment of the defined name.- * @returns The defined name builder.+ * @param {string} comment The comment of the defined name.+ * @returns {FDefinedNameBuilder} The defined name builder.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();- * const definedNameBuilder = UniverAPI.newDefinedName()+ * const workbook = univerAPI.getActiveWorkbook();+ * const definedNameBuilder = univerAPI.newDefinedName()* .setComment('This is a comment')* .build();* workbook.insertDefinedNameBuilder(definedNameBuilder);@@ -153,12 +160,12 @@ export class FDefinedNameBuilder {/*** Sets the hidden status of the defined name builder.- * @param hidden The hidden status of the defined name.- * @returns The defined name builder.+ * @param {boolean} hidden The hidden status of the defined name.+ * @returns {FDefinedNameBuilder} The defined name builder.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();- * const definedNameBuilder = UniverAPI.newDefinedName()+ * const workbook = univerAPI.getActiveWorkbook();+ * const definedNameBuilder = univerAPI.newDefinedName()* .setHidden(true)* .build();* workbook.insertDefinedNameBuilder(definedNameBuilder);@@ -171,11 +178,11 @@ export class FDefinedNameBuilder {/*** Builds the defined name.- * @returns The defined name mutation parameter.+ * @returns {FDefinedNameBuilder} The defined name mutation parameter.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();- * const definedNameBuilder = UniverAPI.newDefinedName()+ * const workbook = univerAPI.getActiveWorkbook();+ * const definedNameBuilder = univerAPI.newDefinedName()* .setRef('Sheet1!$A$1')* .setName('MyDefinedName')* .build();@@ -217,10 +224,10 @@ export class FDefinedName extends FBase {/*** Gets the name of the defined name.- * @returns The name of the defined name.+ * @returns {string} The name of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* console.log(definedName.getName());* ```@@ -231,10 +238,10 @@ export class FDefinedName extends FBase {/*** Sets the name of the defined name.- * @param name The name of the defined name.+ * @param {string} name The name of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedName('MyDefinedName');* definedName.setName('NewDefinedName');* ```@@ -246,10 +253,10 @@ export class FDefinedName extends FBase {/*** Sets the formula of the defined name.- * @param formula The formula of the defined name.+ * @param {string} formula The formula of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedName('MyDefinedName');* definedName.setFormula('SUM(Sheet1!$A$1)');* ```@@ -261,10 +268,10 @@ export class FDefinedName extends FBase {/*** Sets the reference of the defined name.- * @param refString The reference of the defined name.+ * @param {string} refString The reference of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* definedName.setRef('Sheet1!$A$1');* ```@@ -276,10 +283,10 @@ export class FDefinedName extends FBase {/*** Gets the reference of the defined name.- * @returns The reference of the defined name.+ * @returns {string} The reference of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* console.log(definedName.getFormulaOrRefString());* ```@@ -290,13 +297,13 @@ export class FDefinedName extends FBase {/*** Sets the reference of the defined name by range.- * @param row The start row of the range.- * @param column The start column of the range.- * @param numRows The number of rows in the range.- * @param numColumns The number of columns in the range.+ * @param {number} row The start row of the range.+ * @param {number} column The start column of the range.+ * @param {number} numRows The number of rows in the range.+ * @param {number} numColumns The number of columns in the range.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* definedName.setRefByRange(1, 3, 2, 5);* ```@@ -313,10 +320,10 @@ export class FDefinedName extends FBase {/*** Gets the comment of the defined name.- * @returns The comment of the defined name.+ * @returns {string | undefined} The comment of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* console.log(definedName.getComment());* ```@@ -327,10 +334,10 @@ export class FDefinedName extends FBase {/*** Sets the comment of the defined name.- * @param comment The comment of the defined name.+ * @param {string} comment The comment of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* definedName.setComment('This is a comment');* ```@@ -342,10 +349,10 @@ export class FDefinedName extends FBase {/*** Sets the scope of the defined name to the worksheet.- * @param worksheet The worksheet to set the scope to.+ * @param {FWorksheet} worksheet The worksheet to set the scope to.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const worksheet = workbook.getWorksheets[0];* const definedName = workbook.getDefinedNames[0];* definedName.setScopeToWorksheet(worksheet);@@ -360,7 +367,7 @@ export class FDefinedName extends FBase {* Sets the scope of the defined name to the workbook.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* definedName.setScopeToWorkbook();* ```@@ -372,10 +379,10 @@ export class FDefinedName extends FBase {/*** Sets the hidden status of the defined name.- * @param hidden The hidden status of the defined name.+ * @param {boolean} hidden The hidden status of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* definedName.setHidden(true);* ```@@ -389,7 +396,7 @@ export class FDefinedName extends FBase {* Deletes the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* definedName.delete();* ```@@ -400,10 +407,10 @@ export class FDefinedName extends FBase {/*** Gets the local sheet id of the defined name.- * @returns The local sheet id of the defined name.+ * @returns {string | undefined} The local sheet id of the defined name.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* console.log(definedName.getLocalSheetId());* ```@@ -414,10 +421,10 @@ export class FDefinedName extends FBase {/*** Checks if the defined name is in the workbook scope.- * @returns True if the defined name is in the workbook scope, false otherwise.+ * @returns {boolean} True if the defined name is in the workbook scope, false otherwise.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* console.log(definedName.isWorkbookScope());* ```@@ -428,10 +435,10 @@ export class FDefinedName extends FBase {/*** Converts the defined name to a defined name builder.- * @returns The defined name builder.+ * @returns {FDefinedNameBuilder} The defined name builder.* @example* ```ts- * const workbook = UniverAPI.getActiveWorkbook();+ * const workbook = univerAPI.getActiveWorkbook();* const definedName = workbook.getDefinedNames[0];* const definedNameBuilder = definedName.toBuilder();* const param definedNameBuilder.setName('NewDefinedName').setFormula('SUM(Sheet1!$A$1)').build();diff --git a/packages/sheets/src/facade/f-range.ts b/packages/sheets/src/facade/f-range.tsindex 8620e4e2f2..37cdebb062 100644--- a/packages/sheets/src/facade/f-range.ts+++ b/packages/sheets/src/facade/f-range.ts@@ -41,8 +41,7 @@ export class FRange extends FBaseInitialable {/*** Get the unit ID of the current workbook- *- * @return The unit ID of the workbook+ * @returns The unit ID of the workbook*/getUnitId(): string {return this._workbook.getUnitId();@@ -50,8 +49,7 @@ export class FRange extends FBaseInitialable {/*** Gets the name of the worksheet- *- * @return The name of the worksheet+ * @returns The name of the worksheet*/getSheetName(): string {return this._worksheet.getName();@@ -59,8 +57,7 @@ export class FRange extends FBaseInitialable {/*** Gets the area where the statement is applied- *- * @return The area where the statement is applied+ * @returns The area where the statement is applied*/getRange(): IRange {return this._range;@@ -68,8 +65,7 @@ export class FRange extends FBaseInitialable {/*** Gets the starting row number of the applied area- *- * @return The starting row number of the area+ * @returns The starting row number of the area*/getRow(): number {return this._range.startRow;@@ -77,8 +73,7 @@ export class FRange extends FBaseInitialable {/*** Gets the starting column number of the applied area- *- * @return The starting column number of the area+ * @returns The starting column number of the area*/getColumn(): number {return this._range.startColumn;@@ -86,8 +81,7 @@ export class FRange extends FBaseInitialable {/*** Gets the width of the applied area- *- * @return The width of the area+ * @returns The width of the area*/getWidth(): number {return this._range.endColumn - this._range.startColumn + 1;@@ -95,8 +89,7 @@ export class FRange extends FBaseInitialable {/*** Gets the height of the applied area- *- * @return The height of the area+ * @returns The height of the area*/getHeight(): number {return this._range.endRow - this._range.startRow + 1;@@ -228,7 +221,7 @@ export class FRange extends FBaseInitialable {* Set background color for current range.* @param color {string}* @example- * ```+ * ```typescript* univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackgroundColor('red')* ```*/@@ -250,7 +243,7 @@ export class FRange extends FBaseInitialable {/*** Set background color for current range.* @example- * ```+ * ```typescript* univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')* ```* @param color {string}@@ -284,6 +277,7 @@ export class FRange extends FBaseInitialable {/*** Set the cell wrap of the given range.* Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.+ * @param isWrapEnabled*/setWrap(isWrapEnabled: boolean): FRange {this._commandService.syncExecuteCommand(SetTextWrapCommand.id, {@@ -298,6 +292,7 @@ export class FRange extends FBaseInitialable {/*** Sets the text wrapping strategy for the cells in the range.+ * @param strategy*/setWrapStrategy(strategy: WrapStrategy): FRange {this._commandService.syncExecuteCommand(SetTextWrapCommand.id, {@@ -312,6 +307,7 @@ export class FRange extends FBaseInitialable {/*** Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).+ * @param alignment*/setVerticalAlignment(alignment: FVerticalAlignment): FRange {this._commandService.syncExecuteCommand(SetVerticalTextAlignCommand.id, {@@ -326,6 +322,7 @@ export class FRange extends FBaseInitialable {/*** Set the horizontal (left to right) alignment for the given range (left/center/right).+ * @param alignment*/setHorizontalAlignment(alignment: FHorizontalAlignment): FRange {this._commandService.syncExecuteCommand(SetHorizontalTextAlignCommand.id, {@@ -458,6 +455,7 @@ export class FRange extends FBaseInitialable {/*** Sets the font underline style of the given ITextDecoration+ * @param value*/private _setFontUnderline(value: ITextDecoration | null): void {const style: IStyleTypeValue<ITextDecoration | null> = {@@ -476,6 +474,7 @@ export class FRange extends FBaseInitialable {/*** Sets the font strikethrough style of the given ITextDecoration+ * @param value*/private _setFontStrikethrough(value: ITextDecoration | null): void {const style: IStyleTypeValue<ITextDecoration | null> = {@@ -702,6 +701,7 @@ export class FRange extends FBaseInitialable {/*** Returns a string description of the range, in A1 notation.+ * @param withSheet* @returns {string} The A1 notation of the range.* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();diff --git a/packages/sheets/src/facade/f-workbook.ts b/packages/sheets/src/facade/f-workbook.tsindex d74c3bb538..278ee27b3a 100644--- a/packages/sheets/src/facade/f-workbook.ts+++ b/packages/sheets/src/facade/f-workbook.ts@@ -89,8 +89,8 @@ export class FWorkbook extends FBaseInitialable {}/**- * save workbook snapshot data, including conditional formatting, data validation, and other plugin data.- * @return Workbook snapshot data+ * Save workbook snapshot data, including conditional formatting, data validation, and other plugin data.+ * @returns {IWorkbookData} Workbook snapshot data* @example* ```ts* // The code below saves the workbook snapshot data@@ -105,7 +105,7 @@ export class FWorkbook extends FBaseInitialable {/*** @deprecated use 'save' instead.- * @return {*} {IWorkbookData} Workbook snapshot data+ * @returns {*} {IWorkbookData} Workbook snapshot data* @memberof FWorkbook*/getSnapshot(): IWorkbookData {@@ -115,7 +115,7 @@ export class FWorkbook extends FBaseInitialable {/*** Get the active sheet of the workbook.- * @returns The active sheet of the workbook+ * @returns {FWorksheet} The active sheet of the workbook* @example* ```ts* // The code below gets the active sheet of the workbook@@ -130,7 +130,7 @@ export class FWorkbook extends FBaseInitialable {/*** Gets all the worksheets in this workbook- * @returns An array of all the worksheets in the workbook+ * @returns {FWorksheet[]} An array of all the worksheets in the workbook* @example* ```ts* // The code below gets all the worksheets in the workbook@@ -186,7 +186,7 @@ export class FWorkbook extends FBaseInitialable {/*** Get a worksheet by sheet id.* @param sheetId The id of the sheet to get.- * @return The worksheet with given sheet id+ * @returns The worksheet with given sheet id* @example* ```ts* // The code below gets a worksheet by sheet id@@ -285,6 +285,7 @@ export class FWorkbook extends FBaseInitialable {/*** Deletes the specified worksheet.* @param sheet The worksheet to delete.+ * @returns {boolean} True if the worksheet was deleted, false otherwise.* @example* ```ts* // The code below deletes the specified worksheet@@ -305,7 +306,7 @@ export class FWorkbook extends FBaseInitialable {// #region editing/*** Undo the last action.- * @returns A promise that resolves to true if the undo was successful, false otherwise.+ * @returns {FWorkbook} A promise that resolves to true if the undo was successful, false otherwise.* @example* ```ts* // The code below undoes the last action@@ -394,7 +395,6 @@ export class FWorkbook extends FBaseInitialable {/*** Callback for selection changes.- ** @callback onSelectionChangeCallback* @param {IRange[]} selections The new selection.*/@@ -424,21 +424,25 @@ export class FWorkbook extends FBaseInitialable {/*** Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.* @param {boolean} value editable value want to set+ * @returns {FWorkbook} FWorkbook instance*/- setEditable(value: boolean): void {+ setEditable(value: boolean): FWorkbook {const instance = new WorkbookEditablePermission(this._workbook.getUnitId());const editPermissionPoint = this._permissionService.getPermissionPoint(instance.id);if (!editPermissionPoint) {this._permissionService.addPermissionPoint(instance);}this._permissionService.updatePermissionPoint(instance.id, value);++ return this;}/**- * Sets the active selection region for this sheet.+ * Sets the selection region for active sheet.* @param range The range to set as the active selection.+ * @returns {FWorkbook} FWorkbook instance*/- setActiveRange(range: FRange): void {+ setActiveRange(range: FRange): FWorkbook {// In theory, FRange should belong to a specific context, rather than getting the currently active sheetconst sheet = this.getActiveSheet();const sheetId = range.getRange().sheetId || sheet.getSheetId();@@ -461,12 +465,15 @@ export class FWorkbook extends FBaseInitialable {};this._commandService.syncExecuteCommand(SetSelectionsOperation.id, setSelectionOperationParams);++ return this;}/*** Returns the selected range in the active sheet, or null if there is no active range.* @returns the active range*/+ // could sheet have no active range ?getActiveRange(): FRange | null {const activeSheet = this._workbook.getActiveSheet();const selections = this._selectionManagerService.getCurrentSelections();@@ -480,6 +487,7 @@ export class FWorkbook extends FBaseInitialable {/*** Deletes the currently active sheet.+ * @returns {boolean} true if the sheet was deleted, false otherwise* @example* ```ts* // The code below deletes the currently active sheet and stores the new active@@ -556,9 +564,18 @@ export class FWorkbook extends FBaseInitialable {return this._localeService.getCurrentLocale();}+ /**+ * @deprecated use setSpreadsheetLocale instead.+ * @param {LocaleType} locale - The locale to set+ */+ setLocale(locale: LocaleType): void {+ this._localeService.setLocale(locale);+ }+/*** Set the locale of the workbook.* @param {LocaleType} locale The locale to set+ * @returns {FWorkbook} This workbook, for chaining* @example* ```ts* // The code below sets the locale of the workbook@@ -566,9 +583,9 @@ export class FWorkbook extends FBaseInitialable {* activeSpreadsheet.setLocale(LocaleType.EN_US);* ```*/-- setLocale(locale: LocaleType): void {+ setSpreadsheetLocale(locale: LocaleType): FWorkbook {this._localeService.setLocale(locale);+ return this;}/**@@ -610,7 +627,6 @@ export class FWorkbook extends FBaseInitialable {order: sheetIndexVal,subUnitId: sheet.getSheetId(),});-return this;}@@ -632,7 +648,6 @@ export class FWorkbook extends FBaseInitialable {/*** Get the PermissionInstance.- ** @returns {FPermission} - The PermissionInstance.*/getPermission(): FPermission {@@ -683,6 +698,7 @@ export class FWorkbook extends FBaseInitialable {* Insert a defined name.* @param {string} name The name of the defined name to insert* @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert+ * @returns {FWorkbook} The current FWorkbook instance* @example* ```ts* // The code below inserts a defined name@@ -690,11 +706,12 @@ export class FWorkbook extends FBaseInitialable {* activeSpreadsheet.insertDefinedName('MyDefinedName', 'Sheet1!A1');* ```*/- insertDefinedName(name: string, formulaOrRefString: string): void {+ insertDefinedName(name: string, formulaOrRefString: string): FWorkbook {const definedNameBuilder = this._injector.createInstance(FDefinedNameBuilder);const param = definedNameBuilder.setName(name).setRef(formulaOrRefString).build();param.localSheetId = SCOPE_WORKBOOK_VALUE_DEFINED_NAME;this.insertDefinedNameBuilder(param);+ return this;}/**@@ -719,7 +736,7 @@ export class FWorkbook extends FBaseInitialable {}/**- * insert a defined name by builder param+ * Insert a defined name by builder param.* @param {ISetDefinedNameMutationParam} param The param to insert the defined name* @example* ```ts@@ -768,6 +785,7 @@ export class FWorkbook extends FBaseInitialable {/*** Register a custom range theme style.+ * @param rangeThemeStyle* @example* ```ts* // import {RangeThemeStyle} from '@univerjs/sheets';@@ -790,6 +808,7 @@ export class FWorkbook extends FBaseInitialable {/*** Unregister a custom range theme style.+ * @param themeName* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();diff --git a/packages/sheets/src/facade/f-worksheet.ts b/packages/sheets/src/facade/f-worksheet.tsindex 2968afda9d..932d8900a8 100644--- a/packages/sheets/src/facade/f-worksheet.ts+++ b/packages/sheets/src/facade/f-worksheet.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { CustomData, ICellData, IColumnData, IDisposable, IFreeze, IObjectArrayPrimitiveType, IRange, IRowData, IStyleData, Nullable, Workbook, Worksheet } from '@univerjs/core';+import type { CustomData, ICellData, IColumnData, IColumnRange, IDisposable, IFreeze, IObjectArrayPrimitiveType, IRange, IRowData, IRowRange, IStyleData, Nullable, Workbook, Worksheet } from '@univerjs/core';import type { ISetColDataCommandParams, ISetGridlinesColorCommandParams, ISetRangeValuesMutationParams, ISetRowDataCommandParams, IToggleGridlinesCommandParams } from '@univerjs/sheets';import type { FDefinedName } from './f-defined-name';import type { FWorkbook } from './f-workbook';@@ -117,7 +117,7 @@ export class FWorksheet extends FBaseInitialable {/*** Get the default style of the worksheet column* @param {number} index The column index- * @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager+ * @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager* @returns {Nullable<IStyleData> | string} The default style of the worksheet column name or style data*/getColumnDefaultStyle(index: number, keepRaw: boolean = false): Nullable<IStyleData> | string {@@ -267,7 +267,7 @@ export class FWorksheet extends FBaseInitialable {/*** Returns the current number of columns in the sheet, regardless of content.- * @return The maximum columns count of the sheet+ * @returns {number} The maximum columns count of the sheet*/getMaxColumns(): number {return this._worksheet.getMaxColumns();@@ -275,7 +275,7 @@ export class FWorksheet extends FBaseInitialable {/*** Returns the current number of rows in the sheet, regardless of content.- * @return The maximum rows count of the sheet+ * @returns {number}The maximum rows count of the sheet*/getMaxRows(): number {return this._worksheet.getMaxRows();@@ -283,8 +283,8 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a row after the given row position.- * @param afterPosition The row after which the new row should be added, starting at 0 for the first row.- * @returns This sheet, for chaining.+ * @param {number} afterPosition The row after which the new row should be added, starting at 0 for the first row.+ * @returns {FWorksheet} This sheet, for chaining.*/insertRowAfter(afterPosition: number): FWorksheet {return this.insertRowsAfter(afterPosition, 1);@@ -292,8 +292,8 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a row before the given row position.- * @param beforePosition The row before which the new row should be added, starting at 0 for the first row.- * @returns This sheet, for chaining.+ * @param {number} beforePosition The row before which the new row should be added, starting at 0 for the first row.+ * @returns {FWorksheet} This sheet, for chaining.*/insertRowBefore(beforePosition: number): FWorksheet {return this.insertRowsBefore(beforePosition, 1);@@ -461,9 +461,9 @@ export class FWorksheet extends FBaseInitialable {/*** Hides one or more consecutive rows starting at the given index. Use 0-index for this method.- * @param rowIndex The starting index of the rows to hide.- * @param numRows The number of rows to hide.- * @returns This sheet, for chaining.+ * @param {number} rowIndex The starting index of the rows to hide.+ * @param {number} numRows The number of rows to hide.+ * @returns {FWorksheet} This sheet, for chaining.*/hideRows(rowIndex: number, numRows: number = 1): FWorksheet {const unitId = this._workbook.getUnitId();@@ -485,9 +485,9 @@ export class FWorksheet extends FBaseInitialable {}/**- * Unhides the row in the given range.- * @param row The range to unhide, if hidden.- * @returns This sheet, for chaining.+ * Make the row in the given range visible.+ * @param {FRange} row The range to unhide, if hidden.+ * @returns {FWorksheet} This sheet, for chaining.*/unhideRow(row: FRange): FWorksheet {const unitId = this._workbook.getUnitId();@@ -504,10 +504,10 @@ export class FWorksheet extends FBaseInitialable {}/**- * Unhides one or more consecutive rows starting at the given index. Use 0-index for this method.- * @param rowIndex The starting index of the rows to unhide.- * @param numRows The number of rows to unhide.- * @returns This sheet, for chaining.+ * Scrolling sheet to make specific rows visible.+ * @param {number} rowIndex The starting index of the rows+ * @param {number} numRows The number of rows+ * @returns {FWorksheet} This sheet, for chaining.*/showRows(rowIndex: number, numRows: number = 1): FWorksheet {const unitId = this._workbook.getUnitId();@@ -531,20 +531,21 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).- * @param rowPosition The row position to change.- * @param height The height in pixels to set it to.- * @returns This sheet, for chaining.+ * @param {number} rowPosition The row position to change.+ * @param {number} height The height in pixels to set it to.+ * @returns {FWorksheet} This sheet, for chaining.*/setRowHeight(rowPosition: number, height: number): FWorksheet {return this.setRowHeights(rowPosition, 1, height);}/**- * Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).- * @param startRow The starting row position to change.- * @param numRows The number of rows to change.- * @param height The height in pixels to set it to.- * @returns This sheet, for chaining.+ * Sets the height of the given rows in pixels.+ * By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).+ * @param {number} startRow The starting row position to change.+ * @param {number} numRows The number of rows to change.+ * @param {number} height The height in pixels to set it to.+ * @returns {FWorksheet} This sheet, for chaining.*/setRowHeights(startRow: number, numRows: number, height: number): FWorksheet {const unitId = this._workbook.getUnitId();@@ -593,10 +594,10 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. When you use setRowHeightsForced, rows are forced to the specified height even if the cell contents are taller than the row height.- * @param startRow The starting row position to change.- * @param numRows The number of rows to change.- * @param height The height in pixels to set it to.- * @returns This sheet, for chaining.+ * @param {number} startRow The starting row position to change.+ * @param {number} numRows The number of rows to change.+ * @param {number} height The height in pixels to set it to.+ * @returns {FWorksheet} This sheet, for chaining.*/setRowHeightsForced(startRow: number, numRows: number, height: number): FWorksheet {const unitId = this._workbook.getUnitId();@@ -856,7 +857,7 @@ export class FWorksheet extends FBaseInitialable {}/**- * Unhides the column in the given range.+ * Show the column in the given range.* @param column The range to unhide, if hidden.* @returns This sheet, for chaining.*/@@ -875,7 +876,7 @@ export class FWorksheet extends FBaseInitialable {}/**- * Unhides one or more consecutive columns starting at the given index. Use 0-index for this method.+ * Show one or more consecutive columns starting at the given index. Use 0-index for this method.* @param columnIndex The starting index of the columns to unhide.* @param numColumns The number of columns to unhide.* @returns This sheet, for chaining.@@ -1005,9 +1006,10 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the active selection region for this sheet.- * @param range The range to set as the active selection.+ * @param {FRange} range The range to set as the active selection.+ * @returns {FWorksheet} This sheet, for chaining.*/- setActiveRange(range: FRange): void {+ setActiveRange(range: FRange): FWorksheet {const { unitId, sheetId } = range.getRange();if (unitId !== this._workbook.getUnitId() || sheetId !== this._worksheet.getSheetId()) {@@ -1015,6 +1017,7 @@ export class FWorksheet extends FBaseInitialable {}this._fWorkbook.setActiveRange(range);+ return this;}/**@@ -1027,7 +1030,6 @@ export class FWorksheet extends FBaseInitialable {* Sets the frozen state of the current sheet.* @param freeze - the scrolling viewport start range and count of freezed rows and columns.* that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }- ** @deprecated use `setFrozenRows` and `setFrozenColumns` instead.* @returns True if the command was successful, false otherwise.*/@@ -1058,7 +1060,6 @@ export class FWorksheet extends FBaseInitialable {/*** Get the freeze state of the current sheet.* @returns The freeze state of the current sheet.- ** @deprecated use `getRowFreezeStatus` and `getColumnFreezeStatus` instead.*/getFreeze(): IFreeze {@@ -1070,22 +1071,22 @@ export class FWorksheet extends FBaseInitialable {* @param columns The number of columns to freeze.* To unfreeze all columns, set this value to 0.*/- setFrozenColumns(columns: number): void;+ setFrozenColumns(columns: number): FWorksheet;/*** Set freeze column, then the range from startColumn to endColumn will be fixed.* e.g. setFrozenColumns(0, 2) will fix the column range from 0 to 2.* e.g. setFrozenColumns(2, 3) will fix the column range from 2 to 3, And column from 0 to 1 will be invisible.- ** @example- * ``` ts+ * ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorkSheet = fWorkbook.getActiveSheet();* // freeze the first too columns.* fWorkSheet.setFrozenColumns(0, 2);* ```- * @param startColumn- * @param endColumn+ * @param startColumn - The start column of the range to freeze.+ * @param endColumn - The end column of the range to freeze.+ * @returns {FWorksheet} This FWorksheet instance.*/setFrozenColumns(startColumn: number, endColumn: number): FWorksheet;setFrozenColumns(...args: [number] | [number, number]): FWorksheet {@@ -1111,7 +1112,6 @@ export class FWorksheet extends FBaseInitialable {subUnitId: this.getSheetId(),});}-return this;}@@ -1120,15 +1120,14 @@ export class FWorksheet extends FBaseInitialable {* @param rows The number of rows to freeze.* To unfreeze all rows, set this value to 0.*/- setFrozenRows(rows: number): void;+ setFrozenRows(rows: number): FWorksheet;/*** Set freeze row, then the range from startRow to endRow will be fixed.* e.g. setFrozenRows(0, 2) will fix the row range from 0 to 2.* e.g. setFrozenRows(2, 3) will fix the row range from 2 to 3, And row from 0 to 1 will be invisible.- * @param startRow- * @param endRow- *+ * @param startRow - The start row of the range to freeze.+ * @param endRow - The end row of the range to freeze.* @example* ``` ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1161,14 +1160,12 @@ export class FWorksheet extends FBaseInitialable {subUnitId: this.getSheetId(),});}-return this;}/*** Get the number of frozen columns.- * @returns The number of frozen columns.- * Returns 0 if no columns are frozen.+ * @returns The number of frozen columns, returns 0 if no columns are frozen.*/getFrozenColumns(): number {const freeze = this.getFreeze();@@ -1180,8 +1177,7 @@ export class FWorksheet extends FBaseInitialable {/*** Get the number of frozen rows.- * @returns The number of frozen rows.- * Returns 0 if no rows are frozen.+ * @returns The number of frozen rows. returns 0 if no rows are frozen.*/getFrozenRows(): number {const freeze = this.getFreeze();@@ -1193,8 +1189,9 @@ export class FWorksheet extends FBaseInitialable {/*** Get freezed rows.+ * @returns {IRowRange} The range of the frozen rows.*/- getFrozenRowRange(): { startRow: number; endRow: number } {+ getFrozenRowRange(): IRowRange {const cfg = this._worksheet.getFreeze();return {startRow: cfg.startRow - cfg.ySplit,@@ -1204,8 +1201,9 @@ export class FWorksheet extends FBaseInitialable {/*** Get freezed columns+ * @returns {IColumnRange} The range of the frozen columns.*/- getFrozenColumnRange(): { startColumn: number; endColumn: number } {+ getFrozenColumnRange(): IColumnRange {const cfg = this._worksheet.getFreeze();return {startColumn: cfg.startColumn - cfg.xSplit,@@ -1233,6 +1231,7 @@ export class FWorksheet extends FBaseInitialable {/*** Hides or reveals the sheet gridlines.* @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines.+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example* ``` ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1247,7 +1246,6 @@ export class FWorksheet extends FBaseInitialable {subUnitId: this._worksheet.getSheetId(),showGridlines: hidden ? BooleanNumber.FALSE : BooleanNumber.TRUE,} as IToggleGridlinesCommandParams);-return this;}@@ -1269,7 +1267,6 @@ export class FWorksheet extends FBaseInitialable {subUnitId: this._worksheet.getSheetId(),color,} as ISetGridlinesColorCommandParams);-return this;}@@ -1380,13 +1377,14 @@ export class FWorksheet extends FBaseInitialable {/*** Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorkSheet = fWorkbook.getActiveSheet();* // hide the active sheet* fWorkSheet.hideSheet();- * ``+ * ```*/hideSheet(): FWorksheet {const commandService = this._injector.get(ICommandService);@@ -1422,7 +1420,6 @@ export class FWorksheet extends FBaseInitialable {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),});-return this;}@@ -1499,11 +1496,11 @@ export class FWorksheet extends FBaseInitialable {*/clear(options?: IFacadeClearOptions): FWorksheet {if (options && options.contentsOnly && !options.formatOnly) {- return this.clearContents();+ this.clearContents();}if (options && options.formatOnly && !options.contentsOnly) {- return this.clearFormats();+ this.clearFormats();}const unitId = this._workbook.getUnitId();@@ -1523,7 +1520,6 @@ export class FWorksheet extends FBaseInitialable {ranges: [range],options,});-return this;}@@ -1555,7 +1551,6 @@ export class FWorksheet extends FBaseInitialable {subUnitId,ranges: [range],});-return this;}@@ -1627,6 +1622,7 @@ export class FWorksheet extends FBaseInitialable {}/**+ * @deprecated use getLastColumn instead.* Returns the position of the last column that has content. Same as getLastColumns.* @returns {number} the last column of the sheet that contains content.* @example@@ -1642,6 +1638,7 @@ export class FWorksheet extends FBaseInitialable {}/**+ * @deprecated use getLastRow instead.* Returns the position of the last row that has content.* @returns {number} the last row of the sheet that contains content.* @examplediff --git a/packages/sheets/src/facade/utils.ts b/packages/sheets/src/facade/utils.tsindex 46ff30b3fd..57a3438a5a 100644--- a/packages/sheets/src/facade/utils.ts+++ b/packages/sheets/src/facade/utils.ts@@ -29,6 +29,10 @@ import {export type FHorizontalAlignment = 'left' | 'center' | 'normal';export type FVerticalAlignment = 'top' | 'middle' | 'bottom';+/**+ *+ * @param value+ */export function transformFacadeHorizontalAlignment(value: FHorizontalAlignment): HorizontalAlign {switch (value) {case 'left':@@ -42,6 +46,10 @@ export function transformFacadeHorizontalAlignment(value: FHorizontalAlignment):}}+/**+ *+ * @param value+ */export function transformCoreHorizontalAlignment(value: HorizontalAlign): FHorizontalAlignment {switch (value) {case HorizontalAlign.LEFT:@@ -55,6 +63,10 @@ export function transformCoreHorizontalAlignment(value: HorizontalAlign): FHoriz}}+/**+ *+ * @param value+ */export function transformFacadeVerticalAlignment(value: FVerticalAlignment): VerticalAlign {switch (value) {case 'top':@@ -68,6 +80,10 @@ export function transformFacadeVerticalAlignment(value: FVerticalAlignment): Ver}}+/**+ *+ * @param value+ */export function transformCoreVerticalAlignment(value: VerticalAlign): FVerticalAlignment {switch (value) {case VerticalAlign.TOP:@@ -82,7 +98,7 @@ export function transformCoreVerticalAlignment(value: VerticalAlign): FVerticalA}/**- * covert cell value to cell data+ * Covert cell value to cell data.* @param value* @returns*/@@ -106,7 +122,7 @@ export function covertCellValue(value: CellValue | ICellData): ICellData {}/**- * covert cell value array or matrix to cell data+ * Covert cell value array or matrix to cell data.* @param value* @param range* @returns@@ -138,6 +154,11 @@ export function covertCellValues(return cellValue.getMatrix();}+/**+ *+ * @param mergeInfo+ * @param range+ */export function isCellMerged(mergeInfo: IRangeWithCoord, range: IRange): boolean {if (!isSingleCell(mergeInfo, range)) {return false;@@ -145,6 +166,11 @@ export function isCellMerged(mergeInfo: IRangeWithCoord, range: IRange): booleanreturn range.startColumn !== range.endColumn || range.startRow !== range.endRow;}+/**+ *+ * @param mergeInfo+ * @param range+ */export function isSingleCell(mergeInfo: IRangeWithCoord, range: IRange): boolean {return mergeInfo.startColumn === range.startColumn&& mergeInfo.endColumn === range.endColumn@@ -152,6 +178,11 @@ export function isSingleCell(mergeInfo: IRangeWithCoord, range: IRange): boolean&& mergeInfo.endRow === range.endRow;}+/**+ *+ * @param range+ * @param worksheet+ */export function covertToRowRange(range: IRange, worksheet: Worksheet): IRange {return {startRow: range.startRow,@@ -162,6 +193,11 @@ export function covertToRowRange(range: IRange, worksheet: Worksheet): IRange {};}+/**+ *+ * @param range+ * @param worksheet+ */export function covertToColRange(range: IRange, worksheet: Worksheet): IRange {return {startRow: 0,diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 8eb616e380..913868a46f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -59,6 +59,9 @@ importers:eslint-plugin-header:specifier: ^3.1.1version: 3.1.1([email protected]([email protected]))+ eslint-plugin-jsdoc:+ specifier: ^50.6.1+ version: 50.6.1([email protected]([email protected]))eslint-plugin-no-barrel-import:specifier: ^0.0.2version: 0.0.2([email protected]([email protected]))@@ -12037,7 +12040,7 @@ snapshots:'@microsoft/tsdoc': 0.15.1ajv: 8.12.0jju: 1.4.0- resolve: 1.22.8+ resolve: 1.22.10'@microsoft/[email protected]': {}@@ -12462,14 +12465,14 @@ snapshots:fs-extra: 7.0.1import-lazy: 4.0.0jju: 1.4.0- resolve: 1.22.8+ resolve: 1.22.10semver: 7.5.4optionalDependencies:'@types/node': 22.10.2'@rushstack/[email protected]':dependencies:- resolve: 1.22.8+ resolve: 1.22.10strip-json-comments: 3.1.1'@rushstack/[email protected](@types/[email protected])':@@ -15053,7 +15056,7 @@ snapshots:dependencies:debug: 3.2.7is-core-module: 2.15.1- resolve: 1.22.8+ resolve: 1.22.10transitivePeerDependencies:- supports-color@@ -17264,7 +17267,7 @@ snapshots:dependencies:hosted-git-info: 2.8.9- resolve: 1.22.8+ resolve: 1.22.10semver: 5.7.2validate-npm-package-license: 3.0.4@@ -17522,7 +17525,7 @@ snapshots:dependencies:- es-module-lexer: 1.5.4+ es-module-lexer: 1.6.0slashes: 3.0.12@@ -18210,7 +18213,7 @@ snapshots:dependencies:- resolve: 1.22.8+ resolve: 1.22.10dependencies:@@ -18348,7 +18351,7 @@ snapshots:dependencies:path-root: 0.1.1- resolve: 1.22.8+ resolve: 1.22.10