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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/facade.js CHANGED
@@ -979,6 +979,9 @@ function determineScope(editState, viewState) {
979
979
  /**
980
980
  * Check if there are no range protection rules for the given unit and subunit when removing a range protection rule.
981
981
  * If there are no rules left, also remove the associated worksheet protection and update the permission points accordingly.
982
+ * @param {Injector} injector The injector used to resolve permission services.
983
+ * @param {string} unitId The workbook unit id.
984
+ * @param {string} subUnitId The worksheet subunit id.
982
985
  */
983
986
  function handleWorksheetRangePermissionIsEmpty(injector, unitId, subUnitId) {
984
987
  const rangeProtectionRuleModel = injector.get(_univerjs_sheets.RangeProtectionRuleModel);
@@ -993,6 +996,14 @@ function handleWorksheetRangePermissionIsEmpty(injector, unitId, subUnitId) {
993
996
  }
994
997
  /**
995
998
  * Get the list of range protection rules for a specific worksheet or range, and convert them to FRangeProtectionRule instances.
999
+ * @param {Injector} injector The injector used to resolve permission services.
1000
+ * @param {string} unitId The workbook unit id.
1001
+ * @param {string} subUnitId The worksheet subunit id.
1002
+ * @param {object} options Options for listing range protection rules.
1003
+ * @param {FWorksheet} options.worksheet The worksheet facade used to convert ranges.
1004
+ * @param {FRange} [options.specificRange] Optional range used to filter rules.
1005
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
1006
+ * @returns {Promise<FRangeProtectionRule[]>} The range protection rules.
996
1007
  */
997
1008
  async function getListRangeProtectionRules(injector, unitId, subUnitId, options) {
998
1009
  const rangeProtectionRuleModel = injector.get(_univerjs_sheets.RangeProtectionRuleModel);
@@ -1850,6 +1861,8 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
1850
1861
  }
1851
1862
  /**
1852
1863
  * List all range protection rules for the worksheet.
1864
+ * @param {object} [options] Options for listing range protection rules.
1865
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
1853
1866
  * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
1854
1867
  * @example
1855
1868
  * ```ts
@@ -4378,6 +4391,8 @@ let FRangePermission = class FRangePermission extends _univerjs_core_facade.FBas
4378
4391
  }
4379
4392
  /**
4380
4393
  * List all protection rules that intersect with the current range.
4394
+ * @param {object} [options] Options for listing protection rules.
4395
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
4381
4396
  * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
4382
4397
  * @example
4383
4398
  * ```ts
@@ -7080,6 +7095,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7080
7095
  /**
7081
7096
  * Set the name of the workbook.
7082
7097
  * @param {string} name The new name of the workbook.
7098
+ * @returns {FWorkbook} The current FWorkbook instance for chaining.
7083
7099
  * @example
7084
7100
  * ```ts
7085
7101
  * // The code below sets the name of the workbook
@@ -7725,7 +7741,6 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7725
7741
  /**
7726
7742
  * Insert a defined name by builder param.
7727
7743
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
7728
- * @returns {void}
7729
7744
  * @example
7730
7745
  * ```ts
7731
7746
  * // The code below inserts a defined name by builder param
@@ -7744,7 +7759,6 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7744
7759
  /**
7745
7760
  * Update the defined name with the given name.
7746
7761
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
7747
- * @returns {void}
7748
7762
  * @example
7749
7763
  * ```ts
7750
7764
  * // The code below updates the defined name with the given name
@@ -7818,7 +7832,6 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7818
7832
  /**
7819
7833
  * Register a custom range theme style.
7820
7834
  * @param {RangeThemeStyle} rangeThemeStyle The range theme style to register
7821
- * @returns {void}
7822
7835
  * @example
7823
7836
  * ```ts
7824
7837
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -7841,7 +7854,6 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
7841
7854
  /**
7842
7855
  * Unregister a custom range theme style.
7843
7856
  * @param {string} themeName The name of the theme to unregister
7844
- * @returns {void}
7845
7857
  * @example
7846
7858
  * ```ts
7847
7859
  * const fWorkbook = univerAPI.getActiveWorkbook();
package/lib/cjs/index.js CHANGED
@@ -3101,7 +3101,7 @@ function validateDefinedName(name, options) {
3101
3101
  const existingDefinedName = definedNamesService.getValueByName(unitId, name);
3102
3102
  if (existingDefinedName && (id === null || id === void 0 || id.length === 0 || existingDefinedName.id !== id)) return "sheets.definedName.nameDuplicate";
3103
3103
  if (superTableService.hasTable(unitId, name)) return "sheets.definedName.nameDuplicate";
3104
- if (!_univerjs_core.Tools.isValidParameter(name) || (0, _univerjs_engine_formula.isReferenceStringWithEffectiveColumn)(name) || !_univerjs_core.Tools.isStartValidPosition(name) && !(0, _univerjs_engine_render.hasCJKText)(name.substring(0, 1))) return "sheets.definedName.nameInvalid";
3104
+ if (!_univerjs_core.Tools.isValidParameter(name) || (0, _univerjs_engine_formula.isReferenceStringWithEffectiveColumn)(name) || !_univerjs_core.Tools.isStartValidPosition(name) && !_univerjs_engine_render.cjk.hasCJKText(name.substring(0, 1))) return "sheets.definedName.nameInvalid";
3105
3105
  const workbook = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
3106
3106
  if (!workbook) throw new Error(`Workbook not found for unitId: ${unitId}`);
3107
3107
  if (workbook.getSheets().some((sheet) => sheet.getName() === name)) return "sheets.definedName.nameSheetConflict";
@@ -3703,7 +3703,7 @@ function getDelimiterRegexItem(delimiter, treatMultipleDelimitersAsOne, customDe
3703
3703
  if ((delimiter & 4) > 0) delimiterList.push(";");
3704
3704
  if ((delimiter & 8) > 0) delimiterList.push(" ");
3705
3705
  let str = "";
3706
- for (const delimiter of delimiterList) str += (0, _univerjs_core.escapeRegExp)(delimiter);
3706
+ for (const delimiter of delimiterList) str += _univerjs_core.regexp.escapeRegExp(delimiter);
3707
3707
  let allStr = "[".concat(str, "]");
3708
3708
  if (treatMultipleDelimitersAsOne) allStr += "+";
3709
3709
  return new RegExp(allStr);
@@ -12623,12 +12623,14 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
12623
12623
  unitId
12624
12624
  };
12625
12625
  const removeSheetMutationParams = InsertSheetUndoMutationFactory(accessor, insertSheetMutationParams);
12626
+ const copyContext = /* @__PURE__ */ new Map();
12626
12627
  const intercepted = sheetInterceptorService.onCommandExecute({
12627
12628
  id: COPY_SHEET_COMMAND_ID,
12628
12629
  params: {
12629
12630
  unitId,
12630
12631
  subUnitId,
12631
- targetSubUnitId: config.id
12632
+ targetSubUnitId: config.id,
12633
+ copyContext
12632
12634
  }
12633
12635
  });
12634
12636
  return {
@@ -16194,7 +16196,7 @@ let WorksheetPermissionService = class WorksheetPermissionService extends _unive
16194
16196
  getAllWorksheetPermissionPoint().forEach((F) => {
16195
16197
  const instance = new F(unitId, subUnitId);
16196
16198
  instance.value = false;
16197
- this._permissionService.addPermissionPoint(instance);
16199
+ this._addOrUpdatePermissionPoint(instance);
16198
16200
  });
16199
16201
  });
16200
16202
  this._worksheetProtectionRuleModel.changeRuleInitState(true);
@@ -16241,7 +16243,7 @@ let WorksheetPermissionService = class WorksheetPermissionService extends _unive
16241
16243
  Object.keys(resources).forEach((subUnitId) => {
16242
16244
  getAllWorksheetPermissionPointByPointPanel().forEach((F) => {
16243
16245
  const instance = new F(unitId, subUnitId);
16244
- this._permissionService.addPermissionPoint(instance);
16246
+ this._addOrUpdatePermissionPoint(instance);
16245
16247
  });
16246
16248
  });
16247
16249
  },
