@univerjs/sheets 0.22.0 → 0.22.1-insiders.20260516-8900c44
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 +3 -2
- package/lib/cjs/index.js +57 -23
- package/lib/es/facade.js +3 -2
- package/lib/es/index.js +57 -23
- package/lib/facade.js +3 -2
- package/lib/index.js +57 -23
- package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +4 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/cjs/facade.js
CHANGED
|
@@ -6997,7 +6997,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
6997
6997
|
create(name, rows, columns, options) {
|
|
6998
6998
|
var _options$sheet, _options$sheet2, _options$index;
|
|
6999
6999
|
const newSheet = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(_univerjs_core.Tools.deepClone((_options$sheet = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet !== void 0 ? _options$sheet : {}));
|
|
7000
|
-
newSheet.name =
|
|
7000
|
+
newSheet.name = name;
|
|
7001
7001
|
newSheet.rowCount = rows;
|
|
7002
7002
|
newSheet.columnCount = columns;
|
|
7003
7003
|
newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
|
|
@@ -7110,7 +7110,8 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7110
7110
|
insertSheet(sheetName, options) {
|
|
7111
7111
|
var _options$sheet3, _options$sheet4, _options$index2;
|
|
7112
7112
|
const newSheet = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(_univerjs_core.Tools.deepClone((_options$sheet3 = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet3 !== void 0 ? _options$sheet3 : {}));
|
|
7113
|
-
newSheet.name =
|
|
7113
|
+
if (sheetName !== void 0) newSheet.name = sheetName;
|
|
7114
|
+
else delete newSheet.name;
|
|
7114
7115
|
newSheet.id = options === null || options === void 0 || (_options$sheet4 = options.sheet) === null || _options$sheet4 === void 0 ? void 0 : _options$sheet4.id;
|
|
7115
7116
|
const newSheetIndex = (_options$index2 = options === null || options === void 0 ? void 0 : options.index) !== null && _options$index2 !== void 0 ? _options$index2 : this._workbook.getSheets().length;
|
|
7116
7117
|
this._commandService.syncExecuteCommand(_univerjs_sheets.InsertSheetCommand.id, {
|
package/lib/cjs/index.js
CHANGED
|
@@ -235,9 +235,8 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
235
235
|
_defineProperty(this, "_afterCommandInterceptors", []);
|
|
236
236
|
_defineProperty(this, "_workbookDisposables", /* @__PURE__ */ new Map());
|
|
237
237
|
_defineProperty(this, "_worksheetDisposables", /* @__PURE__ */ new Map());
|
|
238
|
-
_defineProperty(this, "_interceptorsDirty", false);
|
|
239
238
|
_defineProperty(this, "_composedInterceptorByKey", /* @__PURE__ */ new Map());
|
|
240
|
-
_defineProperty(this, "
|
|
239
|
+
_defineProperty(this, "_composedInterceptorVersion", 0);
|
|
241
240
|
_defineProperty(this, "writeCellInterceptor", new _univerjs_core.InterceptorManager({
|
|
242
241
|
BEFORE_CELL_EDIT,
|
|
243
242
|
AFTER_CELL_EDIT,
|
|
@@ -272,6 +271,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
272
271
|
this._worksheetDisposables.forEach((disposable) => disposable.dispose());
|
|
273
272
|
this._worksheetDisposables.clear();
|
|
274
273
|
this._interceptorsByName.clear();
|
|
274
|
+
this._composedInterceptorByKey.clear();
|
|
275
275
|
}
|
|
276
276
|
/**
|
|
277
277
|
* Add a listener function to a specific command to add affiliated mutations. It should be called in controllers.
|
|
@@ -437,7 +437,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
437
437
|
var _b$priority6, _a$priority6;
|
|
438
438
|
return ((_b$priority6 = b.priority) !== null && _b$priority6 !== void 0 ? _b$priority6 : 0) - ((_a$priority6 = a.priority) !== null && _a$priority6 !== void 0 ? _a$priority6 : 0);
|
|
439
439
|
});
|
|
440
|
-
this.
|
|
440
|
+
this._invalidateComposedInterceptors();
|
|
441
441
|
if (key === INTERCEPTOR_POINT.CELL_CONTENT) {
|
|
442
442
|
const JOINED_EFFECT = _univerjs_core.InterceptorEffectEnum.Style | _univerjs_core.InterceptorEffectEnum.Value;
|
|
443
443
|
this._interceptorsByName.set(`${key}-${JOINED_EFFECT}`, sortedInterceptors);
|
|
@@ -449,27 +449,44 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
449
449
|
(0, _univerjs_core.remove)(this._interceptorsByName.get(`${key}-${JOINED_EFFECT}`), interceptor);
|
|
450
450
|
(0, _univerjs_core.remove)(this._interceptorsByName.get(`${key}-${_univerjs_core.InterceptorEffectEnum.Style}`), interceptor);
|
|
451
451
|
(0, _univerjs_core.remove)(this._interceptorsByName.get(`${key}-${_univerjs_core.InterceptorEffectEnum.Value}`), interceptor);
|
|
452
|
+
this._invalidateComposedInterceptors();
|
|
452
453
|
}));
|
|
453
454
|
} else {
|
|
454
455
|
this._interceptorsByName.set(key, sortedInterceptors);
|
|
455
|
-
return this.disposeWithMe((0, _univerjs_core.toDisposable)(() =>
|
|
456
|
+
return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => {
|
|
457
|
+
(0, _univerjs_core.remove)(this._interceptorsByName.get(key), interceptor);
|
|
458
|
+
this._invalidateComposedInterceptors();
|
|
459
|
+
}));
|
|
456
460
|
}
|
|
457
461
|
}
|
|
458
462
|
fetchThroughInterceptors(name, effect, _key, filter) {
|
|
459
|
-
var _this$_interceptorsBy;
|
|
460
463
|
const byNamesKey = effect === void 0 ? name : `${name}-${effect}`;
|
|
461
464
|
const key = _key !== null && _key !== void 0 ? _key : byNamesKey;
|
|
462
465
|
let composed = this._composedInterceptorByKey.get(key);
|
|
463
|
-
|
|
464
|
-
if (!composed || !this._interceptorsDirty || composedInterceptorsLength !== (((_this$_interceptorsBy = this._interceptorsByName.get(byNamesKey)) === null || _this$_interceptorsBy === void 0 ? void 0 : _this$_interceptorsBy.length) || 0)) {
|
|
466
|
+
if (!composed) {
|
|
465
467
|
let interceptors = this._interceptorsByName.get(byNamesKey);
|
|
466
468
|
if (interceptors && filter) interceptors = interceptors.filter(filter);
|
|
467
469
|
composed = (0, _univerjs_core.composeInterceptors)(interceptors || []);
|
|
468
470
|
this._composedInterceptorByKey.set(key, composed);
|
|
469
|
-
this._composedInterceptorsLengthByKey.set(key, (interceptors === null || interceptors === void 0 ? void 0 : interceptors.length) || 0);
|
|
470
471
|
}
|
|
471
472
|
return composed;
|
|
472
473
|
}
|
|
474
|
+
_invalidateComposedInterceptors() {
|
|
475
|
+
this._composedInterceptorVersion += 1;
|
|
476
|
+
this._composedInterceptorByKey.clear();
|
|
477
|
+
}
|
|
478
|
+
_getCommonCellContentInterceptor(effect, cache) {
|
|
479
|
+
let composed = cache.get(effect);
|
|
480
|
+
if (!composed) {
|
|
481
|
+
composed = this.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect);
|
|
482
|
+
cache.set(effect, composed);
|
|
483
|
+
}
|
|
484
|
+
return composed;
|
|
485
|
+
}
|
|
486
|
+
_getCommonRowFilteredInterceptor(cache) {
|
|
487
|
+
if (!cache.interceptor) cache.interceptor = this.fetchThroughInterceptors(INTERCEPTOR_POINT.ROW_FILTERED);
|
|
488
|
+
return cache.interceptor;
|
|
489
|
+
}
|
|
473
490
|
_interceptWorkbook(workbook) {
|
|
474
491
|
const disposables = new _univerjs_core.DisposableCollection();
|
|
475
492
|
const unitId = workbook.getUnitId();
|
|
@@ -478,10 +495,14 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
478
495
|
const subUnitId = worksheet.getSheetId();
|
|
479
496
|
worksheet.__interceptViewModel((viewModel) => {
|
|
480
497
|
const sheetDisposables = new _univerjs_core.DisposableCollection();
|
|
498
|
+
const commonCellContentInterceptors = /* @__PURE__ */ new Map();
|
|
499
|
+
const commonRowFilteredInterceptor = { interceptor: null };
|
|
500
|
+
let commonCellContentInterceptorsVersion = -1;
|
|
501
|
+
let commonRowFilteredInterceptorVersion = -1;
|
|
481
502
|
sheetInterceptorService._worksheetDisposables.set(getWorksheetDisposableID(unitId, worksheet), sheetDisposables);
|
|
482
503
|
sheetDisposables.add(viewModel.registerCellContentInterceptor({ getCell(row, col, effect, key, filter) {
|
|
483
504
|
const rawData = worksheet.getCellRaw(row, col);
|
|
484
|
-
|
|
505
|
+
const context = {
|
|
485
506
|
unitId,
|
|
486
507
|
subUnitId,
|
|
487
508
|
row,
|
|
@@ -489,10 +510,22 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
489
510
|
worksheet,
|
|
490
511
|
workbook,
|
|
491
512
|
rawData
|
|
492
|
-
}
|
|
513
|
+
};
|
|
514
|
+
if (key === void 0 && filter === void 0) {
|
|
515
|
+
if (commonCellContentInterceptorsVersion !== sheetInterceptorService._composedInterceptorVersion) {
|
|
516
|
+
commonCellContentInterceptors.clear();
|
|
517
|
+
commonCellContentInterceptorsVersion = sheetInterceptorService._composedInterceptorVersion;
|
|
518
|
+
}
|
|
519
|
+
return sheetInterceptorService._getCommonCellContentInterceptor(effect, commonCellContentInterceptors)(rawData, context);
|
|
520
|
+
}
|
|
521
|
+
return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect, key, filter)(rawData, context);
|
|
493
522
|
} }));
|
|
494
523
|
sheetDisposables.add(viewModel.registerRowFilteredInterceptor({ getRowFiltered(row) {
|
|
495
|
-
|
|
524
|
+
if (commonRowFilteredInterceptorVersion !== sheetInterceptorService._composedInterceptorVersion) {
|
|
525
|
+
commonRowFilteredInterceptor.interceptor = null;
|
|
526
|
+
commonRowFilteredInterceptorVersion = sheetInterceptorService._composedInterceptorVersion;
|
|
527
|
+
}
|
|
528
|
+
return !!sheetInterceptorService._getCommonRowFilteredInterceptor(commonRowFilteredInterceptor)(false, {
|
|
496
529
|
unitId,
|
|
497
530
|
subUnitId,
|
|
498
531
|
row,
|
|
@@ -12793,12 +12826,13 @@ const InsertSheetCommand = {
|
|
|
12793
12826
|
let index = workbook.getSheets().length;
|
|
12794
12827
|
const sheet = params === null || params === void 0 ? void 0 : params.sheet;
|
|
12795
12828
|
const sheetId = sheet === null || sheet === void 0 ? void 0 : sheet.id;
|
|
12829
|
+
const sheetName = sheet === null || sheet === void 0 ? void 0 : sheet.name;
|
|
12796
12830
|
const sheetConfig = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(sheet || {});
|
|
12797
12831
|
if (params) {
|
|
12798
12832
|
var _params$index;
|
|
12799
12833
|
index = (_params$index = params.index) !== null && _params$index !== void 0 ? _params$index : index;
|
|
12800
12834
|
sheetConfig.id = sheetId || (0, _univerjs_core.generateRandomId)();
|
|
12801
|
-
sheetConfig.name =
|
|
12835
|
+
sheetConfig.name = sheetName ? workbook.uniqueSheetName(sheetName) : workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`);
|
|
12802
12836
|
} else {
|
|
12803
12837
|
sheetConfig.id = (0, _univerjs_core.generateRandomId)();
|
|
12804
12838
|
sheetConfig.name = workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`);
|
|
@@ -18931,7 +18965,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
18931
18965
|
});
|
|
18932
18966
|
}
|
|
18933
18967
|
_initUpdateCellInfoCache() {
|
|
18934
|
-
this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe((permission) => {
|
|
18968
|
+
this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe((permission) => {
|
|
18935
18969
|
const { subUnitId, unitId, permissionId } = permission;
|
|
18936
18970
|
const ruleId = this._permissionIdCache.get(permissionId);
|
|
18937
18971
|
if (!ruleId) return;
|
|
@@ -18942,8 +18976,8 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
18942
18976
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
18943
18977
|
for (let i = startRow; i <= endRow; i++) for (let j = startColumn; j <= endColumn; j++) cellInfoMap.delete(`${i}-${j}`);
|
|
18944
18978
|
});
|
|
18945
|
-
});
|
|
18946
|
-
this._ruleModel.ruleChange$.subscribe((info) => {
|
|
18979
|
+
}));
|
|
18980
|
+
this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
|
|
18947
18981
|
const { unitId, subUnitId } = info;
|
|
18948
18982
|
const cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
|
|
18949
18983
|
info.rule.ranges.forEach((range) => {
|
|
@@ -18959,10 +18993,10 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
18959
18993
|
});
|
|
18960
18994
|
});
|
|
18961
18995
|
}
|
|
18962
|
-
});
|
|
18996
|
+
}));
|
|
18963
18997
|
}
|
|
18964
18998
|
_initUpdateCellRuleCache() {
|
|
18965
|
-
this._ruleModel.ruleChange$.subscribe((ruleChange) => {
|
|
18999
|
+
this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((ruleChange) => {
|
|
18966
19000
|
const { type } = ruleChange;
|
|
18967
19001
|
if (type === "add") this._addCellRuleCache(ruleChange);
|
|
18968
19002
|
else if (type === "delete") this._deleteCellRuleCache(ruleChange);
|
|
@@ -18973,7 +19007,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
18973
19007
|
});
|
|
18974
19008
|
this._addCellRuleCache(ruleChange);
|
|
18975
19009
|
}
|
|
18976
|
-
});
|
|
19010
|
+
}));
|
|
18977
19011
|
}
|
|
18978
19012
|
_ensureRuleMap(unitId, subUnitId) {
|
|
18979
19013
|
let subUnitMap = this._cellRuleCache.get(unitId);
|
|
@@ -19106,7 +19140,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
19106
19140
|
});
|
|
19107
19141
|
}
|
|
19108
19142
|
_initUpdateRowColInfoCache() {
|
|
19109
|
-
this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe({ next: (permission) => {
|
|
19143
|
+
this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe({ next: (permission) => {
|
|
19110
19144
|
const { subUnitId, unitId, permissionId } = permission;
|
|
19111
19145
|
const ruleId = this._permissionIdCache.get(permissionId);
|
|
19112
19146
|
if (!ruleId) return;
|
|
@@ -19128,8 +19162,8 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
19128
19162
|
}
|
|
19129
19163
|
}
|
|
19130
19164
|
});
|
|
19131
|
-
} });
|
|
19132
|
-
this._ruleModel.ruleChange$.subscribe((info) => {
|
|
19165
|
+
} }));
|
|
19166
|
+
this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
|
|
19133
19167
|
if (info.type === "delete") {
|
|
19134
19168
|
const { unitId, subUnitId, rule } = info;
|
|
19135
19169
|
const rowInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "row");
|
|
@@ -19146,7 +19180,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
19146
19180
|
}
|
|
19147
19181
|
});
|
|
19148
19182
|
}
|
|
19149
|
-
});
|
|
19183
|
+
}));
|
|
19150
19184
|
}
|
|
19151
19185
|
getCellInfo(unitId, subUnitId, row, col) {
|
|
19152
19186
|
var _this$_cellRuleCache$;
|
|
@@ -19189,7 +19223,7 @@ RangeProtectionCache = __decorate([
|
|
|
19189
19223
|
//#endregion
|
|
19190
19224
|
//#region package.json
|
|
19191
19225
|
var name = "@univerjs/sheets";
|
|
19192
|
-
var version = "0.22.
|
|
19226
|
+
var version = "0.22.1-insiders.20260516-8900c44";
|
|
19193
19227
|
|
|
19194
19228
|
//#endregion
|
|
19195
19229
|
//#region src/controllers/active-worksheet.controller.ts
|
package/lib/es/facade.js
CHANGED
|
@@ -6996,7 +6996,7 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
|
|
|
6996
6996
|
create(name, rows, columns, options) {
|
|
6997
6997
|
var _options$sheet, _options$sheet2, _options$index;
|
|
6998
6998
|
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((_options$sheet = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet !== void 0 ? _options$sheet : {}));
|
|
6999
|
-
newSheet.name =
|
|
6999
|
+
newSheet.name = name;
|
|
7000
7000
|
newSheet.rowCount = rows;
|
|
7001
7001
|
newSheet.columnCount = columns;
|
|
7002
7002
|
newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
|
|
@@ -7109,7 +7109,8 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
|
|
|
7109
7109
|
insertSheet(sheetName, options) {
|
|
7110
7110
|
var _options$sheet3, _options$sheet4, _options$index2;
|
|
7111
7111
|
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((_options$sheet3 = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet3 !== void 0 ? _options$sheet3 : {}));
|
|
7112
|
-
newSheet.name =
|
|
7112
|
+
if (sheetName !== void 0) newSheet.name = sheetName;
|
|
7113
|
+
else delete newSheet.name;
|
|
7113
7114
|
newSheet.id = options === null || options === void 0 || (_options$sheet4 = options.sheet) === null || _options$sheet4 === void 0 ? void 0 : _options$sheet4.id;
|
|
7114
7115
|
const newSheetIndex = (_options$index2 = options === null || options === void 0 ? void 0 : options.index) !== null && _options$index2 !== void 0 ? _options$index2 : this._workbook.getSheets().length;
|
|
7115
7116
|
this._commandService.syncExecuteCommand(InsertSheetCommand.id, {
|
package/lib/es/index.js
CHANGED
|
@@ -234,9 +234,8 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
|
|
|
234
234
|
_defineProperty(this, "_afterCommandInterceptors", []);
|
|
235
235
|
_defineProperty(this, "_workbookDisposables", /* @__PURE__ */ new Map());
|
|
236
236
|
_defineProperty(this, "_worksheetDisposables", /* @__PURE__ */ new Map());
|
|
237
|
-
_defineProperty(this, "_interceptorsDirty", false);
|
|
238
237
|
_defineProperty(this, "_composedInterceptorByKey", /* @__PURE__ */ new Map());
|
|
239
|
-
_defineProperty(this, "
|
|
238
|
+
_defineProperty(this, "_composedInterceptorVersion", 0);
|
|
240
239
|
_defineProperty(this, "writeCellInterceptor", new InterceptorManager({
|
|
241
240
|
BEFORE_CELL_EDIT,
|
|
242
241
|
AFTER_CELL_EDIT,
|
|
@@ -271,6 +270,7 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
|
|
|
271
270
|
this._worksheetDisposables.forEach((disposable) => disposable.dispose());
|
|
272
271
|
this._worksheetDisposables.clear();
|
|
273
272
|
this._interceptorsByName.clear();
|
|
273
|
+
this._composedInterceptorByKey.clear();
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
276
|
* Add a listener function to a specific command to add affiliated mutations. It should be called in controllers.
|
|
@@ -436,7 +436,7 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
|
|
|
436
436
|
var _b$priority6, _a$priority6;
|
|
437
437
|
return ((_b$priority6 = b.priority) !== null && _b$priority6 !== void 0 ? _b$priority6 : 0) - ((_a$priority6 = a.priority) !== null && _a$priority6 !== void 0 ? _a$priority6 : 0);
|
|
438
438
|
});
|
|
439
|
-
this.
|
|
439
|
+
this._invalidateComposedInterceptors();
|
|
440
440
|
if (key === INTERCEPTOR_POINT.CELL_CONTENT) {
|
|
441
441
|
const JOINED_EFFECT = InterceptorEffectEnum.Style | InterceptorEffectEnum.Value;
|
|
442
442
|
this._interceptorsByName.set(`${key}-${JOINED_EFFECT}`, sortedInterceptors);
|
|
@@ -448,27 +448,44 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
|
|
|
448
448
|
remove(this._interceptorsByName.get(`${key}-${JOINED_EFFECT}`), interceptor);
|
|
449
449
|
remove(this._interceptorsByName.get(`${key}-${InterceptorEffectEnum.Style}`), interceptor);
|
|
450
450
|
remove(this._interceptorsByName.get(`${key}-${InterceptorEffectEnum.Value}`), interceptor);
|
|
451
|
+
this._invalidateComposedInterceptors();
|
|
451
452
|
}));
|
|
452
453
|
} else {
|
|
453
454
|
this._interceptorsByName.set(key, sortedInterceptors);
|
|
454
|
-
return this.disposeWithMe(toDisposable(() =>
|
|
455
|
+
return this.disposeWithMe(toDisposable(() => {
|
|
456
|
+
remove(this._interceptorsByName.get(key), interceptor);
|
|
457
|
+
this._invalidateComposedInterceptors();
|
|
458
|
+
}));
|
|
455
459
|
}
|
|
456
460
|
}
|
|
457
461
|
fetchThroughInterceptors(name, effect, _key, filter) {
|
|
458
|
-
var _this$_interceptorsBy;
|
|
459
462
|
const byNamesKey = effect === void 0 ? name : `${name}-${effect}`;
|
|
460
463
|
const key = _key !== null && _key !== void 0 ? _key : byNamesKey;
|
|
461
464
|
let composed = this._composedInterceptorByKey.get(key);
|
|
462
|
-
|
|
463
|
-
if (!composed || !this._interceptorsDirty || composedInterceptorsLength !== (((_this$_interceptorsBy = this._interceptorsByName.get(byNamesKey)) === null || _this$_interceptorsBy === void 0 ? void 0 : _this$_interceptorsBy.length) || 0)) {
|
|
465
|
+
if (!composed) {
|
|
464
466
|
let interceptors = this._interceptorsByName.get(byNamesKey);
|
|
465
467
|
if (interceptors && filter) interceptors = interceptors.filter(filter);
|
|
466
468
|
composed = composeInterceptors(interceptors || []);
|
|
467
469
|
this._composedInterceptorByKey.set(key, composed);
|
|
468
|
-
this._composedInterceptorsLengthByKey.set(key, (interceptors === null || interceptors === void 0 ? void 0 : interceptors.length) || 0);
|
|
469
470
|
}
|
|
470
471
|
return composed;
|
|
471
472
|
}
|
|
473
|
+
_invalidateComposedInterceptors() {
|
|
474
|
+
this._composedInterceptorVersion += 1;
|
|
475
|
+
this._composedInterceptorByKey.clear();
|
|
476
|
+
}
|
|
477
|
+
_getCommonCellContentInterceptor(effect, cache) {
|
|
478
|
+
let composed = cache.get(effect);
|
|
479
|
+
if (!composed) {
|
|
480
|
+
composed = this.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect);
|
|
481
|
+
cache.set(effect, composed);
|
|
482
|
+
}
|
|
483
|
+
return composed;
|
|
484
|
+
}
|
|
485
|
+
_getCommonRowFilteredInterceptor(cache) {
|
|
486
|
+
if (!cache.interceptor) cache.interceptor = this.fetchThroughInterceptors(INTERCEPTOR_POINT.ROW_FILTERED);
|
|
487
|
+
return cache.interceptor;
|
|
488
|
+
}
|
|
472
489
|
_interceptWorkbook(workbook) {
|
|
473
490
|
const disposables = new DisposableCollection();
|
|
474
491
|
const unitId = workbook.getUnitId();
|
|
@@ -477,10 +494,14 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
|
|
|
477
494
|
const subUnitId = worksheet.getSheetId();
|
|
478
495
|
worksheet.__interceptViewModel((viewModel) => {
|
|
479
496
|
const sheetDisposables = new DisposableCollection();
|
|
497
|
+
const commonCellContentInterceptors = /* @__PURE__ */ new Map();
|
|
498
|
+
const commonRowFilteredInterceptor = { interceptor: null };
|
|
499
|
+
let commonCellContentInterceptorsVersion = -1;
|
|
500
|
+
let commonRowFilteredInterceptorVersion = -1;
|
|
480
501
|
sheetInterceptorService._worksheetDisposables.set(getWorksheetDisposableID(unitId, worksheet), sheetDisposables);
|
|
481
502
|
sheetDisposables.add(viewModel.registerCellContentInterceptor({ getCell(row, col, effect, key, filter) {
|
|
482
503
|
const rawData = worksheet.getCellRaw(row, col);
|
|
483
|
-
|
|
504
|
+
const context = {
|
|
484
505
|
unitId,
|
|
485
506
|
subUnitId,
|
|
486
507
|
row,
|
|
@@ -488,10 +509,22 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
|
|
|
488
509
|
worksheet,
|
|
489
510
|
workbook,
|
|
490
511
|
rawData
|
|
491
|
-
}
|
|
512
|
+
};
|
|
513
|
+
if (key === void 0 && filter === void 0) {
|
|
514
|
+
if (commonCellContentInterceptorsVersion !== sheetInterceptorService._composedInterceptorVersion) {
|
|
515
|
+
commonCellContentInterceptors.clear();
|
|
516
|
+
commonCellContentInterceptorsVersion = sheetInterceptorService._composedInterceptorVersion;
|
|
517
|
+
}
|
|
518
|
+
return sheetInterceptorService._getCommonCellContentInterceptor(effect, commonCellContentInterceptors)(rawData, context);
|
|
519
|
+
}
|
|
520
|
+
return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect, key, filter)(rawData, context);
|
|
492
521
|
} }));
|
|
493
522
|
sheetDisposables.add(viewModel.registerRowFilteredInterceptor({ getRowFiltered(row) {
|
|
494
|
-
|
|
523
|
+
if (commonRowFilteredInterceptorVersion !== sheetInterceptorService._composedInterceptorVersion) {
|
|
524
|
+
commonRowFilteredInterceptor.interceptor = null;
|
|
525
|
+
commonRowFilteredInterceptorVersion = sheetInterceptorService._composedInterceptorVersion;
|
|
526
|
+
}
|
|
527
|
+
return !!sheetInterceptorService._getCommonRowFilteredInterceptor(commonRowFilteredInterceptor)(false, {
|
|
495
528
|
unitId,
|
|
496
529
|
subUnitId,
|
|
497
530
|
row,
|
|
@@ -12792,12 +12825,13 @@ const InsertSheetCommand = {
|
|
|
12792
12825
|
let index = workbook.getSheets().length;
|
|
12793
12826
|
const sheet = params === null || params === void 0 ? void 0 : params.sheet;
|
|
12794
12827
|
const sheetId = sheet === null || sheet === void 0 ? void 0 : sheet.id;
|
|
12828
|
+
const sheetName = sheet === null || sheet === void 0 ? void 0 : sheet.name;
|
|
12795
12829
|
const sheetConfig = mergeWorksheetSnapshotWithDefault(sheet || {});
|
|
12796
12830
|
if (params) {
|
|
12797
12831
|
var _params$index;
|
|
12798
12832
|
index = (_params$index = params.index) !== null && _params$index !== void 0 ? _params$index : index;
|
|
12799
12833
|
sheetConfig.id = sheetId || generateRandomId();
|
|
12800
|
-
sheetConfig.name =
|
|
12834
|
+
sheetConfig.name = sheetName ? workbook.uniqueSheetName(sheetName) : workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`);
|
|
12801
12835
|
} else {
|
|
12802
12836
|
sheetConfig.id = generateRandomId();
|
|
12803
12837
|
sheetConfig.name = workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`);
|
|
@@ -18930,7 +18964,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
|
|
|
18930
18964
|
});
|
|
18931
18965
|
}
|
|
18932
18966
|
_initUpdateCellInfoCache() {
|
|
18933
|
-
this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe((permission) => {
|
|
18967
|
+
this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe((permission) => {
|
|
18934
18968
|
const { subUnitId, unitId, permissionId } = permission;
|
|
18935
18969
|
const ruleId = this._permissionIdCache.get(permissionId);
|
|
18936
18970
|
if (!ruleId) return;
|
|
@@ -18941,8 +18975,8 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
|
|
|
18941
18975
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
18942
18976
|
for (let i = startRow; i <= endRow; i++) for (let j = startColumn; j <= endColumn; j++) cellInfoMap.delete(`${i}-${j}`);
|
|
18943
18977
|
});
|
|
18944
|
-
});
|
|
18945
|
-
this._ruleModel.ruleChange$.subscribe((info) => {
|
|
18978
|
+
}));
|
|
18979
|
+
this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
|
|
18946
18980
|
const { unitId, subUnitId } = info;
|
|
18947
18981
|
const cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
|
|
18948
18982
|
info.rule.ranges.forEach((range) => {
|
|
@@ -18958,10 +18992,10 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
|
|
|
18958
18992
|
});
|
|
18959
18993
|
});
|
|
18960
18994
|
}
|
|
18961
|
-
});
|
|
18995
|
+
}));
|
|
18962
18996
|
}
|
|
18963
18997
|
_initUpdateCellRuleCache() {
|
|
18964
|
-
this._ruleModel.ruleChange$.subscribe((ruleChange) => {
|
|
18998
|
+
this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((ruleChange) => {
|
|
18965
18999
|
const { type } = ruleChange;
|
|
18966
19000
|
if (type === "add") this._addCellRuleCache(ruleChange);
|
|
18967
19001
|
else if (type === "delete") this._deleteCellRuleCache(ruleChange);
|
|
@@ -18972,7 +19006,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
|
|
|
18972
19006
|
});
|
|
18973
19007
|
this._addCellRuleCache(ruleChange);
|
|
18974
19008
|
}
|
|
18975
|
-
});
|
|
19009
|
+
}));
|
|
18976
19010
|
}
|
|
18977
19011
|
_ensureRuleMap(unitId, subUnitId) {
|
|
18978
19012
|
let subUnitMap = this._cellRuleCache.get(unitId);
|
|
@@ -19105,7 +19139,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
|
|
|
19105
19139
|
});
|
|
19106
19140
|
}
|
|
19107
19141
|
_initUpdateRowColInfoCache() {
|
|
19108
|
-
this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe({ next: (permission) => {
|
|
19142
|
+
this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe({ next: (permission) => {
|
|
19109
19143
|
const { subUnitId, unitId, permissionId } = permission;
|
|
19110
19144
|
const ruleId = this._permissionIdCache.get(permissionId);
|
|
19111
19145
|
if (!ruleId) return;
|
|
@@ -19127,8 +19161,8 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
|
|
|
19127
19161
|
}
|
|
19128
19162
|
}
|
|
19129
19163
|
});
|
|
19130
|
-
} });
|
|
19131
|
-
this._ruleModel.ruleChange$.subscribe((info) => {
|
|
19164
|
+
} }));
|
|
19165
|
+
this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
|
|
19132
19166
|
if (info.type === "delete") {
|
|
19133
19167
|
const { unitId, subUnitId, rule } = info;
|
|
19134
19168
|
const rowInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "row");
|
|
@@ -19145,7 +19179,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
|
|
|
19145
19179
|
}
|
|
19146
19180
|
});
|
|
19147
19181
|
}
|
|
19148
|
-
});
|
|
19182
|
+
}));
|
|
19149
19183
|
}
|
|
19150
19184
|
getCellInfo(unitId, subUnitId, row, col) {
|
|
19151
19185
|
var _this$_cellRuleCache$;
|
|
@@ -19188,7 +19222,7 @@ RangeProtectionCache = __decorate([
|
|
|
19188
19222
|
//#endregion
|
|
19189
19223
|
//#region package.json
|
|
19190
19224
|
var name = "@univerjs/sheets";
|
|
19191
|
-
var version = "0.22.
|
|
19225
|
+
var version = "0.22.1-insiders.20260516-8900c44";
|
|
19192
19226
|
|
|
19193
19227
|
//#endregion
|
|
19194
19228
|
//#region src/controllers/active-worksheet.controller.ts
|
package/lib/facade.js
CHANGED
|
@@ -6996,7 +6996,7 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
|
|
|
6996
6996
|
create(name, rows, columns, options) {
|
|
6997
6997
|
var _options$sheet, _options$sheet2, _options$index;
|
|
6998
6998
|
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((_options$sheet = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet !== void 0 ? _options$sheet : {}));
|
|
6999
|
-
newSheet.name =
|
|
6999
|
+
newSheet.name = name;
|
|
7000
7000
|
newSheet.rowCount = rows;
|
|
7001
7001
|
newSheet.columnCount = columns;
|
|
7002
7002
|
newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
|
|
@@ -7109,7 +7109,8 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
|
|
|
7109
7109
|
insertSheet(sheetName, options) {
|
|
7110
7110
|
var _options$sheet3, _options$sheet4, _options$index2;
|
|
7111
7111
|
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((_options$sheet3 = options === null || options === void 0 ? void 0 : options.sheet) !== null && _options$sheet3 !== void 0 ? _options$sheet3 : {}));
|
|
7112
|
-
newSheet.name =
|
|
7112
|
+
if (sheetName !== void 0) newSheet.name = sheetName;
|
|
7113
|
+
else delete newSheet.name;
|
|
7113
7114
|
newSheet.id = options === null || options === void 0 || (_options$sheet4 = options.sheet) === null || _options$sheet4 === void 0 ? void 0 : _options$sheet4.id;
|
|
7114
7115
|
const newSheetIndex = (_options$index2 = options === null || options === void 0 ? void 0 : options.index) !== null && _options$index2 !== void 0 ? _options$index2 : this._workbook.getSheets().length;
|
|
7115
7116
|
this._commandService.syncExecuteCommand(InsertSheetCommand.id, {
|