@univerjs/sheets 1.0.0-alpha.8 → 1.0.0-beta.1
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 +57 -59
- package/lib/cjs/index.js +286 -312
- package/lib/cjs/locale/ar-SA.js +1 -2
- package/lib/cjs/locale/ca-ES.js +1 -2
- package/lib/cjs/locale/de-DE.js +1 -2
- package/lib/cjs/locale/en-US.js +1 -2
- package/lib/cjs/locale/es-ES.js +1 -2
- package/lib/cjs/locale/fa-IR.js +1 -2
- package/lib/cjs/locale/fr-FR.js +1 -2
- package/lib/cjs/locale/id-ID.js +1 -2
- package/lib/cjs/locale/it-IT.js +1 -2
- package/lib/cjs/locale/ja-JP.js +1 -2
- package/lib/cjs/locale/ko-KR.js +1 -2
- package/lib/cjs/locale/pl-PL.js +1 -2
- package/lib/cjs/locale/pt-BR.js +1 -2
- package/lib/cjs/locale/ru-RU.js +1 -2
- package/lib/cjs/locale/sk-SK.js +1 -2
- package/lib/cjs/locale/vi-VN.js +1 -2
- package/lib/cjs/locale/zh-CN.js +2 -3
- package/lib/cjs/locale/zh-HK.js +2 -3
- package/lib/cjs/locale/zh-TW.js +2 -3
- package/lib/es/facade.js +57 -59
- package/lib/es/index.js +287 -314
- package/lib/es/locale/ar-SA.js +1 -2
- package/lib/es/locale/ca-ES.js +1 -2
- package/lib/es/locale/de-DE.js +1 -2
- package/lib/es/locale/en-US.js +1 -2
- package/lib/es/locale/es-ES.js +1 -2
- package/lib/es/locale/fa-IR.js +1 -2
- package/lib/es/locale/fr-FR.js +1 -2
- package/lib/es/locale/id-ID.js +1 -2
- package/lib/es/locale/it-IT.js +1 -2
- package/lib/es/locale/ja-JP.js +1 -2
- package/lib/es/locale/ko-KR.js +1 -2
- package/lib/es/locale/pl-PL.js +1 -2
- package/lib/es/locale/pt-BR.js +1 -2
- package/lib/es/locale/ru-RU.js +1 -2
- package/lib/es/locale/sk-SK.js +1 -2
- package/lib/es/locale/vi-VN.js +1 -2
- package/lib/es/locale/zh-CN.js +2 -3
- package/lib/es/locale/zh-HK.js +2 -3
- package/lib/es/locale/zh-TW.js +2 -3
- package/lib/facade.js +57 -59
- package/lib/index.js +287 -314
- package/lib/locale/ar-SA.js +1 -2
- package/lib/locale/ca-ES.js +1 -2
- package/lib/locale/de-DE.js +1 -2
- package/lib/locale/en-US.js +1 -2
- package/lib/locale/es-ES.js +1 -2
- package/lib/locale/fa-IR.js +1 -2
- package/lib/locale/fr-FR.js +1 -2
- package/lib/locale/id-ID.js +1 -2
- package/lib/locale/it-IT.js +1 -2
- package/lib/locale/ja-JP.js +1 -2
- package/lib/locale/ko-KR.js +1 -2
- package/lib/locale/pl-PL.js +1 -2
- package/lib/locale/pt-BR.js +1 -2
- package/lib/locale/ru-RU.js +1 -2
- package/lib/locale/sk-SK.js +1 -2
- package/lib/locale/vi-VN.js +1 -2
- package/lib/locale/zh-CN.js +2 -3
- package/lib/locale/zh-HK.js +2 -3
- package/lib/locale/zh-TW.js +2 -3
- package/lib/types/basics/cell-type.d.ts +2 -1
- package/lib/types/facade/f-worksheet.d.ts +10 -9
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/en-US.d.ts +0 -1
- package/lib/types/services/ref-range/ref-range.service.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -8,6 +8,10 @@ let rxjs_operators = require("rxjs/operators");
|
|
|
8
8
|
let _univerjs_rpc = require("@univerjs/rpc");
|
|
9
9
|
|
|
10
10
|
//#region src/basics/cell-type.ts
|
|
11
|
+
function isCellImage(documentData) {
|
|
12
|
+
var _documentData$drawing;
|
|
13
|
+
return !!(documentData === null || documentData === void 0 || (_documentData$drawing = documentData.drawingsOrder) === null || _documentData$drawing === void 0 ? void 0 : _documentData$drawing.length);
|
|
14
|
+
}
|
|
11
15
|
/**
|
|
12
16
|
* Get cell value type by style, new value and old value.
|
|
13
17
|
* If the new value contains t, then take t directly. In other cases, we need to dynamically determine based on actual data and styles
|
|
@@ -284,10 +288,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
284
288
|
interceptCommand(interceptor) {
|
|
285
289
|
if (this._commandInterceptors.includes(interceptor)) throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
286
290
|
this._commandInterceptors.push(interceptor);
|
|
287
|
-
this._commandInterceptors.sort((a, b) =>
|
|
288
|
-
var _b$priority, _a$priority;
|
|
289
|
-
return ((_b$priority = b.priority) !== null && _b$priority !== void 0 ? _b$priority : 0) - ((_a$priority = a.priority) !== null && _a$priority !== void 0 ? _a$priority : 0);
|
|
290
|
-
});
|
|
291
|
+
this._commandInterceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
291
292
|
return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._commandInterceptors, interceptor)));
|
|
292
293
|
}
|
|
293
294
|
/**
|
|
@@ -298,25 +299,16 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
298
299
|
onCommandExecute(info) {
|
|
299
300
|
const infos = this._commandInterceptors.map((i) => i.getMutations(info));
|
|
300
301
|
return {
|
|
301
|
-
preUndos: infos.map((i) =>
|
|
302
|
-
var _i$preUndos;
|
|
303
|
-
return (_i$preUndos = i.preUndos) !== null && _i$preUndos !== void 0 ? _i$preUndos : [];
|
|
304
|
-
}).flat(),
|
|
302
|
+
preUndos: infos.map((i) => i.preUndos ?? []).flat(),
|
|
305
303
|
undos: infos.map((i) => i.undos).flat(),
|
|
306
|
-
preRedos: infos.map((i) =>
|
|
307
|
-
var _i$preRedos;
|
|
308
|
-
return (_i$preRedos = i.preRedos) !== null && _i$preRedos !== void 0 ? _i$preRedos : [];
|
|
309
|
-
}).flat(),
|
|
304
|
+
preRedos: infos.map((i) => i.preRedos ?? []).flat(),
|
|
310
305
|
redos: infos.map((i) => i.redos).flat()
|
|
311
306
|
};
|
|
312
307
|
}
|
|
313
308
|
interceptAfterCommand(interceptor) {
|
|
314
309
|
if (this._afterCommandInterceptors.includes(interceptor)) throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
315
310
|
this._afterCommandInterceptors.push(interceptor);
|
|
316
|
-
this._afterCommandInterceptors.sort((a, b) =>
|
|
317
|
-
var _b$priority2, _a$priority2;
|
|
318
|
-
return ((_b$priority2 = b.priority) !== null && _b$priority2 !== void 0 ? _b$priority2 : 0) - ((_a$priority2 = a.priority) !== null && _a$priority2 !== void 0 ? _a$priority2 : 0);
|
|
319
|
-
});
|
|
311
|
+
this._afterCommandInterceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
320
312
|
return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._afterCommandInterceptors, interceptor)));
|
|
321
313
|
}
|
|
322
314
|
afterCommandExecute(info) {
|
|
@@ -329,24 +321,15 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
329
321
|
interceptAutoHeight(interceptor) {
|
|
330
322
|
if (this._autoHeightInterceptors.includes(interceptor)) throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
331
323
|
this._autoHeightInterceptors.push(interceptor);
|
|
332
|
-
this._autoHeightInterceptors.sort((a, b) =>
|
|
333
|
-
var _b$priority3, _a$priority3;
|
|
334
|
-
return ((_b$priority3 = b.priority) !== null && _b$priority3 !== void 0 ? _b$priority3 : 0) - ((_a$priority3 = a.priority) !== null && _a$priority3 !== void 0 ? _a$priority3 : 0);
|
|
335
|
-
});
|
|
324
|
+
this._autoHeightInterceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
336
325
|
return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._autoHeightInterceptors, interceptor)));
|
|
337
326
|
}
|
|
338
327
|
generateMutationsOfAutoHeight(ctx) {
|
|
339
328
|
const infos = this._autoHeightInterceptors.map((i) => i.getMutations(ctx));
|
|
340
329
|
return {
|
|
341
|
-
preUndos: infos.map((i) =>
|
|
342
|
-
var _i$preUndos2;
|
|
343
|
-
return (_i$preUndos2 = i.preUndos) !== null && _i$preUndos2 !== void 0 ? _i$preUndos2 : [];
|
|
344
|
-
}).flat(),
|
|
330
|
+
preUndos: infos.map((i) => i.preUndos ?? []).flat(),
|
|
345
331
|
undos: infos.map((i) => i.undos).flat(),
|
|
346
|
-
preRedos: infos.map((i) =>
|
|
347
|
-
var _i$preRedos2;
|
|
348
|
-
return (_i$preRedos2 = i.preRedos) !== null && _i$preRedos2 !== void 0 ? _i$preRedos2 : [];
|
|
349
|
-
}).flat(),
|
|
332
|
+
preRedos: infos.map((i) => i.preRedos ?? []).flat(),
|
|
350
333
|
redos: infos.map((i) => i.redos).flat()
|
|
351
334
|
};
|
|
352
335
|
}
|
|
@@ -362,10 +345,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
362
345
|
interceptBeforeCommand(interceptor) {
|
|
363
346
|
if (this._beforeCommandInterceptor.includes(interceptor)) throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
364
347
|
this._beforeCommandInterceptor.push(interceptor);
|
|
365
|
-
this._beforeCommandInterceptor.sort((a, b) =>
|
|
366
|
-
var _b$priority4, _a$priority4;
|
|
367
|
-
return ((_b$priority4 = b.priority) !== null && _b$priority4 !== void 0 ? _b$priority4 : 0) - ((_a$priority4 = a.priority) !== null && _a$priority4 !== void 0 ? _a$priority4 : 0);
|
|
368
|
-
});
|
|
348
|
+
this._beforeCommandInterceptor.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
369
349
|
return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._beforeCommandInterceptor, interceptor)));
|
|
370
350
|
}
|
|
371
351
|
/**
|
|
@@ -384,24 +364,15 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
384
364
|
interceptRanges(interceptor) {
|
|
385
365
|
if (this._rangeInterceptors.includes(interceptor)) throw new Error("[SheetInterceptorService]: Interceptor already exists!");
|
|
386
366
|
this._rangeInterceptors.push(interceptor);
|
|
387
|
-
this._rangeInterceptors.sort((a, b) =>
|
|
388
|
-
var _b$priority5, _a$priority5;
|
|
389
|
-
return ((_b$priority5 = b.priority) !== null && _b$priority5 !== void 0 ? _b$priority5 : 0) - ((_a$priority5 = a.priority) !== null && _a$priority5 !== void 0 ? _a$priority5 : 0);
|
|
390
|
-
});
|
|
367
|
+
this._rangeInterceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
391
368
|
return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._rangeInterceptors, interceptor)));
|
|
392
369
|
}
|
|
393
370
|
generateMutationsByRanges(info) {
|
|
394
371
|
const infos = this._rangeInterceptors.map((i) => i.getMutations(info));
|
|
395
372
|
return {
|
|
396
|
-
preUndos: infos.map((i) =>
|
|
397
|
-
var _i$preUndos3;
|
|
398
|
-
return (_i$preUndos3 = i.preUndos) !== null && _i$preUndos3 !== void 0 ? _i$preUndos3 : [];
|
|
399
|
-
}).flat(),
|
|
373
|
+
preUndos: infos.map((i) => i.preUndos ?? []).flat(),
|
|
400
374
|
undos: infos.map((i) => i.undos).flat(),
|
|
401
|
-
preRedos: infos.map((i) =>
|
|
402
|
-
var _i$preRedos3;
|
|
403
|
-
return (_i$preRedos3 = i.preRedos) !== null && _i$preRedos3 !== void 0 ? _i$preRedos3 : [];
|
|
404
|
-
}).flat(),
|
|
375
|
+
preRedos: infos.map((i) => i.preRedos ?? []).flat(),
|
|
405
376
|
redos: infos.map((i) => i.redos).flat()
|
|
406
377
|
};
|
|
407
378
|
}
|
|
@@ -433,10 +404,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
433
404
|
if (!this._interceptorsByName.has(key)) this._interceptorsByName.set(key, []);
|
|
434
405
|
const interceptors = this._interceptorsByName.get(key);
|
|
435
406
|
interceptors.push(interceptor);
|
|
436
|
-
const sortedInterceptors = interceptors.sort((a, b) =>
|
|
437
|
-
var _b$priority6, _a$priority6;
|
|
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
|
-
});
|
|
407
|
+
const sortedInterceptors = interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
440
408
|
this._invalidateComposedInterceptors();
|
|
441
409
|
if (key === INTERCEPTOR_POINT.CELL_CONTENT) {
|
|
442
410
|
const JOINED_EFFECT = _univerjs_core.InterceptorEffectEnum.Style | _univerjs_core.InterceptorEffectEnum.Value;
|
|
@@ -461,7 +429,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
|
|
|
461
429
|
}
|
|
462
430
|
fetchThroughInterceptors(name, effect, _key, filter) {
|
|
463
431
|
const byNamesKey = effect === void 0 ? name : `${name}-${effect}`;
|
|
464
|
-
const key = _key
|
|
432
|
+
const key = _key ?? byNamesKey;
|
|
465
433
|
let composed = this._composedInterceptorByKey.get(key);
|
|
466
434
|
if (!composed) {
|
|
467
435
|
let interceptors = this._interceptorsByName.get(byNamesKey);
|
|
@@ -2170,7 +2138,7 @@ function handleStyle(styles, oldVal, newVal) {
|
|
|
2170
2138
|
*/
|
|
2171
2139
|
function transformStyle(oldStyle, newStyle) {
|
|
2172
2140
|
if (!newStyle || !Object.keys(newStyle).length) return oldStyle;
|
|
2173
|
-
const backupStyle = _univerjs_core.Tools.deepClone(oldStyle
|
|
2141
|
+
const backupStyle = _univerjs_core.Tools.deepClone(oldStyle ?? {}) || {};
|
|
2174
2142
|
const styleRecord = newStyle;
|
|
2175
2143
|
for (const key of _univerjs_core.STYLE_KEYS) {
|
|
2176
2144
|
if (!Object.prototype.hasOwnProperty.call(styleRecord, key)) continue;
|
|
@@ -2354,7 +2322,7 @@ const SetRangeValuesUndoMutationFactory = (accessor, params) => {
|
|
|
2354
2322
|
const cell = _univerjs_core.Tools.deepClone(cellMatrix === null || cellMatrix === void 0 ? void 0 : cellMatrix.getValue(row, col)) || {};
|
|
2355
2323
|
const oldStyle = styles.getStyleByCell(cell);
|
|
2356
2324
|
const newStyle = styles.getStyleByCell(newVal);
|
|
2357
|
-
cell.s = isOverrideStyle && Object.prototype.hasOwnProperty.call(newVal
|
|
2325
|
+
cell.s = isOverrideStyle && Object.prototype.hasOwnProperty.call(newVal ?? {}, "s") ? oldStyle ?? null : transformStyle(oldStyle, newStyle);
|
|
2358
2326
|
undoData.setValue(row, col, setNull(cell));
|
|
2359
2327
|
});
|
|
2360
2328
|
return {
|
|
@@ -2646,8 +2614,8 @@ const SetWorksheetRowHeightMutationFactory = (params, worksheet) => {
|
|
|
2646
2614
|
const rowHeight = {};
|
|
2647
2615
|
const manager = worksheet.getRowManager();
|
|
2648
2616
|
for (const { startRow, endRow } of ranges) for (let rowIndex = startRow; rowIndex < endRow + 1; rowIndex++) {
|
|
2649
|
-
var _manager$getRow
|
|
2650
|
-
rowHeight[rowIndex] = (
|
|
2617
|
+
var _manager$getRow;
|
|
2618
|
+
rowHeight[rowIndex] = ((_manager$getRow = manager.getRow(rowIndex)) === null || _manager$getRow === void 0 ? void 0 : _manager$getRow.h) ?? worksheet.getConfig().defaultRowHeight;
|
|
2651
2619
|
}
|
|
2652
2620
|
return {
|
|
2653
2621
|
unitId,
|
|
@@ -2676,11 +2644,11 @@ const SetWorksheetRowAutoHeightMutationFactory = (params, worksheet) => {
|
|
|
2676
2644
|
const results = [];
|
|
2677
2645
|
const manager = worksheet.getRowManager();
|
|
2678
2646
|
for (const rowInfo of rowsAutoHeightInfo) {
|
|
2679
|
-
var _manager$
|
|
2647
|
+
var _manager$getRow3;
|
|
2680
2648
|
const { row } = rowInfo;
|
|
2681
2649
|
results.push({
|
|
2682
2650
|
row,
|
|
2683
|
-
autoHeight: (
|
|
2651
|
+
autoHeight: ((_manager$getRow3 = manager.getRow(row)) === null || _manager$getRow3 === void 0 ? void 0 : _manager$getRow3.ah) ?? worksheet.getConfig().defaultRowHeight
|
|
2684
2652
|
});
|
|
2685
2653
|
}
|
|
2686
2654
|
return {
|
|
@@ -2714,10 +2682,7 @@ const SetWorksheetRowIsAutoHeightMutation = {
|
|
|
2714
2682
|
for (const { startRow, endRow } of ranges) for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
2715
2683
|
const row = manager.getRowOrCreate(rowIndex);
|
|
2716
2684
|
if (typeof autoHeightInfo === "number") row.ia = autoHeightInfo;
|
|
2717
|
-
else
|
|
2718
|
-
var _autoHeightInfo$rowIn;
|
|
2719
|
-
row.ia = (_autoHeightInfo$rowIn = autoHeightInfo[rowIndex]) !== null && _autoHeightInfo$rowIn !== void 0 ? _autoHeightInfo$rowIn : void 0;
|
|
2720
|
-
}
|
|
2685
|
+
else row.ia = autoHeightInfo[rowIndex] ?? void 0;
|
|
2721
2686
|
}
|
|
2722
2687
|
return true;
|
|
2723
2688
|
}
|
|
@@ -4253,8 +4218,7 @@ var WorkbookSelectionModel = class extends _univerjs_core.Disposable {
|
|
|
4253
4218
|
return this._worksheetSelections.get(sheetId);
|
|
4254
4219
|
}
|
|
4255
4220
|
getLastSelectionPrimaryCellOfWorksheet(sheetId) {
|
|
4256
|
-
|
|
4257
|
-
return (_this$_worksheetLastS = this._worksheetLastSelectionPrimaryCell.get(sheetId)) !== null && _this$_worksheetLastS !== void 0 ? _this$_worksheetLastS : null;
|
|
4221
|
+
return this._worksheetLastSelectionPrimaryCell.get(sheetId) ?? null;
|
|
4258
4222
|
}
|
|
4259
4223
|
setSelectionsOfWorksheet(sheetId, selections) {
|
|
4260
4224
|
this._worksheetSelections.set(sheetId, [...selections]);
|
|
@@ -4408,16 +4372,15 @@ let SheetsSelectionsService = class SheetsSelectionsService extends _univerjs_co
|
|
|
4408
4372
|
setSelections(unitIdOrSelections, worksheetIdOrType, selectionDatas, type) {
|
|
4409
4373
|
if (typeof unitIdOrSelections === "string" && typeof worksheetIdOrType === "string") {
|
|
4410
4374
|
const unitId = unitIdOrSelections;
|
|
4411
|
-
this._ensureWorkbookSelection(unitId).setSelections(worksheetIdOrType, selectionDatas || [], type
|
|
4375
|
+
this._ensureWorkbookSelection(unitId).setSelections(worksheetIdOrType, selectionDatas || [], type ?? 3);
|
|
4412
4376
|
return;
|
|
4413
4377
|
}
|
|
4414
4378
|
const current = this._currentSelectionPos;
|
|
4415
4379
|
if (!current) throw new Error("[SheetsSelectionsService]: cannot find current selection position!");
|
|
4416
4380
|
const { unitId, sheetId } = current;
|
|
4417
4381
|
if (typeof unitIdOrSelections === "object") {
|
|
4418
|
-
|
|
4419
|
-
const
|
|
4420
|
-
const type = (_ref = worksheetIdOrType) !== null && _ref !== void 0 ? _ref : 3;
|
|
4382
|
+
const selectionData = unitIdOrSelections ?? selectionDatas;
|
|
4383
|
+
const type = worksheetIdOrType ?? 3;
|
|
4421
4384
|
this._ensureWorkbookSelection(unitId).setSelections(sheetId, selectionData, type);
|
|
4422
4385
|
}
|
|
4423
4386
|
}
|
|
@@ -5115,12 +5078,11 @@ const MoveRangeCommand = {
|
|
|
5115
5078
|
}
|
|
5116
5079
|
};
|
|
5117
5080
|
function _resolveMoveRangeContext(accessor, params) {
|
|
5118
|
-
var _ref, _params$toUnitId, _params$fromSubUnitId, _ref2, _params$toSubUnitId;
|
|
5119
5081
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
5120
5082
|
const target = getSheetCommandTarget(univerInstanceService);
|
|
5121
|
-
const unitId =
|
|
5122
|
-
const fromSubUnitId =
|
|
5123
|
-
const toSubUnitId =
|
|
5083
|
+
const unitId = params.toUnitId ?? params.fromUnitId ?? (target === null || target === void 0 ? void 0 : target.unitId);
|
|
5084
|
+
const fromSubUnitId = params.fromSubUnitId ?? (target === null || target === void 0 ? void 0 : target.subUnitId);
|
|
5085
|
+
const toSubUnitId = params.toSubUnitId ?? params.fromSubUnitId ?? (target === null || target === void 0 ? void 0 : target.subUnitId);
|
|
5124
5086
|
if (!unitId || !fromSubUnitId || !toSubUnitId) return null;
|
|
5125
5087
|
if (params.fromUnitId && params.toUnitId && params.fromUnitId !== params.toUnitId) return null;
|
|
5126
5088
|
const workbook = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
@@ -5136,7 +5098,6 @@ function _resolveMoveRangeContext(accessor, params) {
|
|
|
5136
5098
|
};
|
|
5137
5099
|
}
|
|
5138
5100
|
function getMoveRangeCommandMutations(accessor, params, options = {}) {
|
|
5139
|
-
var _interceptorCommands$, _interceptorCommands$2;
|
|
5140
5101
|
const { includeSelection = true, includeAfterCommand = true, includeAutoHeight = true } = options;
|
|
5141
5102
|
const context = _resolveMoveRangeContext(accessor, params);
|
|
5142
5103
|
if (!context) return null;
|
|
@@ -5158,12 +5119,12 @@ function getMoveRangeCommandMutations(accessor, params, options = {}) {
|
|
|
5158
5119
|
};
|
|
5159
5120
|
const interceptorCommands = sheetInterceptorService.onCommandExecute(commandInfo);
|
|
5160
5121
|
const redos = [
|
|
5161
|
-
...
|
|
5122
|
+
...interceptorCommands.preRedos ?? [],
|
|
5162
5123
|
...moveRangeMutations.redos,
|
|
5163
5124
|
...interceptorCommands.redos
|
|
5164
5125
|
];
|
|
5165
5126
|
const undos = [
|
|
5166
|
-
...
|
|
5127
|
+
...interceptorCommands.preUndos ?? [],
|
|
5167
5128
|
...moveRangeMutations.undos,
|
|
5168
5129
|
...interceptorCommands.undos
|
|
5169
5130
|
];
|
|
@@ -5231,8 +5192,7 @@ function getMoveRangeUndoRedoMutations(accessor, from, to, ignoreMerge = false)
|
|
|
5231
5192
|
const toRedoCellValue = new _univerjs_core.ObjectMatrix();
|
|
5232
5193
|
const toUndoCellValue = new _univerjs_core.ObjectMatrix();
|
|
5233
5194
|
_univerjs_core.Range.foreach(fromRange, (row, col) => {
|
|
5234
|
-
|
|
5235
|
-
const cellData = (_Tools$deepClone = _univerjs_core.Tools.deepClone(fromWorksheetCellMatrix.getValue(row, col))) !== null && _Tools$deepClone !== void 0 ? _Tools$deepClone : null;
|
|
5195
|
+
const cellData = _univerjs_core.Tools.deepClone(fromWorksheetCellMatrix.getValue(row, col)) ?? null;
|
|
5236
5196
|
if (cellData === null || cellData === void 0 ? void 0 : cellData.s) cellData.s = workbook.getStyles().get(cellData.s);
|
|
5237
5197
|
fromRedoCellValue.setValue(row, col, null);
|
|
5238
5198
|
fromUndoCellValue.setValue(row, col, cellData);
|
|
@@ -5242,8 +5202,7 @@ function getMoveRangeUndoRedoMutations(accessor, from, to, ignoreMerge = false)
|
|
|
5242
5202
|
toRedoCellValue.setValue(range.startRow, range.startColumn, _univerjs_core.Tools.deepClone(cellData));
|
|
5243
5203
|
});
|
|
5244
5204
|
_univerjs_core.Range.foreach(toRange, (row, col) => {
|
|
5245
|
-
|
|
5246
|
-
const cellData = (_Tools$deepClone2 = _univerjs_core.Tools.deepClone(toWorksheetCellMatrix.getValue(row, col))) !== null && _Tools$deepClone2 !== void 0 ? _Tools$deepClone2 : null;
|
|
5205
|
+
const cellData = _univerjs_core.Tools.deepClone(toWorksheetCellMatrix.getValue(row, col)) ?? null;
|
|
5247
5206
|
toUndoCellValue.setValue(row, col, cellData);
|
|
5248
5207
|
});
|
|
5249
5208
|
const redoMoveRangeMutationParams = {
|
|
@@ -5310,7 +5269,7 @@ const SetRangeValuesCommand = {
|
|
|
5310
5269
|
id: "sheet.command.set-range-values",
|
|
5311
5270
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5312
5271
|
handler: (accessor, params) => {
|
|
5313
|
-
var _selectionManagerServ
|
|
5272
|
+
var _selectionManagerServ;
|
|
5314
5273
|
const target = getSheetCommandTarget(accessor.get(_univerjs_core.IUniverInstanceService), params);
|
|
5315
5274
|
if (!target) return false;
|
|
5316
5275
|
const currentSelections = (_selectionManagerServ = accessor.get(SheetsSelectionsService).getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range);
|
|
@@ -5338,7 +5297,7 @@ const SetRangeValuesCommand = {
|
|
|
5338
5297
|
const setRangeValuesMutationRedoParams = {
|
|
5339
5298
|
unitId,
|
|
5340
5299
|
subUnitId,
|
|
5341
|
-
cellValue:
|
|
5300
|
+
cellValue: realCellValue ?? cellValue.getMatrix()
|
|
5342
5301
|
};
|
|
5343
5302
|
const setRangeValuesMutationUndoParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationRedoParams);
|
|
5344
5303
|
const cellHeights = (0, _univerjs_core.mapObjectMatrix)(setRangeValuesMutationRedoParams.cellValue, (row, col) => worksheet.getCellHeight(row, col) || void 0);
|
|
@@ -5630,7 +5589,6 @@ const DeleteRangeMoveLeftCommand = {
|
|
|
5630
5589
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5631
5590
|
id: DeleteRangeMoveLeftCommandId,
|
|
5632
5591
|
handler: async (accessor, params) => {
|
|
5633
|
-
var _sheetInterceptor$pre, _sheetInterceptor$pre2;
|
|
5634
5592
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5635
5593
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5636
5594
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -5656,11 +5614,11 @@ const DeleteRangeMoveLeftCommand = {
|
|
|
5656
5614
|
params: { range }
|
|
5657
5615
|
});
|
|
5658
5616
|
const { redo: removeRangeRedo, undo: removeRangeUndo } = getRemoveRangeMutations(accessor, deleteRangeMutationParams);
|
|
5659
|
-
const redos = [...
|
|
5617
|
+
const redos = [...sheetInterceptor.preRedos ?? [], ...removeRangeRedo];
|
|
5660
5618
|
const undos = [...sheetInterceptor.undos, ...removeRangeUndo];
|
|
5661
5619
|
redos.push(...sheetInterceptor.redos);
|
|
5662
5620
|
redos.push(followSelectionOperation(range, workbook, worksheet));
|
|
5663
|
-
undos.push(...
|
|
5621
|
+
undos.push(...sheetInterceptor.preUndos ?? []);
|
|
5664
5622
|
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
5665
5623
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
5666
5624
|
id: DeleteRangeMoveLeftCommand.id,
|
|
@@ -5690,7 +5648,6 @@ const DeleteRangeMoveUpCommand = {
|
|
|
5690
5648
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5691
5649
|
id: DeleteRangeMoveUpCommandId,
|
|
5692
5650
|
handler: async (accessor, params) => {
|
|
5693
|
-
var _sheetInterceptor$pre, _sheetInterceptor$pre2;
|
|
5694
5651
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5695
5652
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5696
5653
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -5716,11 +5673,11 @@ const DeleteRangeMoveUpCommand = {
|
|
|
5716
5673
|
params: { range }
|
|
5717
5674
|
});
|
|
5718
5675
|
const { redo: removeRangeRedo, undo: removeRangeUndo } = getRemoveRangeMutations(accessor, deleteRangeMutationParams);
|
|
5719
|
-
const redos = [...
|
|
5676
|
+
const redos = [...sheetInterceptor.preRedos ?? [], ...removeRangeRedo];
|
|
5720
5677
|
const undos = [...sheetInterceptor.undos, ...removeRangeUndo];
|
|
5721
5678
|
redos.push(...sheetInterceptor.redos);
|
|
5722
5679
|
redos.push(followSelectionOperation(range, workbook, worksheet));
|
|
5723
|
-
undos.push(...
|
|
5680
|
+
undos.push(...sheetInterceptor.preUndos ?? []);
|
|
5724
5681
|
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
5725
5682
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
5726
5683
|
id: DeleteRangeMoveUpCommand.id,
|
|
@@ -5750,7 +5707,6 @@ const InsertRangeMoveDownCommand = {
|
|
|
5750
5707
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5751
5708
|
id: InsertRangeMoveDownCommandId,
|
|
5752
5709
|
handler: async (accessor, params) => {
|
|
5753
|
-
var _sheetInterceptor$pre, _sheetInterceptor$pre2;
|
|
5754
5710
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5755
5711
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5756
5712
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -5826,8 +5782,8 @@ const InsertRangeMoveDownCommand = {
|
|
|
5826
5782
|
});
|
|
5827
5783
|
redoMutations.push(...sheetInterceptor.redos);
|
|
5828
5784
|
redoMutations.push(followSelectionOperation(range, workbook, worksheet));
|
|
5829
|
-
undoMutations.push(...
|
|
5830
|
-
redoMutations.unshift(...
|
|
5785
|
+
undoMutations.push(...sheetInterceptor.preUndos ?? []);
|
|
5786
|
+
redoMutations.unshift(...sheetInterceptor.preRedos ?? []);
|
|
5831
5787
|
undoMutations.unshift(...sheetInterceptor.undos);
|
|
5832
5788
|
if ((0, _univerjs_core.sequenceExecute)(redoMutations, commandService).result) {
|
|
5833
5789
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
@@ -5858,7 +5814,6 @@ const InsertRangeMoveRightCommand = {
|
|
|
5858
5814
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5859
5815
|
id: InsertRangeMoveRightCommandId,
|
|
5860
5816
|
handler: async (accessor, params) => {
|
|
5861
|
-
var _sheetInterceptor$pre, _sheetInterceptor$pre2;
|
|
5862
5817
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5863
5818
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5864
5819
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -5934,8 +5889,8 @@ const InsertRangeMoveRightCommand = {
|
|
|
5934
5889
|
});
|
|
5935
5890
|
redoMutations.push(...sheetInterceptor.redos);
|
|
5936
5891
|
redoMutations.push(followSelectionOperation(range, workbook, worksheet));
|
|
5937
|
-
undoMutations.push(...
|
|
5938
|
-
redoMutations.unshift(...
|
|
5892
|
+
undoMutations.push(...sheetInterceptor.preUndos ?? []);
|
|
5893
|
+
redoMutations.unshift(...sheetInterceptor.preRedos ?? []);
|
|
5939
5894
|
undoMutations.unshift(...sheetInterceptor.undos);
|
|
5940
5895
|
if ((0, _univerjs_core.sequenceExecute)(redoMutations, commandService).result) {
|
|
5941
5896
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
@@ -5988,7 +5943,6 @@ const InsertRowByRangeCommand = {
|
|
|
5988
5943
|
type: _univerjs_core.CommandType.COMMAND,
|
|
5989
5944
|
id: "sheet.command.insert-row-by-range",
|
|
5990
5945
|
handler: (accessor, params) => {
|
|
5991
|
-
var _intercepted$preRedos, _intercepted$redos, _intercepted$preUndos, _intercepted$undos;
|
|
5992
5946
|
const target = getSheetCommandTarget(accessor.get(_univerjs_core.IUniverInstanceService), params);
|
|
5993
5947
|
if (!target) throw new Error("Workbook or Worksheet not found at InsertRowByRangeCommand");
|
|
5994
5948
|
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
@@ -6031,11 +5985,11 @@ const InsertRowByRangeCommand = {
|
|
|
6031
5985
|
id: InsertRowCommand.id,
|
|
6032
5986
|
params
|
|
6033
5987
|
});
|
|
6034
|
-
redos.unshift(...
|
|
6035
|
-
redos.push(...
|
|
5988
|
+
redos.unshift(...intercepted.preRedos ?? []);
|
|
5989
|
+
redos.push(...intercepted.redos ?? []);
|
|
6036
5990
|
redos.push(followSelectionOperation(range, workbook, worksheet));
|
|
6037
|
-
undos.unshift(...
|
|
6038
|
-
undos.push(...
|
|
5991
|
+
undos.unshift(...intercepted.preUndos ?? []);
|
|
5992
|
+
undos.push(...intercepted.undos ?? []);
|
|
6039
5993
|
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
6040
5994
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
6041
5995
|
id: InsertRowCommand.id,
|
|
@@ -6211,7 +6165,6 @@ const InsertColByRangeCommand = {
|
|
|
6211
6165
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6212
6166
|
id: "sheet.command.insert-col-by-range",
|
|
6213
6167
|
handler: (accessor, params) => {
|
|
6214
|
-
var _intercepted$preRedos2, _intercepted$redos2, _intercepted$preUndos2, _intercepted$undos2;
|
|
6215
6168
|
const target = getSheetCommandTarget(accessor.get(_univerjs_core.IUniverInstanceService), params);
|
|
6216
6169
|
if (!target) throw new Error("Workbook or Worksheet not found at InsertColByRangeCommand");
|
|
6217
6170
|
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
@@ -6254,11 +6207,11 @@ const InsertColByRangeCommand = {
|
|
|
6254
6207
|
id: InsertColCommand.id,
|
|
6255
6208
|
params
|
|
6256
6209
|
});
|
|
6257
|
-
redos.unshift(...
|
|
6258
|
-
redos.push(...
|
|
6210
|
+
redos.unshift(...intercepted.preRedos ?? []);
|
|
6211
|
+
redos.push(...intercepted.redos ?? []);
|
|
6259
6212
|
redos.push(followSelectionOperation(range, workbook, worksheet));
|
|
6260
|
-
undos.unshift(...
|
|
6261
|
-
undos.push(...
|
|
6213
|
+
undos.unshift(...intercepted.preUndos ?? []);
|
|
6214
|
+
undos.push(...intercepted.undos ?? []);
|
|
6262
6215
|
if ((0, _univerjs_core.sequenceExecute)(redos, commandService).result) {
|
|
6263
6216
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
6264
6217
|
id: InsertColCommand.id,
|
|
@@ -6420,7 +6373,6 @@ const RemoveRowByRangeCommand = {
|
|
|
6420
6373
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6421
6374
|
id: "sheet.command.remove-row-by-range",
|
|
6422
6375
|
handler: (accessor, params) => {
|
|
6423
|
-
var _intercepted$preRedos;
|
|
6424
6376
|
if (!params) return false;
|
|
6425
6377
|
const target = getSheetCommandTarget(accessor.get(_univerjs_core.IUniverInstanceService), params);
|
|
6426
6378
|
if (!target) return false;
|
|
@@ -6467,11 +6419,10 @@ const RemoveRowByRangeCommand = {
|
|
|
6467
6419
|
});
|
|
6468
6420
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
6469
6421
|
if ((0, _univerjs_core.sequenceExecute)([
|
|
6470
|
-
...
|
|
6422
|
+
...intercepted.preRedos ?? [],
|
|
6471
6423
|
...redoMutations,
|
|
6472
6424
|
...intercepted.redos
|
|
6473
6425
|
], commandService).result) {
|
|
6474
|
-
var _intercepted$preUndos, _intercepted$preRedos2;
|
|
6475
6426
|
setSelection(range, workbook, worksheet, commandService);
|
|
6476
6427
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
6477
6428
|
id: RemoveRowCommandId,
|
|
@@ -6481,13 +6432,13 @@ const RemoveRowByRangeCommand = {
|
|
|
6481
6432
|
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
6482
6433
|
unitID: unitId,
|
|
6483
6434
|
undoMutations: [
|
|
6484
|
-
...
|
|
6435
|
+
...intercepted.preUndos ?? [],
|
|
6485
6436
|
...undoMutations,
|
|
6486
6437
|
...intercepted.undos,
|
|
6487
6438
|
...afterInterceptors.undos
|
|
6488
6439
|
],
|
|
6489
6440
|
redoMutations: [
|
|
6490
|
-
...
|
|
6441
|
+
...intercepted.preRedos ?? [],
|
|
6491
6442
|
...redoMutations,
|
|
6492
6443
|
...intercepted.redos,
|
|
6493
6444
|
...afterInterceptors.redos
|
|
@@ -6539,7 +6490,6 @@ const RemoveColByRangeCommand = {
|
|
|
6539
6490
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6540
6491
|
id: "sheet.command.remove-col-by-range",
|
|
6541
6492
|
handler: (accessor, params) => {
|
|
6542
|
-
var _intercepted$preRedos3;
|
|
6543
6493
|
if (!params) return false;
|
|
6544
6494
|
const target = getSheetCommandTarget(accessor.get(_univerjs_core.IUniverInstanceService), params);
|
|
6545
6495
|
if (!target) return false;
|
|
@@ -6564,14 +6514,13 @@ const RemoveColByRangeCommand = {
|
|
|
6564
6514
|
});
|
|
6565
6515
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
6566
6516
|
if ((0, _univerjs_core.sequenceExecute)([
|
|
6567
|
-
...
|
|
6517
|
+
...intercepted.preRedos ?? [],
|
|
6568
6518
|
{
|
|
6569
6519
|
id: RemoveColMutation.id,
|
|
6570
6520
|
params: removeColParams
|
|
6571
6521
|
},
|
|
6572
6522
|
...intercepted.redos
|
|
6573
6523
|
], commandService).result) {
|
|
6574
|
-
var _intercepted$preUndos2, _intercepted$preRedos4;
|
|
6575
6524
|
setSelection(range, workbook, worksheet, commandService);
|
|
6576
6525
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
6577
6526
|
id: RemoveColCommandId,
|
|
@@ -6581,7 +6530,7 @@ const RemoveColByRangeCommand = {
|
|
|
6581
6530
|
accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
|
|
6582
6531
|
unitID: unitId,
|
|
6583
6532
|
undoMutations: [
|
|
6584
|
-
...
|
|
6533
|
+
...intercepted.preUndos ?? [],
|
|
6585
6534
|
{
|
|
6586
6535
|
id: InsertColMutation.id,
|
|
6587
6536
|
params: undoRemoveColParams
|
|
@@ -6594,7 +6543,7 @@ const RemoveColByRangeCommand = {
|
|
|
6594
6543
|
...afterInterceptors.undos
|
|
6595
6544
|
],
|
|
6596
6545
|
redoMutations: [
|
|
6597
|
-
...
|
|
6546
|
+
...intercepted.preRedos ?? [],
|
|
6598
6547
|
{
|
|
6599
6548
|
id: RemoveColMutation.id,
|
|
6600
6549
|
params: removeColParams
|
|
@@ -6696,7 +6645,6 @@ const MoveRowsCommand = {
|
|
|
6696
6645
|
id: MoveRowsCommandId,
|
|
6697
6646
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6698
6647
|
handler: (accessor, params) => {
|
|
6699
|
-
var _interceptorCommands$, _interceptorCommands$2;
|
|
6700
6648
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
6701
6649
|
const { fromRange: { startRow: fromRow }, toRange: { startRow: toRow }, range } = params;
|
|
6702
6650
|
const selections = range ? [covertRangeToSelection(range)] : selectionManagerService.getCurrentSelections();
|
|
@@ -6738,11 +6686,11 @@ const MoveRowsCommand = {
|
|
|
6738
6686
|
id: MoveRowsCommand.id,
|
|
6739
6687
|
params
|
|
6740
6688
|
});
|
|
6741
|
-
const redos = [...
|
|
6689
|
+
const redos = [...interceptorCommands.preRedos ?? [], {
|
|
6742
6690
|
id: MoveRowsMutation.id,
|
|
6743
6691
|
params: moveRowsParams
|
|
6744
6692
|
}];
|
|
6745
|
-
const undos = [...
|
|
6693
|
+
const undos = [...interceptorCommands.preUndos ?? [], {
|
|
6746
6694
|
id: MoveRowsMutation.id,
|
|
6747
6695
|
params: undoMoveRowsParams
|
|
6748
6696
|
}];
|
|
@@ -6808,7 +6756,6 @@ const MoveColsCommand = {
|
|
|
6808
6756
|
id: MoveColsCommandId,
|
|
6809
6757
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6810
6758
|
handler: (accessor, params) => {
|
|
6811
|
-
var _interceptorCommands$3, _interceptorCommands$4;
|
|
6812
6759
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
6813
6760
|
const { fromRange: { startColumn: fromCol }, toRange: { startColumn: toCol }, range } = params;
|
|
6814
6761
|
const selections = range ? [covertRangeToSelection(range)] : selectionManagerService.getCurrentSelections();
|
|
@@ -6850,11 +6797,11 @@ const MoveColsCommand = {
|
|
|
6850
6797
|
id: MoveColsCommand.id,
|
|
6851
6798
|
params
|
|
6852
6799
|
});
|
|
6853
|
-
const redos = [...
|
|
6800
|
+
const redos = [...interceptorCommands.preRedos ?? [], {
|
|
6854
6801
|
id: MoveColsMutation.id,
|
|
6855
6802
|
params: moveColsParams
|
|
6856
6803
|
}];
|
|
6857
|
-
const undos = [...
|
|
6804
|
+
const undos = [...interceptorCommands.preUndos ?? [], {
|
|
6858
6805
|
id: MoveColsMutation.id,
|
|
6859
6806
|
params: undoMoveColsParams
|
|
6860
6807
|
}];
|
|
@@ -6929,7 +6876,6 @@ const ReorderRangeCommand = {
|
|
|
6929
6876
|
id: ReorderRangeCommandId,
|
|
6930
6877
|
type: _univerjs_core.CommandType.COMMAND,
|
|
6931
6878
|
handler: (accessor, params) => {
|
|
6932
|
-
var _interceptorCommands$, _interceptorCommands$2;
|
|
6933
6879
|
const { subUnitId, unitId, range, order } = params;
|
|
6934
6880
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
6935
6881
|
const reorderMutation = {
|
|
@@ -6951,12 +6897,12 @@ const ReorderRangeCommand = {
|
|
|
6951
6897
|
params
|
|
6952
6898
|
});
|
|
6953
6899
|
const redos = [
|
|
6954
|
-
...
|
|
6900
|
+
...interceptorCommands.preRedos ?? [],
|
|
6955
6901
|
reorderMutation,
|
|
6956
6902
|
...interceptorCommands.redos
|
|
6957
6903
|
];
|
|
6958
6904
|
const undos = [
|
|
6959
|
-
...
|
|
6905
|
+
...interceptorCommands.preUndos ?? [],
|
|
6960
6906
|
undoReorderMutation,
|
|
6961
6907
|
...interceptorCommands.undos
|
|
6962
6908
|
];
|
|
@@ -7053,6 +6999,88 @@ const rotateRange = (range) => {
|
|
|
7053
6999
|
rangeType
|
|
7054
7000
|
};
|
|
7055
7001
|
};
|
|
7002
|
+
function mergeAndSortRanges(ranges) {
|
|
7003
|
+
return sortRanges(ranges.length > 1 ? _univerjs_core.Rectangle.mergeRanges(ranges) : ranges);
|
|
7004
|
+
}
|
|
7005
|
+
function sortRanges(ranges) {
|
|
7006
|
+
return ranges.sort((a, b) => a.startRow - b.startRow || a.startColumn - b.startColumn || a.endRow - b.endRow || a.endColumn - b.endColumn);
|
|
7007
|
+
}
|
|
7008
|
+
function translateRange(range, rowOffset, columnOffset) {
|
|
7009
|
+
return {
|
|
7010
|
+
startRow: range.startRow + rowOffset,
|
|
7011
|
+
endRow: range.endRow + rowOffset,
|
|
7012
|
+
startColumn: range.startColumn + columnOffset,
|
|
7013
|
+
endColumn: range.endColumn + columnOffset
|
|
7014
|
+
};
|
|
7015
|
+
}
|
|
7016
|
+
function moveRangeAlongAxis(targetRange, from, count, to, isRow) {
|
|
7017
|
+
let transforms;
|
|
7018
|
+
if (from > to) transforms = [
|
|
7019
|
+
{
|
|
7020
|
+
start: Number.NEGATIVE_INFINITY,
|
|
7021
|
+
end: to - 1,
|
|
7022
|
+
offset: 0
|
|
7023
|
+
},
|
|
7024
|
+
{
|
|
7025
|
+
start: to,
|
|
7026
|
+
end: from - 1,
|
|
7027
|
+
offset: count
|
|
7028
|
+
},
|
|
7029
|
+
{
|
|
7030
|
+
start: from,
|
|
7031
|
+
end: from + count - 1,
|
|
7032
|
+
offset: to - from
|
|
7033
|
+
},
|
|
7034
|
+
{
|
|
7035
|
+
start: from + count,
|
|
7036
|
+
end: Number.POSITIVE_INFINITY,
|
|
7037
|
+
offset: 0
|
|
7038
|
+
}
|
|
7039
|
+
];
|
|
7040
|
+
else {
|
|
7041
|
+
if (from + count > to) throw new Error("Invalid move operation");
|
|
7042
|
+
transforms = [
|
|
7043
|
+
{
|
|
7044
|
+
start: Number.NEGATIVE_INFINITY,
|
|
7045
|
+
end: from - 1,
|
|
7046
|
+
offset: 0
|
|
7047
|
+
},
|
|
7048
|
+
{
|
|
7049
|
+
start: from,
|
|
7050
|
+
end: from + count - 1,
|
|
7051
|
+
offset: to - from - count
|
|
7052
|
+
},
|
|
7053
|
+
{
|
|
7054
|
+
start: from + count,
|
|
7055
|
+
end: to - 1,
|
|
7056
|
+
offset: -count
|
|
7057
|
+
},
|
|
7058
|
+
{
|
|
7059
|
+
start: to,
|
|
7060
|
+
end: Number.POSITIVE_INFINITY,
|
|
7061
|
+
offset: 0
|
|
7062
|
+
}
|
|
7063
|
+
];
|
|
7064
|
+
}
|
|
7065
|
+
const rangeStart = isRow ? targetRange.startRow : targetRange.startColumn;
|
|
7066
|
+
const rangeEnd = isRow ? targetRange.endRow : targetRange.endColumn;
|
|
7067
|
+
return mergeAndSortRanges(transforms.flatMap(({ start, end, offset }) => {
|
|
7068
|
+
const intersectStart = Math.max(rangeStart, start);
|
|
7069
|
+
const intersectEnd = Math.min(rangeEnd, end);
|
|
7070
|
+
if (intersectStart > intersectEnd) return [];
|
|
7071
|
+
return [translateRange(isRow ? {
|
|
7072
|
+
startRow: intersectStart,
|
|
7073
|
+
endRow: intersectEnd,
|
|
7074
|
+
startColumn: targetRange.startColumn,
|
|
7075
|
+
endColumn: targetRange.endColumn
|
|
7076
|
+
} : {
|
|
7077
|
+
startRow: targetRange.startRow,
|
|
7078
|
+
endRow: targetRange.endRow,
|
|
7079
|
+
startColumn: intersectStart,
|
|
7080
|
+
endColumn: intersectEnd
|
|
7081
|
+
}, isRow ? offset : 0, isRow ? 0 : offset)];
|
|
7082
|
+
}));
|
|
7083
|
+
}
|
|
7056
7084
|
/**
|
|
7057
7085
|
* see docs/tldr/ref-range/move-rows-cols.tldr
|
|
7058
7086
|
*/
|
|
@@ -7158,33 +7186,33 @@ const handleMoveRowsCommon = (params, targetRange) => {
|
|
|
7158
7186
|
const fromRow = fromRange.startRow;
|
|
7159
7187
|
const count = fromRange.endRow - fromRange.startRow + 1;
|
|
7160
7188
|
const toRow = toRange.startRow;
|
|
7161
|
-
|
|
7162
|
-
_univerjs_core.Range.foreach(targetRange, (row, col) => {
|
|
7163
|
-
matrix.setValue(row, col, 1);
|
|
7164
|
-
});
|
|
7165
|
-
matrix.moveRows(fromRow, count, toRow);
|
|
7166
|
-
return (0, _univerjs_core.queryObjectMatrix)(matrix, (value) => value === 1);
|
|
7189
|
+
return moveRangeAlongAxis(targetRange, fromRow, count, toRow, true);
|
|
7167
7190
|
};
|
|
7168
7191
|
const handleReorderRangeCommon = (param, targetRange) => {
|
|
7169
7192
|
const { range, order } = param.params || {};
|
|
7170
7193
|
if (!range || !order) return [targetRange];
|
|
7171
|
-
const
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
if (
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7194
|
+
const overwrittenRows = [];
|
|
7195
|
+
const additions = [];
|
|
7196
|
+
const startColumn = Math.max(range.startColumn, targetRange.startColumn);
|
|
7197
|
+
const endColumn = Math.min(range.endColumn, targetRange.endColumn);
|
|
7198
|
+
Object.keys(order).forEach((key) => {
|
|
7199
|
+
const row = Number(key);
|
|
7200
|
+
if (row < range.startRow || row > range.endRow) return;
|
|
7201
|
+
overwrittenRows.push({
|
|
7202
|
+
startRow: row,
|
|
7203
|
+
endRow: row,
|
|
7204
|
+
startColumn: range.startColumn,
|
|
7205
|
+
endColumn: range.endColumn
|
|
7206
|
+
});
|
|
7207
|
+
const sourceRow = order[row];
|
|
7208
|
+
if (sourceRow >= targetRange.startRow && sourceRow <= targetRange.endRow && startColumn <= endColumn) additions.push({
|
|
7209
|
+
startRow: row,
|
|
7210
|
+
endRow: row,
|
|
7211
|
+
startColumn,
|
|
7212
|
+
endColumn
|
|
7213
|
+
});
|
|
7186
7214
|
});
|
|
7187
|
-
return (
|
|
7215
|
+
return mergeAndSortRanges([..._univerjs_core.Rectangle.subtractMulti([targetRange], overwrittenRows), ...additions]);
|
|
7188
7216
|
};
|
|
7189
7217
|
const handleMoveCols = (params, targetRange) => {
|
|
7190
7218
|
const { fromRange, toRange } = params.params || {};
|
|
@@ -7215,12 +7243,7 @@ const handleMoveColsCommon = (params, targetRange) => {
|
|
|
7215
7243
|
const fromCol = fromRange.startColumn;
|
|
7216
7244
|
const count = fromRange.endColumn - fromRange.startColumn + 1;
|
|
7217
7245
|
const toCol = toRange.startColumn;
|
|
7218
|
-
|
|
7219
|
-
_univerjs_core.Range.foreach(targetRange, (row, col) => {
|
|
7220
|
-
matrix.setValue(row, col, 1);
|
|
7221
|
-
});
|
|
7222
|
-
matrix.moveColumns(fromCol, count, toCol);
|
|
7223
|
-
return (0, _univerjs_core.queryObjectMatrix)(matrix, (value) => value === 1);
|
|
7246
|
+
return moveRangeAlongAxis(targetRange, fromCol, count, toCol, false);
|
|
7224
7247
|
};
|
|
7225
7248
|
const handleMoveRange = (param, targetRange) => {
|
|
7226
7249
|
var _param$params, _param$params2;
|
|
@@ -7250,33 +7273,12 @@ const handleMoveRangeCommon = (param, targetRange) => {
|
|
|
7250
7273
|
const relativeRange = _univerjs_core.Rectangle.getRelativeRange(targetRange, fromRange);
|
|
7251
7274
|
return [_univerjs_core.Rectangle.getPositionRange(relativeRange, toRange)];
|
|
7252
7275
|
}
|
|
7253
|
-
const matrix = new _univerjs_core.ObjectMatrix();
|
|
7254
|
-
_univerjs_core.Range.foreach(targetRange, (row, col) => {
|
|
7255
|
-
matrix.setValue(row, col, 1);
|
|
7256
|
-
});
|
|
7257
|
-
const fromMatrix = new _univerjs_core.ObjectMatrix();
|
|
7258
|
-
const loopFromRange = (0, _univerjs_core.getIntersectRange)(fromRange, targetRange);
|
|
7259
|
-
loopFromRange && _univerjs_core.Range.foreach(loopFromRange, (row, col) => {
|
|
7260
|
-
if (matrix.getValue(row, col)) {
|
|
7261
|
-
matrix.setValue(row, col, void 0);
|
|
7262
|
-
fromMatrix.setValue(row, col, 1);
|
|
7263
|
-
}
|
|
7264
|
-
});
|
|
7265
7276
|
const columnOffset = toRange.startColumn - fromRange.startColumn;
|
|
7266
7277
|
const rowOffset = toRange.startRow - fromRange.startRow;
|
|
7267
|
-
const
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
endRow: toRange.endRow - rowOffset
|
|
7272
|
-
};
|
|
7273
|
-
loopToRange && _univerjs_core.Range.foreach(loopToRange, (row, col) => {
|
|
7274
|
-
var _fromMatrix$getValue;
|
|
7275
|
-
const targetRow = row + rowOffset;
|
|
7276
|
-
const targetCol = col + columnOffset;
|
|
7277
|
-
matrix.setValue(targetRow, targetCol, (_fromMatrix$getValue = fromMatrix.getValue(row, col)) !== null && _fromMatrix$getValue !== void 0 ? _fromMatrix$getValue : 0);
|
|
7278
|
-
});
|
|
7279
|
-
return (0, _univerjs_core.queryObjectMatrix)(matrix, (value) => value === 1);
|
|
7278
|
+
const movedRange = (0, _univerjs_core.getIntersectRange)(fromRange, targetRange);
|
|
7279
|
+
const remainingRanges = _univerjs_core.Rectangle.subtractMulti([targetRange], [fromRange, toRange]);
|
|
7280
|
+
const translatedRanges = movedRange ? [translateRange(movedRange, rowOffset, columnOffset)] : [];
|
|
7281
|
+
return mergeAndSortRanges([...remainingRanges, ...translatedRanges]);
|
|
7280
7282
|
};
|
|
7281
7283
|
const handleBaseRemoveRange = (_removeRange, _targetRange) => {
|
|
7282
7284
|
const removeRange = handleRangeTypeInput(_removeRange);
|
|
@@ -7486,16 +7488,7 @@ const handleInsertRangeMoveDownCommon = (param, targetRange) => {
|
|
|
7486
7488
|
const noMoveRanges = _univerjs_core.Rectangle.subtract(targetRange, bottomRange);
|
|
7487
7489
|
const targetMoveRange = (0, _univerjs_core.getIntersectRange)(bottomRange, targetRange);
|
|
7488
7490
|
if (!targetMoveRange) return [targetRange];
|
|
7489
|
-
|
|
7490
|
-
noMoveRanges.forEach((noMoveRange) => {
|
|
7491
|
-
_univerjs_core.Range.foreach(noMoveRange, (row, col) => {
|
|
7492
|
-
matrix.setValue(row, col, 1);
|
|
7493
|
-
});
|
|
7494
|
-
});
|
|
7495
|
-
targetMoveRange && _univerjs_core.Range.foreach(targetMoveRange, (row, col) => {
|
|
7496
|
-
matrix.setValue(row + moveCount, col, 1);
|
|
7497
|
-
});
|
|
7498
|
-
return (0, _univerjs_core.queryObjectMatrix)(matrix, (v) => v === 1);
|
|
7491
|
+
return sortRanges([...noMoveRanges, translateRange(targetMoveRange, moveCount, 0)]);
|
|
7499
7492
|
};
|
|
7500
7493
|
const handleInsertRangeMoveRight = (param, targetRange) => {
|
|
7501
7494
|
var _param$params11;
|
|
@@ -7523,16 +7516,7 @@ const handleInsertRangeMoveRightCommon = (param, targetRange) => {
|
|
|
7523
7516
|
const noMoveRanges = _univerjs_core.Rectangle.subtract(targetRange, bottomRange);
|
|
7524
7517
|
const targetMoveRange = (0, _univerjs_core.getIntersectRange)(bottomRange, targetRange);
|
|
7525
7518
|
if (!targetMoveRange) return [targetRange];
|
|
7526
|
-
|
|
7527
|
-
noMoveRanges.forEach((noMoveRange) => {
|
|
7528
|
-
_univerjs_core.Range.foreach(noMoveRange, (row, col) => {
|
|
7529
|
-
matrix.setValue(row, col, 1);
|
|
7530
|
-
});
|
|
7531
|
-
});
|
|
7532
|
-
targetMoveRange && _univerjs_core.Range.foreach(targetMoveRange, (row, col) => {
|
|
7533
|
-
matrix.setValue(row, col + moveCount, 1);
|
|
7534
|
-
});
|
|
7535
|
-
return (0, _univerjs_core.queryObjectMatrix)(matrix, (v) => v === 1);
|
|
7519
|
+
return sortRanges([...noMoveRanges, translateRange(targetMoveRange, 0, moveCount)]);
|
|
7536
7520
|
};
|
|
7537
7521
|
const handleDeleteRangeMoveLeft = (param, targetRange) => {
|
|
7538
7522
|
var _param$params13;
|
|
@@ -7562,23 +7546,11 @@ const handleDeleteRangeMoveLeftCommon = (param, targetRange) => {
|
|
|
7562
7546
|
endColumn: Number.POSITIVE_INFINITY
|
|
7563
7547
|
};
|
|
7564
7548
|
const moveCount = range.endColumn - range.startColumn + 1;
|
|
7565
|
-
const targetDeleteRange = (0, _univerjs_core.getIntersectRange)(range, targetRange);
|
|
7566
7549
|
const noMoveRanges = _univerjs_core.Rectangle.subtract(targetRange, rightRange);
|
|
7567
7550
|
const targetMoveRange = (0, _univerjs_core.getIntersectRange)(rightRange, targetRange);
|
|
7568
|
-
if (!
|
|
7569
|
-
const
|
|
7570
|
-
|
|
7571
|
-
matrix.setValue(row, col - moveCount, 1);
|
|
7572
|
-
});
|
|
7573
|
-
targetDeleteRange && _univerjs_core.Range.foreach(targetDeleteRange, (row, col) => {
|
|
7574
|
-
matrix.setValue(row, col - moveCount, 0);
|
|
7575
|
-
});
|
|
7576
|
-
noMoveRanges.forEach((noMoveRange) => {
|
|
7577
|
-
_univerjs_core.Range.foreach(noMoveRange, (row, col) => {
|
|
7578
|
-
matrix.setValue(row, col, 1);
|
|
7579
|
-
});
|
|
7580
|
-
});
|
|
7581
|
-
return (0, _univerjs_core.queryObjectMatrix)(matrix, (v) => v === 1);
|
|
7551
|
+
if (!targetMoveRange) return [targetRange];
|
|
7552
|
+
const movedRanges = targetMoveRange ? _univerjs_core.Rectangle.subtract(targetMoveRange, range).map((target) => translateRange(target, 0, -moveCount)) : [];
|
|
7553
|
+
return mergeAndSortRanges([...noMoveRanges, ...movedRanges]);
|
|
7582
7554
|
};
|
|
7583
7555
|
const handleDeleteRangeMoveUp = (param, targetRange) => {
|
|
7584
7556
|
var _param$params15;
|
|
@@ -7607,27 +7579,14 @@ const handleDeleteRangeMoveUpCommon = (param, targetRange) => {
|
|
|
7607
7579
|
endRow: Number.POSITIVE_INFINITY
|
|
7608
7580
|
};
|
|
7609
7581
|
const moveCount = range.endRow - range.startRow + 1;
|
|
7610
|
-
const targetDeleteRange = (0, _univerjs_core.getIntersectRange)(range, targetRange);
|
|
7611
7582
|
const noMoveRanges = _univerjs_core.Rectangle.subtract(targetRange, bottomRange);
|
|
7612
7583
|
const targetMoveRange = (0, _univerjs_core.getIntersectRange)(bottomRange, targetRange);
|
|
7613
|
-
if (!
|
|
7614
|
-
const
|
|
7615
|
-
|
|
7616
|
-
matrix.setValue(row - moveCount, col, 1);
|
|
7617
|
-
});
|
|
7618
|
-
targetDeleteRange && _univerjs_core.Range.foreach(targetDeleteRange, (row, col) => {
|
|
7619
|
-
matrix.setValue(row - moveCount, col, 0);
|
|
7620
|
-
});
|
|
7621
|
-
noMoveRanges.forEach((noMoveRange) => {
|
|
7622
|
-
_univerjs_core.Range.foreach(noMoveRange, (row, col) => {
|
|
7623
|
-
matrix.setValue(row, col, 1);
|
|
7624
|
-
});
|
|
7625
|
-
});
|
|
7626
|
-
return (0, _univerjs_core.queryObjectMatrix)(matrix, (v) => v === 1);
|
|
7584
|
+
if (!targetMoveRange) return [targetRange];
|
|
7585
|
+
const movedRanges = targetMoveRange ? _univerjs_core.Rectangle.subtract(targetMoveRange, range).map((target) => translateRange(target, -moveCount, 0)) : [];
|
|
7586
|
+
return mergeAndSortRanges([...noMoveRanges, ...movedRanges]);
|
|
7627
7587
|
};
|
|
7628
7588
|
const handleRemoveRowCommon = (param, targetRange) => {
|
|
7629
|
-
|
|
7630
|
-
const mergedRemoved = (0, _univerjs_core.mergeIntervals)(((_param$ranges = param.ranges) !== null && _param$ranges !== void 0 ? _param$ranges : [param.range]).map((range) => [range.startRow, range.endRow]));
|
|
7589
|
+
const mergedRemoved = (0, _univerjs_core.mergeIntervals)((param.ranges ?? [param.range]).map((range) => [range.startRow, range.endRow]));
|
|
7631
7590
|
let targetStartRow = targetRange.startRow;
|
|
7632
7591
|
let targetEndRow = targetRange.endRow;
|
|
7633
7592
|
for (let i = mergedRemoved.length - 1; i >= 0; i--) {
|
|
@@ -8178,8 +8137,9 @@ function getSeparateEffectedRangesOnCommand(accessor, command) {
|
|
|
8178
8137
|
const MERGE_REDO = (0, _univerjs_core.createInterceptorKey)("MERGE_REDO");
|
|
8179
8138
|
const MERGE_UNDO = (0, _univerjs_core.createInterceptorKey)("MERGE_UNDO");
|
|
8180
8139
|
var WatchRange = class extends _univerjs_core.Disposable {
|
|
8181
|
-
constructor(_unitId, _subUnitId, _range, _callback, _skipIntersects = false) {
|
|
8140
|
+
constructor(revision, _unitId, _subUnitId, _range, _callback, _skipIntersects = false) {
|
|
8182
8141
|
super();
|
|
8142
|
+
this.revision = revision;
|
|
8183
8143
|
this._unitId = _unitId;
|
|
8184
8144
|
this._subUnitId = _subUnitId;
|
|
8185
8145
|
this._range = _range;
|
|
@@ -8218,6 +8178,8 @@ let RefRangeService = class RefRangeService extends _univerjs_core.Disposable {
|
|
|
8218
8178
|
MERGE_UNDO
|
|
8219
8179
|
}));
|
|
8220
8180
|
_defineProperty(this, "_watchRanges", /* @__PURE__ */ new Set());
|
|
8181
|
+
_defineProperty(this, "_watchRangesListener", null);
|
|
8182
|
+
_defineProperty(this, "_watchRangeRevision", 0);
|
|
8221
8183
|
_defineProperty(this, "_refRangeManagerMap", /* @__PURE__ */ new Map());
|
|
8222
8184
|
_defineProperty(this, "_serializer", createRangeSerializer());
|
|
8223
8185
|
_defineProperty(this, "_onRefRangeChange", () => {
|
|
@@ -8249,15 +8211,14 @@ let RefRangeService = class RefRangeService extends _univerjs_core.Disposable {
|
|
|
8249
8211
|
}], unitId, subUnitId);
|
|
8250
8212
|
}
|
|
8251
8213
|
case EffectRefRangId.MoveRangeCommandId: {
|
|
8252
|
-
var _params$toUnitId, _params$toSubUnitId;
|
|
8253
8214
|
const params = command.params;
|
|
8254
8215
|
const sourceTarget = getSheetCommandTarget(this._univerInstanceService, {
|
|
8255
8216
|
unitId: params.fromUnitId,
|
|
8256
8217
|
subUnitId: params.fromSubUnitId
|
|
8257
8218
|
});
|
|
8258
8219
|
const destinationTarget = getSheetCommandTarget(this._univerInstanceService, {
|
|
8259
|
-
unitId:
|
|
8260
|
-
subUnitId:
|
|
8220
|
+
unitId: params.toUnitId ?? params.fromUnitId,
|
|
8221
|
+
subUnitId: params.toSubUnitId ?? params.fromSubUnitId
|
|
8261
8222
|
});
|
|
8262
8223
|
if (!sourceTarget && !destinationTarget) return [];
|
|
8263
8224
|
if (sourceTarget && destinationTarget && sourceTarget.unitId === destinationTarget.unitId && sourceTarget.subUnitId === destinationTarget.subUnitId) return this._checkRange([params.fromRange, params.toRange], sourceTarget.unitId, sourceTarget.subUnitId);
|
|
@@ -8375,11 +8336,10 @@ let RefRangeService = class RefRangeService extends _univerjs_core.Disposable {
|
|
|
8375
8336
|
result.push(v);
|
|
8376
8337
|
return result;
|
|
8377
8338
|
}, []).reduce((result, currentValue) => {
|
|
8378
|
-
var _currentValue$preRedo, _currentValue$preUndo;
|
|
8379
8339
|
result.redos.push(...currentValue.redos);
|
|
8380
8340
|
result.undos.push(...currentValue.undos);
|
|
8381
|
-
result.preRedos.push(...
|
|
8382
|
-
result.preUndos.push(...
|
|
8341
|
+
result.preRedos.push(...currentValue.preRedos ?? []);
|
|
8342
|
+
result.preUndos.push(...currentValue.preUndos ?? []);
|
|
8383
8343
|
return result;
|
|
8384
8344
|
}, {
|
|
8385
8345
|
redos: [],
|
|
@@ -8470,18 +8430,22 @@ let RefRangeService = class RefRangeService extends _univerjs_core.Disposable {
|
|
|
8470
8430
|
});
|
|
8471
8431
|
}
|
|
8472
8432
|
watchRange(unitId, subUnitId, range, callback, skipIntersects) {
|
|
8473
|
-
|
|
8474
|
-
if (this._watchRanges.size === 0) watchRangesListener = this._commandService.onCommandExecuted((command) => {
|
|
8433
|
+
if (!this._watchRangesListener) this._watchRangesListener = this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
8475
8434
|
if (command.type !== _univerjs_core.CommandType.MUTATION) return false;
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8435
|
+
const revision = this._watchRangeRevision;
|
|
8436
|
+
for (const watchRange of this._watchRanges) {
|
|
8437
|
+
if (watchRange.revision > revision) continue;
|
|
8438
|
+
watchRange.onMutation(command);
|
|
8439
|
+
}
|
|
8440
|
+
}));
|
|
8441
|
+
const watchRange = new WatchRange(++this._watchRangeRevision, unitId, subUnitId, range, callback, skipIntersects);
|
|
8479
8442
|
this._watchRanges.add(watchRange);
|
|
8480
8443
|
const teardownWatching = (0, _univerjs_core.toDisposable)(() => {
|
|
8481
8444
|
this._watchRanges.delete(watchRange);
|
|
8482
8445
|
if (this._watchRanges.size === 0) {
|
|
8483
|
-
|
|
8484
|
-
|
|
8446
|
+
var _this$_watchRangesLis;
|
|
8447
|
+
(_this$_watchRangesLis = this._watchRangesListener) === null || _this$_watchRangesLis === void 0 || _this$_watchRangesLis.dispose();
|
|
8448
|
+
this._watchRangesListener = null;
|
|
8485
8449
|
}
|
|
8486
8450
|
});
|
|
8487
8451
|
const registerToService = this.disposeWithMe(teardownWatching);
|
|
@@ -8875,11 +8839,10 @@ let MergeCellController = class MergeCellController extends _univerjs_core.Dispo
|
|
|
8875
8839
|
};
|
|
8876
8840
|
}
|
|
8877
8841
|
_handleMoveRangeCommand(params, unitId, subUnitId) {
|
|
8878
|
-
var _params$fromSubUnitId, _params$toSubUnitId;
|
|
8879
8842
|
const workbook = getWorkbook(this._univerInstanceService, unitId);
|
|
8880
8843
|
if (!workbook) return this._handleNull();
|
|
8881
|
-
const sourceSubUnitId =
|
|
8882
|
-
const targetSubUnitId =
|
|
8844
|
+
const sourceSubUnitId = params.fromSubUnitId ?? subUnitId;
|
|
8845
|
+
const targetSubUnitId = params.toSubUnitId ?? sourceSubUnitId;
|
|
8883
8846
|
const sourceWorksheet = getWorksheet(workbook, sourceSubUnitId);
|
|
8884
8847
|
const targetWorksheet = getWorksheet(workbook, targetSubUnitId);
|
|
8885
8848
|
if (!sourceWorksheet || !targetWorksheet) return this._handleNull();
|
|
@@ -9797,8 +9760,8 @@ function getClearContentMutationParamForRange(worksheet, range) {
|
|
|
9797
9760
|
let leftTopCellValue = null;
|
|
9798
9761
|
cellMatrix.forValue((row, col, cellData) => {
|
|
9799
9762
|
if (cellData && row >= startRow && col >= startColumn) {
|
|
9800
|
-
var _cellData$p
|
|
9801
|
-
if (!leftTopCellValue && worksheet.cellHasValue(cellData) && (cellData.v !== "" || ((
|
|
9763
|
+
var _cellData$p;
|
|
9764
|
+
if (!leftTopCellValue && worksheet.cellHasValue(cellData) && (cellData.v !== "" || (((_cellData$p = cellData.p) === null || _cellData$p === void 0 || (_cellData$p = _cellData$p.body) === null || _cellData$p === void 0 || (_cellData$p = _cellData$p.dataStream) === null || _cellData$p === void 0 ? void 0 : _cellData$p.length) ?? 0) > 2)) leftTopCellValue = cellData;
|
|
9802
9765
|
redoMatrix.setValue(row, col, cellData.s ? {
|
|
9803
9766
|
v: null,
|
|
9804
9767
|
t: null,
|
|
@@ -12621,7 +12584,6 @@ function splitCellDataIntoBatches(unitId, subUnitId, cellData, batchSize) {
|
|
|
12621
12584
|
}
|
|
12622
12585
|
const COPY_SHEET_COMMAND_ID = "sheet.command.copy-sheet";
|
|
12623
12586
|
function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitId, localeService, sheetInterceptorService) {
|
|
12624
|
-
var _intercepted$preRedos, _intercepted$preUndos;
|
|
12625
12587
|
const pluginConfig = accessor.get(_univerjs_core.IConfigService).getConfig(SHEETS_PLUGIN_CONFIG_KEY);
|
|
12626
12588
|
const largeSheetConfig = {
|
|
12627
12589
|
...defaultLargeSheetOperationConfig,
|
|
@@ -12666,7 +12628,7 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
|
|
|
12666
12628
|
});
|
|
12667
12629
|
return {
|
|
12668
12630
|
redos: [
|
|
12669
|
-
...
|
|
12631
|
+
...intercepted.preRedos ?? [],
|
|
12670
12632
|
{
|
|
12671
12633
|
id: InsertSheetMutation.id,
|
|
12672
12634
|
params: insertSheetMutationParams
|
|
@@ -12674,7 +12636,7 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
|
|
|
12674
12636
|
...intercepted.redos
|
|
12675
12637
|
],
|
|
12676
12638
|
undos: [
|
|
12677
|
-
...
|
|
12639
|
+
...intercepted.preUndos ?? [],
|
|
12678
12640
|
{
|
|
12679
12641
|
id: RemoveSheetMutation.id,
|
|
12680
12642
|
params: removeSheetMutationParams
|
|
@@ -12889,8 +12851,7 @@ const InsertSheetCommand = {
|
|
|
12889
12851
|
const sheetName = sheet === null || sheet === void 0 ? void 0 : sheet.name;
|
|
12890
12852
|
const sheetConfig = (0, _univerjs_core.mergeWorksheetSnapshotWithDefault)(sheet || {});
|
|
12891
12853
|
if (params) {
|
|
12892
|
-
|
|
12893
|
-
index = (_params$index = params.index) !== null && _params$index !== void 0 ? _params$index : index;
|
|
12854
|
+
index = params.index ?? index;
|
|
12894
12855
|
sheetConfig.id = sheetId || (0, _univerjs_core.generateRandomId)();
|
|
12895
12856
|
sheetConfig.name = sheetName ? workbook.uniqueSheetName(sheetName) : workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`);
|
|
12896
12857
|
} else {
|
|
@@ -13005,7 +12966,6 @@ const RemoveDefinedNameCommand = {
|
|
|
13005
12966
|
id: "sheet.command.remove-defined-name",
|
|
13006
12967
|
type: _univerjs_core.CommandType.COMMAND,
|
|
13007
12968
|
handler: (accessor, params) => {
|
|
13008
|
-
var _interceptorCommands$, _interceptorCommands$2;
|
|
13009
12969
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
13010
12970
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
13011
12971
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
@@ -13016,7 +12976,7 @@ const RemoveDefinedNameCommand = {
|
|
|
13016
12976
|
params
|
|
13017
12977
|
});
|
|
13018
12978
|
const redos = [
|
|
13019
|
-
...
|
|
12979
|
+
...interceptorCommands.preRedos ?? [],
|
|
13020
12980
|
{
|
|
13021
12981
|
id: _univerjs_engine_formula.RemoveDefinedNameMutation.id,
|
|
13022
12982
|
params: removeSheetMutationParams
|
|
@@ -13024,7 +12984,7 @@ const RemoveDefinedNameCommand = {
|
|
|
13024
12984
|
...interceptorCommands.redos
|
|
13025
12985
|
];
|
|
13026
12986
|
const undos = [
|
|
13027
|
-
...
|
|
12987
|
+
...interceptorCommands.preUndos ?? [],
|
|
13028
12988
|
{
|
|
13029
12989
|
id: _univerjs_engine_formula.SetDefinedNameMutation.id,
|
|
13030
12990
|
params: removeSheetMutationParams
|
|
@@ -13052,7 +13012,6 @@ const RemoveSheetCommand = {
|
|
|
13052
13012
|
id: "sheet.command.remove-sheet",
|
|
13053
13013
|
type: _univerjs_core.CommandType.COMMAND,
|
|
13054
13014
|
handler: (accessor, params) => {
|
|
13055
|
-
var _intercepted$preRedos, _intercepted$preUndos;
|
|
13056
13015
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
13057
13016
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
13058
13017
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
@@ -13082,7 +13041,7 @@ const RemoveSheetCommand = {
|
|
|
13082
13041
|
}
|
|
13083
13042
|
});
|
|
13084
13043
|
const redos = [
|
|
13085
|
-
...
|
|
13044
|
+
...intercepted.preRedos ?? [],
|
|
13086
13045
|
{
|
|
13087
13046
|
id: RemoveSheetMutation.id,
|
|
13088
13047
|
params: RemoveSheetMutationParams
|
|
@@ -13090,7 +13049,7 @@ const RemoveSheetCommand = {
|
|
|
13090
13049
|
...intercepted.redos
|
|
13091
13050
|
];
|
|
13092
13051
|
const undos = isLargeSheet ? [] : [
|
|
13093
|
-
...
|
|
13052
|
+
...intercepted.preUndos ?? [],
|
|
13094
13053
|
{
|
|
13095
13054
|
id: InsertSheetMutation.id,
|
|
13096
13055
|
params: InsertSheetMutationParams
|
|
@@ -13620,7 +13579,6 @@ const SetSpecificColsVisibleCommand = {
|
|
|
13620
13579
|
});
|
|
13621
13580
|
const interceptedResult = (0, _univerjs_core.sequenceExecute)([...intercepted.redos], commandService);
|
|
13622
13581
|
if (result.result && interceptedResult.result) {
|
|
13623
|
-
var _intercepted$undos, _intercepted$preRedos;
|
|
13624
13582
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
13625
13583
|
id: SetSpecificColsVisibleCommand.id,
|
|
13626
13584
|
params
|
|
@@ -13637,11 +13595,11 @@ const SetSpecificColsVisibleCommand = {
|
|
|
13637
13595
|
id: SetSelectionsOperation.id,
|
|
13638
13596
|
params: undoSetSelectionsOperationParams
|
|
13639
13597
|
},
|
|
13640
|
-
...
|
|
13598
|
+
...intercepted.undos ?? [],
|
|
13641
13599
|
...afterInterceptors.undos
|
|
13642
13600
|
],
|
|
13643
13601
|
redoMutations: [
|
|
13644
|
-
...
|
|
13602
|
+
...intercepted.preRedos ?? [],
|
|
13645
13603
|
{
|
|
13646
13604
|
id: SetColVisibleMutation.id,
|
|
13647
13605
|
params: redoMutationParams
|
|
@@ -13731,7 +13689,6 @@ const SetColHiddenCommand = {
|
|
|
13731
13689
|
});
|
|
13732
13690
|
const interceptedResult = (0, _univerjs_core.sequenceExecute)([...intercepted.redos], commandService);
|
|
13733
13691
|
if (result.result && interceptedResult.result) {
|
|
13734
|
-
var _intercepted$undos2, _intercepted$preRedos2;
|
|
13735
13692
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
13736
13693
|
id: SetColHiddenCommand.id,
|
|
13737
13694
|
params: redoMutationParams
|
|
@@ -13748,11 +13705,11 @@ const SetColHiddenCommand = {
|
|
|
13748
13705
|
id: SetSelectionsOperation.id,
|
|
13749
13706
|
params: undoSetSelectionsOperationParams
|
|
13750
13707
|
},
|
|
13751
|
-
...
|
|
13708
|
+
...intercepted.undos ?? [],
|
|
13752
13709
|
...afterInterceptors.undos
|
|
13753
13710
|
],
|
|
13754
13711
|
redoMutations: [
|
|
13755
|
-
...
|
|
13712
|
+
...intercepted.preRedos ?? [],
|
|
13756
13713
|
{
|
|
13757
13714
|
id: SetColHiddenMutation.id,
|
|
13758
13715
|
params: redoMutationParams
|
|
@@ -13861,7 +13818,6 @@ const SetDefinedNameCommand = {
|
|
|
13861
13818
|
id: "sheet.command.set-defined-name",
|
|
13862
13819
|
type: _univerjs_core.CommandType.COMMAND,
|
|
13863
13820
|
handler: (accessor, params) => {
|
|
13864
|
-
var _interceptorCommands$, _interceptorCommands$2;
|
|
13865
13821
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
13866
13822
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
13867
13823
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
@@ -13873,7 +13829,7 @@ const SetDefinedNameCommand = {
|
|
|
13873
13829
|
params
|
|
13874
13830
|
});
|
|
13875
13831
|
const redos = [
|
|
13876
|
-
...
|
|
13832
|
+
...interceptorCommands.preRedos ?? [],
|
|
13877
13833
|
...oldDefinedNameMutationParams ? [{
|
|
13878
13834
|
id: _univerjs_engine_formula.RemoveDefinedNameMutation.id,
|
|
13879
13835
|
params: oldDefinedNameMutationParams
|
|
@@ -13885,7 +13841,7 @@ const SetDefinedNameCommand = {
|
|
|
13885
13841
|
...interceptorCommands.redos
|
|
13886
13842
|
];
|
|
13887
13843
|
const undos = [
|
|
13888
|
-
...
|
|
13844
|
+
...interceptorCommands.preUndos ?? [],
|
|
13889
13845
|
{
|
|
13890
13846
|
id: _univerjs_engine_formula.RemoveDefinedNameMutation.id,
|
|
13891
13847
|
params: newDefinedNameMutationParams
|
|
@@ -14351,7 +14307,6 @@ const SetSpecificRowsVisibleCommand = {
|
|
|
14351
14307
|
});
|
|
14352
14308
|
const interceptedResult = (0, _univerjs_core.sequenceExecute)([...intercepted.redos], commandService);
|
|
14353
14309
|
if (result.result && interceptedResult.result) {
|
|
14354
|
-
var _intercepted$preUndos, _intercepted$undos, _intercepted$preRedos;
|
|
14355
14310
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
14356
14311
|
id: SetSpecificRowsVisibleCommand.id,
|
|
14357
14312
|
params
|
|
@@ -14360,7 +14315,7 @@ const SetSpecificRowsVisibleCommand = {
|
|
|
14360
14315
|
undoRedoService.pushUndoRedo({
|
|
14361
14316
|
unitID: unitId,
|
|
14362
14317
|
undoMutations: [
|
|
14363
|
-
...
|
|
14318
|
+
...intercepted.preUndos ?? [],
|
|
14364
14319
|
{
|
|
14365
14320
|
id: SetRowHiddenMutation.id,
|
|
14366
14321
|
params: undoMutationParams
|
|
@@ -14369,11 +14324,11 @@ const SetSpecificRowsVisibleCommand = {
|
|
|
14369
14324
|
id: SetSelectionsOperation.id,
|
|
14370
14325
|
params: undoSetSelectionsOperationParams
|
|
14371
14326
|
},
|
|
14372
|
-
...
|
|
14327
|
+
...intercepted.undos ?? [],
|
|
14373
14328
|
...afterInterceptors.undos
|
|
14374
14329
|
],
|
|
14375
14330
|
redoMutations: [
|
|
14376
|
-
...
|
|
14331
|
+
...intercepted.preRedos ?? [],
|
|
14377
14332
|
{
|
|
14378
14333
|
id: SetRowVisibleMutation.id,
|
|
14379
14334
|
params: redoMutationParams
|
|
@@ -14415,7 +14370,7 @@ const SetRowHiddenCommand = {
|
|
|
14415
14370
|
type: _univerjs_core.CommandType.COMMAND,
|
|
14416
14371
|
id: "sheet.command.set-rows-hidden",
|
|
14417
14372
|
handler: (accessor, params) => {
|
|
14418
|
-
var _params$ranges
|
|
14373
|
+
var _params$ranges;
|
|
14419
14374
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
14420
14375
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
14421
14376
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
@@ -14457,7 +14412,7 @@ const SetRowHiddenCommand = {
|
|
|
14457
14412
|
params: redoMutationParams
|
|
14458
14413
|
});
|
|
14459
14414
|
if ((0, _univerjs_core.sequenceExecute)([
|
|
14460
|
-
...
|
|
14415
|
+
...intercepted.preRedos ?? [],
|
|
14461
14416
|
{
|
|
14462
14417
|
id: SetRowHiddenMutation.id,
|
|
14463
14418
|
params: redoMutationParams
|
|
@@ -14468,7 +14423,6 @@ const SetRowHiddenCommand = {
|
|
|
14468
14423
|
},
|
|
14469
14424
|
...intercepted.redos
|
|
14470
14425
|
], commandService).result) {
|
|
14471
|
-
var _intercepted$preUndos2, _intercepted$undos2, _intercepted$preRedos3;
|
|
14472
14426
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
14473
14427
|
id: SetRowHiddenCommand.id,
|
|
14474
14428
|
params: redoMutationParams
|
|
@@ -14477,7 +14431,7 @@ const SetRowHiddenCommand = {
|
|
|
14477
14431
|
undoRedoService.pushUndoRedo({
|
|
14478
14432
|
unitID: unitId,
|
|
14479
14433
|
undoMutations: [
|
|
14480
|
-
...
|
|
14434
|
+
...intercepted.preUndos ?? [],
|
|
14481
14435
|
{
|
|
14482
14436
|
id: SetRowVisibleMutation.id,
|
|
14483
14437
|
params: undoMutationParams
|
|
@@ -14486,11 +14440,11 @@ const SetRowHiddenCommand = {
|
|
|
14486
14440
|
id: SetSelectionsOperation.id,
|
|
14487
14441
|
params: undoSetSelectionsOperationParams
|
|
14488
14442
|
},
|
|
14489
|
-
...
|
|
14443
|
+
...intercepted.undos ?? [],
|
|
14490
14444
|
...afterInterceptors.undos
|
|
14491
14445
|
],
|
|
14492
14446
|
redoMutations: [
|
|
14493
|
-
...
|
|
14447
|
+
...intercepted.preRedos ?? [],
|
|
14494
14448
|
{
|
|
14495
14449
|
id: SetRowHiddenMutation.id,
|
|
14496
14450
|
params: redoMutationParams
|
|
@@ -14662,7 +14616,6 @@ const SetWorkbookNameCommand = {
|
|
|
14662
14616
|
type: _univerjs_core.CommandType.COMMAND,
|
|
14663
14617
|
id: "sheet.command.set-workbook-name",
|
|
14664
14618
|
handler: (accessor, params) => {
|
|
14665
|
-
var _interceptedCommands$;
|
|
14666
14619
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
14667
14620
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
14668
14621
|
if (!getSheetCommandTargetWorkbook(accessor.get(_univerjs_core.IUniverInstanceService), params)) return false;
|
|
@@ -14675,7 +14628,7 @@ const SetWorkbookNameCommand = {
|
|
|
14675
14628
|
unitId: params.unitId
|
|
14676
14629
|
};
|
|
14677
14630
|
return (0, _univerjs_core.sequenceExecute)([
|
|
14678
|
-
...
|
|
14631
|
+
...interceptedCommands.preRedos ?? [],
|
|
14679
14632
|
{
|
|
14680
14633
|
id: SetWorkbookNameMutation.id,
|
|
14681
14634
|
params: redoMutationParams
|
|
@@ -14851,7 +14804,6 @@ const SetColWidthCommand = {
|
|
|
14851
14804
|
});
|
|
14852
14805
|
const result = (0, _univerjs_core.sequenceExecute)([...intercepted.redos, ...autoHeightRedos], commandService);
|
|
14853
14806
|
if (setColWidthResult && result.result) {
|
|
14854
|
-
var _intercepted$preUndos, _intercepted$preRedos;
|
|
14855
14807
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
14856
14808
|
id: SetColWidthCommand.id,
|
|
14857
14809
|
params: redoMutationParams
|
|
@@ -14860,7 +14812,7 @@ const SetColWidthCommand = {
|
|
|
14860
14812
|
undoRedoService.pushUndoRedo({
|
|
14861
14813
|
unitID: unitId,
|
|
14862
14814
|
undoMutations: [
|
|
14863
|
-
...
|
|
14815
|
+
...intercepted.preUndos ?? [],
|
|
14864
14816
|
{
|
|
14865
14817
|
id: SetWorksheetColWidthMutation.id,
|
|
14866
14818
|
params: undoMutationParams
|
|
@@ -14870,7 +14822,7 @@ const SetColWidthCommand = {
|
|
|
14870
14822
|
...autoHeightUndos
|
|
14871
14823
|
],
|
|
14872
14824
|
redoMutations: [
|
|
14873
|
-
...
|
|
14825
|
+
...intercepted.preRedos ?? [],
|
|
14874
14826
|
{
|
|
14875
14827
|
id: SetWorksheetColWidthMutation.id,
|
|
14876
14828
|
params: redoMutationParams
|
|
@@ -15086,7 +15038,6 @@ const SetWorksheetNameCommand = {
|
|
|
15086
15038
|
type: _univerjs_core.CommandType.COMMAND,
|
|
15087
15039
|
id: "sheet.command.set-worksheet-name",
|
|
15088
15040
|
handler: (accessor, params) => {
|
|
15089
|
-
var _interceptorCommands$, _interceptorCommands$2;
|
|
15090
15041
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
15091
15042
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
15092
15043
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
@@ -15104,7 +15055,7 @@ const SetWorksheetNameCommand = {
|
|
|
15104
15055
|
params
|
|
15105
15056
|
});
|
|
15106
15057
|
const redos = [
|
|
15107
|
-
...
|
|
15058
|
+
...interceptorCommands.preRedos ?? [],
|
|
15108
15059
|
{
|
|
15109
15060
|
id: SetWorksheetNameMutation.id,
|
|
15110
15061
|
params: redoMutationParams
|
|
@@ -15112,7 +15063,7 @@ const SetWorksheetNameCommand = {
|
|
|
15112
15063
|
...interceptorCommands.redos
|
|
15113
15064
|
];
|
|
15114
15065
|
const undos = [
|
|
15115
|
-
...
|
|
15066
|
+
...interceptorCommands.preUndos ?? [],
|
|
15116
15067
|
{
|
|
15117
15068
|
id: SetWorksheetNameMutation.id,
|
|
15118
15069
|
params: undoMutationParams
|
|
@@ -16413,10 +16364,7 @@ const SetWorksheetRightToLeftCommand = {
|
|
|
16413
16364
|
if (!target) return false;
|
|
16414
16365
|
const { unitId, subUnitId } = target;
|
|
16415
16366
|
let rightToLeft = _univerjs_core.BooleanNumber.FALSE;
|
|
16416
|
-
if (params)
|
|
16417
|
-
var _params$rightToLeft;
|
|
16418
|
-
rightToLeft = (_params$rightToLeft = params.rightToLeft) !== null && _params$rightToLeft !== void 0 ? _params$rightToLeft : _univerjs_core.BooleanNumber.FALSE;
|
|
16419
|
-
}
|
|
16367
|
+
if (params) rightToLeft = params.rightToLeft ?? _univerjs_core.BooleanNumber.FALSE;
|
|
16420
16368
|
const setWorksheetRightToLeftMutationParams = {
|
|
16421
16369
|
rightToLeft,
|
|
16422
16370
|
unitId,
|
|
@@ -16549,7 +16497,6 @@ const DeltaRowHeightCommand = {
|
|
|
16549
16497
|
}], commandService);
|
|
16550
16498
|
const interceptedResult = (0, _univerjs_core.sequenceExecute)([...intercepted.redos], commandService);
|
|
16551
16499
|
if (result.result && interceptedResult.result) {
|
|
16552
|
-
var _intercepted$preUndos, _intercepted$preRedos;
|
|
16553
16500
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
16554
16501
|
id: DeltaRowHeightCommand.id,
|
|
16555
16502
|
params: redoMutationParams
|
|
@@ -16558,7 +16505,7 @@ const DeltaRowHeightCommand = {
|
|
|
16558
16505
|
undoRedoService.pushUndoRedo({
|
|
16559
16506
|
unitID: unitId,
|
|
16560
16507
|
undoMutations: [
|
|
16561
|
-
...
|
|
16508
|
+
...intercepted.preUndos ?? [],
|
|
16562
16509
|
{
|
|
16563
16510
|
id: SetWorksheetRowHeightMutation.id,
|
|
16564
16511
|
params: undoMutationParams
|
|
@@ -16571,7 +16518,7 @@ const DeltaRowHeightCommand = {
|
|
|
16571
16518
|
...afterInterceptors.undos
|
|
16572
16519
|
],
|
|
16573
16520
|
redoMutations: [
|
|
16574
|
-
...
|
|
16521
|
+
...intercepted.preRedos ?? [],
|
|
16575
16522
|
{
|
|
16576
16523
|
id: SetWorksheetRowHeightMutation.id,
|
|
16577
16524
|
params: redoMutationParams
|
|
@@ -16631,7 +16578,6 @@ const SetRowHeightCommand = {
|
|
|
16631
16578
|
});
|
|
16632
16579
|
const sheetInterceptorResult = (0, _univerjs_core.sequenceExecute)([...intercepted.redos], commandService);
|
|
16633
16580
|
if (result.result && sheetInterceptorResult.result) {
|
|
16634
|
-
var _intercepted$preRedos2, _intercepted$preRedos3;
|
|
16635
16581
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
16636
16582
|
id: SetRowHeightCommand.id,
|
|
16637
16583
|
params: redoMutationParams
|
|
@@ -16640,7 +16586,7 @@ const SetRowHeightCommand = {
|
|
|
16640
16586
|
undoRedoService.pushUndoRedo({
|
|
16641
16587
|
unitID: unitId,
|
|
16642
16588
|
undoMutations: [
|
|
16643
|
-
...
|
|
16589
|
+
...intercepted.preRedos ?? [],
|
|
16644
16590
|
{
|
|
16645
16591
|
id: SetWorksheetRowHeightMutation.id,
|
|
16646
16592
|
params: undoMutationParams
|
|
@@ -16653,7 +16599,7 @@ const SetRowHeightCommand = {
|
|
|
16653
16599
|
...afterInterceptors.undos
|
|
16654
16600
|
],
|
|
16655
16601
|
redoMutations: [
|
|
16656
|
-
...
|
|
16602
|
+
...intercepted.preRedos ?? [],
|
|
16657
16603
|
{
|
|
16658
16604
|
id: SetWorksheetRowHeightMutation.id,
|
|
16659
16605
|
params: redoMutationParams
|
|
@@ -17007,18 +16953,26 @@ const TextToNumberCommand = {
|
|
|
17007
16953
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
17008
16954
|
const { worksheet, unitId, subUnitId } = target;
|
|
17009
16955
|
const newCellValue = new _univerjs_core.ObjectMatrix();
|
|
16956
|
+
const setNumfmtCells = [];
|
|
17010
16957
|
const removeNumfmtRanges = [];
|
|
17011
16958
|
for (let i = 0; i < ranges.length; i++) for (let r = ranges[i].startRow; r <= ranges[i].endRow; r++) for (let c = ranges[i].startColumn; c <= ranges[i].endColumn; c++) {
|
|
17012
16959
|
var _worksheet$getStyleDa, _cell$s;
|
|
17013
16960
|
if (newCellValue.getValue(r, c)) continue;
|
|
17014
16961
|
const cell = worksheet.getCellRaw(r, c);
|
|
17015
16962
|
const pattern = typeof (cell === null || cell === void 0 ? void 0 : cell.s) === "string" ? (_worksheet$getStyleDa = worksheet.getStyleDataByHash(cell.s)) === null || _worksheet$getStyleDa === void 0 || (_worksheet$getStyleDa = _worksheet$getStyleDa.n) === null || _worksheet$getStyleDa === void 0 ? void 0 : _worksheet$getStyleDa.pattern : cell === null || cell === void 0 || (_cell$s = cell.s) === null || _cell$s === void 0 || (_cell$s = _cell$s.n) === null || _cell$s === void 0 ? void 0 : _cell$s.pattern;
|
|
17016
|
-
|
|
16963
|
+
const parsedValue = typeof (cell === null || cell === void 0 ? void 0 : cell.v) === "string" ? (0, _univerjs_core.getNumfmtParseValueFilter)(cell.v) : null;
|
|
16964
|
+
const numberValue = (0, _univerjs_core.isRealNum)(cell === null || cell === void 0 ? void 0 : cell.v) ? Number(cell === null || cell === void 0 ? void 0 : cell.v) : typeof (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.v) === "number" ? parsedValue.v : null;
|
|
16965
|
+
if (cell && cell.v && (cell.t !== _univerjs_core.CellValueType.NUMBER || (0, _univerjs_core.isTextFormat)(pattern)) && numberValue !== null) {
|
|
17017
16966
|
newCellValue.setValue(r, c, {
|
|
17018
|
-
v:
|
|
16967
|
+
v: numberValue,
|
|
17019
16968
|
t: _univerjs_core.CellValueType.NUMBER
|
|
17020
16969
|
});
|
|
17021
|
-
if ((0, _univerjs_core.isTextFormat)(pattern))
|
|
16970
|
+
if ((parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.z) && (!pattern || (0, _univerjs_core.isTextFormat)(pattern))) setNumfmtCells.push({
|
|
16971
|
+
pattern: parsedValue.z,
|
|
16972
|
+
row: r,
|
|
16973
|
+
col: c
|
|
16974
|
+
});
|
|
16975
|
+
else if ((0, _univerjs_core.isTextFormat)(pattern)) removeNumfmtRanges.push({
|
|
17022
16976
|
startRow: r,
|
|
17023
16977
|
endRow: r,
|
|
17024
16978
|
startColumn: c,
|
|
@@ -17039,6 +16993,14 @@ const TextToNumberCommand = {
|
|
|
17039
16993
|
id: SetRangeValuesMutation.id,
|
|
17040
16994
|
params: SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams)
|
|
17041
16995
|
}];
|
|
16996
|
+
if (setNumfmtCells.length) {
|
|
16997
|
+
const setNumfmtMutationParams = transformCellsToRange(unitId, subUnitId, setNumfmtCells);
|
|
16998
|
+
redos.push({
|
|
16999
|
+
id: SetNumfmtMutation.id,
|
|
17000
|
+
params: setNumfmtMutationParams
|
|
17001
|
+
});
|
|
17002
|
+
undos.push(...factorySetNumfmtUndoMutation(accessor, setNumfmtMutationParams));
|
|
17003
|
+
}
|
|
17042
17004
|
if (removeNumfmtRanges.length) {
|
|
17043
17005
|
const removeNumfmtMutationParams = {
|
|
17044
17006
|
unitId,
|
|
@@ -17853,14 +17815,14 @@ const effectedByOnlyLocalMutationIds = [
|
|
|
17853
17815
|
];
|
|
17854
17816
|
let SheetsFreezeSyncController = class SheetsFreezeSyncController extends _univerjs_core.Disposable {
|
|
17855
17817
|
constructor(_univerInstanceService, _commandService, _configService) {
|
|
17856
|
-
var _this$_configService
|
|
17818
|
+
var _this$_configService$;
|
|
17857
17819
|
super();
|
|
17858
17820
|
this._univerInstanceService = _univerInstanceService;
|
|
17859
17821
|
this._commandService = _commandService;
|
|
17860
17822
|
this._configService = _configService;
|
|
17861
17823
|
_defineProperty(this, "_d", new _univerjs_core.DisposableCollection());
|
|
17862
17824
|
_defineProperty(this, "_enabled", true);
|
|
17863
|
-
const freezeSync = (
|
|
17825
|
+
const freezeSync = ((_this$_configService$ = this._configService.getConfig("sheets.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.freezeSync) ?? true;
|
|
17864
17826
|
this.setEnabled(freezeSync);
|
|
17865
17827
|
}
|
|
17866
17828
|
getEnabled() {
|
|
@@ -18256,6 +18218,19 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18256
18218
|
}, params.unitId, params.localSheetId);
|
|
18257
18219
|
errorMsg = this._localeService.t("sheets.permission.dialog.editErr");
|
|
18258
18220
|
break;
|
|
18221
|
+
case TextToNumberCommand.id:
|
|
18222
|
+
params = commandInfo.params;
|
|
18223
|
+
permission = this.permissionCheckWithRanges({
|
|
18224
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
18225
|
+
worksheetTypes: [
|
|
18226
|
+
WorksheetSetCellValuePermission,
|
|
18227
|
+
WorksheetSetCellStylePermission,
|
|
18228
|
+
WorksheetEditPermission
|
|
18229
|
+
],
|
|
18230
|
+
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
18231
|
+
}, params === null || params === void 0 ? void 0 : params.ranges, params === null || params === void 0 ? void 0 : params.unitId, params === null || params === void 0 ? void 0 : params.subUnitId);
|
|
18232
|
+
errorMsg = this._localeService.t("sheets.permission.dialog.editErr");
|
|
18233
|
+
break;
|
|
18259
18234
|
default: break;
|
|
18260
18235
|
}
|
|
18261
18236
|
if (!permission) this.blockExecuteWithoutPermission(errorMsg);
|
|
@@ -18280,7 +18255,7 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18280
18255
|
})) return false;
|
|
18281
18256
|
if (rangeTypes && rangeTypes.length > 0) {
|
|
18282
18257
|
var _this$_selectionManag;
|
|
18283
|
-
const ranges = selectionRanges
|
|
18258
|
+
const ranges = selectionRanges ?? ((_this$_selectionManag = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag === void 0 ? void 0 : _this$_selectionManag.map((s) => s.range));
|
|
18284
18259
|
if (!ranges) return false;
|
|
18285
18260
|
const rules = this._rangeProtectionRuleModel.getSubunitRuleList(_unitId, _subUnitId);
|
|
18286
18261
|
if (rules.length === 0) return true;
|
|
@@ -18497,11 +18472,11 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
18497
18472
|
return true;
|
|
18498
18473
|
}
|
|
18499
18474
|
_permissionCheckWithInsertOrDeleteMoveRange(direction, params) {
|
|
18500
|
-
var
|
|
18475
|
+
var _this$_selectionManag3;
|
|
18501
18476
|
const target = getSheetCommandTarget(this._univerInstanceService);
|
|
18502
18477
|
if (!target) return false;
|
|
18503
18478
|
const { worksheet, unitId, subUnitId } = target;
|
|
18504
|
-
const range = (
|
|
18479
|
+
const range = (params === null || params === void 0 ? void 0 : params.range) ?? ((_this$_selectionManag3 = this._selectionManagerService.getCurrentLastSelection()) === null || _this$_selectionManag3 === void 0 ? void 0 : _this$_selectionManag3.range);
|
|
18505
18480
|
if (!range) return false;
|
|
18506
18481
|
if (!this.permissionCheckWithRanges({
|
|
18507
18482
|
workbookTypes: [WorkbookEditablePermission],
|
|
@@ -19085,10 +19060,9 @@ let RangeProtectionRenderModel = class RangeProtectionRenderModel extends _unive
|
|
|
19085
19060
|
const result = [];
|
|
19086
19061
|
for (const rule of ruleMap) if (rule.ranges.some((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col)) {
|
|
19087
19062
|
const permissionMap = getAllRangePermissionPoint().reduce((result, F) => {
|
|
19088
|
-
var _permission$value;
|
|
19089
19063
|
const instance = new F(unitId, subUnitId, rule.permissionId);
|
|
19090
19064
|
const permission = this._permissionService.getPermissionPoint(instance.id);
|
|
19091
|
-
result[instance.subType] = (
|
|
19065
|
+
result[instance.subType] = (permission === null || permission === void 0 ? void 0 : permission.value) ?? instance.value;
|
|
19092
19066
|
return result;
|
|
19093
19067
|
}, {});
|
|
19094
19068
|
result.push({
|
|
@@ -19244,11 +19218,11 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
|
|
|
19244
19218
|
this._permissionIdCache.delete(rule.permissionId);
|
|
19245
19219
|
}
|
|
19246
19220
|
_getSelectionActions(unitId, subUnitId, rule) {
|
|
19247
|
-
var _this$_permissionServ,
|
|
19248
|
-
const edit = (_this$_permissionServ =
|
|
19249
|
-
const view = (
|
|
19250
|
-
const manageProtection = (
|
|
19251
|
-
const deleteProtection = (
|
|
19221
|
+
var _this$_permissionServ, _RangeProtectionPermi, _this$_permissionServ2, _RangeProtectionPermi2, _this$_permissionServ3, _RangeProtectionPermi3, _this$_permissionServ4, _RangeProtectionPermi4;
|
|
19222
|
+
const edit = ((_this$_permissionServ = this._permissionService.getPermissionPoint((_RangeProtectionPermi = new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId)) === null || _RangeProtectionPermi === void 0 ? void 0 : _RangeProtectionPermi.id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value) ?? false;
|
|
19223
|
+
const view = ((_this$_permissionServ2 = this._permissionService.getPermissionPoint((_RangeProtectionPermi2 = new RangeProtectionPermissionViewPoint(unitId, subUnitId, rule.permissionId)) === null || _RangeProtectionPermi2 === void 0 ? void 0 : _RangeProtectionPermi2.id)) === null || _this$_permissionServ2 === void 0 ? void 0 : _this$_permissionServ2.value) ?? false;
|
|
19224
|
+
const manageProtection = ((_this$_permissionServ3 = this._permissionService.getPermissionPoint((_RangeProtectionPermi3 = new RangeProtectionPermissionManageCollaPoint(unitId, subUnitId, rule.permissionId)) === null || _RangeProtectionPermi3 === void 0 ? void 0 : _RangeProtectionPermi3.id)) === null || _this$_permissionServ3 === void 0 ? void 0 : _this$_permissionServ3.value) ?? false;
|
|
19225
|
+
const deleteProtection = ((_this$_permissionServ4 = this._permissionService.getPermissionPoint((_RangeProtectionPermi4 = new RangeProtectionPermissionDeleteProtectionPoint(unitId, subUnitId, rule.permissionId)) === null || _RangeProtectionPermi4 === void 0 ? void 0 : _RangeProtectionPermi4.id)) === null || _this$_permissionServ4 === void 0 ? void 0 : _this$_permissionServ4.value) ?? false;
|
|
19252
19226
|
return {
|
|
19253
19227
|
[_univerjs_protocol.UnitAction.Edit]: edit,
|
|
19254
19228
|
[_univerjs_protocol.UnitAction.View]: view,
|
|
@@ -19396,7 +19370,7 @@ RangeProtectionCache = __decorate([
|
|
|
19396
19370
|
//#endregion
|
|
19397
19371
|
//#region package.json
|
|
19398
19372
|
var name = "@univerjs/sheets";
|
|
19399
|
-
var version = "1.0.0-
|
|
19373
|
+
var version = "1.0.0-beta.1";
|
|
19400
19374
|
|
|
19401
19375
|
//#endregion
|
|
19402
19376
|
//#region src/controllers/active-worksheet.controller.ts
|
|
@@ -19503,7 +19477,6 @@ const ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY = "ONLY_REGISTER_FORMULA_RELAT
|
|
|
19503
19477
|
//#region src/controllers/basic-worksheet.controller.ts
|
|
19504
19478
|
let BasicWorksheetController = class BasicWorksheetController extends _univerjs_core.Disposable {
|
|
19505
19479
|
constructor(_commandService, _configService, _dataSyncPrimaryController) {
|
|
19506
|
-
var _this$_configService$;
|
|
19507
19480
|
super();
|
|
19508
19481
|
this._commandService = _commandService;
|
|
19509
19482
|
this._configService = _configService;
|
|
@@ -19545,7 +19518,7 @@ let BasicWorksheetController = class BasicWorksheetController extends _univerjs_
|
|
|
19545
19518
|
this._commandService.registerCommand(mutation);
|
|
19546
19519
|
(_this$_dataSyncPrimar = this._dataSyncPrimaryController) === null || _this$_dataSyncPrimar === void 0 || _this$_dataSyncPrimar.registerSyncingMutations(mutation);
|
|
19547
19520
|
});
|
|
19548
|
-
if (!(
|
|
19521
|
+
if (!(this._configService.getConfig("ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY") ?? false)) [
|
|
19549
19522
|
AddWorksheetMergeCommand,
|
|
19550
19523
|
AddWorksheetMergeAllCommand,
|
|
19551
19524
|
AddWorksheetMergeVerticalCommand,
|
|
@@ -19783,10 +19756,10 @@ let SheetPermissionViewModelController = class SheetPermissionViewModelControlle
|
|
|
19783
19756
|
const { unitId, subUnitId } = context;
|
|
19784
19757
|
const worksheetRule = this._worksheetProtectionRuleModel.getRule(unitId, subUnitId);
|
|
19785
19758
|
if (worksheetRule === null || worksheetRule === void 0 ? void 0 : worksheetRule.permissionId) {
|
|
19786
|
-
var _this$_permissionServ, _this$_permissionServ2,
|
|
19759
|
+
var _this$_permissionServ, _this$_permissionServ2, _selectionProtection$;
|
|
19787
19760
|
const selectionProtection = [{
|
|
19788
|
-
[_univerjs_protocol.UnitAction.View]: (_this$_permissionServ =
|
|
19789
|
-
[_univerjs_protocol.UnitAction.Edit]: (
|
|
19761
|
+
[_univerjs_protocol.UnitAction.View]: ((_this$_permissionServ = this._permissionService.getPermissionPoint(new WorksheetViewPermission(unitId, subUnitId).id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value) ?? false,
|
|
19762
|
+
[_univerjs_protocol.UnitAction.Edit]: ((_this$_permissionServ2 = this._permissionService.getPermissionPoint(new WorksheetEditPermission(unitId, subUnitId).id)) === null || _this$_permissionServ2 === void 0 ? void 0 : _this$_permissionServ2.value) ?? false
|
|
19790
19763
|
}];
|
|
19791
19764
|
const isSkipRender = !((_selectionProtection$ = selectionProtection[0]) === null || _selectionProtection$ === void 0 ? void 0 : _selectionProtection$[_univerjs_protocol.UnitAction.View]);
|
|
19792
19765
|
const _cellData = !cell || cell === context.rawData ? { ...cell } : cell;
|
|
@@ -21857,6 +21830,7 @@ exports.handleInsertRow = handleInsertRow;
|
|
|
21857
21830
|
exports.handleMoveCols = handleMoveCols;
|
|
21858
21831
|
exports.handleMoveRange = handleMoveRange;
|
|
21859
21832
|
exports.handleMoveRows = handleMoveRows;
|
|
21833
|
+
exports.isCellImage = isCellImage;
|
|
21860
21834
|
exports.isSingleCellSelection = isSingleCellSelection;
|
|
21861
21835
|
exports.rangeMerge = rangeMerge;
|
|
21862
21836
|
exports.rangeToDiscreteRange = rangeToDiscreteRange;
|