@@ -16250,6 +16252,13 @@ let WorksheetPermissionService = class WorksheetPermissionService extends _unive
16250
16252
  }
16251
16253
  }));
16252
16254
  }
16255
+ _addOrUpdatePermissionPoint(instance) {
16256
+ if (this._permissionService.getPermissionPoint(instance.id)) {
16257
+ this._permissionService.updatePermissionPoint(instance.id, instance.value);
16258
+ return;
16259
+ }
16260
+ this._permissionService.addPermissionPoint(instance);
16261
+ }
16253
16262
  };
16254
16263
  WorksheetPermissionService = __decorate([
16255
16264
  __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.IPermissionService)),
@@ -19348,7 +19357,7 @@ RangeProtectionCache = __decorate([
19348
19357
  //#endregion
19349
19358
  //#region package.json
19350
19359
  var name = "@univerjs/sheets";
19351
- var version = "1.0.0-alpha.1";
19360
+ var version = "1.0.0-alpha.3";
19352
19361
 
19353
19362
  //#endregion
19354
19363
  //#region src/controllers/active-worksheet.controller.ts
@@ -20605,7 +20614,7 @@ let RangeProtectionService = class RangeProtectionService extends _univerjs_core
20605
20614
  getAllRangePermissionPoint().forEach((Factor) => {
20606
20615
  const instance = new Factor(unitId, subUnitId, rule.permissionId);
20607
20616
  instance.value = false;
20608
- this._permissionService.addPermissionPoint(instance);
20617
+ this._addOrUpdatePermissionPoint(instance);
20609
20618
  });
20610
20619
  });
