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
feat(facade): add effect ranges on skeleton change (#4496)
zhangw7957d958043e
diff --git a/packages/sheets-data-validation/src/facade/f-data-validation-builder.ts b/packages/sheets-data-validation/src/facade/f-data-validation-builder.tsindex bcd9565561..b1728314b1 100644--- a/packages/sheets-data-validation/src/facade/f-data-validation-builder.ts+++ b/packages/sheets-data-validation/src/facade/f-data-validation-builder.ts@@ -22,10 +22,13 @@ import { FDataValidation } from './f-data-validation';/*** Builder for data validation rules.- *- * Set the data validation for cell A1 to require a value from B1:B10.- * var rule = FUniver.newDataValidation().requireValueInRange(range).build();- * cell.setDataValidation(rule);+ * @example+ * ```typescript+ * // Set the data validation for cell A1 to require a value from B1:B10+ * const range = FRange.create('Sheet1', 'B1:B10');+ * const rule = FUniver.newDataValidation().requireValueInRange(range).build();+ * cell.setDataValidation(rule);+ * ```*/export class FDataValidationBuilder {private _rule: IDataValidationRule;@@ -41,6 +44,11 @@ export class FDataValidationBuilder {/*** Builds an FDataValidation instance based on the _rule property of the current class* @returns {FDataValidation} A new instance of the FDataValidation class+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const validation = builder.requireNumberBetween(1, 10).build();+ * ```*/build(): FDataValidation {return new FDataValidation(this._rule);@@ -49,6 +57,11 @@ export class FDataValidationBuilder {/*** Creates a duplicate of the current DataValidationBuilder object* @returns {FDataValidationBuilder} A new instance of the DataValidationBuilder class+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const copy = builder.requireNumberBetween(1, 10).copy();+ * ```*/copy(): FDataValidationBuilder {return new FDataValidationBuilder({@@ -60,6 +73,11 @@ export class FDataValidationBuilder {/*** Determines whether invalid data is allowed* @returns {boolean} True if invalid data is allowed, False otherwise+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const allowsInvalid = builder.getAllowInvalid();+ * ```*/getAllowInvalid(): boolean {return this._rule.errorStyle !== DataValidationErrorStyle.STOP;@@ -67,7 +85,12 @@ export class FDataValidationBuilder {/*** Gets the data validation type of the rule- * @returns {DataValidationType} The data validation type+ * @returns {DataValidationType | string} The data validation type+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const type = builder.getCriteriaType();+ * ```*/getCriteriaType(): DataValidationType | string {return this._rule.type;@@ -75,7 +98,12 @@ export class FDataValidationBuilder {/*** Gets the values used for criteria evaluation- * @returns {[string, string, string]} An array containing the operator, formula1, and formula2 values+ * @returns {[string | undefined, string | undefined, string | undefined]} An array containing the operator, formula1, and formula2 values+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const [operator, formula1, formula2] = builder.getCriteriaValues();+ * ```*/getCriteriaValues(): [string | undefined, string | undefined, string | undefined] {return [this._rule.operator, this._rule.formula1, this._rule.formula2];@@ -83,7 +111,12 @@ export class FDataValidationBuilder {/*** Gets the help text information, which is used to provide users with guidance and support- * @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value.+ * @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const helpText = builder.getHelpText();+ * ```*/getHelpText(): string | undefined {return this._rule.error;@@ -91,9 +124,14 @@ export class FDataValidationBuilder {/*** Sets the data validation type to CHECKBOX and sets the checked and unchecked values- * @param checkedValue The value when the checkbox is checked (Optional)- * @param uncheckedValue The value when the checkbox is unchecked (Optional)- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {string} [checkedValue] - The value when the checkbox is checked+ * @param {string} [uncheckedValue] - The value when the checkbox is unchecked+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireCheckbox('Yes', 'No').build();+ * ```*/requireCheckbox(checkedValue?: string, uncheckedValue?: string): FDataValidationBuilder {this._rule.type = DataValidationType.CHECKBOX;@@ -105,8 +143,13 @@ export class FDataValidationBuilder {/*** Set the data validation type to DATE and configure the validation rules to be after a specific date- * @param date The date to compare against. The formatted date string will be set as formula1- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {Date} date - The date to compare against+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireDateAfter(new Date('2024-01-01')).build();+ * ```*/requireDateAfter(date: Date): FDataValidationBuilder {this._rule.type = DataValidationType.DATE;@@ -118,8 +161,13 @@ export class FDataValidationBuilder {/*** Set the data validation type to DATE and configure the validation rules to be before a specific date- * @param date The date to compare against. The formatted date string will be set as formula1- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {Date} date - The date to compare against+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireDateBefore(new Date('2024-12-31')).build();+ * ```*/requireDateBefore(date: Date): FDataValidationBuilder {this._rule.type = DataValidationType.DATE;@@ -132,9 +180,16 @@ export class FDataValidationBuilder {/*** Set the data validation type to DATE and configure the validation rules to be within a specific date range- * @param start The starting date of the range. The formatted date string will be set as formula1- * @param end The ending date of the range. The formatted date string will be set as formula2- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {Date} start - The starting date of the range+ * @param {Date} end - The ending date of the range+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder+ * .requireDateBetween(new Date('2024-01-01'), new Date('2024-12-31'))+ * .build();+ * ```*/requireDateBetween(start: Date, end: Date): FDataValidationBuilder {this._rule.type = DataValidationType.DATE;@@ -147,8 +202,13 @@ export class FDataValidationBuilder {/*** Set the data validation type to DATE and configure the validation rules to be equal to a specific date- * @param date The date to compare against. The formatted date string will be set as formula1- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {Date} date - The date to compare against+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireDateEqualTo(new Date('2024-01-01')).build();+ * ```*/requireDateEqualTo(date: Date): FDataValidationBuilder {this._rule.type = DataValidationType.DATE;@@ -161,9 +221,16 @@ export class FDataValidationBuilder {/*** Set the data validation type to DATE and configure the validation rules to be not within a specific date range- * @param start The starting date of the date range- * @param end The ending date of the date range- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {Date} start - The starting date of the date range+ * @param {Date} end - The ending date of the date range+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder+ * .requireDateNotBetween(new Date('2024-01-01'), new Date('2024-12-31'))+ * .build();+ * ```*/requireDateNotBetween(start: Date, end: Date): FDataValidationBuilder {this._rule.type = DataValidationType.DATE;@@ -176,8 +243,13 @@ export class FDataValidationBuilder {/*** Set the data validation type to DATE and configure the validation rules to be on or after a specific date- * @param date The date to compare against. The formatted date string will be set as formula1- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {Date} date - The date to compare against+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireDateOnOrAfter(new Date('2024-01-01')).build();+ * ```*/requireDateOnOrAfter(date: Date): FDataValidationBuilder {this._rule.type = DataValidationType.DATE;@@ -190,8 +262,13 @@ export class FDataValidationBuilder {/*** Set the data validation type to DATE and configure the validation rules to be on or before a specific date- * @param date The date to compare against. The formatted date string will be set as formula1- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {Date} date - The date to compare against+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireDateOnOrBefore(new Date('2024-12-31')).build();+ * ```*/requireDateOnOrBefore(date: Date): FDataValidationBuilder {this._rule.type = DataValidationType.DATE;@@ -203,10 +280,14 @@ export class FDataValidationBuilder {}/**- * Requires that a custom formula be satisfied.- * Sets the data validation type to CUSTOM and configures the validation rule based on the provided formula string.- * @param formula The formula string that needs to be satisfied.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Requires that a custom formula be satisfied+ * @param {string} formula - The formula string that needs to be satisfied+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireFormulaSatisfied('=A1>0').build();+ * ```*/requireFormulaSatisfied(formula: string): FDataValidationBuilder {this._rule.type = DataValidationType.CUSTOM;@@ -216,12 +297,16 @@ export class FDataValidationBuilder {}/**- * Requires the user to enter a number within a specific range, which can be integer or decimal.- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number range.- * @param start The starting value of the number range.- * @param end The ending value of the number range.- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or decimal.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Requires the user to enter a number within a specific range, which can be integer or decimal+ * @param {number} start - The starting value of the number range+ * @param {number} end - The ending value of the number range+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberBetween(1, 10).build();+ * ```*/requireNumberBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${start}`;@@ -233,11 +318,15 @@ export class FDataValidationBuilder {}/**- * Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal.- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.- * @param num The number to which the entered number should be equal.- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal+ * @param {number} num - The number to which the entered number should be equal+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberEqualTo(10).build();+ * ```*/requireNumberEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${num}`;@@ -248,11 +337,15 @@ export class FDataValidationBuilder {}/**- * Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal.- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.- * @param num The number to which the entered number should be greater.- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal+ * @param {number} num - The number to which the entered number should be greater+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberGreaterThan(10).build();+ * ```*/requireNumberGreaterThan(num: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${num}`;@@ -263,11 +356,15 @@ export class FDataValidationBuilder {}/**- * Requires the user to enter a number that is greater than or equal to a specific value, which can be an integer or a decimal.- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.- * @param num The number to which the entered number should be greater than or equal.- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Requires the user to enter a number that is greater than or equal to a specific value, which can be an integer or a decimal+ * @param {number} num - The number to which the entered number should be greater than or equal+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberGreaterThanOrEqualTo(10).build();+ * ```*/requireNumberGreaterThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${num}`;@@ -278,11 +375,15 @@ export class FDataValidationBuilder {}/**- * Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal.- * Sets the data validation type based on the isInteger parameter and configures the validation rules for the specified number.- * @param num The number to which the entered number should be less.- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal+ * @param {number} num - The number to which the entered number should be less+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberLessThan(10).build();+ * ```*/requireNumberLessThan(num: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${num}`;@@ -295,9 +396,14 @@ export class FDataValidationBuilder {/*** Sets the data validation rule to require a number less than or equal to a specified value* The specified value can be an integer or a decimal- * @param num The number to which the entered number should be less than or equal- * @param isInteger Indicates whether the required number is an integer- * @returns The current instance of the DataValidationBuilder class, allowing for method chaining+ * @param {number} num - The number to which the entered number should be less than or equal+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberLessThanOrEqualTo(10).build();+ * ```*/requireNumberLessThanOrEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${num}`;@@ -310,10 +416,15 @@ export class FDataValidationBuilder {/*** Sets a data validation rule that requires the user to enter a number outside a specified range* The specified range includes all integers and decimals- * @param start The starting point of the specified range- * @param end The end point of the specified range- * @param isInteger Optional parameter, indicating whether the number to be verified is an integer. Default value is false- * @returns An instance of the FDataValidationBuilder class, allowing for method chaining+ * @param {number} start - The starting point of the specified range+ * @param {number} end - The end point of the specified range+ * @param {boolean} [isInteger] - Optional parameter, indicating whether the number to be verified is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberNotBetween(1, 10).build();+ * ```*/requireNumberNotBetween(start: number, end: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${start}`;@@ -327,9 +438,14 @@ export class FDataValidationBuilder {/*** Creates a data validation rule that requires the user to enter a number that is not equal to a specific value* The specific value can be an integer or a decimal- * @param num The number to which the entered number should not be equal- * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or a decimal- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining+ * @param {number} num - The number to which the entered number should not be equal+ * @param {boolean} [isInteger] - Indicates whether the required number is an integer+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireNumberNotEqualTo(10).build();+ * ```*/requireNumberNotEqualTo(num: number, isInteger?: boolean): FDataValidationBuilder {this._rule.formula1 = `${num}`;@@ -340,12 +456,17 @@ export class FDataValidationBuilder {}/**- * Sets a data validation rule that requires the user to enter a value from a list of specific values.- * The list can be displayed in a dropdown, and the user can choose multiple values according to the settings.- * @param values An array containing the specific values that the user can enter.- * @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.- * @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.- * @returns An instance of the FDataValidationBuilder class, allowing for method chaining.+ * Sets a data validation rule that requires the user to enter a value from a list of specific values+ * The list can be displayed in a dropdown, and the user can choose multiple values according to the settings+ * @param {string[]} values - An array containing the specific values that the user can enter+ * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values+ * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.requireValueInList(['Yes', 'No']).build();+ * ```*/requireValueInList(values: string[], multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder {this._rule.type = multiple ? DataValidationType.LIST_MULTIPLE : DataValidationType.LIST;@@ -357,12 +478,18 @@ export class FDataValidationBuilder {}/**- * Sets a data validation rule that requires the user to enter a value within a specific range.- * The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range.- * @param range An FRange object representing the range of values that the user can enter.- * @param multiple Optional parameter indicating whether the user can select multiple values. Default is false, meaning only one value can be selected.- * @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Sets a data validation rule that requires the user to enter a value within a specific range+ * The range is defined by an FRange object, which contains the unit ID, sheet name, and cell range+ * @param {FRange} range - An FRange object representing the range of values that the user can enter+ * @param {boolean} [multiple] - Optional parameter indicating whether the user can select multiple values+ * @param {boolean} [showDropdown] - Optional parameter indicating whether to display the list in a dropdown+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const range = FRange.create('Sheet1', 'B1:B10');+ * const rule = builder.requireValueInRange(range).build();+ * ```*/requireValueInRange(range: FRange, multiple?: boolean, showDropdown?: boolean): FDataValidationBuilder {this._rule.type = multiple ? DataValidationType.LIST_MULTIPLE : DataValidationType.LIST;@@ -378,11 +505,16 @@ export class FDataValidationBuilder {}/**- * Sets whether to allow invalid data and configures the error style for data validation.- * If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error.- * If invalid data is allowed, the error style will be set to WARNING, indicating that a warning will be displayed when invalid data is entered, but data entry can continue.- * @param allowInvalidData A boolean value indicating whether to allow invalid data.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Sets whether to allow invalid data and configures the error style+ * If invalid data is not allowed, the error style will be set to STOP, indicating that data entry must stop upon encountering an error+ * If invalid data is allowed, the error style will be set to WARNING, indicating that a warning will be displayed when invalid data is entered, but data entry can continue+ * @param {boolean} allowInvalidData - Whether to allow invalid data+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.setAllowInvalid(true).build();+ * ```*/setAllowInvalid(allowInvalidData: boolean): FDataValidationBuilder {this._rule.errorStyle = !allowInvalidData ? DataValidationErrorStyle.STOP : DataValidationErrorStyle.WARNING;@@ -390,44 +522,33 @@ export class FDataValidationBuilder {}/**- * Sets the help text and enables the display of error messages for data validation.- * This method allows you to set a custom help text that will be displayed when the user enters invalid data.- * @param helpText The text to display as help information.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Sets whether to allow blank values+ * @param {boolean} allowBlank - Whether to allow blank values+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.setAllowBlank(true).build();+ * ```*/- setHelpText(helpText: string): FDataValidationBuilder {- this._rule.error = helpText;- this._rule.showErrorMessage = true;- return this;- }-- /**- * Sets the criteria values for data validation.- * This method is used to configure the validation rules based on specific criteria values.- * @param type The type of data validation.- * @param values An array containing the criteria values.- * The array should have three elements: [operator, formula1, formula2].- * operator is a DataValidationOperator enum value, formula1 is the first formula, and formula2 is the second formula.- * @returns The current instance of the FDataValidationBuilder class, allowing for method chaining.- */- withCriteriaValues(type: DataValidationType | string, values: [DataValidationOperator, string, string]): this {- this._rule.type = type;- this._rule.operator = values[0];- this._rule.formula1 = values[1];- this._rule.formula2 = values[2];- return this;- }-setAllowBlank(allowBlank: boolean): FDataValidationBuilder {this._rule.allowBlank = allowBlank;return this;}/**- * Sets the options for the data validation rule.- * For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions- * @param options The options to set for the data validation rule.- * @returns The current instance of the FDataValidationBuilder class to allow for method chaining.+ * Sets the options for the data validation rule+ * @param {Partial<IDataValidationRuleOptions>} options - The options to set for the data validation rule+ * @returns {FDataValidationBuilder} The current instance for method chaining+ * @example+ * ```typescript+ * const builder = univerAPI.newDataValidation();+ * const rule = builder.setOptions({+ * allowBlank: true,+ * showErrorMessage: true,+ * error: 'Please enter a valid value'+ * }).build();+ * ```*/setOptions(options: Partial<IDataValidationRuleOptions>): this {Object.assign(this._rule, options);diff --git a/packages/sheets-data-validation/src/facade/f-data-validation.ts b/packages/sheets-data-validation/src/facade/f-data-validation.tsindex 7ff8a55c04..9d926825c0 100644--- a/packages/sheets-data-validation/src/facade/f-data-validation.ts+++ b/packages/sheets-data-validation/src/facade/f-data-validation.ts@@ -34,8 +34,17 @@ export class FDataValidation {}/**- * Gets whether invalid data is allowed based on the error style value.- * @returns true if invalid data is allowed, false otherwise.+ * Gets whether invalid data is allowed based on the error style value+ * @returns {boolean} true if invalid data is allowed, false otherwise+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const allowsInvalid = dataValidation.getAllowInvalid();+ * ```*/getAllowInvalid(): boolean {return this.rule.errorStyle !== DataValidationErrorStyle.STOP;@@ -43,7 +52,16 @@ export class FDataValidation {/*** Gets the data validation type of the rule- * @returns The data validation type+ * @returns {DataValidationType | string} The data validation type+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const type = dataValidation.getCriteriaType();+ * ```*/getCriteriaType(): DataValidationType | string {return this.rule.type;@@ -51,7 +69,16 @@ export class FDataValidation {/*** Gets the values used for criteria evaluation- * @returns An array containing the operator, formula1, and formula2 values+ * @returns {[string | undefined, string | undefined, string | undefined]} An array containing the operator, formula1, and formula2 values+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const [operator, formula1, formula2] = dataValidation.getCriteriaValues();+ * ```*/getCriteriaValues(): [string | undefined, string | undefined, string | undefined] {return [this.rule.operator, this.rule.formula1, this.rule.formula2];@@ -59,24 +86,51 @@ export class FDataValidation {/*** Gets the help text information, which is used to provide users with guidance and support- * @returns Returns the help text information. If there is no error message, it returns an undefined value.+ * @returns {string | undefined} Returns the help text information. If there is no error message, it returns an undefined value+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const helpText = dataValidation.getHelpText();+ * ```*/getHelpText(): string | undefined {return this.rule.error;};/**- * Creates a new instance of FDataValidationBuilder using the current rule object.- * This method is useful for copying an existing data validation rule configuration.- * @returns A new FDataValidationBuilder instance with the same rule configuration.+ * Creates a new instance of FDataValidationBuilder using the current rule object+ * @returns {FDataValidationBuilder} A new FDataValidationBuilder instance with the same rule configuration+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const builder = dataValidation.copy();+ * const newRule = builder.setAllowInvalid(true).build();+ * ```*/copy(): FDataValidationBuilder {return new FDataValidationBuilder(this.rule);}/**- * Gets whether the data validation rule is applied to the worksheet.- * @returns true if the rule is applied, false otherwise.+ * Gets whether the data validation rule is applied to the worksheet+ * @returns {boolean} true if the rule is applied, false otherwise+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const isApplied = dataValidation.getApplied();+ * ```*/getApplied(): boolean {if (!this._worksheet) {@@ -93,8 +147,17 @@ export class FDataValidation {}/**- * Gets the ranges to which the data validation rule is applied.- * @returns An array of IRange objects representing the ranges to which the data validation rule is applied.+ * Gets the ranges to which the data validation rule is applied+ * @returns {FRange[]} An array of FRange objects representing the ranges to which the data validation rule is applied+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const ranges = dataValidation.getRanges();+ * ```*/getRanges(): FRange[] {if (!this.getApplied()) {@@ -106,27 +169,58 @@ export class FDataValidation {}/**- * Gets the title of the error message dialog box.- * @returns The title of the error message dialog box.+ * Gets the unit ID of the worksheet+ * @returns {string | undefined} The unit ID of the worksheet+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const unitId = dataValidation.getUnitId();+ * ```*/getUnitId(): string | undefined {return this._worksheet?.getUnitId();}/**- * Gets the sheetId of the worksheet.- * @returns The sheetId of the worksheet.+ * Gets the sheet ID of the worksheet+ * @returns {string | undefined} The sheet ID of the worksheet+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const sheetId = dataValidation.getSheetId();+ * ```*/getSheetId(): string | undefined {return this._worksheet?.getSheetId();}/**- * Set Criteria for the data validation rule.- * @param type The type of data validation criteria.- * @param values An array containing the operator, formula1, and formula2 values.- * @param allowBlank- * @returns true if the criteria is set successfully, false otherwise.+ * Set Criteria for the data validation rule+ * @param {DataValidationType} type - The type of data validation criteria+ * @param {[DataValidationOperator, string, string]} values - An array containing the operator, formula1, and formula2 values+ * @param {boolean} [allowBlank] - Whether to allow blank values+ * @returns {FDataValidation} The current instance for method chaining+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * dataValidation.setCriteria(+ * DataValidationType.DECIMAL,+ * [DataValidationOperator.BETWEEN, '1', '10'],+ * true+ * );+ * ```*/setCriteria(type: DataValidationType, values: [DataValidationOperator, string, string], allowBlank = true): FDataValidation {if (this.getApplied()) {@@ -159,10 +253,22 @@ export class FDataValidation {}/**- * Set the options for the data validation rule.- * For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions- * @param options An object containing the options to set. `IDataValidationRuleOptions`- * @returns true if the options are set successfully, false otherwise.+ * Set the options for the data validation rule+ * @param {Partial<IDataValidationRuleOptions>} options - The options to set for the data validation rule+ * @returns {FDataValidation} The current instance for method chaining+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * dataValidation.setOptions({+ * allowBlank: true,+ * showErrorMessage: true,+ * error: 'Please enter a valid value'+ * });+ * ```*/setOptions(options: Partial<IDataValidationRuleOptions>): FDataValidation {if (this.getApplied()) {@@ -187,9 +293,19 @@ export class FDataValidation {}/**- * Set the ranges to the data validation rule.- * @param ranges new ranges array.- * @returns true if the ranges are set successfully, false otherwise.+ * Set the ranges to the data validation rule+ * @param {FRange[]} ranges - New ranges array+ * @returns {FDataValidation} The current instance for method chaining+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const range = FRange.create('Sheet1', 'A1:B10');+ * dataValidation.setRanges([range]);+ * ```*/setRanges(ranges: FRange[]): FDataValidation {if (this.getApplied()) {@@ -211,8 +327,17 @@ export class FDataValidation {}/**- * Delete the data validation rule from the worksheet.- * @returns true if the rule is deleted successfully, false otherwise.+ * Delete the data validation rule from the worksheet+ * @returns {boolean} true if the rule is deleted successfully, false otherwise+ * @example+ * ```typescript+ * const dataValidation = univerAPI+ * .getActiveWorkbook()+ * .getActiveWorksheet()+ * .getActiveRange()+ * .getDataValidation();+ * const isDeleted = dataValidation.delete();+ * ```*/delete(): boolean {if (!this.getApplied()) {diff --git a/packages/sheets-data-validation/src/facade/f-range.ts b/packages/sheets-data-validation/src/facade/f-range.tsindex 26dd3a321e..27fd6d8d3a 100644--- a/packages/sheets-data-validation/src/facade/f-range.ts+++ b/packages/sheets-data-validation/src/facade/f-range.ts@@ -22,22 +22,49 @@ import { FDataValidation } from './f-data-validation';export interface IFRangeDataValidationMixin {/**- * Set a data validation rule to current range.- * @param rule data validation rule, build by `FUniver.newDataValidation`+ * Set a data validation rule to current range. if rule is null, clear data validation rule.+ * @param {Nullable<FDataValidation>} rule data validation rule, build by `FUniver.newDataValidation`* @returns current range+ * @example+ * ```ts+ * const rule = FUniver.newDataValidation().requireValueInRange(range).build();+ * cell.setDataValidation(rule);+ * ```*/- setDataValidation(this: FRange, rule: Nullable<FDataValidation>): FRange;+ setDataValidation(rule: Nullable<FDataValidation>): FRange;/*** Get first data validation rule in current range.- * @returns data validation rule+ * @returns {Nullable<FDataValidation>} data validation rule+ * @example+ * ```ts+ * const workbook = univerAPI.getActiveWorkbook();+ * const worksheet = workbook.getActiveSheet();+ * const dataValidation = worksheet.getActiveRange().getDataValidation();+ * ```*/- getDataValidation(this: FRange): Nullable<FDataValidation>;+ getDataValidation(): Nullable<FDataValidation>;/*** Get all data validation rules in current range.- * @returns all data validation rules+ * @returns {FDataValidation[]} all data validation rules+ * @example+ * ```ts+ * const workbook = univerAPI.getActiveWorkbook();+ * const worksheet = workbook.getActiveSheet();+ * const dataValidations = worksheet.getActiveRange().getDataValidations();+ * ```+ */+ getDataValidations(): FDataValidation[];+ /**+ * Get data validation validator status for current range.+ * @returns {Promise<DataValidationStatus[][]>} matrix of validator status+ * @example+ * ```ts+ * const workbook = univerAPI.getActiveWorkbook();+ * const worksheet = workbook.getActiveSheet();+ * const validatorStatus = worksheet.getActiveRange().getValidatorStatus();+ * ```*/- getDataValidations(this: FRange): FDataValidation[];getValidatorStatus(): Promise<DataValidationStatus[][]>;}diff --git a/packages/sheets-data-validation/src/facade/f-univer.ts b/packages/sheets-data-validation/src/facade/f-univer.tsindex 80f639d994..4c6eff11b5 100644--- a/packages/sheets-data-validation/src/facade/f-univer.ts+++ b/packages/sheets-data-validation/src/facade/f-univer.ts@@ -23,14 +23,24 @@ import { FDataValidation } from './f-data-validation';import { FDataValidationBuilder } from './f-data-validation-builder';export class FUnvierDataValidationMixin extends FUniver {+ // eslint-disable-next-line jsdoc/require-returns/**/**- * @deparecated use `univerAPI.newDataValidation()` as instead.+ * @deprecated use `univerAPI.newDataValidation()` as instead.*/static override newDataValidation(): FDataValidationBuilder {return new FDataValidationBuilder();}+ /**+ * Creates a new instance of FDataValidationBuilder+ * @returns {FDataValidationBuilder} A new instance of the FDataValidationBuilder class+ * @example+ * ```ts+ * const rule = FUnvier.newDataValidation();+ * cell.setDataValidation(rule.requireValueInRange(range));+ * ```+ */newDataValidation(): FDataValidationBuilder {return new FDataValidationBuilder();}diff --git a/packages/sheets-data-validation/src/facade/f-workbook.ts b/packages/sheets-data-validation/src/facade/f-workbook.tsindex 5f8a52b814..6ff8e1c717 100644--- a/packages/sheets-data-validation/src/facade/f-workbook.ts+++ b/packages/sheets-data-validation/src/facade/f-workbook.ts@@ -51,27 +51,21 @@ export interface IFWorkbookDataValidationMixin {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 {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+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.SheetDataValidationChanged, (event) => { ... })` instead*/onDataValidationChange(callback: (ruleChange: IRuleChange) => void): IDisposable;/**- * The onDataValidationStatusChange event is fired when the data validation status of this sheet is changed.- * @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+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.SheetDataValidatorStatusChanged, (event) => { ... })` instead*/onDataValidationStatusChange(callback: (statusChange: IValidStatusChange) => void): IDisposable;/**- * The onBeforeAddDataValidation event is fired before the data validation rule is added.- * @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+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationAdd, (event) => { ... })` instead*/onBeforeAddDataValidation(this: FWorkbook,@@ -79,9 +73,7 @@ export interface IFWorkbookDataValidationMixin {): IDisposable;/**- * 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- * @returns A disposable object that can be used to unsubscribe from the event+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationCriteriaUpdate, (event) => { ... })` instead*/onBeforeUpdateDataValidationCriteria(this: FWorkbook,@@ -89,18 +81,14 @@ export interface IFWorkbookDataValidationMixin {): IDisposable;/**- * 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- * @returns A disposable object that can be used to unsubscribe from the event+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationRangeUpdate, (event) => { ... })` instead*/onBeforeUpdateDataValidationRange(this: FWorkbook,callback: (params: IUpdateSheetDataValidationRangeCommandParams, options: IExecutionOptions | undefined) => void | false): 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- * @returns A disposable object that can be used to unsubscribe from the event+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationOptionsUpdate, (event) => { ... })` instead*/onBeforeUpdateDataValidationOptions(this: FWorkbook,@@ -108,9 +96,7 @@ export interface IFWorkbookDataValidationMixin {): IDisposable;/**- * 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- * @returns A disposable object that can be used to unsubscribe from the event+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationDelete, (event) => { ... })` instead*/onBeforeDeleteDataValidation(this: FWorkbook,@@ -118,9 +104,7 @@ export interface IFWorkbookDataValidationMixin {): IDisposable;/**- * The onBeforeDeleteAllDataValidation event is fired before delete all data validation rules.- * @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+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.BeforeSheetDataValidationDeleteAll, (event) => { ... })` instead*/onBeforeDeleteAllDataValidation(this: FWorkbook,diff --git a/packages/sheets-data-validation/src/facade/f-worksheet.ts b/packages/sheets-data-validation/src/facade/f-worksheet.tsindex 418a444f42..6970ca29f7 100644--- a/packages/sheets-data-validation/src/facade/f-worksheet.ts+++ b/packages/sheets-data-validation/src/facade/f-worksheet.ts@@ -23,7 +23,7 @@ import { FDataValidation } from './f-data-validation';export interface IFWorksheetDataValidationMixin {/*** Get all data validation rules in current sheet.- * @returns all data validation rules+ * @returns {FDataValidation[]} all data validation rules* ```ts* const workbook = univerAPI.getActiveWorkbook();* const worksheet = workbook.getWorksheet('sheet1');@@ -31,21 +31,26 @@ export interface IFWorksheetDataValidationMixin {* ```*/getDataValidations(): FDataValidation[];++ /**+ * @deprecated use `getValidatorStatusAsync` instead+ */+ getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;+/*** Get data validation validator status for current sheet.- * @returns matrix of validator status+ * @returns {Promise<ObjectMatrix<Nullable<DataValidationStatus>>>} matrix of validator status* ```ts* const workbook = univerAPI.getActiveWorkbook();* const worksheet = workbook.getWorksheet('sheet1');* const validatorStatus = worksheet.getValidatorStatus();* ```*/- getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;-+ getValidatorStatusAsync(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>;/*** get data validation rule by rule id* @param ruleId - the rule id- * @returns data validation rule+ * @returns {Nullable<FDataValidation>} data validation rule* ```ts* const workbook = univerAPI.getActiveWorkbook();* const worksheet = workbook.getWorksheet('sheet1');@@ -70,6 +75,10 @@ export class FWorksheetDataValidationMixin extends FWorksheet implements IFWorks);}+ override getValidatorStatusAsync(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>> {+ return this.getValidatorStatus();+ }+override getDataValidation(ruleId: string): Nullable<FDataValidation> {const dataValidationModel = this._injector.get(DataValidationModel);const rule = dataValidationModel.getRuleById(this._workbook.getUnitId(), this._worksheet.getSheetId(), ruleId);diff --git a/packages/sheets-hyper-link/src/facade/f-event.ts b/packages/sheets-hyper-link/src/facade/f-event.tsnew file mode 100644index 0000000000..0f002e45d5--- /dev/null+++ b/packages/sheets-hyper-link/src/facade/f-event.ts@@ -0,0 +1,127 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICellLinkContent, ISheetHyperLink } from '@univerjs/sheets-hyper-link';+import type { FWorkbook, FWorksheet } from '@univerjs/sheets/facade';+import { FEventName, type IEventBase } from '@univerjs/core';++interface IFSheetLinkEvent {+ /**+ * Event triggered before adding a link+ * @example+ * ```ts+ * univerAPI.addEvent(univerAPI.Event.BeforeSheetLinkAdd, (params) => {+ * const { workbook, worksheet, row, col, link } = params;+ * console.log('before sheet link add', params);+ * });+ * ```+ */+ readonly BeforeSheetLinkAdd: 'BeforeSheetLinkAdd';+ /**+ * Event triggered before canceling a link+ * @example+ * ```ts+ * univerAPI.addEvent(univerAPI.Event.BeforeSheetLinkCancel, (params) => {+ * const { workbook, worksheet, row, column, id } = params;+ * console.log('before sheet link cancel', params);+ * });+ * ```+ */+ readonly BeforeSheetLinkCancel: 'BeforeSheetLinkCancel';+ /**+ * Event triggered before updating a link+ * @example+ * ```ts+ * univerAPI.addEvent(univerAPI.Event.BeforeSheetLinkUpdate, (params) => {+ * const { workbook, worksheet, row, column, id, payload } = params;+ * console.log('before sheet link update', params);+ * });+ * ```+ */+ readonly BeforeSheetLinkUpdate: 'BeforeSheetLinkUpdate';+}++export class FSheetLinkEvent implements IFSheetLinkEvent {+ get BeforeSheetLinkAdd(): 'BeforeSheetLinkAdd' {+ return 'BeforeSheetLinkAdd' as const;+ }++ get BeforeSheetLinkCancel(): 'BeforeSheetLinkCancel' {+ return 'BeforeSheetLinkCancel' as const;+ }++ get BeforeSheetLinkUpdate(): 'BeforeSheetLinkUpdate' {+ return 'BeforeSheetLinkUpdate' as const;+ }+}++export interface IBeforeSheetLinkAddEvent extends IEventBase {+ /** The workbook instance */+ workbook: FWorkbook;+ /** The worksheet where the link will be added */+ worksheet: FWorksheet;+ /** The row index of the target cell */+ row: number;+ /** The column index of the target cell */+ col: number;+ /** The hyperlink information to be added */+ link: ISheetHyperLink;+}++export interface IBeforeSheetLinkCancelEvent extends IEventBase {+ /** The workbook instance */+ workbook: FWorkbook;+ /** The worksheet containing the link */+ worksheet: FWorksheet;+ /** The row index of the cell */+ row: number;+ /** The column index of the cell */+ column: number;+ /** The unique identifier of the hyperlink */+ id: string;+}++export interface IBeforeSheetLinkUpdateEvent extends IEventBase {+ /** The workbook instance */+ workbook: FWorkbook;+ /** The worksheet containing the link */+ worksheet: FWorksheet;+ /** The row index of the cell */+ row: number;+ /** The column index of the cell */+ column: number;+ /** The unique identifier of the hyperlink */+ id: string;+ /** The new hyperlink content/information */+ payload: ICellLinkContent;+}++export interface ISheetLinkEventConfig {+ BeforeSheetLinkAdd: IBeforeSheetLinkAddEvent;+ BeforeSheetLinkCancel: IBeforeSheetLinkCancelEvent;+ BeforeSheetLinkUpdate: IBeforeSheetLinkUpdateEvent;+}++FEventName.extend(FSheetLinkEvent);++declare module '@univerjs/core' {+ // eslint-disable-next-line ts/naming-convention+ interface FEventName extends IFSheetLinkEvent {+ }++ interface IEventParamConfig extends ISheetLinkEventConfig {+ }+}diff --git a/packages/sheets-hyper-link/src/facade/f-range.ts b/packages/sheets-hyper-link/src/facade/f-range.tsindex 7ff0d87c46..cfb6c26a8d 100644--- a/packages/sheets-hyper-link/src/facade/f-range.ts+++ b/packages/sheets-hyper-link/src/facade/f-range.ts@@ -54,11 +54,6 @@ export interface IFRangeHyperlinkMixin {export class FRangeHyperlinkMixin extends FRange implements IFRangeHyperlinkMixin {// #region hyperlink- /**- * @param url- * @param label- * @deprecated- */override setHyperLink(url: string, label?: string): Promise<boolean> {const params: IAddHyperLinkCommandParams = {unitId: this.getUnitId(),@@ -75,9 +70,6 @@ export class FRangeHyperlinkMixin extends FRange implements IFRangeHyperlinkMixireturn this._commandService.executeCommand(AddHyperLinkCommand.id, params);}- /**- * @deprecated- */override getHyperLinks(): ICellHyperLink[] {const cellValue = this._worksheet.getCellRaw(this._range.startRow, this._range.startColumn);if (!cellValue?.p) {@@ -95,12 +87,6 @@ export class FRangeHyperlinkMixin extends FRange implements IFRangeHyperlinkMixi})) ?? [];}- /**- * @param id- * @param url- * @param label- * @deprecated- */override updateHyperLink(id: string, url: string, label?: string): Promise<boolean> {const params: IUpdateHyperLinkCommandParams = {unitId: this.getUnitId(),@@ -117,10 +103,6 @@ export class FRangeHyperlinkMixin extends FRange implements IFRangeHyperlinkMixireturn this._commandService.executeCommand(UpdateHyperLinkCommand.id, params);}- /**- * @param id- * @deprecated- */override cancelHyperLink(id: string): boolean {const params: ICancelHyperLinkCommandParams = {unitId: this.getUnitId(),diff --git a/packages/sheets-hyper-link/src/facade/f-univer.ts b/packages/sheets-hyper-link/src/facade/f-univer.tsnew file mode 100644index 0000000000..6f97095416--- /dev/null+++ b/packages/sheets-hyper-link/src/facade/f-univer.ts@@ -0,0 +1,86 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Injector } from '@univerjs/core';+import type { IAddHyperLinkCommandParams, ICancelHyperLinkCommandParams, IUpdateHyperLinkCommandParams } from '@univerjs/sheets-hyper-link';+import type { IBeforeSheetLinkAddEvent, IBeforeSheetLinkCancelEvent, IBeforeSheetLinkUpdateEvent } from './f-event';+import { CanceledError, FUniver, ICommandService } from '@univerjs/core';+import { AddHyperLinkCommand, CancelHyperLinkCommand, UpdateHyperLinkCommand } from '@univerjs/sheets-hyper-link';++export class FSheetLinkUniver extends FUniver {+ override _initialize(injector: Injector): void {+ const commandService = injector.get(ICommandService);++ this.disposeWithMe(+ commandService.beforeCommandExecuted((commandInfo) => {+ if (commandInfo.id === AddHyperLinkCommand.id) {+ if (!this._eventListend(this.Event.BeforeSheetLinkAdd)) return;+ const eventTarget = this.getCommandSheetTarget(commandInfo);+ if (!eventTarget) return;+ const params = commandInfo.params as IAddHyperLinkCommandParams;+ const eventParams: IBeforeSheetLinkAddEvent = {+ workbook: eventTarget.workbook,+ worksheet: eventTarget.worksheet,+ row: params.link.row,+ col: params.link.column,+ link: params.link,+ };+ this.fireEvent(this.Event.BeforeSheetLinkAdd, eventParams);+ if (eventParams.cancel) {+ throw new CanceledError();+ }+ }++ if (commandInfo.id === UpdateHyperLinkCommand.id) {+ const eventTarget = this.getCommandSheetTarget(commandInfo);+ if (!eventTarget) return;+ const params = commandInfo.params as IUpdateHyperLinkCommandParams;+ const eventParams: IBeforeSheetLinkUpdateEvent = {+ workbook: eventTarget.workbook,+ worksheet: eventTarget.worksheet,+ row: params.row,+ column: params.column,+ id: params.id,+ payload: params.payload,+ };+ this.fireEvent(this.Event.BeforeSheetLinkUpdate, eventParams);+ if (eventParams.cancel) {+ throw new CanceledError();+ }+ }++ if (commandInfo.id === CancelHyperLinkCommand.id) {+ const eventTarget = this.getCommandSheetTarget(commandInfo);+ if (!eventTarget) return;+ const params = commandInfo.params as ICancelHyperLinkCommandParams;+ const eventParams: IBeforeSheetLinkCancelEvent = {+ workbook: eventTarget.workbook,+ worksheet: eventTarget.worksheet,+ row: params.row,+ column: params.column,+ id: params.id,+ };+ this.fireEvent(this.Event.BeforeSheetLinkCancel, eventParams);+ if (eventParams.cancel) {+ throw new CanceledError();+ }+ }+ })+ );+ }+}++FUniver.extend(FSheetLinkUniver);diff --git a/packages/sheets-hyper-link/src/facade/index.ts b/packages/sheets-hyper-link/src/facade/index.tsindex 4cee2076df..8320a45b9c 100644--- a/packages/sheets-hyper-link/src/facade/index.ts+++ b/packages/sheets-hyper-link/src/facade/index.ts@@ -17,10 +17,12 @@import './f-workbook';import './f-worksheet';import './f-range';+import './f-event';+import './f-univer';-export { FWorkbookHyperLinkMixin } from './f-workbook';--// eslint-disable-next-line perfectionist/sort-exports+export type * from './f-event';export type * from './f-range';+export type * from './f-univer';+export { FWorkbookHyperLinkMixin } from './f-workbook';export type * from './f-workbook';export type * from './f-worksheet';diff --git a/packages/sheets-ui/src/facade/f-event.ts b/packages/sheets-ui/src/facade/f-event.tsindex b60bc4148f..8e0c95da76 100644--- a/packages/sheets-ui/src/facade/f-event.ts+++ b/packages/sheets-ui/src/facade/f-event.ts@@ -16,7 +16,7 @@import type { IEventBase, IRange, RichTextValue } from '@univerjs/core';import type { DeviceInputEventType, SpreadsheetSkeleton } from '@univerjs/engine-render';-import type { CommandListenerSkeletonChange, CommandListenerValueChange } from '@univerjs/sheets';+import type { CommandListenerSkeletonChange } from '@univerjs/sheets';import type { FRange, FWorkbook, FWorksheet } from '@univerjs/sheets/facade';import type { KeyCode } from '@univerjs/ui';import { FEventName } from '@univerjs/core';@@ -520,17 +520,6 @@ export interface IFSheetsUIEventNameMixin {*/readonly SheetSkeletonChanged: 'SheetSkeletonChanged';- /**- * Event fired when sheet value changed- * @example- * ```ts- * univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (p)=> {- * const { workbook, effectedRanges, payload } = p;- * });- * ```- */- readonly SheetValueChanged: 'SheetValueChanged';-}export class FSheetsUIEventName extends FEventName implements IFSheetsUIEventNameMixin {@@ -653,10 +642,6 @@ export class FSheetsUIEventName extends FEventName implements IFSheetsUIEventNamoverride get SheetSkeletonChanged(): 'SheetSkeletonChanged' {return 'SheetSkeletonChanged' as const;}-- override get SheetValueChanged(): 'SheetValueChanged' {- return 'SheetValueChanged' as const;- }}export interface ISheetUIEventBase extends IEventBase {@@ -759,11 +744,7 @@ export interface ISheetColumnHeaderEvent extends ISheetUIEventBase {export interface ISheetSkeletonChangedEvent extends ISheetUIEventBase {skeleton: SpreadsheetSkeleton;payload: CommandListenerSkeletonChange;-}--export interface ISheetValueChangedEvent extends IEventBase {effectedRanges: FRange[];- payload: CommandListenerValueChange;}export interface IFSheetsUIEventParamConfig {@@ -771,13 +752,11 @@ export interface IFSheetsUIEventParamConfig {ClipboardChanged: IClipboardChangedParam;BeforeClipboardPaste: IBeforeClipboardPasteParam;ClipboardPasted: IClipboardPastedParam;-BeforeSheetEditStart: IBeforeSheetEditStartEventParams;SheetEditStarted: ISheetEditStartedEventParams;SheetEditChanging: ISheetEditChangingEventParams;BeforeSheetEditEnd: IBeforeSheetEditEndEventParams;SheetEditEnded: ISheetEditEndedEventParams;-CellClicked: ICellEventParam;CellHover: ICellEventParam;CellPointerDown: ICellEventParam;@@ -785,31 +764,26 @@ export interface IFSheetsUIEventParamConfig {CellPointerMove: ICellEventParam;Drop: ICellEventParam;DragOver: ICellEventParam;-RowHeaderClick: ISheetRowHeaderEvent;RowHeaderDbClick: ISheetRowHeaderEvent;RowHeaderHover: ISheetRowHeaderEvent;RowHeaderPointerDown: ISheetRowHeaderEvent;RowHeaderPointerUp: ISheetRowHeaderEvent;-ColumnHeaderClick: ISheetColumnHeaderEvent;ColumnHeaderDbClick: ISheetColumnHeaderEvent;ColumnHeaderHover: ISheetColumnHeaderEvent;ColumnHeaderPointerDown: ISheetColumnHeaderEvent;ColumnHeaderPointerUp: ISheetColumnHeaderEvent;-Scroll: IScrollEventParam;SelectionChanging: ISelectionEventParam;SelectionMoveStart: ISelectionEventParam;SelectionMoving: ISelectionEventParam;SelectionMoveEnd: ISelectionEventParam;SelectionChanged: ISelectionEventParam;-SheetZoomChanged: ISheetZoomEvent;BeforeSheetZoomChange: ISheetZoomEvent;SheetSkeletonChanged: ISheetSkeletonChangedEvent;- SheetValueChanged: ISheetValueChangedEvent;}FEventName.extend(FSheetsUIEventName);diff --git a/packages/sheets-ui/src/facade/f-range.ts b/packages/sheets-ui/src/facade/f-range.tsindex 3ee2a758f6..7724d86532 100644--- a/packages/sheets-ui/src/facade/f-range.ts+++ b/packages/sheets-ui/src/facade/f-range.ts@@ -217,6 +217,7 @@ declare module '@univerjs/sheets/facade' {* Transform component key* @param {IFComponentKey} component - The component key to transform.* @param {ComponentManager} componentManager - The component manager to use for registration.+ * @returns {string} The transformed component key.*/export function transformComponentKey(component: IFComponentKey, componentManager: ComponentManager): { key: string; disposableCollection: DisposableCollection } {const { componentKey, isVue3 } = component;diff --git a/packages/sheets-ui/src/facade/f-univer.ts b/packages/sheets-ui/src/facade/f-univer.tsindex 8ff1df9944..42c7f38de2 100644--- a/packages/sheets-ui/src/facade/f-univer.ts+++ b/packages/sheets-ui/src/facade/f-univer.ts@@ -26,14 +26,14 @@ import type {SpreadsheetColumnHeader,SpreadsheetRowHeader,} from '@univerjs/engine-render';-import type { CommandListenerSkeletonChange, CommandListenerValueChange } from '@univerjs/sheets';+import type { CommandListenerSkeletonChange } from '@univerjs/sheets';import type { IEditorBridgeServiceVisibleParam, ISetZoomRatioCommandParams, ISheetPasteByShortKeyParams, IViewportScrollState } from '@univerjs/sheets-ui';import type { FRange } from '@univerjs/sheets/facade';import type { IBeforeClipboardChangeParam, IBeforeClipboardPasteParam, IBeforeSheetEditEndEventParams, IBeforeSheetEditStartEventParams, ISheetEditChangingEventParams, ISheetEditEndedEventParams, ISheetEditStartedEventParams } from './f-event';import { CanceledError, DisposableCollection, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, FUniver, ICommandService, ILogService, IUniverInstanceService, LifecycleService, LifecycleStages, RichTextValue, toDisposable, UniverInstanceType } from '@univerjs/core';import { RichTextEditingMutation } from '@univerjs/docs';import { IRenderManagerService } from '@univerjs/engine-render';-import { COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, getValueChangedEffectedRange, SheetsSelectionsService } from '@univerjs/sheets';+import { COMMAND_LISTENER_SKELETON_CHANGE, getSkeletonChangedEffectedRange, SheetsSelectionsService } from '@univerjs/sheets';import { DragManagerService, HoverManagerService, IEditorBridgeService, ISheetClipboardService, SetCellEditVisibleOperation, SetZoomRatioCommand, SHEET_VIEW_KEY, SheetPasteShortKeyCommand, SheetScrollManagerService } from '@univerjs/sheets-ui';import { FSheetHooks } from '@univerjs/sheets/facade';import { CopyCommand, CutCommand, HTML_CLIPBOARD_MIME_TYPE, IClipboardInterfaceService, KeyCode, PasteCommand, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, supportClipboardAPI } from '@univerjs/ui';@@ -588,27 +588,21 @@ export class FUniverSheetsUIMixin extends FUniver implements IFUniverSheetsUIMixif (!this._eventListend(this.Event.SheetSkeletonChanged)) return;const sheet = this.getActiveSheet();if (!sheet) return;+ const ranges = getSkeletonChangedEffectedRange(commandInfo)+ .map((range) => this.getWorkbook(range.unitId)?.getSheetBySheetId(range.subUnitId)?.getRange(range.range))+ .filter(Boolean) as FRange[];+ if (!ranges.length) return;+this.fireEvent(this.Event.SheetSkeletonChanged, {workbook: sheet.workbook,worksheet: sheet.worksheet,payload: commandInfo as CommandListenerSkeletonChange,skeleton: sheet.worksheet.getSkeleton()!,+ effectedRanges: ranges,});return;}- if (COMMAND_LISTENER_VALUE_CHANGE.indexOf(commandInfo.id) > -1) {- if (!this._eventListend(this.Event.SheetValueChanged)) return;- const sheet = this.getActiveSheet();- if (!sheet) return;- this.fireEvent(this.Event.SheetValueChanged, {- payload: commandInfo as CommandListenerValueChange,- effectedRanges: getValueChangedEffectedRange(commandInfo).map(- (range) => this.getWorkbook(range.unitId)?.getSheetBySheetId(range.subUnitId)?.getRange(range.range)- ).filter(Boolean) as FRange[],- });- return;- }switch (commandInfo.id) {case CopyCommand.id:case CutCommand.id:diff --git a/packages/sheets-ui/src/facade/f-worksheet.ts b/packages/sheets-ui/src/facade/f-worksheet.tsindex e6e6d0b0b4..2e30989a6b 100644--- a/packages/sheets-ui/src/facade/f-worksheet.ts+++ b/packages/sheets-ui/src/facade/f-worksheet.ts@@ -20,7 +20,7 @@ import type { SpreadsheetSkeleton } from '@univerjs/engine-render';import type { IScrollState } from '@univerjs/sheets-ui';import { ICommandService } from '@univerjs/core';import { IRenderManagerService, SHEET_VIEWPORT_KEY, sheetContentViewportKeys } from '@univerjs/engine-render';-import { ChangeZoomRatioCommand, SheetScrollManagerService, SheetSkeletonManagerService, SheetsScrollRenderController } from '@univerjs/sheets-ui';+import { ChangeZoomRatioCommand, SetWorksheetColAutoWidthCommand, SheetScrollManagerService, SheetSkeletonManagerService, SheetsScrollRenderController } from '@univerjs/sheets-ui';import { FWorksheet } from '@univerjs/sheets/facade';export interface IFWorksheetSkeletonMixin {@@ -103,6 +103,19 @@ export interface IFWorksheetSkeletonMixin {*/getSkeleton(): Nullable<SpreadsheetSkeleton>;+ /**+ * Set the given column width to fix-content.+ * @param {number} columnPosition - Column position+ * @param {number} numColumn - Number of columns+ * @example+ * ```ts+ * const fWorkbook = univerAPI.getActiveWorkbook();+ * const fWorksheet = fWorkbook.getActiveSheet();+ * fWorksheet.setColumnAutoWidth(0, 3);+ * ```+ */+ setColumnAutoWidth(columnPosition: number, numColumn: number): FWorksheet;+}export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSkeletonMixin {@@ -203,6 +216,27 @@ export class FWorksheetSkeletonMixin extends FWorksheet implements IFWorksheetSkconst service = this._injector.get(IRenderManagerService).getRenderById(this._workbook.getUnitId())?.with(SheetSkeletonManagerService);return service?.getWorksheetSkeleton(this._worksheet.getSheetId())?.skeleton;}++ override setColumnAutoWidth(columnPosition: number, numColumn: number): FWorksheet {+ const unitId = this._workbook.getUnitId();+ const subUnitId = this._worksheet.getSheetId();+ const ranges = [+ {+ startColumn: columnPosition,+ endColumn: columnPosition + numColumn - 1,+ startRow: 0,+ endRow: this._worksheet.getRowCount() - 1,+ },+ ];++ this._commandService.syncExecuteCommand(SetWorksheetColAutoWidthCommand.id, {+ unitId,+ subUnitId,+ ranges,+ });++ return this;+ }}FWorksheet.extend(FWorksheetSkeletonMixin);diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.tsindex f6df7231cc..da807745d2 100644--- a/packages/sheets-ui/src/index.ts+++ b/packages/sheets-ui/src/index.ts@@ -111,6 +111,7 @@ export { SELECTION_SHAPE_DEPTH } from './services/selection/const';export { type IBaseSheetBarProps } from './views/sheet-bar/sheet-bar-tabs/SheetBarItem';// #region - all commands+export { SetWorksheetColAutoWidthCommand } from './commands/commands/set-worksheet-auto-col-width.command';export { AutoClearContentCommand, AutoFillCommand } from './commands/commands/auto-fill.command';export {type ISheetPasteByShortKeyParams,diff --git a/packages/sheets/src/basics/const/command-listener-const.ts b/packages/sheets/src/basics/const/command-listener-const.tsindex f5cff271b7..c2505d9183 100644--- a/packages/sheets/src/basics/const/command-listener-const.ts+++ b/packages/sheets/src/basics/const/command-listener-const.ts@@ -32,7 +32,7 @@ import type {import type { IToggleGridlinesMutationParams } from '../../commands/mutations/toggle-gridlines.mutation';import type { ISetWorksheetActiveOperationParams } from '../../commands/operations/set-worksheet-active.operation';import type { IAddWorksheetMergeMutationParams, IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowsMutationParams, IRemoveWorksheetMergeMutationParams, IWorksheetRangeThemeStyleMutationParams } from '../interfaces';-import { type ICommandInfo, type IRange, ObjectMatrix } from '@univerjs/core';+import { type ICommandInfo, type IRange, ObjectMatrix, RANGE_TYPE } from '@univerjs/core';import { AddWorksheetMergeMutation } from '../../commands/mutations/add-worksheet-merge.mutation';import { SetWorksheetRangeThemeStyleMutation } from '../../commands/mutations/add-worksheet-range-theme.mutation';import { DeleteWorksheetRangeThemeStyleMutation } from '../../commands/mutations/delete-worksheet-range-theme.mutation';@@ -59,6 +59,45 @@ import {import { ToggleGridlinesMutation } from '../../commands/mutations/toggle-gridlines.mutation';import { SetWorksheetActiveOperation } from '../../commands/operations/set-worksheet-active.operation';+/**+ * Enum for all skeleton change command IDs+ */+export enum SheetSkeletonChangeType {+ SET_WORKSHEET_ROW_HEIGHT = 'sheet.mutation.set-worksheet-row-height',+ SET_WORKSHEET_ROW_IS_AUTO_HEIGHT = 'sheet.mutation.set-worksheet-row-is-auto-height',+ SET_WORKSHEET_ROW_AUTO_HEIGHT = 'sheet.mutation.set-worksheet-row-auto-height',+ SET_WORKSHEET_COL_WIDTH = 'sheet.mutation.set-worksheet-col-width',+ SET_WORKSHEET_ACTIVE = 'sheet.operation.set-worksheet-active',+ MOVE_ROWS = 'sheet.mutation.move-rows',+ MOVE_COLUMNS = 'sheet.mutation.move-columns',+ SET_COL_HIDDEN = 'sheet.mutation.set-col-hidden',+ SET_COL_VISIBLE = 'sheet.mutation.set-col-visible',+ SET_ROW_HIDDEN = 'sheet.mutation.set-row-hidden',+ SET_ROW_VISIBLE = 'sheet.mutation.set-row-visible',+ INSERT_COL = 'sheet.mutation.insert-col',+ INSERT_ROW = 'sheet.mutation.insert-row',+ REMOVE_COL = 'sheet.mutation.remove-col',+ REMOVE_ROW = 'sheet.mutation.remove-row',+ TOGGLE_GRIDLINES = 'sheet.mutation.toggle-gridlines',+ SET_GRIDLINES_COLOR = 'sheet.mutation.set-gridlines-color',+}++/**+ * Enum for all value change command IDs+ */+export enum SheetValueChangeType {+ SET_RANGE_VALUES = 'sheet.mutation.set-range-values',+ MOVE_RANGE = 'sheet.mutation.move-range',+ REMOVE_WORKSHEET_MERGE = 'sheet.mutation.remove-worksheet-merge',+ ADD_WORKSHEET_MERGE = 'sheet.mutation.add-worksheet-merge',+ REORDER_RANGE = 'sheet.mutation.reorder-range',+ SET_WORKSHEET_DEFAULT_STYLE = 'sheet.mutation.set-worksheet-default-style',+ SET_ROW_DATA = 'sheet.mutation.set-row-data',+ SET_COL_DATA = 'sheet.mutation.set-col-data',+ SET_WORKSHEET_RANGE_THEME_STYLE = 'sheet.mutation.set-worksheet-range-theme-style',+ DELETE_WORKSHEET_RANGE_THEME_STYLE = 'sheet.mutation.delete-worksheet-range-theme-style',+}+/*** Mutations those will trigger the skeleton change.*/@@ -82,135 +121,135 @@ export const COMMAND_LISTENER_SKELETON_CHANGE = [SetGridlinesColorMutation.id,];+export const COMMAND_LISTENER_VALUE_CHANGE = [+ SetRangeValuesMutation.id,+ MoveRangeMutation.id,+ RemoveWorksheetMergeMutation.id,+ AddWorksheetMergeMutation.id,+ ReorderRangeMutation.id,+ SetWorksheetDefaultStyleMutation.id,+ SetRowDataMutation.id,+ SetColDataMutation.id,+ SetWorksheetRangeThemeStyleMutation.id,+ DeleteWorksheetRangeThemeStyleMutation.id,+];+export type CommandListenerSkeletonChange =| {- id: 'sheet.mutation.set-worksheet-row-height';+ id: SheetSkeletonChangeType.SET_WORKSHEET_ROW_HEIGHT;params: ISetWorksheetRowHeightMutationParams;}| {- id: 'sheet.mutation.set-worksheet-row-is-auto-height';+ id: SheetSkeletonChangeType.SET_WORKSHEET_ROW_IS_AUTO_HEIGHT;params: ISetWorksheetRowIsAutoHeightMutationParams;}| {- id: 'sheet.mutation.set-worksheet-row-auto-height';+ id: SheetSkeletonChangeType.SET_WORKSHEET_ROW_AUTO_HEIGHT;params: ISetWorksheetRowAutoHeightMutationParams;}| {- id: 'sheet.mutation.set-worksheet-col-width';+ id: SheetSkeletonChangeType.SET_WORKSHEET_COL_WIDTH;params: ISetWorksheetColWidthMutationParams;}| {- id: 'sheet.operation.set-worksheet-active';+ id: SheetSkeletonChangeType.SET_WORKSHEET_ACTIVE;params: ISetWorksheetActiveOperationParams;}| {- id: 'sheet.mutation.move-rows';+ id: SheetSkeletonChangeType.MOVE_ROWS;params: IMoveRowsMutationParams;}| {- id: 'sheet.mutation.move-cols';+ id: SheetSkeletonChangeType.MOVE_COLUMNS;params: IMoveColumnsMutationParams;}| {- id: 'sheet.mutation.set-col-hidden';+ id: SheetSkeletonChangeType.SET_COL_HIDDEN;params: ISetColHiddenMutationParams;}| {- id: 'sheet.mutation.set-col-visible';+ id: SheetSkeletonChangeType.SET_COL_VISIBLE;params: ISetColVisibleMutationParams;}| {- id: 'sheet.mutation.set-row-hidden';+ id: SheetSkeletonChangeType.SET_ROW_HIDDEN;params: ISetRowHiddenMutationParams;}| {- id: 'sheet.mutation.set-row-visible';+ id: SheetSkeletonChangeType.SET_ROW_VISIBLE;params: ISetRowVisibleMutationParams;}| {- id: 'sheet.mutation.insert-col';+ id: SheetSkeletonChangeType.INSERT_COL;params: IInsertColMutationParams;}| {- id: 'sheet.mutation.insert-row';+ id: SheetSkeletonChangeType.INSERT_ROW;params: IInsertRowMutationParams;}| {- id: 'sheet.mutation.remove-col';+ id: SheetSkeletonChangeType.REMOVE_COL;params: IRemoveColMutationParams;}| {- id: 'sheet.mutation.remove-row';+ id: SheetSkeletonChangeType.REMOVE_ROW;params: IRemoveRowsMutationParams;}| {- id: 'sheet.mutation.toggle-gridlines';+ id: SheetSkeletonChangeType.TOGGLE_GRIDLINES;params: IToggleGridlinesMutationParams;}| {- id: 'sheet.mutation.set-gridlines-color';+ id: SheetSkeletonChangeType.SET_GRIDLINES_COLOR;params: ISetGridlinesColorMutationParams;};-export const COMMAND_LISTENER_VALUE_CHANGE = [- SetRangeValuesMutation.id,- MoveRangeMutation.id,- RemoveWorksheetMergeMutation.id,- AddWorksheetMergeMutation.id,- ReorderRangeMutation.id,- SetWorksheetDefaultStyleMutation.id,- SetRowDataMutation.id,- SetColDataMutation.id,- SetWorksheetRangeThemeStyleMutation.id,- DeleteWorksheetRangeThemeStyleMutation.id,-];-export type CommandListenerValueChange =| {- id: 'sheet.mutation.set-range-values';+ id: SheetValueChangeType.SET_RANGE_VALUES;params: ISetRangeValuesMutationParams;}| {- id: 'sheet.mutation.move-range';+ id: SheetValueChangeType.MOVE_RANGE;params: IMoveRangeMutationParams;}| {- id: 'sheet.mutation.remove-worksheet-merge';+ id: SheetValueChangeType.REMOVE_WORKSHEET_MERGE;params: IRemoveWorksheetMergeMutationParams;}| {- id: 'sheet.mutation.add-worksheet-merge';+ id: SheetValueChangeType.ADD_WORKSHEET_MERGE;params: IAddWorksheetMergeMutationParams;}| {- id: 'sheet.mutation.reorder-range';+ id: SheetValueChangeType.REORDER_RANGE;params: IReorderRangeMutationParams;}| {- id: 'sheet.mutation.set-worksheet-default-style';+ id: SheetValueChangeType.SET_WORKSHEET_DEFAULT_STYLE;params: ISetWorksheetDefaultStyleMutationParams;}| {- id: 'sheet.mutation.set-row-data';+ id: SheetValueChangeType.SET_ROW_DATA;params: ISetRowDataMutationParams;}| {- id: 'sheet.mutation.set-col-data';+ id: SheetValueChangeType.SET_COL_DATA;params: ISetColDataMutationParams;}| {- id: 'sheet.mutation.set-worksheet-range-theme-style';+ id: SheetValueChangeType.SET_WORKSHEET_RANGE_THEME_STYLE;params: IWorksheetRangeThemeStyleMutationParams;}| {- id: 'sheet.mutation.delete-worksheet-range-theme-style';+ id: SheetValueChangeType.DELETE_WORKSHEET_RANGE_THEME_STYLE;params: IWorksheetRangeThemeStyleMutationParams;};// eslint-disable-next-line max-lines-per-functionexport function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitId: string;subUnitId: string; range: IRange }[] {switch (commandInfo.id) {- case SetRangeValuesMutation.id: {+ case SheetValueChangeType.SET_RANGE_VALUES: {const params = commandInfo.params as ISetRangeValuesMutationParams;return params.cellValue? [{@@ -221,7 +260,7 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI: [];}- case MoveRangeMutation.id: {+ case SheetValueChangeType.MOVE_RANGE: {const params = commandInfo.params as IMoveRangeMutationParams;return [{unitId: params.unitId,@@ -234,7 +273,7 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}];}- case RemoveWorksheetMergeMutation.id: {+ case SheetValueChangeType.REMOVE_WORKSHEET_MERGE: {const params = commandInfo.params as IRemoveWorksheetMergeMutationParams;return params.ranges.map((range) => ({unitId: params.unitId,@@ -243,7 +282,7 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}));}- case AddWorksheetMergeMutation.id: {+ case SheetValueChangeType.ADD_WORKSHEET_MERGE: {const params = commandInfo.params as IAddWorksheetMergeMutationParams;return params.ranges.map((range) => ({unitId: params.unitId,@@ -252,7 +291,7 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}));}- case ReorderRangeMutation.id: {+ case SheetValueChangeType.REORDER_RANGE: {const params = commandInfo.params as IReorderRangeMutationParams;return [{unitId: params.unitId,@@ -261,7 +300,7 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}];}- case SetWorksheetDefaultStyleMutation.id: {+ case SheetValueChangeType.SET_WORKSHEET_DEFAULT_STYLE: {const params = commandInfo.params as ISetWorksheetDefaultStyleMutationParams;return [{unitId: params.unitId,@@ -270,7 +309,7 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}];}- case SetRowDataMutation.id: {+ case SheetValueChangeType.SET_ROW_DATA: {const params = commandInfo.params as ISetRowDataMutationParams;const rowIndices = Object.keys(params.rowData).map(Number);if (rowIndices.length === 0) return [];@@ -286,7 +325,7 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}];}- case SetColDataMutation.id: {+ case SheetValueChangeType.SET_COL_DATA: {const params = commandInfo.params as ISetColDataMutationParams;const colIndices = Object.keys(params.columnData).map(Number);if (colIndices.length === 0) return [];@@ -302,7 +341,8 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}];}- case SetWorksheetRangeThemeStyleMutation.id: {+ case SheetValueChangeType.SET_WORKSHEET_RANGE_THEME_STYLE:+ case SheetValueChangeType.DELETE_WORKSHEET_RANGE_THEME_STYLE: {const params = commandInfo.params as IWorksheetRangeThemeStyleMutationParams;return [{unitId: params.unitId,@@ -311,15 +351,138 @@ export function getValueChangedEffectedRange(commandInfo: ICommandInfo): { unitI}];}- case DeleteWorksheetRangeThemeStyleMutation.id: {- const params = commandInfo.params as IWorksheetRangeThemeStyleMutationParams;+ default:+ return [];+ }+}++/**+ * Get the affected range for skeleton change commands+ * @param {ICommandInfo} commandInfo The command information+ * @returns {{ unitId: string; subUnitId: string; range: IRange }[]} Array of affected ranges+ */+// eslint-disable-next-line max-lines-per-function+export function getSkeletonChangedEffectedRange(commandInfo: ICommandInfo): { unitId: string; subUnitId: string; range: IRange }[] {+ switch (commandInfo.id) {+ case SheetSkeletonChangeType.SET_WORKSHEET_ROW_HEIGHT:+ case SheetSkeletonChangeType.SET_WORKSHEET_ROW_IS_AUTO_HEIGHT:+ case SheetSkeletonChangeType.SET_WORKSHEET_ROW_AUTO_HEIGHT: {+ const params = commandInfo.params as ISetWorksheetRowHeightMutationParams;+ return params.ranges.map((range) => ({+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...range,+ rangeType: RANGE_TYPE.ROW,+ },+ }));+ }++ case SheetSkeletonChangeType.SET_WORKSHEET_COL_WIDTH: {+ const params = commandInfo.params as ISetWorksheetColWidthMutationParams;+ return params.ranges.map((range) => ({+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...range,+ rangeType: RANGE_TYPE.COLUMN,+ },+ }));+ }++ case SheetSkeletonChangeType.MOVE_ROWS:+ case SheetSkeletonChangeType.MOVE_COLUMNS: {+ const params = commandInfo.params as IMoveRowsMutationParams;return [{unitId: params.unitId,subUnitId: params.subUnitId,- range: params.range,+ range: params.targetRange,+ }, {+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: params.sourceRange,}];}+ case SheetSkeletonChangeType.SET_COL_HIDDEN:+ case SheetSkeletonChangeType.SET_COL_VISIBLE: {+ const params = commandInfo.params as ISetColVisibleMutationParams;+ return params.ranges.map((range) => ({+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...range,+ rangeType: RANGE_TYPE.COLUMN,+ },+ }));+ }++ case SheetSkeletonChangeType.SET_ROW_HIDDEN:+ case SheetSkeletonChangeType.SET_ROW_VISIBLE: {+ const params = commandInfo.params as ISetRowVisibleMutationParams;+ return params.ranges.map((range) => ({+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...range,+ rangeType: RANGE_TYPE.ROW,+ },+ }));+ }++ case SheetSkeletonChangeType.INSERT_COL: {+ const params = commandInfo.params as IInsertColMutationParams;+ return [{+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...params.range,+ rangeType: RANGE_TYPE.COLUMN,+ },+ }];+ }++ case SheetSkeletonChangeType.INSERT_ROW: {+ const params = commandInfo.params as IInsertRowMutationParams;+ return [{+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...params.range,+ rangeType: RANGE_TYPE.ROW,+ },+ }];+ }++ case SheetSkeletonChangeType.REMOVE_COL: {+ const params = commandInfo.params as IRemoveColMutationParams;+ return [{+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...params.range,+ rangeType: RANGE_TYPE.COLUMN,+ },+ }];+ }++ case SheetSkeletonChangeType.REMOVE_ROW: {+ const params = commandInfo.params as IRemoveRowsMutationParams;+ return [{+ unitId: params.unitId,+ subUnitId: params.subUnitId,+ range: {+ ...params.range,+ rangeType: RANGE_TYPE.ROW,+ },+ }];+ }++ case SheetSkeletonChangeType.TOGGLE_GRIDLINES:+ case SheetSkeletonChangeType.SET_GRIDLINES_COLOR: {+ return [];+ }+default:return [];}diff --git a/packages/sheets/src/facade/f-enum.ts b/packages/sheets/src/facade/f-enum.tsnew file mode 100644index 0000000000..6e6ffcf335--- /dev/null+++ b/packages/sheets/src/facade/f-enum.ts@@ -0,0 +1,49 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { FEnum } from '@univerjs/core';+import { SheetSkeletonChangeType, SheetValueChangeType } from '@univerjs/sheets';++export interface IFSheetsEnum {+ /**+ * Sheet value change command types. These commands affect the content or style of cells.+ * Includes operations like setting cell values, moving ranges, merging cells, and applying styles.+ */+ SheetValueChangeType: typeof SheetValueChangeType;++ /**+ * Sheet skeleton change command types. These commands affect the structure of the worksheet.+ * Includes operations like changing row/column dimensions, visibility, and grid properties.+ */+ SheetSkeletonChangeType: typeof SheetSkeletonChangeType;+}++export class FSheetsEnum implements IFSheetsEnum {+ get SheetValueChangeType(): typeof SheetValueChangeType {+ return SheetValueChangeType;+ }++ get SheetSkeletonChangeType(): typeof SheetSkeletonChangeType {+ return SheetSkeletonChangeType;+ }+}++FEnum.extend(FSheetsEnum);+declare module '@univerjs/core' {+ // eslint-disable-next-line ts/naming-convention+ export interface FEnum extends IFSheetsEnum {+ }+}diff --git a/packages/sheets/src/facade/f-event.ts b/packages/sheets/src/facade/f-event.tsindex e18933e638..4620d3bb0b 100644--- a/packages/sheets/src/facade/f-event.ts+++ b/packages/sheets/src/facade/f-event.ts@@ -15,6 +15,8 @@*/import type { IEventBase, IWorkbookData, IWorksheetData, UniverInstanceType } from '@univerjs/core';+import type { CommandListenerValueChange } from '@univerjs/sheets';+import type { FRange } from './f-range';import type { FWorkbook } from './f-workbook';import type { FWorksheet } from './f-worksheet';import { FEventName } from '@univerjs/core';@@ -255,6 +257,18 @@ export interface IFSheetEventMixin {* ```*/get BeforeGridlineColorChange(): 'BeforeGridlineColorChange';++ /**+ * Event fired when sheet value changed+ * @example+ * ```ts+ * univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (p)=> {+ * const { workbook, effectedRanges, payload } = p;+ * });+ * ```+ */+ readonly SheetValueChanged: 'SheetValueChanged';+}/**@@ -506,6 +520,17 @@ export interface IBeforeSheetHideChangeEvent extends IEventBase {hidden: boolean;}+/**+ * Interface for sheet value changed event+ * Contains information about the sheet value change+ */+export interface ISheetValueChangedEvent extends IEventBase {+ /** The affected ranges of the sheet */+ effectedRanges: FRange[];+ /** The payload of the value change */+ payload: CommandListenerValueChange;+}+/*** Configuration interface for sheet-related events* Provides event names and their corresponding event parameter interfaces@@ -549,6 +574,8 @@ export interface ISheetEventParamConfig {SheetHideChanged: ISheetHideChangedEvent;/** Event fired before a sheet visibility is changed */BeforeSheetHideChange: IBeforeSheetHideChangeEvent;+ /** Event fired after a sheet value is changed */+ SheetValueChanged: ISheetValueChangedEvent;}export class FSheetEventName extends FEventName implements IFSheetEventMixin {@@ -627,6 +654,10 @@ export class FSheetEventName extends FEventName implements IFSheetEventMixin {override get BeforeSheetHideChange(): 'BeforeSheetHideChange' {return 'BeforeSheetHideChange' as const;}++ override get SheetValueChanged(): 'SheetValueChanged' {+ return 'SheetValueChanged' as const;+ }}FEventName.extend(FSheetEventName);diff --git a/packages/sheets/src/facade/f-univer.ts b/packages/sheets/src/facade/f-univer.tsindex 033775e11c..9af28287b0 100644--- a/packages/sheets/src/facade/f-univer.ts+++ b/packages/sheets/src/facade/f-univer.ts@@ -15,11 +15,12 @@*/import type { ICommandInfo, IDisposable, Injector, IWorkbookData, Nullable, Workbook } from '@univerjs/core';-import type { IInsertSheetCommandParams, IRemoveSheetCommandParams, ISetGridlinesColorCommandParams, ISetTabColorMutationParams, ISetWorksheetActivateCommandParams, ISetWorksheetHideMutationParams, ISetWorksheetNameCommandParams, ISetWorksheetOrderMutationParams, IToggleGridlinesCommandParams } from '@univerjs/sheets';+import type { CommandListenerValueChange, IInsertSheetCommandParams, IRemoveSheetCommandParams, ISetGridlinesColorCommandParams, ISetTabColorMutationParams, ISetWorksheetActivateCommandParams, ISetWorksheetHideMutationParams, ISetWorksheetNameCommandParams, ISetWorksheetOrderMutationParams, IToggleGridlinesCommandParams } from '@univerjs/sheets';import type { IBeforeSheetCreateEventParams, ISheetCreatedEventParams } from './f-event';+import type { FRange } from './f-range';import type { FWorksheet } from './f-worksheet';import { CanceledError, FUniver, ICommandService, IUniverInstanceService, toDisposable, UniverInstanceType } from '@univerjs/core';-import { InsertSheetCommand, RemoveSheetCommand, SetGridlinesColorCommand, SetTabColorCommand, SetWorksheetActivateCommand, SetWorksheetHideCommand, SetWorksheetNameCommand, SetWorksheetOrderCommand, ToggleGridlinesCommand } from '@univerjs/sheets';+import { COMMAND_LISTENER_VALUE_CHANGE, getValueChangedEffectedRange, InsertSheetCommand, RemoveSheetCommand, SetGridlinesColorCommand, SetTabColorCommand, SetWorksheetActivateCommand, SetWorksheetHideCommand, SetWorksheetNameCommand, SetWorksheetOrderCommand, ToggleGridlinesCommand } from '@univerjs/sheets';import { FDefinedNameBuilder } from './f-defined-name';import { FPermission } from './f-permission';import { FWorkbook } from './f-workbook';@@ -304,6 +305,25 @@ export class FUniverSheetsMixin extends FUniver implements IFUniverSheetsMixin {this.disposeWithMe(// eslint-disable-next-line max-lines-per-function, complexitycommandService.onCommandExecuted((commandInfo) => {+ if (COMMAND_LISTENER_VALUE_CHANGE.indexOf(commandInfo.id) > -1) {+ if (!this._eventListend(this.Event.SheetValueChanged)) return;+ const sheet = this.getActiveSheet();+ if (!sheet) return;+ const ranges = getValueChangedEffectedRange(commandInfo)+ .map(+ (range) => this.getWorkbook(range.unitId)+ ?.getSheetBySheetId(range.subUnitId)+ ?.getRange(range.range)+ )+ .filter(Boolean) as FRange[];+ if (!ranges.length) return;+ this.fireEvent(this.Event.SheetValueChanged, {+ payload: commandInfo as CommandListenerValueChange,+ effectedRanges: ranges,+ });+ return;+ }+switch (commandInfo.id) {case InsertSheetCommand.id: {const params = commandInfo.params as IInsertSheetCommandParams;diff --git a/packages/sheets/src/facade/f-worksheet.ts b/packages/sheets/src/facade/f-worksheet.tsindex 26d90d37b7..9941a2cb94 100644--- a/packages/sheets/src/facade/f-worksheet.ts+++ b/packages/sheets/src/facade/f-worksheet.ts@@ -35,6 +35,16 @@ interface IFacadeClearOptions {* Represents a worksheet facade api instance. Which provides a set of methods to interact with the worksheet.*/export class FWorksheet extends FBaseInitialable {+ /**+ * Creates a new worksheet facade instance+ * @param {FWorkbook} _fWorkbook - The facade workbook instance+ * @param {Workbook} _workbook - The workbook instance+ * @param {Worksheet} _worksheet - The worksheet instance+ * @param {Injector} _injector - The injector instance+ * @param {SheetsSelectionsService} _selectionManagerService - The selection manager service+ * @param {ILogService} _logService - The log service+ * @param {ICommandService} _commandService - The command service+ */constructor(protected readonly _fWorkbook: FWorkbook,protected readonly _workbook: Workbook,@@ -61,7 +71,7 @@ export class FWorksheet extends FBaseInitialable {/*** Returns the injector- * @returns The injector+ * @returns {Injector} The injector* @example* ```typescript* const injector = univerAPI.getActiveWorkbook().getActiveSheet().getInject();@@ -146,9 +156,9 @@ export class FWorksheet extends FBaseInitialable {/*** Get the default style of the worksheet row- * @param {number} index The row index- * @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from row manager- * @returns {Nullable<IStyleData> | string} The default style of the worksheet row name or style data+ * @param {number} index - The row index+ * @param {boolean} [keepRaw] - If true, return the raw style data maybe the style name or style data, otherwise return the data from row manager+ * @returns {(Nullable<IStyleData> | string)} The default style of the worksheet row name or style data* @example* ```typescript* const sheet = univerAPI.getActiveWorkbook().getActiveSheet();@@ -164,9 +174,9 @@ 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- * @returns {Nullable<IStyleData> | string} The default style of the worksheet column name or style data+ * @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+ * @returns {(Nullable<IStyleData> | string)} The default style of the worksheet column name or style data* @example* ```typescript* const sheet = univerAPI.getActiveWorkbook().getActiveSheet();@@ -182,10 +192,10 @@ export class FWorksheet extends FBaseInitialable {/*** Set the default style of the worksheet- * @param {StyleDataInfo} style default style- * @returns {FWorksheet} This sheet, for chaining.+ * @param {string} style - The style to set+ * @returns {FWorksheet} This worksheet instance for chaining* @example- * ```ts+ * ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorksheet = fWorkbook.getActiveSheet();* fWorksheet.setDefaultStyle('default');@@ -205,8 +215,8 @@ export class FWorksheet extends FBaseInitialable {/*** Set the default style of the worksheet row- * @param {number} index The row index- * @param {string | Nullable<IStyleData>} style The style name or style data+ * @param {number} index - The row index+ * @param {string | Nullable<IStyleData>} style - The style name or style data* @returns {FWorksheet} This sheet, for chaining.* @example* ```ts@@ -235,8 +245,8 @@ export class FWorksheet extends FBaseInitialable {/*** Set the default style of the worksheet column- * @param {number} index The column index- * @param {string | Nullable<IStyleData>} style The style name or style data+ * @param {number} index - The column index+ * @param {string | Nullable<IStyleData>} style - The style name or style data* @returns {FWorksheet} This sheet, for chaining.* @example* ```ts@@ -267,9 +277,9 @@ export class FWorksheet extends FBaseInitialable {/*** Returns a Range object representing a single cell at the specified row and column.- * @param row The row index of the cell.- * @param column The column index of the cell.- * @returns A Range object representing the specified cell.+ * @param {number} row - The row index of the cell.+ * @param {number} column - The column index of the cell.+ * @returns {FRange} A Range object representing the specified cell.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -280,25 +290,25 @@ export class FWorksheet extends FBaseInitialable {getRange(row: number, column: number): FRange;/*** Returns a Range object representing a range starting at the specified row and column, with the specified number of rows.- * @param row The starting row index of the range.- * @param column The starting column index of the range.- * @param numRows The number of rows in the range.- * @returns A Range object representing the specified range.+ * @param {number} row - The starting row index of the range.+ * @param {number} column - The starting column index of the range.+ * @param {number} numRows - The number of rows in the range.+ * @returns {FRange} A Range object representing the specified range.*/getRange(row: number, column: number, numRows: number): FRange;/*** Returns a Range object representing a range starting at the specified row and column, with the specified number of rows and columns.- * @param row The starting row index of the range.- * @param column The starting column index of the range.- * @param numRows The number of rows in the range.- * @param numColumns The number of columns in the range.- * @returns A Range object representing the specified range.+ * @param {number} row - The starting row index of the range.+ * @param {number} column - The starting column index of the range.+ * @param {number} numRows - The number of rows in the range.+ * @param {number} numColumns - The number of columns in the range.+ * @returns {FRange} A Range object representing the specified range.*/getRange(row: number, column: number, numRows: number, numColumns: number): FRange;/*** Returns a Range object specified by A1 notation.- * @param a1Notation A string representing a range in A1 notation.- * @returns A Range object representing the specified range.+ * @param {string} a1Notation - A string representing a range in A1 notation.+ * @returns {FRange} A Range object representing the specified range.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -311,6 +321,11 @@ export class FWorksheet extends FBaseInitialable {* ```*/getRange(a1Notation: string): FRange;+ /**+ * Returns a Range object for the specified range.+ * @param {IRange} range - The range specification.+ * @returns {FRange} A Range object representing the specified range.+ */getRange(range: IRange): FRange;getRange(rowOrA1Notation: IRange | number | string, column?: number, numRows?: number, numColumns?: number): FRange {let range: IRange;@@ -389,7 +404,7 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a row after the given row position.- * @param {number} afterPosition The row after which the new row should be added, starting at 0 for the first row.+ * @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.* @example* ```typescript@@ -406,7 +421,7 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a row before the given row position.- * @param {number} beforePosition The row before which the new row should be added, starting at 0 for the first row.+ * @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.* @example* ```typescript@@ -423,9 +438,9 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts one or more consecutive blank rows in a sheet starting at the specified location.- * @param rowIndex The index indicating where to insert a row, starting at 0 for the first row.- * @param numRows The number of rows to insert.- * @returns This sheet, for chaining.+ * @param {number} rowIndex - The index indicating where to insert a row, starting at 0 for the first row.+ * @param {number} numRows - The number of rows to insert.+ * @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -441,9 +456,9 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a number of rows after the given row position.- * @param afterPosition The row after which the new rows should be added, starting at 0 for the first row.- * @param howMany The number of rows to insert.- * @returns This sheet, for chaining.+ * @param {number} afterPosition - The row after which the new rows should be added, starting at 0 for the first row.+ * @param {number} howMany - The number of rows to insert.+ * @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -484,9 +499,9 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a number of rows before the given row position.- * @param beforePosition The row before which the new rows should be added, starting at 0 for the first row.- * @param howMany The number of rows to insert.- * @returns This sheet, for chaining.+ * @param {number} beforePosition - The row before which the new rows should be added, starting at 0 for the first row.+ * @param {number} howMany - The number of rows to insert.+ * @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -527,8 +542,8 @@ export class FWorksheet extends FBaseInitialable {/*** Deletes the row at the given row position.- * @param rowPosition The position of the row, starting at 0 for the first row.- * @returns This sheet, for chaining.+ * @param {number} rowPosition - The position of the row, starting at 0 for the first row.+ * @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -544,9 +559,9 @@ export class FWorksheet extends FBaseInitialable {/*** Deletes a number of rows starting at the given row position.- * @param rowPosition The position of the first row to delete, starting at 0 for the first row.- * @param howMany The number of rows to delete.- * @returns This sheet, for chaining.+ * @param {number} rowPosition - The position of the first row to delete, starting at 0 for the first row.+ * @param {number} howMany - The number of rows to delete.+ * @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -575,9 +590,9 @@ export class FWorksheet extends FBaseInitialable {/*** Moves the rows selected by the given range to the position indicated by the destinationIndex. The rowSpec itself does not have to exactly represent an entire row or group of rows to move—it selects all rows that the range spans.- * @param rowSpec A range spanning the rows that should be moved.- * @param destinationIndex The index that the rows should be moved to. Note that this index is based on the coordinates before the rows are moved. Existing data is shifted down to make room for the moved rows while the source rows are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.- * @returns This sheet, for chaining.+ * @param {FRange} rowSpec - A range spanning the rows that should be moved.+ * @param {number} destinationIndex - The index that the rows should be moved to. Note that this index is based on the coordinates before the rows are moved. Existing data is shifted down to make room for the moved rows while the source rows are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.+ * @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -612,7 +627,7 @@ export class FWorksheet extends FBaseInitialable {/*** Hides the rows in the given range.- * @param {number} row The row range to hide.+ * @param {FRange} row - The row range to hide.* @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript@@ -638,9 +653,9 @@ export class FWorksheet extends FBaseInitialable {}/**- * Hides one or more consecutive rows starting at the given index. Use 0-index for this method.- * @param {number} rowIndex The starting index of the rows to hide.- * @param {number} numRows The number of rows to hide.+ * Hides one or more consecutive rows starting at the given index. Use 0-index for this method+ * @param {number} rowIndex - The starting index of the rows to hide+ * @param {number} numRow - The number of rows to hide* @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript@@ -651,12 +666,12 @@ export class FWorksheet extends FBaseInitialable {* sheet.hideRows(0);* ```*/- hideRows(rowIndex: number, numRows: number = 1): FWorksheet {+ hideRows(rowIndex: number, numRow: number = 1): FWorksheet {const unitId = this._workbook.getUnitId();const subUnitId = this._worksheet.getSheetId();const range: IRange = {startRow: rowIndex,- endRow: rowIndex + numRows - 1,+ endRow: rowIndex + numRow - 1,startColumn: 0,endColumn: this._worksheet.getColumnCount() - 1,rangeType: RANGE_TYPE.ROW,@@ -672,7 +687,7 @@ export class FWorksheet extends FBaseInitialable {/*** Make the row in the given range visible.- * @param {FRange} row The range to unhide, if hidden.+ * @param {FRange} row - The range to unhide, if hidden.* @returns {FWorksheet} This sheet, for chaining.* @example* ```typescript@@ -699,9 +714,9 @@ export class FWorksheet extends FBaseInitialable {/*** 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.+ * @param {number} rowIndex - The starting index of the rows+ * @param {number} numRow - The number of rows+ * @returns {FWorksheet} This worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -711,12 +726,12 @@ export class FWorksheet extends FBaseInitialable {* sheet.showRows(0);* ```*/- showRows(rowIndex: number, numRows: number = 1): FWorksheet {+ showRows(rowIndex: number, numRow: number = 1): FWorksheet {const unitId = this._workbook.getUnitId();const subUnitId = this._worksheet.getSheetId();const range: IRange = {startRow: rowIndex,- endRow: rowIndex + numRows - 1,+ endRow: rowIndex + numRow - 1,startColumn: 0,endColumn: this._worksheet.getColumnCount() - 1,rangeType: RANGE_TYPE.ROW,@@ -733,9 +748,9 @@ 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 {number} rowPosition The row position to change.- * @param {number} height The height in pixels to set it to.- * @returns {FWorksheet} 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 worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -752,10 +767,10 @@ export class FWorksheet extends FBaseInitialable {/*** 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.+ * @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 worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -807,12 +822,44 @@ export class FWorksheet extends FBaseInitialable {return this;}+ /**+ * Sets the height of the given rows to auto.+ * @param {number} startRow - The starting row position to change+ * @param {number} numRows - The number of rows to change+ * @returns {FWorksheet} This worksheet instance for chaining+ * @example+ * ```typescript+ * const sheet = workbook.getActiveSheet();+ * sheet.setRowAutoHeight(1, 10);+ * ```+ */+ setRowAutoHeight(startRow: number, numRows: number): FWorksheet {+ const unitId = this._workbook.getUnitId();+ const subUnitId = this._worksheet.getSheetId();+ const ranges = [+ {+ startRow,+ endRow: startRow + numRows - 1,+ startColumn: 0,+ endColumn: this._worksheet.getColumnCount() - 1,+ },+ ];++ this._commandService.syncExecuteCommand(SetWorksheetRowIsAutoHeightCommand.id, {+ unitId,+ subUnitId,+ ranges,+ });++ return this;+ }+/*** 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 {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.+ * @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 worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -845,10 +892,10 @@ export class FWorksheet extends FBaseInitialable {/*** Set custom properties for given rows.- * @param custom The custom properties to set.- * @returns This sheet, for chaining.+ * @param {IObjectArrayPrimitiveType<CustomData>} custom - The custom properties to set+ * @returns {FWorksheet} This worksheet instance for chaining* @example- * ```ts+ * ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorkSheet = fWorkbook.getActiveSheet();* fWorkSheet.setRowCustom({ key: 'value' });@@ -880,8 +927,8 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a column after the given column position.- * @param afterPosition The column after which the new column should be added, starting at 0 for the first column.- * @returns This sheet, for chaining.+ * @param {number} afterPosition - The column after which the new column should be added, starting at 0 for the first column+ * @returns {FWorksheet} This worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -897,8 +944,8 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a column before the given column position.- * @param beforePosition The column before which the new column should be added, starting at 0 for the first column.- * @returns This sheet, for chaining.+ * @param {number} beforePosition - The column before which the new column should be added, starting at 0 for the first column+ * @returns {FWorksheet} This worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -914,9 +961,9 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts one or more consecutive blank columns in a sheet starting at the specified location.- * @param columnIndex The index indicating where to insert a column, starting at 0 for the first column.- * @param numColumns The number of columns to insert.- * @returns This sheet, for chaining.+ * @param {number} columnIndex - The index indicating where to insert a column, starting at 0 for the first column+ * @param {number} numColumns - The number of columns to insert+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -932,9 +979,9 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a given number of columns after the given column position.- * @param afterPosition The column after which the new column should be added, starting at 0 for the first column.- * @param howMany The number of columns to insert.- * @returns This sheet, for chaining.+ * @param {number} afterPosition - The column after which the new columns should be added, starting at 0 for the first column+ * @param {number} howMany - The number of columns to insert+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -975,9 +1022,9 @@ export class FWorksheet extends FBaseInitialable {/*** Inserts a number of columns before the given column position.- * @param beforePosition The column before which the new column should be added, starting at 0 for the first column.- * @param howMany The number of columns to insert.- * @returns This sheet, for chaining.+ * @param {number} beforePosition - The column before which the new columns should be added, starting at 0 for the first column+ * @param {number} howMany - The number of columns to insert+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1018,8 +1065,8 @@ export class FWorksheet extends FBaseInitialable {/*** Deletes the column at the given column position.- * @param columnPosition The position of the column, starting at 0 for the first column.- * @returns This sheet, for chaining.+ * @param {number} columnPosition - The position of the column, starting at 0 for the first column+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1035,9 +1082,9 @@ export class FWorksheet extends FBaseInitialable {/*** Deletes a number of columns starting at the given column position.- * @param columnPosition The position of the first column to delete, starting at 0 for the first column.- * @param howMany The number of columns to delete.- * @returns This sheet, for chaining.+ * @param {number} columnPosition - The position of the first column to delete, starting at 0 for the first column+ * @param {number} howMany - The number of columns to delete+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1066,9 +1113,9 @@ export class FWorksheet extends FBaseInitialable {/*** Moves the columns selected by the given range to the position indicated by the destinationIndex. The columnSpec itself does not have to exactly represent an entire column or group of columns to move—it selects all columns that the range spans.- * @param columnSpec A range spanning the columns that should be moved.- * @param destinationIndex The index that the columns should be moved to. Note that this index is based on the coordinates before the columns are moved. Existing data is shifted right to make room for the moved columns while the source columns are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.- * @returns This sheet, for chaining.+ * @param {FRange} columnSpec - A range spanning the columns that should be moved+ * @param {number} destinationIndex - The index that the columns should be moved to. Note that this index is based on the coordinates before the columns are moved. Existing data is shifted right to make room for the moved columns while the source columns are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1103,8 +1150,8 @@ export class FWorksheet extends FBaseInitialable {/*** Hides the column or columns in the given range.- * @param column The column range to hide.- * @returns This sheet, for chaining.+ * @param {FRange} column - The column range to hide+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1129,10 +1176,10 @@ export class FWorksheet extends FBaseInitialable {}/**- * Hides 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 hide.- * @param numColumns The number of columns to hide.- * @returns This sheet, for chaining.+ * Hides one or more consecutive columns starting at the given index. Use 0-index for this method+ * @param {number} columnIndex - The starting index of the columns to hide+ * @param {number} numColumn - The number of columns to hide+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1142,14 +1189,14 @@ export class FWorksheet extends FBaseInitialable {* sheet.hideColumns(0, 1);* ```*/- hideColumns(columnIndex: number, numColumns: number = 1): FWorksheet {+ hideColumns(columnIndex: number, numColumn: number = 1): FWorksheet {const unitId = this._workbook.getUnitId();const subUnitId = this._worksheet.getSheetId();const range: IRange = {startRow: 0,endRow: this._worksheet.getRowCount() - 1,startColumn: columnIndex,- endColumn: columnIndex + numColumns - 1,+ endColumn: columnIndex + numColumn - 1,rangeType: RANGE_TYPE.COLUMN,};@@ -1164,8 +1211,8 @@ export class FWorksheet extends FBaseInitialable {/*** Show the column in the given range.- * @param column The range to unhide, if hidden.- * @returns This sheet, for chaining.+ * @param {FRange} column - The range to unhide, if hidden+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1190,10 +1237,10 @@ export class FWorksheet extends FBaseInitialable {}/**- * 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.+ * Show one or more consecutive columns starting at the given index. Use 0-index for this method+ * @param {number} columnIndex - The starting index of the columns to unhide+ * @param {number} numColumn - The number of columns to unhide+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1203,14 +1250,14 @@ export class FWorksheet extends FBaseInitialable {* sheet.unhideColumns(0, 1);* ```*/- showColumns(columnIndex: number, numColumns: number = 1): FWorksheet {+ showColumns(columnIndex: number, numColumn: number = 1): FWorksheet {const unitId = this._workbook.getUnitId();const subUnitId = this._worksheet.getSheetId();const range: IRange = {startRow: 0,endRow: this._worksheet.getRowCount() - 1,startColumn: columnIndex,- endColumn: columnIndex + numColumns - 1,+ endColumn: columnIndex + numColumn - 1,rangeType: RANGE_TYPE.COLUMN,};@@ -1225,9 +1272,9 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the width of the given column in pixels.- * @param columnPosition The position of the given column to set.- * @param width The width in pixels to set it to.- * @returns This sheet, for chaining.+ * @param {number} columnPosition - The position of the given column to set+ * @param {number} width - The width in pixels to set it to+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1241,10 +1288,10 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the width of the given columns in pixels.- * @param startColumn The starting column position to change.- * @param numColumns The number of columns to change.- * @param width The width in pixels to set it to.- * @returns This sheet, for chaining.+ * @param {number} startColumn - The starting column position to change+ * @param {number} numColumn - The number of columns to change+ * @param {number} width - The width in pixels to set it to+ * @returns {FWorksheet} This sheet, for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1252,13 +1299,13 @@ export class FWorksheet extends FBaseInitialable {* sheet.setColumnWidths(1, 3, 100);* ```*/- setColumnWidths(startColumn: number, numColumns: number, width: number): FWorksheet {+ setColumnWidths(startColumn: number, numColumn: number, width: number): FWorksheet {const unitId = this._workbook.getUnitId();const subUnitId = this._worksheet.getSheetId();const ranges = [{startColumn,- endColumn: startColumn + numColumns - 1,+ endColumn: startColumn + numColumn - 1,startRow: 0,endRow: this._worksheet.getRowCount() - 1,},@@ -1278,8 +1325,8 @@ export class FWorksheet extends FBaseInitialable {/*** Set custom properties for given columns.- * @param custom The custom properties to set.- * @returns This sheet, for chaining.+ * @param {IObjectArrayPrimitiveType<CustomData>} custom - The custom properties to set+ * @returns {FWorksheet} This worksheet instance for chaining* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1313,7 +1360,7 @@ export class FWorksheet extends FBaseInitialable {/*** Get all merged cells in the current sheet- * @returns all merged cells+ * @returns {FRange[]} all merged cells* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1332,9 +1379,9 @@ export class FWorksheet extends FBaseInitialable {/*** Get the merged cell data of the specified row and column.- * @param {number} row The row index.- * @param {number} column The column index.- * @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged.+ * @param {number} row - The row index+ * @param {number} column - The column index+ * @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1357,7 +1404,7 @@ export class FWorksheet extends FBaseInitialable {/*** Returns the selected range in the active sheet, or null if there is no active range.- * @returns the active range+ * @returns {FRange | null} the active range* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1374,8 +1421,8 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the active selection region for this sheet.- * @param {FRange} range The range to set as the active selection.- * @returns {FWorksheet} This sheet, for chaining.+ * @param {FRange} range - The range to set as the active selection+ * @returns {FWorksheet} This sheet, for chaining* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1396,8 +1443,8 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the active selection region for this sheet.- * @param range The range to set as the active selection.- * @returns This sheet, for chaining.+ * @param range - The range to set as the active selection+ * @returns This sheet, for chaining* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1409,10 +1456,10 @@ 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.+ * @param {IFreeze} 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.+ * @returns {FWorksheet} This worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1432,13 +1479,12 @@ export class FWorksheet extends FBaseInitialable {unitId: this._workbook.getUnitId(),subUnitId: this.getSheetId(),});-return this;}/*** Cancels the frozen state of the current sheet.- * @returns True if the command was successful, false otherwise.+ * @returns {FWorksheet} This worksheet instance for chaining* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1457,7 +1503,7 @@ export class FWorksheet extends FBaseInitialable {/*** Get the freeze state of the current sheet.- * @returns The freeze state of the current sheet.+ * @returns {IFreeze} The freeze state of the current sheet* @example* ```typescript* const sheet = workbook.getActiveSheet();@@ -1472,7 +1518,7 @@ export class FWorksheet extends FBaseInitialable {/*** Set the number of frozen columns.- * @param columns The number of columns to freeze.+ * @param columns - The number of columns to freeze.* To unfreeze all columns, set this value to 0.* @returns {FWorksheet} This FWorksheet instance.* @example@@ -1489,6 +1535,9 @@ export class FWorksheet extends FBaseInitialable {* 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.+ * @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.* @example* ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1496,9 +1545,6 @@ export class FWorksheet extends FBaseInitialable {* // freeze the first too columns.* fWorkSheet.setFrozenColumns(0, 2);* ```- * @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 {@@ -1529,7 +1575,7 @@ export class FWorksheet extends FBaseInitialable {/*** Set the number of frozen rows.- * @param rows The number of rows to freeze.+ * @param rows - The number of rows to freeze.* To unfreeze all rows, set this value to 0.* @returns {FWorksheet} This FWorksheet instance.* @example@@ -1546,17 +1592,18 @@ export class FWorksheet extends FBaseInitialable {* 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 - The start row of the range to freeze.- * @param endRow - The end row of the range to freeze.+ * @param startRow - The start row of the range to freeze+ * @param endRow - The end row of the range to freeze+ * @returns {FWorksheet} This FWorksheet instance.* @example- * ``` ts+ * ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorkSheet = fWorkbook.getActiveSheet();* // freeze the first too rows.* fWorkSheet.setFrozenRows(0, 2);* ```*/- setFrozenRows(startColumn: number, endColumn: number): FWorksheet;+ setFrozenRows(startRow: number, endRow: number): FWorksheet;setFrozenRows(...args: [number] | [number, number]): FWorksheet {const freezeCfg = this.getFreeze();if (arguments.length === 1) {@@ -1585,7 +1632,7 @@ export class FWorksheet extends FBaseInitialable {/*** Get the number of frozen columns.- * @returns The number of frozen columns, returns 0 if no columns are frozen.+ * @returns {number} The number of frozen columns, returns 0 if no columns are frozen.* @example* ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1605,7 +1652,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 {number} The number of frozen rows. returns 0 if no rows are frozen.* @example* ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();@@ -1682,7 +1729,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.+ * @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@@ -1703,7 +1750,7 @@ export class FWorksheet extends FBaseInitialable {/*** Set the color of the gridlines in the sheet.- * @param {string|undefined} color The color to set for the gridlines.Undefined or null to reset to the default color.+ * @param {string|undefined} color - The color to set for the gridlines.Undefined or null to reset to the default color.* @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example* ```ts@@ -1739,7 +1786,7 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the sheet tab color.- * @param {string|null|undefined} color A color code in CSS notation (like '#ffffff' or 'white'), or null to reset the tab color.+ * @param {string|null|undefined} color - A color code in CSS notation (like '#ffffff' or 'white'), or null to reset the tab color.* @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example* ```ts@@ -1774,21 +1821,9 @@ export class FWorksheet extends FBaseInitialable {return this._worksheet.getTabColor() as string | undefined;}+ // eslint-disable-next-line/**- * Subscribe to the cell data change event.- * @param callback - The callback function to be executed when the cell data changes.- * @returns - A disposable object to unsubscribe from the event.- * @example- * ```ts- * const fWorkbook = univerAPI.getActiveWorkbook();- * const fWorkSheet = fWorkbook.getActiveSheet();- * // subscribe to the cell data change event- * const disposable = fWorkSheet.onCellDataChange((cellValue) => {- * console.log(cellValue.toArray());- * });- * // unsubscribe from the event- * disposable.dispose();- * ```+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, callback)` instead*/onCellDataChange(callback: (cellValue: ObjectMatrix<Nullable<ICellData>>) => void): IDisposable {const commandService = this._injector.get(ICommandService);@@ -1806,21 +1841,9 @@ export class FWorksheet extends FBaseInitialable {});}+ // eslint-disable-next-line/**- * Subscribe to the cell data change event.- * @param callback - The callback function to be executed before the cell data changes.- * @returns - A disposable object to unsubscribe from the event.- * @example- * ```ts- * const fWorkbook = univerAPI.getActiveWorkbook();- * const fWorkSheet = fWorkbook.getActiveSheet();- * // subscribe to the cell data change event- * const disposable = fWorkSheet.onBeforeCellDataChange((cellValue) => {- * console.log(cellValue.toArray());- * });- * // unsubscribe from the event- * disposable.dispose();- * ```+ * @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, callback)` instead*/onBeforeCellDataChange(callback: (cellValue: ObjectMatrix<Nullable<ICellData>>) => void): IDisposable {const commandService = this._injector.get(ICommandService);@@ -1892,7 +1915,7 @@ export class FWorksheet extends FBaseInitialable {/*** Sets the sheet name.- * @param {string} name The new name for the sheet.+ * @param {string} name - The new name for the sheet.* @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example* ```ts@@ -1914,7 +1937,7 @@ export class FWorksheet extends FBaseInitialable {/*** Activates this sheet. Does not alter the sheet itself, only the parent's notion of the active sheet.- * @returns Current sheet, for chaining.+ * @returns {FWorksheet} Current sheet, for chaining.*/activate(): FWorksheet {this._fWorkbook.setActiveSheet(this);@@ -1939,9 +1962,9 @@ export class FWorksheet extends FBaseInitialable {/*** Clears the sheet of content and formatting information.Or Optionally clears only the contents or only the formatting.- * @param {IFacadeClearOptions} [options] Options for clearing the sheet. If not provided, the contents and formatting are cleared both.- * @param {boolean} [options.contentsOnly] If true, the contents of the sheet are cleared. If false, the contents and formatting are cleared. Default is false.- * @param {boolean} [options.formatOnly] If true, the formatting of the sheet is cleared. If false, the contents and formatting are cleared. Default is false.+ * @param {IFacadeClearOptions} [options] - Options for clearing the sheet. If not provided, the contents and formatting are cleared both.+ * @param {boolean} [options.contentsOnly] - If true, the contents of the sheet are cleared. If false, the contents and formatting are cleared. Default is false.+ * @param {boolean} [options.formatOnly] - If true, the formatting of the sheet is cleared. If false, the contents and formatting are cleared. Default is false.* @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example* ```ts@@ -1986,7 +2009,7 @@ export class FWorksheet extends FBaseInitialable {* Clears the sheet of contents, while preserving formatting information.* @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example- * ```ts+ * ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorkSheet = fWorkbook.getActiveSheet();* // clear the sheet of content only@@ -2017,7 +2040,7 @@ export class FWorksheet extends FBaseInitialable {* Clears the sheet of formatting, while preserving contents.* @returns {FWorksheet} Returns the current worksheet instance for method chaining* @example- * ```ts+ * ```typescript* const fWorkbook = univerAPI.getActiveWorkbook();* const fWorkSheet = fWorkbook.getActiveSheet();* // clear the sheet of formatting only@@ -2129,7 +2152,7 @@ export class FWorksheet extends FBaseInitialable {/*** Judge whether provided FWorksheet is equal to current.- * @param {FWorksheet} other the FWorksheet to compare with.+ * @param {FWorksheet} other - the FWorksheet to compare with.* @returns {boolean} true if the FWorksheet is equal to the current FWorksheet, false otherwise.* @example* ```ts@@ -2148,8 +2171,8 @@ export class FWorksheet extends FBaseInitialable {/** Insert a defined name for worksheet.- * @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+ * @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* @example* ```ts* // The code below inserts a defined name@@ -2183,7 +2206,7 @@ export class FWorksheet extends FBaseInitialable {/*** Set custom metadata of worksheet- * @param {CustomData | undefined} custom custom metadata+ * @param {CustomData | undefined} custom - custom metadata* @returns {FWorksheet}* @example* ```ts@@ -2199,9 +2222,9 @@ export class FWorksheet extends FBaseInitialable {/*** Set custom metadata of row- * @param {number} index row index- * @param {CustomData | undefined} custom custom metadata- * @returns {FWorksheet}+ * @param {number} index - row index+ * @param {CustomData | undefined} custom - custom metadata+ * @returns {FWorksheet} Current worksheet, for chaining.* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -2216,9 +2239,9 @@ export class FWorksheet extends FBaseInitialable {/*** Set custom metadata of column- * @param {number} index column index- * @param {CustomData | undefined} custom custom metadata- * @returns {FWorksheet}+ * @param {number} index - column index+ * @param {CustomData | undefined} custom - custom metadata+ * @returns {FWorksheet} Current worksheet, for chaining.* @example* ```ts* const fWorkbook = univerAPI.getActiveWorkbook();@@ -2233,7 +2256,7 @@ export class FWorksheet extends FBaseInitialable {/*** Get custom metadata of row- * @param {number} index row index+ * @param {number} index - row index* @returns {CustomData | undefined} custom metadata* @example* ```ts@@ -2248,7 +2271,7 @@ export class FWorksheet extends FBaseInitialable {/*** Get custom metadata of column- * @param {number} index column index+ * @param {number} index - column index* @returns {CustomData | undefined} custom metadata* @example* ```tsdiff --git a/packages/sheets/src/facade/index.ts b/packages/sheets/src/facade/index.tsindex 38be3d0bb1..0dcb9279dc 100644--- a/packages/sheets/src/facade/index.ts+++ b/packages/sheets/src/facade/index.ts@@ -15,14 +15,14 @@*/import './f-univer';+import './f-enum';+export * from './f-enum';export * from './f-event';export { FPermission } from './f-permission';export { FRange } from './f-range';export { FSelection } from './f-selection';-export { FSheetHooks } from './f-sheet-hooks';-export { FWorkbook } from './f-workbook';// eslint-disable-next-line perfectionist/sort-exportsdiff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex 563c6263e7..7312d3df96 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -22,7 +22,10 @@ export {COMMAND_LISTENER_VALUE_CHANGE,type CommandListenerSkeletonChange,type CommandListenerValueChange,+ getSkeletonChangedEffectedRange,getValueChangedEffectedRange,+ SheetSkeletonChangeType,+ SheetValueChangeType,} from './basics/const/command-listener-const';export {type IAddWorksheetMergeMutationParams,