@univerjs/sheets 0.2.11 → 0.2.13
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/index.js +3 -3
- package/lib/es/index.js +199 -135
- package/lib/types/basics/__tests__/cell-custom.spec.d.ts +16 -0
- package/lib/types/basics/cell-custom.d.ts +12 -0
- package/lib/types/commands/commands/add-worksheet-merge.command.d.ts +2 -1
- package/lib/types/commands/mutations/set-range-values.mutation.d.ts +0 -4
- package/lib/types/commands/mutations/set-worksheet-col-width.mutation.d.ts +8 -2
- package/lib/types/commands/mutations/set-worksheet-row-height.mutation.d.ts +4 -4
- package/lib/types/controllers/__tests__/util.d.ts +8 -8
- package/lib/types/controllers/config.schema.d.ts +13 -0
- package/lib/types/index.d.ts +4 -2
- package/lib/types/model/range-protection-rule.model.d.ts +1 -0
- package/lib/types/services/__tests__/util.d.ts +8 -8
- package/lib/types/services/exclusive-range/exclusive-range-service.d.ts +60 -0
- package/lib/types/services/numfmt/type.d.ts +1 -1
- package/lib/types/services/permission/permission-point/range/edit.d.ts +1 -1
- package/lib/types/services/permission/worksheet-permission/worksheet-permission-rule.model.d.ts +1 -0
- package/lib/types/services/ref-range/__tests__/__testing__.d.ts +8 -8
- package/lib/types/services/ref-range/__tests__/ref-range.service.spec.d.ts +8 -8
- package/lib/types/services/selections/ref-selections.service.d.ts +1 -1
- package/lib/types/services/selections/selection-manager.service.d.ts +2 -2
- package/lib/types/services/sheet-interceptor/__tests__/create-core-test-bed.d.ts +8 -8
- package/lib/types/sheets-plugin.d.ts +5 -13
- package/lib/umd/index.js +3 -3
- package/package.json +14 -14
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, toDisposable, remove, composeInterceptors, DisposableCollection, Tools, normalizeTextRuns, CellValueType,
|
|
5
|
+
import { RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, toDisposable, remove, composeInterceptors, DisposableCollection, Tools, normalizeTextRuns, CellValueType, isRealNum, isBooleanString, isSafeNumeric, CommandType, ObjectMatrix, ICommandService, IUndoRedoService, sequenceExecute, LocaleService, createIdentifier, IContextService, selectionToArray, Rectangle, RANGE_TYPE, ErrorService, Range, cellToRange, PermissionStatus, IPermissionService, isICellData, Dimension, getArrayLength, insertMatrixArray, spliceArray, sliceMatrixArray, concatMatrixArray, BooleanNumber, Direction, mergeWorksheetSnapshotWithDefault, moveMatrixArray, BorderType, BorderStyleTypes, FontWeight, FontItalic, runOnLifecycle, LifecycleStages, OnLifecycle, Inject, Injector, IResourceManagerService, Optional, IConfigService, queryObjectMatrix, InterceptorManager, ILogService, LRUMap, DependentOn, Plugin, mergeOverrideWithDependencies, ColorKit, getCellInfoInMergeData, makeCellRangeToRangeData, createRowColIter } from "@univerjs/core";
|
|
6
6
|
import { SetDefinedNameMutation, RemoveDefinedNameMutation, SetFormulaCalculationResultMutation, handleNumfmtInCell, IDefinedNamesService, stripErrorMargin, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
|
|
7
7
|
import { DataSyncPrimaryController } from "@univerjs/rpc";
|
|
8
8
|
import { shareReplay, takeUntil, switchMap, of, Subject, BehaviorSubject, merge, map } from "rxjs";
|
|
@@ -64,8 +64,8 @@ let SheetsSelectionsService = (_a = class extends RxDisposable {
|
|
|
64
64
|
this._ensureWorkbookSelection(unitId).addSelections(sheetId, unitIdOrSelections);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* Set
|
|
68
|
-
* If type is not
|
|
67
|
+
* Set selection data to WorkbookSelections.
|
|
68
|
+
* If type is not specified, this method would clear all existing selections.
|
|
69
69
|
* @param unitIdOrSelections
|
|
70
70
|
* @param worksheetIdOrType
|
|
71
71
|
* @param selectionDatas
|
|
@@ -165,7 +165,7 @@ const _WorkbookSelections = class _WorkbookSelections extends Disposable {
|
|
|
165
165
|
* @param selectionDatas
|
|
166
166
|
* @param type
|
|
167
167
|
*/
|
|
168
|
-
setSelections(sheetId, selectionDatas, type) {
|
|
168
|
+
setSelections(sheetId, selectionDatas = [], type) {
|
|
169
169
|
switch (this._ensureSheetSelection(sheetId).length = 0, this._ensureSheetSelection(sheetId).push(...selectionDatas), type) {
|
|
170
170
|
case 0:
|
|
171
171
|
this._selectionMoveStart$.next(selectionDatas);
|
|
@@ -385,6 +385,24 @@ function getWorksheetDisposableID(unitId, worksheet) {
|
|
|
385
385
|
return `${unitId}|${worksheet.getSheetId()}`;
|
|
386
386
|
}
|
|
387
387
|
__name(getWorksheetDisposableID, "getWorksheetDisposableID");
|
|
388
|
+
function handleCustom(oldVal, newVal) {
|
|
389
|
+
const merge2 = mergeCustom(oldVal.custom, newVal.custom);
|
|
390
|
+
merge2 && Tools.removeNull(merge2), Tools.isEmptyObject(merge2) ? delete oldVal.custom : oldVal.custom = merge2;
|
|
391
|
+
}
|
|
392
|
+
__name(handleCustom, "handleCustom");
|
|
393
|
+
function mergeCustom(oldCustom, newCustom) {
|
|
394
|
+
return newCustom === null ? newCustom : newCustom === void 0 ? oldCustom : { ...oldCustom, ...newCustom };
|
|
395
|
+
}
|
|
396
|
+
__name(mergeCustom, "mergeCustom");
|
|
397
|
+
function transformCustom(oldCustom, newCustom) {
|
|
398
|
+
if (!newCustom || !Object.keys(newCustom).length)
|
|
399
|
+
return oldCustom;
|
|
400
|
+
const backupCustom = oldCustom || {};
|
|
401
|
+
for (const k in newCustom)
|
|
402
|
+
k in backupCustom || (backupCustom[k] = null);
|
|
403
|
+
return backupCustom;
|
|
404
|
+
}
|
|
405
|
+
__name(transformCustom, "transformCustom");
|
|
388
406
|
function handleStyle(styles, oldVal, newVal) {
|
|
389
407
|
var _a20;
|
|
390
408
|
const oldStyle = styles.getStyleByCell(oldVal);
|
|
@@ -397,10 +415,6 @@ function handleStyle(styles, oldVal, newVal) {
|
|
|
397
415
|
}
|
|
398
416
|
__name(handleStyle, "handleStyle");
|
|
399
417
|
function transformStyle(oldStyle, newStyle) {
|
|
400
|
-
return transformNormalKey(oldStyle, newStyle);
|
|
401
|
-
}
|
|
402
|
-
__name(transformStyle, "transformStyle");
|
|
403
|
-
function transformNormalKey(oldStyle, newStyle) {
|
|
404
418
|
if (!newStyle || !Object.keys(newStyle).length)
|
|
405
419
|
return oldStyle;
|
|
406
420
|
const backupStyle = oldStyle || {};
|
|
@@ -408,7 +422,7 @@ function transformNormalKey(oldStyle, newStyle) {
|
|
|
408
422
|
k === "bd" ? backupStyle[k] = transformBorders(backupStyle[k] || {}, newStyle[k]) : k in backupStyle || (backupStyle[k] = null);
|
|
409
423
|
return backupStyle;
|
|
410
424
|
}
|
|
411
|
-
__name(
|
|
425
|
+
__name(transformStyle, "transformStyle");
|
|
412
426
|
function transformBorders(oldBorders, newBorders) {
|
|
413
427
|
if (!newBorders || !Object.keys(newBorders).length)
|
|
414
428
|
return oldBorders;
|
|
@@ -421,11 +435,9 @@ function mergeStyle(oldStyle, newStyle, isRichText = !1) {
|
|
|
421
435
|
if (newStyle === null) return newStyle;
|
|
422
436
|
if (newStyle === void 0) return oldStyle;
|
|
423
437
|
const backupStyle = Tools.deepClone(oldStyle) || {};
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return "cl" in backupStyle && ("ul" in backupStyle && backupStyle.ul && (backupStyle.ul.cl = backupStyle.cl), "ol" in backupStyle && backupStyle.ol && (backupStyle.ol.cl = backupStyle.cl), "st" in backupStyle && backupStyle.st && (backupStyle.st.cl = backupStyle.cl)), backupStyle;
|
|
428
|
-
}
|
|
438
|
+
for (const k in newStyle)
|
|
439
|
+
isRichText && ["bd", "tr", "td", "ht", "vt", "tb", "pd", "bg"].includes(k) || (k in backupStyle && k === "bd" ? backupStyle[k] = Object.assign(backupStyle[k], newStyle[k]) : backupStyle[k] = newStyle[k]);
|
|
440
|
+
return "cl" in backupStyle && ("ul" in backupStyle && backupStyle.ul && (backupStyle.ul.cl = backupStyle.cl), "ol" in backupStyle && backupStyle.ol && (backupStyle.ol.cl = backupStyle.cl), "st" in backupStyle && backupStyle.st && (backupStyle.st.cl = backupStyle.cl)), backupStyle;
|
|
429
441
|
}
|
|
430
442
|
__name(mergeStyle, "mergeStyle");
|
|
431
443
|
function skipParagraphs(paragraphs, offset) {
|
|
@@ -463,36 +475,6 @@ function mergeRichTextStyle(p, newStyle) {
|
|
|
463
475
|
p.body.textRuns = normalizeTextRuns(newTextRuns);
|
|
464
476
|
}
|
|
465
477
|
__name(mergeRichTextStyle, "mergeRichTextStyle");
|
|
466
|
-
function getCellValue(type, cell) {
|
|
467
|
-
return type === CellValueType.NUMBER ? Number(cell.v) : type === CellValueType.BOOLEAN ? extractBooleanValue(cell.v) ? 1 : 0 : type === CellValueType.STRING || type === CellValueType.FORCE_STRING ? `${cell.v}` : cell.v;
|
|
468
|
-
}
|
|
469
|
-
__name(getCellValue, "getCellValue");
|
|
470
|
-
function extractBooleanValue(value) {
|
|
471
|
-
if (typeof value == "string") {
|
|
472
|
-
if (value.toUpperCase() === "TRUE")
|
|
473
|
-
return !0;
|
|
474
|
-
if (value.toUpperCase() === "FALSE")
|
|
475
|
-
return !1;
|
|
476
|
-
if (isSafeNumeric(value)) {
|
|
477
|
-
if (Number(value) === 0)
|
|
478
|
-
return !1;
|
|
479
|
-
if (Number(value) === 1)
|
|
480
|
-
return !0;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
if (typeof value == "number") {
|
|
484
|
-
if (value === 0)
|
|
485
|
-
return !1;
|
|
486
|
-
if (value === 1)
|
|
487
|
-
return !0;
|
|
488
|
-
}
|
|
489
|
-
return typeof value == "boolean" ? value : null;
|
|
490
|
-
}
|
|
491
|
-
__name(extractBooleanValue, "extractBooleanValue");
|
|
492
|
-
function setNull(value) {
|
|
493
|
-
return value == null ? null : (value.f === void 0 && (value.f = null), value.si === void 0 && (value.si = null), value.p === void 0 && (value.p = null), value.v === void 0 && (value.v = null), value.t === void 0 && (value.t = null), value.s === void 0 && (value.s = null), value.custom === void 0 && (value.custom = null), value);
|
|
494
|
-
}
|
|
495
|
-
__name(setNull, "setNull");
|
|
496
478
|
function getCellType(styles, newVal, oldVal) {
|
|
497
479
|
if (newVal.t) return newVal.t;
|
|
498
480
|
if (newVal.v === null) return null;
|
|
@@ -531,6 +513,36 @@ function getCellTypeByPattern(cell, pattern) {
|
|
|
531
513
|
return cell.t === CellValueType.FORCE_STRING ? CellValueType.FORCE_STRING : pattern === DEFAULT_TEXT_FORMAT ? CellValueType.STRING : checkCellValueType(cell.v, cell.t);
|
|
532
514
|
}
|
|
533
515
|
__name(getCellTypeByPattern, "getCellTypeByPattern");
|
|
516
|
+
function getCellValue(type, cell) {
|
|
517
|
+
return type === CellValueType.NUMBER ? Number(cell.v) : type === CellValueType.BOOLEAN ? extractBooleanValue(cell.v) ? 1 : 0 : type === CellValueType.STRING || type === CellValueType.FORCE_STRING ? `${cell.v}` : cell.v;
|
|
518
|
+
}
|
|
519
|
+
__name(getCellValue, "getCellValue");
|
|
520
|
+
function extractBooleanValue(value) {
|
|
521
|
+
if (typeof value == "string") {
|
|
522
|
+
if (value.toUpperCase() === "TRUE")
|
|
523
|
+
return !0;
|
|
524
|
+
if (value.toUpperCase() === "FALSE")
|
|
525
|
+
return !1;
|
|
526
|
+
if (isSafeNumeric(value)) {
|
|
527
|
+
if (Number(value) === 0)
|
|
528
|
+
return !1;
|
|
529
|
+
if (Number(value) === 1)
|
|
530
|
+
return !0;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (typeof value == "number") {
|
|
534
|
+
if (value === 0)
|
|
535
|
+
return !1;
|
|
536
|
+
if (value === 1)
|
|
537
|
+
return !0;
|
|
538
|
+
}
|
|
539
|
+
return typeof value == "boolean" ? value : null;
|
|
540
|
+
}
|
|
541
|
+
__name(extractBooleanValue, "extractBooleanValue");
|
|
542
|
+
function setNull(value) {
|
|
543
|
+
return value == null ? null : (value.f === void 0 && (value.f = null), value.si === void 0 && (value.si = null), value.p === void 0 && (value.p = null), value.v === void 0 && (value.v = null), value.t === void 0 && (value.t = null), value.s === void 0 && (value.s = null), value.custom === void 0 && (value.custom = null), value);
|
|
544
|
+
}
|
|
545
|
+
__name(setNull, "setNull");
|
|
534
546
|
const SetRangeValuesUndoMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
535
547
|
const { unitId, subUnitId, cellValue } = params, workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(unitId);
|
|
536
548
|
if (workbook == null)
|
|
@@ -540,9 +552,8 @@ const SetRangeValuesUndoMutationFactory = /* @__PURE__ */ __name((accessor, para
|
|
|
540
552
|
throw new Error("worksheet is null error!");
|
|
541
553
|
const cellMatrix = worksheet.getCellMatrix(), styles = workbook.getStyles(), undoData = new ObjectMatrix();
|
|
542
554
|
return new ObjectMatrix(cellValue).forValue((row, col, newVal) => {
|
|
543
|
-
const cell = Tools.deepClone(cellMatrix == null ? void 0 : cellMatrix.getValue(row, col)) || {}, oldStyle = styles.getStyleByCell(cell);
|
|
544
|
-
|
|
545
|
-
newStyle = transformStyle(oldStyle, newStyle), cell.s = newStyle, undoData.setValue(row, col, setNull(cell));
|
|
555
|
+
const cell = Tools.deepClone(cellMatrix == null ? void 0 : cellMatrix.getValue(row, col)) || {}, oldStyle = styles.getStyleByCell(cell), newStyle = styles.getStyleByCell(newVal);
|
|
556
|
+
cell.s = transformStyle(oldStyle, newStyle), cell.custom = transformCustom(cell.custom, newVal == null ? void 0 : newVal.custom), undoData.setValue(row, col, setNull(cell));
|
|
546
557
|
}), {
|
|
547
558
|
...params,
|
|
548
559
|
options: {},
|
|
@@ -564,7 +575,7 @@ const SetRangeValuesUndoMutationFactory = /* @__PURE__ */ __name((accessor, para
|
|
|
564
575
|
cellMatrix == null || cellMatrix.setValue(row, col, {});
|
|
565
576
|
else {
|
|
566
577
|
const oldVal = cellMatrix.getValue(row, col) || {}, type = getCellType(styles, newVal, oldVal);
|
|
567
|
-
newVal.f !== void 0 && (oldVal.f = newVal.f), newVal.si !== void 0 && (oldVal.si = newVal.si), newVal.p !== void 0 && (oldVal.p = newVal.p), newVal.v !== void 0 && (oldVal.v = getCellValue(type, newVal)), oldVal.v !== void 0 && (oldVal.t = type, oldVal.v = getCellValue(type, oldVal)), newVal.s !== void 0 && handleStyle(styles, oldVal, newVal), newVal.custom !== void 0 && (oldVal
|
|
578
|
+
newVal.f !== void 0 && (oldVal.f = newVal.f), newVal.si !== void 0 && (oldVal.si = newVal.si), newVal.p !== void 0 && (oldVal.p = newVal.p), newVal.v !== void 0 && (oldVal.v = getCellValue(type, newVal)), oldVal.v !== void 0 && (oldVal.t = type, oldVal.v = getCellValue(type, oldVal)), newVal.s !== void 0 && handleStyle(styles, oldVal, newVal), newVal.custom !== void 0 && handleCustom(oldVal, newVal), cellMatrix.setValue(row, col, Tools.removeNull(oldVal));
|
|
568
579
|
}
|
|
569
580
|
}), !0;
|
|
570
581
|
}, "handler")
|
|
@@ -2767,9 +2778,9 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
|
2767
2778
|
type: CommandType.COMMAND,
|
|
2768
2779
|
id: "sheet.command.remove-worksheet-merge",
|
|
2769
2780
|
// eslint-disable-next-line max-lines-per-function
|
|
2770
|
-
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
2781
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
2771
2782
|
var _a20;
|
|
2772
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
|
|
2783
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (params == null ? void 0 : params.ranges) || ((_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range));
|
|
2773
2784
|
if (!(selections != null && selections.length)) return !1;
|
|
2774
2785
|
const target = getSheetCommandTarget(univerInstanceService);
|
|
2775
2786
|
if (!target) return !1;
|
|
@@ -3992,14 +4003,8 @@ const SetStyleCommand = {
|
|
|
3992
4003
|
}, SET_WORKSHEET_ACTIVE_DELAY);
|
|
3993
4004
|
});
|
|
3994
4005
|
}, "handler")
|
|
3995
|
-
}, SetWorksheetColWidthMutationFactory = /* @__PURE__ */ __name((
|
|
3996
|
-
const
|
|
3997
|
-
if (universheet == null)
|
|
3998
|
-
throw new Error("universheet is null error!");
|
|
3999
|
-
const worksheet = universheet.getSheetBySheetId(params.subUnitId);
|
|
4000
|
-
if (worksheet == null)
|
|
4001
|
-
throw new Error("universheet is null error!");
|
|
4002
|
-
const colWidth = {}, manager = worksheet.getColumnManager(), ranges = params.ranges;
|
|
4006
|
+
}, SetWorksheetColWidthMutationFactory = /* @__PURE__ */ __name((params, worksheet) => {
|
|
4007
|
+
const { unitId, subUnitId, ranges } = params, colWidth = {}, manager = worksheet.getColumnManager();
|
|
4003
4008
|
for (let i = 0; i < ranges.length; i++) {
|
|
4004
4009
|
const range = ranges[i];
|
|
4005
4010
|
for (let j = range.startColumn; j < range.endColumn + 1; j++) {
|
|
@@ -4008,9 +4013,9 @@ const SetStyleCommand = {
|
|
|
4008
4013
|
}
|
|
4009
4014
|
}
|
|
4010
4015
|
return {
|
|
4011
|
-
unitId
|
|
4012
|
-
subUnitId
|
|
4013
|
-
ranges
|
|
4016
|
+
unitId,
|
|
4017
|
+
subUnitId,
|
|
4018
|
+
ranges,
|
|
4014
4019
|
colWidth
|
|
4015
4020
|
};
|
|
4016
4021
|
}, "SetWorksheetColWidthMutationFactory"), SetWorksheetColWidthMutation = {
|
|
@@ -4018,18 +4023,14 @@ const SetStyleCommand = {
|
|
|
4018
4023
|
type: CommandType.MUTATION,
|
|
4019
4024
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4020
4025
|
var _a20;
|
|
4021
|
-
const
|
|
4022
|
-
if (
|
|
4023
|
-
|
|
4024
|
-
const worksheet = universheet.getSheetBySheetId(params.subUnitId);
|
|
4025
|
-
if (!worksheet)
|
|
4026
|
-
return !1;
|
|
4027
|
-
const defaultColumnWidth = worksheet.getConfig().defaultColumnWidth, manager = worksheet.getColumnManager(), ranges = params.ranges;
|
|
4026
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4027
|
+
if (!target) return !1;
|
|
4028
|
+
const { worksheet } = target, defaultColumnWidth = worksheet.getConfig().defaultColumnWidth, manager = worksheet.getColumnManager(), ranges = params.ranges;
|
|
4028
4029
|
for (let i = 0; i < ranges.length; i++) {
|
|
4029
4030
|
const range = ranges[i];
|
|
4030
4031
|
for (let j = range.startColumn; j < range.endColumn + 1; j++) {
|
|
4031
4032
|
const column = manager.getColumnOrCreate(j);
|
|
4032
|
-
typeof params.colWidth == "number" ? column.w = params.colWidth : column.w = (_a20 = params.colWidth[j
|
|
4033
|
+
typeof params.colWidth == "number" ? column.w = params.colWidth : column.w = (_a20 = params.colWidth[j]) != null ? _a20 : defaultColumnWidth;
|
|
4033
4034
|
}
|
|
4034
4035
|
}
|
|
4035
4036
|
return !0;
|
|
@@ -4040,7 +4041,7 @@ const SetStyleCommand = {
|
|
|
4040
4041
|
// eslint-disable-next-line max-lines-per-function
|
|
4041
4042
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
4042
4043
|
const selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
4043
|
-
if (
|
|
4044
|
+
if (!(selections != null && selections.length))
|
|
4044
4045
|
return !1;
|
|
4045
4046
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
4046
4047
|
if (!target) return !1;
|
|
@@ -4081,8 +4082,8 @@ const SetStyleCommand = {
|
|
|
4081
4082
|
id: DeltaColumnWidthCommand.id,
|
|
4082
4083
|
params: redoMutationParams
|
|
4083
4084
|
}), undoMutationParams = SetWorksheetColWidthMutationFactory(
|
|
4084
|
-
|
|
4085
|
-
|
|
4085
|
+
redoMutationParams,
|
|
4086
|
+
worksheet
|
|
4086
4087
|
), setColWidthResult = commandService.syncExecuteCommand(
|
|
4087
4088
|
SetWorksheetColWidthMutation.id,
|
|
4088
4089
|
redoMutationParams
|
|
@@ -4102,18 +4103,12 @@ const SetStyleCommand = {
|
|
|
4102
4103
|
if (!(selections != null && selections.length)) return !1;
|
|
4103
4104
|
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
|
|
4104
4105
|
if (!target) return !1;
|
|
4105
|
-
const { subUnitId, unitId } = target, redoMutationParams = {
|
|
4106
|
+
const { subUnitId, unitId, worksheet } = target, redoMutationParams = {
|
|
4106
4107
|
subUnitId,
|
|
4107
4108
|
unitId,
|
|
4108
4109
|
ranges: selections,
|
|
4109
4110
|
colWidth: params.value
|
|
4110
|
-
}, undoMutationParams = SetWorksheetColWidthMutationFactory(
|
|
4111
|
-
accessor,
|
|
4112
|
-
redoMutationParams
|
|
4113
|
-
), setColWidthResult = commandService.syncExecuteCommand(
|
|
4114
|
-
SetWorksheetColWidthMutation.id,
|
|
4115
|
-
redoMutationParams
|
|
4116
|
-
), { undos, redos } = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
4111
|
+
}, undoMutationParams = SetWorksheetColWidthMutationFactory(redoMutationParams, worksheet), setColWidthResult = commandService.syncExecuteCommand(SetWorksheetColWidthMutation.id, redoMutationParams), { undos, redos } = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
4117
4112
|
id: SetColWidthCommand.id,
|
|
4118
4113
|
params: redoMutationParams
|
|
4119
4114
|
}), intercepted = sheetInterceptorService.onCommandExecute({
|
|
@@ -4248,11 +4243,8 @@ const SetStyleCommand = {
|
|
|
4248
4243
|
redoMutations: [{ id: SetWorksheetOrderMutation.id, params: setWorksheetOrderMutationParams }]
|
|
4249
4244
|
}), !0) : !1;
|
|
4250
4245
|
}, "handler")
|
|
4251
|
-
}, MAXIMUM_ROW_HEIGHT = 2e3, SetWorksheetRowHeightMutationFactory = /* @__PURE__ */ __name((
|
|
4252
|
-
const { unitId, subUnitId, ranges } = params,
|
|
4253
|
-
if (worksheet == null)
|
|
4254
|
-
throw new Error("worksheet is null error!");
|
|
4255
|
-
const rowHeight = {}, manager = worksheet.getRowManager();
|
|
4246
|
+
}, MAXIMUM_ROW_HEIGHT = 2e3, SetWorksheetRowHeightMutationFactory = /* @__PURE__ */ __name((params, worksheet) => {
|
|
4247
|
+
const { unitId, subUnitId, ranges } = params, rowHeight = {}, manager = worksheet.getRowManager();
|
|
4256
4248
|
for (const { startRow, endRow } of ranges)
|
|
4257
4249
|
for (let rowIndex = startRow; rowIndex < endRow + 1; rowIndex++) {
|
|
4258
4250
|
const row = manager.getRowOrCreate(rowIndex);
|
|
@@ -4264,8 +4256,8 @@ const SetStyleCommand = {
|
|
|
4264
4256
|
ranges,
|
|
4265
4257
|
rowHeight
|
|
4266
4258
|
};
|
|
4267
|
-
}, "SetWorksheetRowHeightMutationFactory"), SetWorksheetRowIsAutoHeightMutationFactory = /* @__PURE__ */ __name((
|
|
4268
|
-
const { unitId, subUnitId, ranges } = params,
|
|
4259
|
+
}, "SetWorksheetRowHeightMutationFactory"), SetWorksheetRowIsAutoHeightMutationFactory = /* @__PURE__ */ __name((params, worksheet) => {
|
|
4260
|
+
const { unitId, subUnitId, ranges } = params, autoHeightHash = {}, manager = worksheet.getRowManager();
|
|
4269
4261
|
for (const { startRow, endRow } of ranges)
|
|
4270
4262
|
for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
4271
4263
|
const row = manager.getRowOrCreate(rowIndex);
|
|
@@ -4277,21 +4269,11 @@ const SetStyleCommand = {
|
|
|
4277
4269
|
ranges,
|
|
4278
4270
|
autoHeightInfo: autoHeightHash
|
|
4279
4271
|
};
|
|
4280
|
-
}, "SetWorksheetRowIsAutoHeightMutationFactory"), SetWorksheetRowAutoHeightMutationFactory = /* @__PURE__ */ __name((
|
|
4281
|
-
const { unitId, subUnitId, rowsAutoHeightInfo } = params,
|
|
4282
|
-
if (!worksheet)
|
|
4283
|
-
return {
|
|
4284
|
-
unitId,
|
|
4285
|
-
subUnitId,
|
|
4286
|
-
rowsAutoHeightInfo: []
|
|
4287
|
-
};
|
|
4288
|
-
const results = [], manager = worksheet.getRowManager();
|
|
4272
|
+
}, "SetWorksheetRowIsAutoHeightMutationFactory"), SetWorksheetRowAutoHeightMutationFactory = /* @__PURE__ */ __name((params, worksheet) => {
|
|
4273
|
+
const { unitId, subUnitId, rowsAutoHeightInfo } = params, results = [], manager = worksheet.getRowManager();
|
|
4289
4274
|
for (const rowInfo of rowsAutoHeightInfo) {
|
|
4290
4275
|
const { row } = rowInfo, { ah } = manager.getRowOrCreate(row);
|
|
4291
|
-
results.push({
|
|
4292
|
-
row,
|
|
4293
|
-
autoHeight: ah
|
|
4294
|
-
});
|
|
4276
|
+
results.push({ row, autoHeight: ah });
|
|
4295
4277
|
}
|
|
4296
4278
|
return {
|
|
4297
4279
|
unitId,
|
|
@@ -4303,10 +4285,9 @@ const SetStyleCommand = {
|
|
|
4303
4285
|
type: CommandType.MUTATION,
|
|
4304
4286
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4305
4287
|
var _a20;
|
|
4306
|
-
const {
|
|
4307
|
-
if (!
|
|
4308
|
-
|
|
4309
|
-
const defaultRowHeight = worksheet.getConfig().defaultRowHeight, manager = worksheet.getRowManager();
|
|
4288
|
+
const { ranges, rowHeight } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4289
|
+
if (!target) return !1;
|
|
4290
|
+
const { worksheet } = target, defaultRowHeight = worksheet.getConfig().defaultRowHeight, manager = worksheet.getRowManager();
|
|
4310
4291
|
for (const { startRow, endRow } of ranges)
|
|
4311
4292
|
for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
4312
4293
|
const row = manager.getRowOrCreate(rowIndex);
|
|
@@ -4319,14 +4300,13 @@ const SetStyleCommand = {
|
|
|
4319
4300
|
type: CommandType.MUTATION,
|
|
4320
4301
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4321
4302
|
var _a20;
|
|
4322
|
-
const {
|
|
4323
|
-
if (!
|
|
4324
|
-
|
|
4325
|
-
const defaultRowIsAutoHeight = void 0, manager = worksheet.getRowManager();
|
|
4303
|
+
const { ranges, autoHeightInfo } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4304
|
+
if (!target) return !1;
|
|
4305
|
+
const manager = target.worksheet.getRowManager();
|
|
4326
4306
|
for (const { startRow, endRow } of ranges)
|
|
4327
4307
|
for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
4328
4308
|
const row = manager.getRowOrCreate(rowIndex);
|
|
4329
|
-
typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a20 = autoHeightInfo[rowIndex]) != null ? _a20 :
|
|
4309
|
+
typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a20 = autoHeightInfo[rowIndex]) != null ? _a20 : void 0;
|
|
4330
4310
|
}
|
|
4331
4311
|
return !0;
|
|
4332
4312
|
}, "handler")
|
|
@@ -4334,10 +4314,9 @@ const SetStyleCommand = {
|
|
|
4334
4314
|
id: "sheet.mutation.set-worksheet-row-auto-height",
|
|
4335
4315
|
type: CommandType.MUTATION,
|
|
4336
4316
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
4337
|
-
const {
|
|
4338
|
-
if (!
|
|
4339
|
-
|
|
4340
|
-
const rowManager = worksheet.getRowManager();
|
|
4317
|
+
const { rowsAutoHeightInfo } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4318
|
+
if (!target) return !1;
|
|
4319
|
+
const rowManager = target.worksheet.getRowManager();
|
|
4341
4320
|
for (const { row, autoHeight } of rowsAutoHeightInfo) {
|
|
4342
4321
|
const curRow = rowManager.getRowOrCreate(row);
|
|
4343
4322
|
curRow.ah = autoHeight;
|
|
@@ -4388,15 +4367,12 @@ const SetStyleCommand = {
|
|
|
4388
4367
|
}
|
|
4389
4368
|
]
|
|
4390
4369
|
};
|
|
4391
|
-
const undoMutationParams = SetWorksheetRowHeightMutationFactory(
|
|
4392
|
-
accessor,
|
|
4393
|
-
redoMutationParams
|
|
4394
|
-
), redoSetIsAutoHeightParams = {
|
|
4370
|
+
const undoMutationParams = SetWorksheetRowHeightMutationFactory(redoMutationParams, worksheet), redoSetIsAutoHeightParams = {
|
|
4395
4371
|
unitId,
|
|
4396
4372
|
subUnitId,
|
|
4397
4373
|
ranges: redoMutationParams.ranges,
|
|
4398
4374
|
autoHeightInfo: BooleanNumber.FALSE
|
|
4399
|
-
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(
|
|
4375
|
+
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(redoSetIsAutoHeightParams, worksheet), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), intercepted = sheetInterceptorService.onCommandExecute({
|
|
4400
4376
|
id: DeltaRowHeightCommand.id,
|
|
4401
4377
|
params: redoMutationParams
|
|
4402
4378
|
}), result = sequenceExecute([
|
|
@@ -4448,20 +4424,17 @@ const SetStyleCommand = {
|
|
|
4448
4424
|
return !1;
|
|
4449
4425
|
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
4450
4426
|
if (!target) return !1;
|
|
4451
|
-
const { unitId, subUnitId } = target, redoMutationParams = {
|
|
4427
|
+
const { unitId, subUnitId, worksheet } = target, redoMutationParams = {
|
|
4452
4428
|
subUnitId,
|
|
4453
4429
|
unitId,
|
|
4454
4430
|
ranges: selections,
|
|
4455
4431
|
rowHeight: params.value
|
|
4456
|
-
}, undoMutationParams = SetWorksheetRowHeightMutationFactory(
|
|
4457
|
-
accessor,
|
|
4458
|
-
redoMutationParams
|
|
4459
|
-
), redoSetIsAutoHeightParams = {
|
|
4432
|
+
}, undoMutationParams = SetWorksheetRowHeightMutationFactory(redoMutationParams, worksheet), redoSetIsAutoHeightParams = {
|
|
4460
4433
|
unitId,
|
|
4461
4434
|
subUnitId,
|
|
4462
4435
|
ranges: redoMutationParams.ranges,
|
|
4463
4436
|
autoHeightInfo: BooleanNumber.FALSE
|
|
4464
|
-
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(
|
|
4437
|
+
}, undoSetIsAutoHeightParams = SetWorksheetRowIsAutoHeightMutationFactory(redoSetIsAutoHeightParams, worksheet), result = sequenceExecute([
|
|
4465
4438
|
{
|
|
4466
4439
|
id: SetWorksheetRowHeightMutation.id,
|
|
4467
4440
|
params: redoMutationParams
|
|
@@ -4509,7 +4482,7 @@ const SetStyleCommand = {
|
|
|
4509
4482
|
var _a20, _b;
|
|
4510
4483
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4511
4484
|
if (!target) return !1;
|
|
4512
|
-
const { unitId, subUnitId } = target, ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
|
|
4485
|
+
const { unitId, subUnitId, worksheet } = target, ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
|
|
4513
4486
|
if (!(ranges != null && ranges.length))
|
|
4514
4487
|
return !1;
|
|
4515
4488
|
const redoMutationParams = {
|
|
@@ -4518,7 +4491,7 @@ const SetStyleCommand = {
|
|
|
4518
4491
|
ranges,
|
|
4519
4492
|
autoHeightInfo: BooleanNumber.TRUE
|
|
4520
4493
|
// Hard code first, maybe it will change by the menu item in the future.
|
|
4521
|
-
}, undoMutationParams = SetWorksheetRowIsAutoHeightMutationFactory(
|
|
4494
|
+
}, undoMutationParams = SetWorksheetRowIsAutoHeightMutationFactory(redoMutationParams, worksheet), setIsAutoHeightResult = commandService.syncExecuteCommand(
|
|
4522
4495
|
SetWorksheetRowIsAutoHeightMutation.id,
|
|
4523
4496
|
redoMutationParams
|
|
4524
4497
|
), { undos, redos } = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
@@ -4842,6 +4815,9 @@ let WorksheetProtectionRuleModel = (_a4 = class {
|
|
|
4842
4815
|
changeRuleInitState(state) {
|
|
4843
4816
|
this._worksheetRuleInitStateChange.next(state);
|
|
4844
4817
|
}
|
|
4818
|
+
getSheetRuleInitState() {
|
|
4819
|
+
return this._worksheetRuleInitStateChange.value;
|
|
4820
|
+
}
|
|
4845
4821
|
addRule(unitId, rule) {
|
|
4846
4822
|
this._ensureSubUnitMap(unitId).set(rule.subUnitId, rule), this._ruleChange.next({ unitId, rule, type: "add", subUnitId: rule.subUnitId });
|
|
4847
4823
|
}
|
|
@@ -4949,6 +4925,9 @@ let RangeProtectionRuleModel = (_a5 = class {
|
|
|
4949
4925
|
ruleRefresh(id) {
|
|
4950
4926
|
this._ruleRefresh.next(id);
|
|
4951
4927
|
}
|
|
4928
|
+
getRangeRuleInitState() {
|
|
4929
|
+
return this._rangeRuleInitStateChange.value;
|
|
4930
|
+
}
|
|
4952
4931
|
changeRuleInitState(state) {
|
|
4953
4932
|
this._rangeRuleInitStateChange.next(state);
|
|
4954
4933
|
}
|
|
@@ -6290,7 +6269,7 @@ function adjustRangeOnMutation(range, mutation) {
|
|
|
6290
6269
|
break;
|
|
6291
6270
|
case MoveRangeMutation.id:
|
|
6292
6271
|
{
|
|
6293
|
-
const fromRange = params.fromRange, toRange = params.toRange;
|
|
6272
|
+
const fromRange = params.fromRange || new ObjectMatrix(params.from).getRange(), toRange = params.toRange || new ObjectMatrix(params.to).getRange();
|
|
6294
6273
|
baseRangeOperator = handleBaseMoveRange(
|
|
6295
6274
|
fromRange,
|
|
6296
6275
|
toRange,
|
|
@@ -6457,9 +6436,11 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
|
|
|
6457
6436
|
if (!this._range)
|
|
6458
6437
|
return;
|
|
6459
6438
|
if (this._skipIntersects) {
|
|
6439
|
+
if (mutation.id === RemoveSheetMutation.id)
|
|
6440
|
+
return;
|
|
6460
6441
|
const effectRanges = getEffectedRangesOnMutation(mutation);
|
|
6461
6442
|
if (effectRanges != null && effectRanges.some((effectRange) => Rectangle.intersects(effectRange, this._range)))
|
|
6462
|
-
return
|
|
6443
|
+
return;
|
|
6463
6444
|
}
|
|
6464
6445
|
const afterRange = adjustRangeOnMutation(this._range, mutation);
|
|
6465
6446
|
if (afterRange && Rectangle.equals(afterRange, this._range))
|
|
@@ -8114,6 +8095,66 @@ NumberCellDisplayController = __decorateClass$1([
|
|
|
8114
8095
|
OnLifecycle(LifecycleStages.Ready, NumberCellDisplayController),
|
|
8115
8096
|
__decorateParam$1(0, Inject(SheetInterceptorService))
|
|
8116
8097
|
], NumberCellDisplayController);
|
|
8098
|
+
const IExclusiveRangeService = createIdentifier("univer.exclusive-range-service"), _ExclusiveRangeService = class _ExclusiveRangeService extends Disposable {
|
|
8099
|
+
constructor() {
|
|
8100
|
+
super(...arguments);
|
|
8101
|
+
/**
|
|
8102
|
+
* Exclusive range data structure is as follows: unitId -> sheetId -> feature -> range
|
|
8103
|
+
*/
|
|
8104
|
+
__publicField(this, "_exclusiveRanges", /* @__PURE__ */ new Map());
|
|
8105
|
+
}
|
|
8106
|
+
_ensureUnitMap(unitId) {
|
|
8107
|
+
return this._exclusiveRanges.has(unitId) || this._exclusiveRanges.set(unitId, /* @__PURE__ */ new Map()), this._exclusiveRanges.get(unitId);
|
|
8108
|
+
}
|
|
8109
|
+
_ensureSubunitMap(unitId, sheetId) {
|
|
8110
|
+
const unitMap = this._ensureUnitMap(unitId);
|
|
8111
|
+
return unitMap.has(sheetId) || unitMap.set(sheetId, /* @__PURE__ */ new Map()), unitMap.get(sheetId);
|
|
8112
|
+
}
|
|
8113
|
+
_ensureFeature(unitId, sheetId, feature) {
|
|
8114
|
+
const subunitMap = this._ensureSubunitMap(unitId, sheetId);
|
|
8115
|
+
return subunitMap.has(feature) || subunitMap.set(feature, []), subunitMap.get(feature);
|
|
8116
|
+
}
|
|
8117
|
+
addExclusiveRange(unitId, sheetId, feature, ranges) {
|
|
8118
|
+
this._ensureFeature(unitId, sheetId, feature).push(...ranges);
|
|
8119
|
+
}
|
|
8120
|
+
getExclusiveRanges(unitId, sheetId, feature) {
|
|
8121
|
+
var _a20, _b;
|
|
8122
|
+
return (_b = (_a20 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a20.get(sheetId)) == null ? void 0 : _b.get(feature);
|
|
8123
|
+
}
|
|
8124
|
+
clearExclusiveRanges(unitId, sheetId, feature) {
|
|
8125
|
+
this._ensureFeature(unitId, sheetId, feature), this._exclusiveRanges.get(unitId).get(sheetId).set(feature, []);
|
|
8126
|
+
}
|
|
8127
|
+
clearExclusiveRangesByGroupId(unitId, sheetId, feature, groupId) {
|
|
8128
|
+
const featureMap = this.getExclusiveRanges(unitId, sheetId, feature);
|
|
8129
|
+
if (featureMap) {
|
|
8130
|
+
const newFeatureMap = featureMap.filter((item) => item.groupId !== groupId);
|
|
8131
|
+
this._exclusiveRanges.get(unitId).get(sheetId).set(feature, newFeatureMap);
|
|
8132
|
+
}
|
|
8133
|
+
}
|
|
8134
|
+
getInterestGroupId(selections) {
|
|
8135
|
+
const interestGroupId = [];
|
|
8136
|
+
return selections.forEach((selection) => {
|
|
8137
|
+
var _a20;
|
|
8138
|
+
const range = selection.range, { unitId, sheetId } = range;
|
|
8139
|
+
if (!unitId || !sheetId) return;
|
|
8140
|
+
const featureMap = (_a20 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a20.get(sheetId);
|
|
8141
|
+
if (featureMap)
|
|
8142
|
+
for (const feature of featureMap.keys()) {
|
|
8143
|
+
const featureMapRanges = featureMap.get(feature);
|
|
8144
|
+
if (featureMapRanges) {
|
|
8145
|
+
for (const featureMapRange of featureMapRanges)
|
|
8146
|
+
if (Rectangle.intersects(range, featureMapRange.range)) {
|
|
8147
|
+
interestGroupId.push(feature);
|
|
8148
|
+
break;
|
|
8149
|
+
}
|
|
8150
|
+
}
|
|
8151
|
+
}
|
|
8152
|
+
}), interestGroupId;
|
|
8153
|
+
}
|
|
8154
|
+
};
|
|
8155
|
+
__name(_ExclusiveRangeService, "ExclusiveRangeService");
|
|
8156
|
+
let ExclusiveRangeService = _ExclusiveRangeService;
|
|
8157
|
+
const PLUGIN_CONFIG_KEY = "sheets.config", defaultPluginConfig = {};
|
|
8117
8158
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
8118
8159
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8119
8160
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -8122,8 +8163,10 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
|
|
|
8122
8163
|
const PLUGIN_NAME = "SHEET_PLUGIN";
|
|
8123
8164
|
var _a19;
|
|
8124
8165
|
let UniverSheetsPlugin = (_a19 = class extends Plugin {
|
|
8125
|
-
constructor(_config,
|
|
8126
|
-
super(), this._config = _config, this.
|
|
8166
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
8167
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
|
8168
|
+
const { ...rest } = this._config;
|
|
8169
|
+
this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initConfig(), this._initDependencies(_injector);
|
|
8127
8170
|
}
|
|
8128
8171
|
onRendered() {
|
|
8129
8172
|
}
|
|
@@ -8154,19 +8197,23 @@ let UniverSheetsPlugin = (_a19 = class extends Plugin {
|
|
|
8154
8197
|
[RangeProtectionRenderModel],
|
|
8155
8198
|
[RangeProtectionRuleModel],
|
|
8156
8199
|
[RangeProtectionRefRangeService],
|
|
8157
|
-
[RangeProtectionService]
|
|
8200
|
+
[RangeProtectionService],
|
|
8201
|
+
[IExclusiveRangeService, {
|
|
8202
|
+
useClass: ExclusiveRangeService,
|
|
8203
|
+
deps: [SheetsSelectionsService]
|
|
8204
|
+
}]
|
|
8158
8205
|
];
|
|
8159
8206
|
(_a20 = this._config) != null && _a20.notExecuteFormula || dependencies.push([CalculateResultApplyController]), mergeOverrideWithDependencies(dependencies, (_b = this._config) == null ? void 0 : _b.override).forEach((d) => {
|
|
8160
8207
|
sheetInjector.add(d);
|
|
8161
|
-
}), this._injector.get(SheetInterceptorService), this._injector.get(RangeProtectionService);
|
|
8208
|
+
}), this._injector.get(SheetInterceptorService), this._injector.get(RangeProtectionService), this._injector.get(IExclusiveRangeService);
|
|
8162
8209
|
}
|
|
8163
8210
|
}, __name(_a19, "UniverSheetsPlugin"), _a19);
|
|
8164
8211
|
__publicField2(UniverSheetsPlugin, "pluginName", PLUGIN_NAME);
|
|
8165
8212
|
__publicField2(UniverSheetsPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
8166
8213
|
UniverSheetsPlugin = __decorateClass([
|
|
8167
8214
|
DependentOn(UniverFormulaEnginePlugin),
|
|
8168
|
-
__decorateParam(1,
|
|
8169
|
-
__decorateParam(2,
|
|
8215
|
+
__decorateParam(1, Inject(Injector)),
|
|
8216
|
+
__decorateParam(2, IConfigService)
|
|
8170
8217
|
], UniverSheetsPlugin);
|
|
8171
8218
|
const COMMAND_LISTENER_SKELETON_CHANGE = [
|
|
8172
8219
|
SetWorksheetRowHeightMutation.id,
|
|
@@ -8634,7 +8681,21 @@ const AddWorksheetMergeCommand = {
|
|
|
8634
8681
|
subUnitId
|
|
8635
8682
|
});
|
|
8636
8683
|
}, "handler")
|
|
8637
|
-
}
|
|
8684
|
+
};
|
|
8685
|
+
async function addMergeCellsUtil(injector, unitId, subUnitId, ranges) {
|
|
8686
|
+
const univerInstanceService = injector.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, { unitId, subUnitId });
|
|
8687
|
+
if (!target) return;
|
|
8688
|
+
const { worksheet } = target;
|
|
8689
|
+
if (worksheet.getMergeData().some((mergeRange) => ranges.some((range) => Rectangle.intersects(range, mergeRange))))
|
|
8690
|
+
throw new Error("The ranges to be merged overlap with the existing merged cells");
|
|
8691
|
+
await injector.get(ICommandService).executeCommand(AddWorksheetMergeCommand.id, {
|
|
8692
|
+
unitId,
|
|
8693
|
+
subUnitId,
|
|
8694
|
+
selections: ranges
|
|
8695
|
+
});
|
|
8696
|
+
}
|
|
8697
|
+
__name(addMergeCellsUtil, "addMergeCellsUtil");
|
|
8698
|
+
const SetHideGridlinesUndoMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
8638
8699
|
const oldStatus = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId).getSheetBySheetId(params.subUnitId).getConfig().showGridlines;
|
|
8639
8700
|
return {
|
|
8640
8701
|
...Tools.deepClone(params),
|
|
@@ -8751,9 +8812,11 @@ export {
|
|
|
8751
8812
|
DeltaRowHeightCommand,
|
|
8752
8813
|
EffectRefRangId,
|
|
8753
8814
|
EmptyMutation,
|
|
8815
|
+
ExclusiveRangeService,
|
|
8754
8816
|
FactoryAddRangeProtectionMutation,
|
|
8755
8817
|
FactoryDeleteRangeProtectionMutation,
|
|
8756
8818
|
FactorySetRangeProtectionMutation,
|
|
8819
|
+
IExclusiveRangeService,
|
|
8757
8820
|
INTERCEPTOR_POINT,
|
|
8758
8821
|
INumfmtService,
|
|
8759
8822
|
IRefSelectionsService,
|
|
@@ -8933,6 +8996,7 @@ export {
|
|
|
8933
8996
|
WorksheetSetRowStylePermission,
|
|
8934
8997
|
WorksheetSortPermission,
|
|
8935
8998
|
WorksheetViewPermission,
|
|
8999
|
+
addMergeCellsUtil,
|
|
8936
9000
|
alignToMergedCellsBorders,
|
|
8937
9001
|
checkRangesEditablePermission,
|
|
8938
9002
|
convertPrimaryWithCoordToPrimary,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|