20611
20620
  this._selectionProtectionCache.reBuildCache(unitId, subUnitId);
@@ -20616,6 +20625,13 @@ let RangeProtectionService = class RangeProtectionService extends _univerjs_core
20616
20625
  }
20617
20626
  }));
20618
20627
  }
20628
+ _addOrUpdatePermissionPoint(instance) {
20629
+ if (this._permissionService.getPermissionPoint(instance.id)) {
20630
+ this._permissionService.updatePermissionPoint(instance.id, instance.value);
20631
+ return;
20632
+ }
20633
+ this._permissionService.addPermissionPoint(instance);
20634
+ }
20619
20635
  };
20620
20636
  RangeProtectionService = __decorate([
20621
20637
  __decorateParam(0, (0, _univerjs_core.Inject)(RangeProtectionRuleModel)),
@@ -12,12 +12,12 @@ const locale = { sheets: {
12
12
  hideSheet: "No hi ha fulls visibles després d'ocultar aquest"
13
13
  },
14
14
  definedName: {
15
- nameEmpty: "名称不能为空",
16
- nameDuplicate: "名称已存在",
17
- nameInvalid: "名称无效",
18
- nameSheetConflict: "名称与工作表名称冲突",
19
- formulaOrRefStringEmpty: "公式或引用字符串不能为空",
20
- nameConflict: "名称与函数名称冲突",
15
+ nameEmpty: "El nom no pot estar buit",
16
+ nameDuplicate: "El nom ja existeix",
17
+ nameInvalid: "El nom no és vàlid",
18
+ nameSheetConflict: "El nom entra en conflicte amb el nom del full de càlcul",
19
+ formulaOrRefStringEmpty: "La fórmula o la cadena de referència no pot estar buida",
20
+ nameConflict: "El nom entra en conflicte amb el nom d'una funció",
21
21
  defaultName: "NomDefinit"
22
22
  },
23
23
  permission: { dialog: {
@@ -34,10 +34,10 @@ const locale = { sheets: {
34
34
  setStyleErr: "L'interval està protegit i no teniu permís per establir estils. Per establir estils, contacteu amb el creador."
35
35
  } },
36
36
  autoFill: {
37
- copy: "复制单元格",
38
- series: "填充序列",
39
- formatOnly: "仅格式",
40
- noFormat: "无格式"
37
+ copy: "Copia les cel·les",
38
+ series: "Omple la sèrie",
39
+ formatOnly: "Només el format",
40
+ noFormat: "Sense format"
41
41
  },
42
42
  merge: { confirm: {
43
43
  title: "Continuar la fusió només conservarà el valor de la cel·la superior esquerra, descartant els altres valors. Estàs segur de continuar?",
package/lib/es/facade.js CHANGED
@@ -978,6 +978,9 @@ function determineScope(editState, viewState) {
978
978
  /**
979
979
  * Check if there are no range protection rules for the given unit and subunit when removing a range protection rule.
980
980
  * If there are no rules left, also remove the associated worksheet protection and update the permission points accordingly.
981
+ * @param {Injector} injector The injector used to resolve permission services.
982
+ * @param {string} unitId The workbook unit id.
983
+ * @param {string} subUnitId The worksheet subunit id.
981
984
  */
982
985
  function handleWorksheetRangePermissionIsEmpty(injector, unitId, subUnitId) {
983
986
  const rangeProtectionRuleModel = injector.get(RangeProtectionRuleModel);
@@ -992,6 +995,14 @@ function handleWorksheetRangePermissionIsEmpty(injector, unitId, subUnitId) {
992
995
  }
993
996
  /**
994
997
  * Get the list of range protection rules for a specific worksheet or range, and convert them to FRangeProtectionRule instances.
998
+ * @param {Injector} injector The injector used to resolve permission services.
999
+ * @param {string} unitId The workbook unit id.
1000
+ * @param {string} subUnitId The worksheet subunit id.
1001
+ * @param {object} options Options for listing range protection rules.
1002
+ * @param {FWorksheet} options.worksheet The worksheet facade used to convert ranges.
1003
+ * @param {FRange} [options.specificRange] Optional range used to filter rules.
1004
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
1005
+ * @returns {Promise<FRangeProtectionRule[]>} The range protection rules.
995
1006
  */
996
1007
  async function getListRangeProtectionRules(injector, unitId, subUnitId, options) {
997
1008
  const rangeProtectionRuleModel = injector.get(RangeProtectionRuleModel);
@@ -1849,6 +1860,8 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
1849
1860
  }
1850
1861
  /**
1851
1862
  * List all range protection rules for the worksheet.
1863
+ * @param {object} [options] Options for listing range protection rules.
1864
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
1852
1865
  * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
1853
1866
  * @example
1854
1867
  * ```ts
@@ -4377,6 +4390,8 @@ let FRangePermission = class FRangePermission extends FBase {
4377
4390
  }
4378
4391
  /**
4379
4392
  * List all protection rules that intersect with the current range.
4393
+ * @param {object} [options] Options for listing protection rules.
4394
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
4380
4395
  * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
4381
4396
  * @example
4382
4397
  * ```ts
@@ -7079,6 +7094,7 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7079
7094
  /**
7080
7095
  * Set the name of the workbook.
7081
7096
  * @param {string} name The new name of the workbook.
7097
+ * @returns {FWorkbook} The current FWorkbook instance for chaining.
7082
7098
  * @example
7083
7099
  * ```ts
7084
7100
  * // The code below sets the name of the workbook
@@ -7724,7 +7740,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7724
7740
  /**
7725
7741
  * Insert a defined name by builder param.
7726
7742
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
7727
- * @returns {void}
7728
7743
  * @example
7729
7744
  * ```ts
7730
7745
  * // The code below inserts a defined name by builder param
@@ -7743,7 +7758,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7743
7758
  /**
7744
7759
  * Update the defined name with the given name.
7745
7760
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
7746
- * @returns {void}
7747
7761
  * @example
7748
7762
  * ```ts
7749
7763
  * // The code below updates the defined name with the given name
@@ -7817,7 +7831,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7817
7831
  /**
7818
7832
  * Register a custom range theme style.
7819
7833
  * @param {RangeThemeStyle} rangeThemeStyle The range theme style to register
7820
- * @returns {void}
7821
7834
  * @example
7822
7835
  * ```ts
7823
7836
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -7840,7 +7853,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7840
7853
  /**
7841
7854
  * Unregister a custom range theme style.
7842
7855
  * @param {string} themeName The name of the theme to unregister
7843
- * @returns {void}
7844
7856
  * @example
7845
7857
  * ```ts
7846
7858
  * const fWorkbook = univerAPI.getActiveWorkbook();
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, escapeRegExp, generateRandomId, getArrayLength, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, queryObjectMatrix, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
1
+ import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, generateRandomId, getArrayLength, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, queryObjectMatrix, regexp, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
2
2
  import { BehaviorSubject, Subject, distinctUntilChanged, filter, first, map, merge as merge$1, of, share, shareReplay, skip, switchMap, takeUntil } from "rxjs";
3
3
  import { IDefinedNamesService, LexerTreeBuilder, RemoveDefinedNameMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFormulaCalculationResultMutation, UniverFormulaEnginePlugin, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, handleNumfmtInCell, isReferenceStringWithEffectiveColumn, operatorToken, sequenceNodeType, stripErrorMargin } from "@univerjs/engine-formula";
4
- import { SpreadsheetSkeleton, hasCJKText, precisionTo } from "@univerjs/engine-render";
4
+ import { SpreadsheetSkeleton, cjk, precisionTo } from "@univerjs/engine-render";
5
5
  import { UnitAction, UnitObject } from "@univerjs/protocol";
6
6
  import { filter as filter$1, map as map$1, takeUntil as takeUntil$1 } from "rxjs/operators";
7
7
  import { DataSyncPrimaryController } from "@univerjs/rpc";
@@ -3100,7 +3100,7 @@ function validateDefinedName(name, options) {
3100
3100
  const existingDefinedName = definedNamesService.getValueByName(unitId, name);
3101
3101
  if (existingDefinedName && (id === null || id === void 0 || id.length === 0 || existingDefinedName.id !== id)) return "sheets.definedName.nameDuplicate";
3102
3102
  if (superTableService.hasTable(unitId, name)) return "sheets.definedName.nameDuplicate";
3103
- if (!Tools.isValidParameter(name) || isReferenceStringWithEffectiveColumn(name) || !Tools.isStartValidPosition(name) && !hasCJKText(name.substring(0, 1))) return "sheets.definedName.nameInvalid";
3103
+ if (!Tools.isValidParameter(name) || isReferenceStringWithEffectiveColumn(name) || !Tools.isStartValidPosition(name) && !cjk.hasCJKText(name.substring(0, 1))) return "sheets.definedName.nameInvalid";
3104
3104
  const workbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
3105
3105
  if (!workbook) throw new Error(`Workbook not found for unitId: ${unitId}`);
3106
3106
  if (workbook.getSheets().some((sheet) => sheet.getName() === name)) return "sheets.definedName.nameSheetConflict";
@@ -3702,7 +3702,7 @@ function getDelimiterRegexItem(delimiter, treatMultipleDelimitersAsOne, customDe
3702
3702
  if ((delimiter & 4) > 0) delimiterList.push(";");
3703
3703
  if ((delimiter & 8) > 0) delimiterList.push(" ");
3704
3704
  let str = "";
3705
- for (const delimiter of delimiterList) str += escapeRegExp(delimiter);
3705
+ for (const delimiter of delimiterList) str += regexp.escapeRegExp(delimiter);
3706
3706
  let allStr = "[".concat(str, "]");
3707
3707
  if (treatMultipleDelimitersAsOne) allStr += "+";
3708
3708
  return new RegExp(allStr);
@@ -12622,12 +12622,14 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
12622
12622
  unitId
12623
12623
  };
12624
12624
  const removeSheetMutationParams = InsertSheetUndoMutationFactory(accessor, insertSheetMutationParams);
12625
+ const copyContext = /* @__PURE__ */ new Map();
12625
12626
  const intercepted = sheetInterceptorService.onCommandExecute({
12626
12627
  id: COPY_SHEET_COMMAND_ID,
12627
12628
  params: {
12628
12629
  unitId,
12629
12630
  subUnitId,
12630
- targetSubUnitId: config.id
12631
+ targetSubUnitId: config.id,
12632
+ copyContext
12631
12633
  }
12632
12634
  });
12633
12635
  return {
@@ -16193,7 +16195,7 @@ let WorksheetPermissionService = class WorksheetPermissionService extends RxDisp
16193
16195
  getAllWorksheetPermissionPoint().forEach((F) => {
16194
16196
  const instance = new F(unitId, subUnitId);
16195
16197
  instance.value = false;
16196
- this._permissionService.addPermissionPoint(instance);
16198
+ this._addOrUpdatePermissionPoint(instance);
16197
16199
  });
16198
16200
  });
16199
16201
  this._worksheetProtectionRuleModel.changeRuleInitState(true);
@@ -16240,7 +16242,7 @@ let WorksheetPermissionService = class WorksheetPermissionService extends RxDisp
16240
16242
  Object.keys(resources).forEach((subUnitId) => {
16241
16243
  getAllWorksheetPermissionPointByPointPanel().forEach((F) => {
16242
16244
  const instance = new F(unitId, subUnitId);
16243
- this._permissionService.addPermissionPoint(instance);
16245
+ this._addOrUpdatePermissionPoint(instance);
16244
16246
  });
16245
16247
  });
16246
16248
  },
@@ -16249,6 +16251,13 @@ let WorksheetPermissionService = class WorksheetPermissionService extends RxDisp
16249
16251
  }
16250
16252
  }));
16251
16253
  }
16254
+ _addOrUpdatePermissionPoint(instance) {
16255
+ if (this._permissionService.getPermissionPoint(instance.id)) {
16256
+ this._permissionService.updatePermissionPoint(instance.id, instance.value);
16257
+ return;
16258
+ }
16259
+ this._permissionService.addPermissionPoint(instance);
16260
+ }
16252
16261
  };
16253
16262
  WorksheetPermissionService = __decorate([
16254
16263
  __decorateParam(0, Inject(IPermissionService)),
@@ -19347,7 +19356,7 @@ RangeProtectionCache = __decorate([
19347
19356
  //#endregion
19348
19357
  //#region package.json
19349
19358
  var name = "@univerjs/sheets";
19350
- var version = "1.0.0-alpha.1";
19359
+ var version = "1.0.0-alpha.3";
19351
19360
 
19352
19361
  //#endregion
19353
19362
  //#region src/controllers/active-worksheet.controller.ts
@@ -20604,7 +20613,7 @@ let RangeProtectionService = class RangeProtectionService extends Disposable {
20604
20613
  getAllRangePermissionPoint().forEach((Factor) => {
20605
20614
  const instance = new Factor(unitId, subUnitId, rule.permissionId);
20606
20615
  instance.value = false;
20607
- this._permissionService.addPermissionPoint(instance);
20616
+ this._addOrUpdatePermissionPoint(instance);
20608
20617
  });
20609
20618
  });
20610
20619
  this._selectionProtectionCache.reBuildCache(unitId, subUnitId);
@@ -20615,6 +20624,13 @@ let RangeProtectionService = class RangeProtectionService extends Disposable {
20615
20624
  }
20616
20625
  }));
20617
20626
  }
20627
+ _addOrUpdatePermissionPoint(instance) {
20628
+ if (this._permissionService.getPermissionPoint(instance.id)) {
20629
+ this._permissionService.updatePermissionPoint(instance.id, instance.value);
20630
+ return;
20631
+ }
20632
+ this._permissionService.addPermissionPoint(instance);
20633
+ }
20618
20634
  };
20619
20635
  RangeProtectionService = __decorate([
20620
20636
  __decorateParam(0, Inject(RangeProtectionRuleModel)),
@@ -11,12 +11,12 @@ const locale = { sheets: {
11
11
  hideSheet: "No hi ha fulls visibles després d'ocultar aquest"
12
12
  },
13
13
  definedName: {
14
- nameEmpty: "名称不能为空",
15
- nameDuplicate: "名称已存在",
16
- nameInvalid: "名称无效",
17
- nameSheetConflict: "名称与工作表名称冲突",
18
- formulaOrRefStringEmpty: "公式或引用字符串不能为空",
19
- nameConflict: "名称与函数名称冲突",
14
+ nameEmpty: "El nom no pot estar buit",
15
+ nameDuplicate: "El nom ja existeix",
16
+ nameInvalid: "El nom no és vàlid",
17
+ nameSheetConflict: "El nom entra en conflicte amb el nom del full de càlcul",
18
+ formulaOrRefStringEmpty: "La fórmula o la cadena de referència no pot estar buida",
19
+ nameConflict: "El nom entra en conflicte amb el nom d'una funció",
20
20
  defaultName: "NomDefinit"
21
21
  },
22
22
  permission: { dialog: {
@@ -33,10 +33,10 @@ const locale = { sheets: {
33
33
  setStyleErr: "L'interval està protegit i no teniu permís per establir estils. Per establir estils, contacteu amb el creador."
34
34
  } },
35
35
  autoFill: {
36
- copy: "复制单元格",
37
- series: "填充序列",
38
- formatOnly: "仅格式",
39
- noFormat: "无格式"
36
+ copy: "Copia les cel·les",
37
+ series: "Omple la sèrie",
38
+ formatOnly: "Només el format",
39
+ noFormat: "Sense format"
40
40
  },
41
41
  merge: { confirm: {
42
42
  title: "Continuar la fusió només conservarà el valor de la cel·la superior esquerra, descartant els altres valors. Estàs segur de continuar?",
package/lib/facade.js CHANGED
@@ -978,6 +978,9 @@ function determineScope(editState, viewState) {
978
978
  /**
979
979
  * Check if there are no range protection rules for the given unit and subunit when removing a range protection rule.
980
980
  * If there are no rules left, also remove the associated worksheet protection and update the permission points accordingly.
981
+ * @param {Injector} injector The injector used to resolve permission services.
982
+ * @param {string} unitId The workbook unit id.
983
+ * @param {string} subUnitId The worksheet subunit id.
981
984
  */
982
985
  function handleWorksheetRangePermissionIsEmpty(injector, unitId, subUnitId) {
983
986
  const rangeProtectionRuleModel = injector.get(RangeProtectionRuleModel);
@@ -992,6 +995,14 @@ function handleWorksheetRangePermissionIsEmpty(injector, unitId, subUnitId) {
992
995
  }
993
996
  /**
994
997
  * Get the list of range protection rules for a specific worksheet or range, and convert them to FRangeProtectionRule instances.
998
+ * @param {Injector} injector The injector used to resolve permission services.
999
+ * @param {string} unitId The workbook unit id.
1000
+ * @param {string} subUnitId The worksheet subunit id.
1001
+ * @param {object} options Options for listing range protection rules.
1002
+ * @param {FWorksheet} options.worksheet The worksheet facade used to convert ranges.
1003
+ * @param {FRange} [options.specificRange] Optional range used to filter rules.
1004
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
1005
+ * @returns {Promise<FRangeProtectionRule[]>} The range protection rules.
995
1006
  */
996
1007
  async function getListRangeProtectionRules(injector, unitId, subUnitId, options) {
997
1008
  const rangeProtectionRuleModel = injector.get(RangeProtectionRuleModel);
@@ -1849,6 +1860,8 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
1849
1860
  }
1850
1861
  /**
1851
1862
  * List all range protection rules for the worksheet.
1863
+ * @param {object} [options] Options for listing range protection rules.
1864
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
1852
1865
  * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
1853
1866
  * @example
1854
1867
  * ```ts
@@ -4377,6 +4390,8 @@ let FRangePermission = class FRangePermission extends FBase {
4377
4390
  }
4378
4391
  /**
4379
4392
  * List all protection rules that intersect with the current range.
4393
+ * @param {object} [options] Options for listing protection rules.
4394
+ * @param {boolean} [options.ignoreCollaborators] Whether to skip fetching collaborators for performance.
4380
4395
  * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
4381
4396
  * @example
4382
4397
  * ```ts
@@ -7079,6 +7094,7 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7079
7094
  /**
7080
7095
  * Set the name of the workbook.
7081
7096
  * @param {string} name The new name of the workbook.
7097
+ * @returns {FWorkbook} The current FWorkbook instance for chaining.
7082
7098
  * @example
7083
7099
  * ```ts
7084
7100
  * // The code below sets the name of the workbook
@@ -7724,7 +7740,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7724
7740
  /**
7725
7741
  * Insert a defined name by builder param.
7726
7742
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
7727
- * @returns {void}
7728
7743
  * @example
7729
7744
  * ```ts
7730
7745
  * // The code below inserts a defined name by builder param
@@ -7743,7 +7758,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7743
7758
  /**
7744
7759
  * Update the defined name with the given name.
7745
7760
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
7746
- * @returns {void}
7747
7761
  * @example
7748
7762
  * ```ts
7749
7763
  * // The code below updates the defined name with the given name
@@ -7817,7 +7831,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7817
7831
  /**
7818
7832
  * Register a custom range theme style.
7819
7833
  * @param {RangeThemeStyle} rangeThemeStyle The range theme style to register
7820
- * @returns {void}
7821
7834
  * @example
7822
7835
  * ```ts
7823
7836
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -7840,7 +7853,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7840
7853
  /**
7841
7854
  * Unregister a custom range theme style.
7842
7855
  * @param {string} themeName The name of the theme to unregister
7843
- * @returns {void}
7844
7856
  * @example
7845
7857
  * ```ts
7846
7858
  * const fWorkbook = univerAPI.getActiveWorkbook();
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, escapeRegExp, generateRandomId, getArrayLength, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, queryObjectMatrix, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
1
+ import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, generateRandomId, getArrayLength, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, queryObjectMatrix, regexp, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
2
2
  import { BehaviorSubject, Subject, distinctUntilChanged, filter, first, map, merge as merge$1, of, share, shareReplay, skip, switchMap, takeUntil } from "rxjs";
3
3
  import { IDefinedNamesService, LexerTreeBuilder, RemoveDefinedNameMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFormulaCalculationResultMutation, UniverFormulaEnginePlugin, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, handleNumfmtInCell, isReferenceStringWithEffectiveColumn, operatorToken, sequenceNodeType, stripErrorMargin } from "@univerjs/engine-formula";
4
- import { SpreadsheetSkeleton, hasCJKText, precisionTo } from "@univerjs/engine-render";
4
+ import { SpreadsheetSkeleton, cjk, precisionTo } from "@univerjs/engine-render";
5
5
  import { UnitAction, UnitObject } from "@univerjs/protocol";
6
6
  import { filter as filter$1, map as map$1, takeUntil as takeUntil$1 } from "rxjs/operators";
7
7
  import { DataSyncPrimaryController } from "@univerjs/rpc";
@@ -3100,7 +3100,7 @@ function validateDefinedName(name, options) {
3100
3100
  const existingDefinedName = definedNamesService.getValueByName(unitId, name);
3101
3101
  if (existingDefinedName && (id === null || id === void 0 || id.length === 0 || existingDefinedName.id !== id)) return "sheets.definedName.nameDuplicate";
3102
3102
  if (superTableService.hasTable(unitId, name)) return "sheets.definedName.nameDuplicate";
3103
- if (!Tools.isValidParameter(name) || isReferenceStringWithEffectiveColumn(name) || !Tools.isStartValidPosition(name) && !hasCJKText(name.substring(0, 1))) return "sheets.definedName.nameInvalid";
3103
+ if (!Tools.isValidParameter(name) || isReferenceStringWithEffectiveColumn(name) || !Tools.isStartValidPosition(name) && !cjk.hasCJKText(name.substring(0, 1))) return "sheets.definedName.nameInvalid";
3104
3104
  const workbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
3105
3105
  if (!workbook) throw new Error(`Workbook not found for unitId: ${unitId}`);
3106
3106
  if (workbook.getSheets().some((sheet) => sheet.getName() === name)) return "sheets.definedName.nameSheetConflict";
@@ -3702,7 +3702,7 @@ function getDelimiterRegexItem(delimiter, treatMultipleDelimitersAsOne, customDe
3702
3702
  if ((delimiter & 4) > 0) delimiterList.push(";");
3703
3703
  if ((delimiter & 8) > 0) delimiterList.push(" ");
3704
3704
  let str = "";
3705
- for (const delimiter of delimiterList) str += escapeRegExp(delimiter);
3705
+ for (const delimiter of delimiterList) str += regexp.escapeRegExp(delimiter);
3706
3706
  let allStr = "[".concat(str, "]");
3707
3707
  if (treatMultipleDelimitersAsOne) allStr += "+";
3708
3708
  return new RegExp(allStr);
@@ -12622,12 +12622,14 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
12622
12622
  unitId
12623
12623
  };
12624
12624
  const removeSheetMutationParams = InsertSheetUndoMutationFactory(accessor, insertSheetMutationParams);
12625
+ const copyContext = /* @__PURE__ */ new Map();
12625
12626
  const intercepted = sheetInterceptorService.onCommandExecute({
12626
12627
  id: COPY_SHEET_COMMAND_ID,
12627
12628
  params: {
12628
12629
  unitId,
12629
12630
  subUnitId,
12630
- targetSubUnitId: config.id
12631
+ targetSubUnitId: config.id,
12632
+ copyContext
12631
12633
  }
12632
12634
  });
12633
12635
  return {
@@ -16193,7 +16195,7 @@ let WorksheetPermissionService = class WorksheetPermissionService extends RxDisp
16193
16195
  getAllWorksheetPermissionPoint().forEach((F) => {
16194
16196
  const instance = new F(unitId, subUnitId);
16195
16197
  instance.value = false;
16196
- this._permissionService.addPermissionPoint(instance);
16198
+ this._addOrUpdatePermissionPoint(instance);
16197
16199
  });
16198
16200
  });
16199
16201
  this._worksheetProtectionRuleModel.changeRuleInitState(true);
@@ -16240,7 +16242,7 @@ let WorksheetPermissionService = class WorksheetPermissionService extends RxDisp
16240
16242
  Object.keys(resources).forEach((subUnitId) => {
16241
16243
  getAllWorksheetPermissionPointByPointPanel().forEach((F) => {
16242
16244
  const instance = new F(unitId, subUnitId);
16243
- this._permissionService.addPermissionPoint(instance);
16245
+ this._addOrUpdatePermissionPoint(instance);
16244
16246
  });
16245
16247
  });
16246
16248
  },
@@ -16249,6 +16251,13 @@ let WorksheetPermissionService = class WorksheetPermissionService extends RxDisp
16249
16251
  }
16250
16252
  }));
16251
16253
  }
16254
+ _addOrUpdatePermissionPoint(instance) {
16255
+ if (this._permissionService.getPermissionPoint(instance.id)) {
16256
+ this._permissionService.updatePermissionPoint(instance.id, instance.value);
16257
+ return;
16258
+ }
16259
+ this._permissionService.addPermissionPoint(instance);
16260
+ }
16252
16261
  };
16253
16262
  WorksheetPermissionService = __decorate([
16254
16263
  __decorateParam(0, Inject(IPermissionService)),
@@ -19347,7 +19356,7 @@ RangeProtectionCache = __decorate([
19347
19356
  //#endregion
19348
19357
  //#region package.json
19349
19358
  var name = "@univerjs/sheets";
19350
- var version = "1.0.0-alpha.1";
19359
+ var version = "1.0.0-alpha.3";
19351
19360
 
19352
19361
  //#endregion
19353
19362
  //#region src/controllers/active-worksheet.controller.ts
@@ -20604,7 +20613,7 @@ let RangeProtectionService = class RangeProtectionService extends Disposable {
20604
20613
  getAllRangePermissionPoint().forEach((Factor) => {
20605
20614
  const instance = new Factor(unitId, subUnitId, rule.permissionId);
20606
20615
  instance.value = false;
20607
- this._permissionService.addPermissionPoint(instance);
20616
+ this._addOrUpdatePermissionPoint(instance);
20608
20617
  });
20609
20618
  });
20610
20619
  this._selectionProtectionCache.reBuildCache(unitId, subUnitId);
@@ -20615,6 +20624,13 @@ let RangeProtectionService = class RangeProtectionService extends Disposable {
20615
20624
  }
20616
20625
  }));
20617
20626
  }
20627
+ _addOrUpdatePermissionPoint(instance) {
20628
+ if (this._permissionService.getPermissionPoint(instance.id)) {
20629
+ this._permissionService.updatePermissionPoint(instance.id, instance.value);
20630
+ return;
20631
+ }
20632
+ this._permissionService.addPermissionPoint(instance);
20633
+ }
20618
20634
  };
20619
20635
  RangeProtectionService = __decorate([
20620
20636
  __decorateParam(0, Inject(RangeProtectionRuleModel)),