@univerjs/sheets 0.2.14 → 0.2.15
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 +2 -2
- package/lib/es/index.js +19 -33
- package/lib/types/basics/selection.d.ts +1 -0
- package/lib/types/commands/commands/set-border-command.d.ts +1 -1
- package/lib/types/commands/operations/selection.operation.d.ts +2 -0
- package/lib/types/controllers/merge-cell.controller.d.ts +3 -3
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +2 -2
- package/package.json +11 -11
- package/lib/types/commands/commands/utils/merged-cell-util.d.ts +0 -6
package/lib/es/index.js
CHANGED
|
@@ -87,7 +87,7 @@ let SheetsSelectionsService = (_a = class extends RxDisposable {
|
|
|
87
87
|
const { unitId, sheetId } = current;
|
|
88
88
|
this._ensureWorkbookSelection(unitId).setSelections(
|
|
89
89
|
sheetId,
|
|
90
|
-
unitIdOrSelections,
|
|
90
|
+
unitIdOrSelections != null ? unitIdOrSelections : selectionDatas,
|
|
91
91
|
worksheetIdOrType != null ? worksheetIdOrType : 2
|
|
92
92
|
/* MOVE_END */
|
|
93
93
|
);
|
|
@@ -2719,7 +2719,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
|
2719
2719
|
const mergeConfigData = worksheet.getConfig().mergeData, mergeAppendData = params.ranges;
|
|
2720
2720
|
for (let i = 0; i < mergeAppendData.length; i++)
|
|
2721
2721
|
mergeConfigData.push(mergeAppendData[i]);
|
|
2722
|
-
return !0;
|
|
2722
|
+
return worksheet.getSpanModel().rebuild(mergeConfigData), !0;
|
|
2723
2723
|
}, "handler")
|
|
2724
2724
|
}, RemoveMergeUndoMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
2725
2725
|
const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);
|
|
@@ -2754,7 +2754,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
|
|
|
2754
2754
|
const configMerge = mergeConfigData[i], removeMerge = mergeRemoveData[j];
|
|
2755
2755
|
Rectangle.intersects(configMerge, removeMerge) && mergeConfigData.splice(i, 1);
|
|
2756
2756
|
}
|
|
2757
|
-
return !0;
|
|
2757
|
+
return worksheet.getSpanModel().rebuild(mergeConfigData), !0;
|
|
2758
2758
|
}, "handler")
|
|
2759
2759
|
}, RemoveWorksheetMergeCommand = {
|
|
2760
2760
|
type: CommandType.COMMAND,
|
|
@@ -2907,7 +2907,7 @@ const SetBorderBasicCommand = {
|
|
|
2907
2907
|
var _a20;
|
|
2908
2908
|
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), borderStyleManagerService = accessor.get(BorderStyleManagerService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
2909
2909
|
if (!target) return !1;
|
|
2910
|
-
const { worksheet, unitId, subUnitId } = target, selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range)
|
|
2910
|
+
const { worksheet, unitId, subUnitId } = target, selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
|
|
2911
2911
|
if (!(selections != null && selections.length))
|
|
2912
2912
|
return !1;
|
|
2913
2913
|
const { style, color, type, activeBorderType } = borderStyleManagerService.getBorderInfo();
|
|
@@ -2957,21 +2957,11 @@ const SetBorderBasicCommand = {
|
|
|
2957
2957
|
cl: {
|
|
2958
2958
|
rgb: color
|
|
2959
2959
|
}
|
|
2960
|
-
}
|
|
2961
|
-
let res = null;
|
|
2962
|
-
return mergeData.forEach((merge2) => {
|
|
2963
|
-
Rectangle.intersects(merge2, {
|
|
2964
|
-
startColumn: column,
|
|
2965
|
-
endColumn: column,
|
|
2966
|
-
startRow: row,
|
|
2967
|
-
endRow: row
|
|
2968
|
-
}) && (res = merge2);
|
|
2969
|
-
}), res;
|
|
2970
|
-
}, "hasMerge");
|
|
2960
|
+
};
|
|
2971
2961
|
function setBorderStyle(range2, defaultStyle, reserve) {
|
|
2972
2962
|
range2.startRow < 0 || range2.startColumn < 0 || forEach(range2, (row, column) => {
|
|
2973
2963
|
var _a21, _b;
|
|
2974
|
-
const rectangle =
|
|
2964
|
+
const rectangle = worksheet.getMergedCell(row, column);
|
|
2975
2965
|
let bdStyle = defaultStyle;
|
|
2976
2966
|
if (rectangle && (defaultStyle.bc_tr || defaultStyle.ml_tr || defaultStyle.bl_tr || defaultStyle.tl_mr || defaultStyle.tl_bc || defaultStyle.tl_br)) {
|
|
2977
2967
|
if (reserve) {
|
|
@@ -2996,7 +2986,7 @@ const SetBorderBasicCommand = {
|
|
|
2996
2986
|
}
|
|
2997
2987
|
__name(setBorderStyle, "setBorderStyle"), top && (setBorderStyle(topRangeOut, { b: null }), setBorderStyle(topRange, { t: Tools.deepClone(border) }, !0)), bottom && (setBorderStyle(bottomRangeOut, { t: null }), setBorderStyle(bottomRange, { b: Tools.deepClone(border) }, !0)), left && (setBorderStyle(leftRangeOut, { r: null }), setBorderStyle(leftRange, { l: Tools.deepClone(border) }, !0)), right && (setBorderStyle(rightRangeOut, { l: null }), setBorderStyle(rightRange, { r: Tools.deepClone(border) }, !0)), tl_br && setBorderStyle(range, { tl_br: Tools.deepClone(border) }, !0), tl_bc && setBorderStyle(range, { tl_bc: Tools.deepClone(border) }, !0), tl_mr && setBorderStyle(range, { tl_mr: Tools.deepClone(border) }, !0), bl_tr && setBorderStyle(range, { bl_tr: Tools.deepClone(border) }, !0), ml_tr && setBorderStyle(range, { ml_tr: Tools.deepClone(border) }, !0), bc_tr && setBorderStyle(range, { bc_tr: Tools.deepClone(border) }, !0), vertical && forEach(range, (row, column) => {
|
|
2998
2988
|
var _a21, _b, _c, _d;
|
|
2999
|
-
const rectangle =
|
|
2989
|
+
const rectangle = worksheet.getMergedCell(row, column);
|
|
3000
2990
|
if (rectangle) {
|
|
3001
2991
|
if (rectangle.endColumn !== range.endColumn) {
|
|
3002
2992
|
const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
|
|
@@ -3034,7 +3024,7 @@ const SetBorderBasicCommand = {
|
|
|
3034
3024
|
}
|
|
3035
3025
|
}), horizontal && forEach(range, (row, column) => {
|
|
3036
3026
|
var _a21, _b, _c, _d;
|
|
3037
|
-
const rectangle =
|
|
3027
|
+
const rectangle = worksheet.getMergedCell(row, column);
|
|
3038
3028
|
if (rectangle) {
|
|
3039
3029
|
if (rectangle.endRow !== range.endRow) {
|
|
3040
3030
|
const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
|
|
@@ -3072,7 +3062,7 @@ const SetBorderBasicCommand = {
|
|
|
3072
3062
|
}
|
|
3073
3063
|
}), !top && !bottom && !left && !right && !vertical && !horizontal && !tl_br && !tl_bc && !tl_mr && !bl_tr && !ml_tr && !bc_tr && (setBorderStyle(topRangeOut, { b: null }), setBorderStyle(topRange, { t: null }, !0), setBorderStyle(bottomRangeOut, { t: null }), setBorderStyle(bottomRange, { b: null }, !0), setBorderStyle(leftRangeOut, { r: null }), setBorderStyle(leftRange, { l: null }, !0), setBorderStyle(rightRangeOut, { l: null }), setBorderStyle(rightRange, { r: null }, !0), setBorderStyle(range, { tl_br: null }, !0), setBorderStyle(range, { tl_bc: null }, !0), setBorderStyle(range, { tl_mr: null }, !0), setBorderStyle(range, { bl_tr: null }, !0), setBorderStyle(range, { ml_tr: null }, !0), setBorderStyle(range, { bc_tr: null }, !0), forEach(range, (row, column) => {
|
|
3074
3064
|
var _a21, _b, _c, _d, _e, _f, _g, _h;
|
|
3075
|
-
const rectangle =
|
|
3065
|
+
const rectangle = worksheet.getMergedCell(row, column);
|
|
3076
3066
|
if (rectangle) {
|
|
3077
3067
|
if (rectangle.endColumn !== range.endColumn) {
|
|
3078
3068
|
const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
|
|
@@ -3219,6 +3209,7 @@ const SetBorderBasicCommand = {
|
|
|
3219
3209
|
}, setSelectionOperationParams = {
|
|
3220
3210
|
unitId,
|
|
3221
3211
|
subUnitId,
|
|
3212
|
+
reveal: !0,
|
|
3222
3213
|
selections: ranges.map((r) => ({ range: r, primary: getPrimaryForRange(r, worksheet), style: null }))
|
|
3223
3214
|
}, undoMutationParams = SetColVisibleUndoMutationFactory(accessor, redoMutationParams), undoSetSelectionsOperationParams = {
|
|
3224
3215
|
unitId,
|
|
@@ -3289,6 +3280,7 @@ const SetBorderBasicCommand = {
|
|
|
3289
3280
|
}, undoMutationParams = SetColHiddenUndoMutationFactory(accessor, redoMutationParams), undoSetSelectionsOperationParams = {
|
|
3290
3281
|
unitId,
|
|
3291
3282
|
subUnitId,
|
|
3283
|
+
reveal: !0,
|
|
3292
3284
|
selections: ranges.map((range) => ({
|
|
3293
3285
|
range,
|
|
3294
3286
|
primary: getPrimaryForRange(range, worksheet),
|
|
@@ -3479,6 +3471,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
|
3479
3471
|
const { worksheet } = target, redoMutationParams = { unitId, subUnitId, ranges }, setSelectionOperationParams = {
|
|
3480
3472
|
unitId,
|
|
3481
3473
|
subUnitId,
|
|
3474
|
+
reveal: !0,
|
|
3482
3475
|
selections: ranges.map((range) => ({
|
|
3483
3476
|
range,
|
|
3484
3477
|
primary: getPrimaryForRange(range, worksheet),
|
|
@@ -3556,6 +3549,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
|
|
|
3556
3549
|
}, undoMutationParams = SetRowHiddenUndoMutationFactory(accessor, redoMutationParams), undoSetSelectionsOperationParams = {
|
|
3557
3550
|
unitId,
|
|
3558
3551
|
subUnitId,
|
|
3552
|
+
reveal: !0,
|
|
3559
3553
|
selections: ranges.map((range) => ({
|
|
3560
3554
|
range,
|
|
3561
3555
|
primary: getPrimaryForRange(range, worksheet),
|
|
@@ -4269,7 +4263,7 @@ const SetStyleCommand = {
|
|
|
4269
4263
|
var _a20;
|
|
4270
4264
|
const { ranges, rowHeight } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
|
|
4271
4265
|
if (!target) return !1;
|
|
4272
|
-
const { worksheet } = target,
|
|
4266
|
+
const { worksheet } = target, manager = worksheet.getRowManager(), defaultRowHeight = worksheet.getConfig().defaultRowHeight;
|
|
4273
4267
|
for (const { startRow, endRow } of ranges)
|
|
4274
4268
|
for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
|
|
4275
4269
|
const row = manager.getRowOrCreate(rowIndex);
|
|
@@ -7370,17 +7364,11 @@ let MergeCellController = (_a11 = class extends Disposable {
|
|
|
7370
7364
|
unitId,
|
|
7371
7365
|
subUnitId,
|
|
7372
7366
|
ranges: removeMergeData
|
|
7373
|
-
}, undoRemoveMergeParams = RemoveMergeUndoMutationFactory(
|
|
7374
|
-
this._injector,
|
|
7375
|
-
removeMergeParams
|
|
7376
|
-
), addMergeParams = {
|
|
7367
|
+
}, undoRemoveMergeParams = RemoveMergeUndoMutationFactory(this._injector, removeMergeParams), addMergeParams = {
|
|
7377
7368
|
unitId,
|
|
7378
7369
|
subUnitId,
|
|
7379
7370
|
ranges: addMergeData
|
|
7380
|
-
}, undoAddMergeParams = AddMergeUndoMutationFactory(
|
|
7381
|
-
this._injector,
|
|
7382
|
-
addMergeParams
|
|
7383
|
-
);
|
|
7371
|
+
}, undoAddMergeParams = AddMergeUndoMutationFactory(this._injector, addMergeParams);
|
|
7384
7372
|
return {
|
|
7385
7373
|
redos: [
|
|
7386
7374
|
{ id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
|
|
@@ -7416,7 +7404,7 @@ let MergeCellController = (_a11 = class extends Disposable {
|
|
|
7416
7404
|
mergeData.forEach((merge2) => {
|
|
7417
7405
|
let { startRow, endRow, startColumn, endColumn, rangeType } = merge2;
|
|
7418
7406
|
Rectangle.intersects(merge2, sourceRange) || (isRowMove ? sourceStart < startRow && targetStart > endRow ? (startRow -= moveLength, endRow -= moveLength) : sourceStart > endRow && targetStart <= startRow && (startRow += moveLength, endRow += moveLength) : sourceStart < startColumn && targetStart > endColumn ? (startColumn -= moveLength, endColumn -= moveLength) : sourceStart > endColumn && targetStart <= startColumn && (startColumn += moveLength, endColumn += moveLength)), merge2.startRow === merge2.endRow && merge2.startColumn === merge2.endColumn || adjustedMergedCells.push({ startRow, endRow, startColumn, endColumn, rangeType });
|
|
7419
|
-
}), worksheet.
|
|
7407
|
+
}), worksheet.setMergeData(adjustedMergedCells), this.disposableCollection.dispose();
|
|
7420
7408
|
const { unitId, subUnitId } = command.params, handler = /* @__PURE__ */ __name((config) => this.refRangeHandle(config, unitId, subUnitId), "handler");
|
|
7421
7409
|
adjustedMergedCells.forEach((range) => {
|
|
7422
7410
|
this.disposableCollection.add(this._refRangeService.registerRefRange(range, handler, unitId, subUnitId));
|
|
@@ -7433,7 +7421,7 @@ let MergeCellController = (_a11 = class extends Disposable {
|
|
|
7433
7421
|
mergeData.forEach((merge2) => {
|
|
7434
7422
|
let { startRow, endRow, startColumn, endColumn, rangeType } = merge2;
|
|
7435
7423
|
isAddOperation ? isRowOperation ? operationStart <= startRow && (startRow += operationCount, endRow += operationCount) : operationStart <= startColumn && (startColumn += operationCount, endColumn += operationCount) : isRowOperation ? operationEnd < startRow && (startRow -= operationCount, endRow -= operationCount) : operationEnd < startColumn && (startColumn -= operationCount, endColumn -= operationCount), merge2.startRow === merge2.endRow && merge2.startColumn === merge2.endColumn || adjustedMergedCells.push({ startRow, endRow, startColumn, endColumn, rangeType });
|
|
7436
|
-
}), worksheet.
|
|
7424
|
+
}), worksheet.setMergeData(adjustedMergedCells), this.disposableCollection.dispose();
|
|
7437
7425
|
const { unitId, subUnitId } = command.params, handler = /* @__PURE__ */ __name((config) => this.refRangeHandle(config, unitId, subUnitId), "handler");
|
|
7438
7426
|
adjustedMergedCells.forEach((range2) => {
|
|
7439
7427
|
this.disposableCollection.add(this._refRangeService.registerRefRange(range2, handler, unitId, subUnitId));
|
|
@@ -8352,9 +8340,7 @@ function hasValueFromMatrixWithSpanInfo(cell, matrix) {
|
|
|
8352
8340
|
}
|
|
8353
8341
|
__name(hasValueFromMatrixWithSpanInfo, "hasValueFromMatrixWithSpanInfo");
|
|
8354
8342
|
function getMatrixWithSpanInfo(worksheet, startRow, startColumn, endRow, endColumn) {
|
|
8355
|
-
const matrix = worksheet.getCellMatrix(), mergedCellsInRange = worksheet.
|
|
8356
|
-
(rect) => Rectangle.intersects({ startRow, startColumn, endRow, endColumn }, rect)
|
|
8357
|
-
), returnCellMatrix = new ObjectMatrix();
|
|
8343
|
+
const matrix = worksheet.getCellMatrix(), mergedCellsInRange = worksheet.getSpanModel().getMergedCellRange(startRow, startColumn, endRow, endColumn), returnCellMatrix = new ObjectMatrix();
|
|
8358
8344
|
return matrix.forValue((row, col) => {
|
|
8359
8345
|
const v = matrix.getValue(row, col);
|
|
8360
8346
|
v && returnCellMatrix.setValue(row, col, v);
|
|
@@ -136,6 +136,7 @@ export declare function convertPrimaryWithCoordToPrimary(primaryWithCoord: ISele
|
|
|
136
136
|
endColumn: number;
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
|
+
* @deprecated Use worksheet.getCellInfoInMergeData or SpreadsheetSkeleton.getCellByIndex instead
|
|
139
140
|
* Convert the coordinates of a single cell into a selection data.
|
|
140
141
|
* @param row Specified Row Coordinate
|
|
141
142
|
* @param column Specified Column Coordinate
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BorderStyleTypes, ICommand
|
|
1
|
+
import { BorderType, BorderStyleTypes, ICommand } from '@univerjs/core';
|
|
2
2
|
import { IBorderInfo } from '../../services/border-style-manager.service';
|
|
3
3
|
export interface ISetBorderBasicCommandParams {
|
|
4
4
|
unitId?: string;
|
|
@@ -6,5 +6,7 @@ export interface ISetSelectionsOperationParams {
|
|
|
6
6
|
subUnitId: string;
|
|
7
7
|
selections: ISelectionWithStyle[];
|
|
8
8
|
type?: SelectionMoveType;
|
|
9
|
+
/** If should scroll to the selected range. */
|
|
10
|
+
reveal?: boolean;
|
|
9
11
|
}
|
|
10
12
|
export declare const SetSelectionsOperation: IOperation<ISetSelectionsOperationParams>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IRemoveWorksheetMergeMutationParams } from '../basics/interfaces/mutation-interface';
|
|
1
|
+
import { Dimension, Disposable, DisposableCollection, ICommandService, Injector, InterceptorManager, IUniverInstanceService, IRange } from '@univerjs/core';
|
|
3
2
|
import { RefRangeService } from '../services/ref-range/ref-range.service';
|
|
4
|
-
import { EffectRefRangeParams } from '../services/ref-range/type';
|
|
5
3
|
import { SheetsSelectionsService } from '../services/selections/selection-manager.service';
|
|
6
4
|
import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';
|
|
5
|
+
import { IRemoveWorksheetMergeMutationParams } from '../basics/interfaces/mutation-interface';
|
|
6
|
+
import { EffectRefRangeParams } from '../services/ref-range/type';
|
|
7
7
|
/**
|
|
8
8
|
* calculates the selection based on the merged cell type
|
|
9
9
|
* @param {IRange[]} selection
|
package/lib/types/index.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ export { SetWorksheetPermissionPointsCommand } from './commands/commands/set-wor
|
|
|
109
109
|
export { SetWorksheetRightToLeftCommand } from './commands/commands/set-worksheet-right-to-left.command';
|
|
110
110
|
export { DeltaRowHeightCommand, SetRowHeightCommand, SetWorksheetRowIsAutoHeightCommand, type IDeltaRowHeightCommand, type ISetWorksheetRowIsAutoHeightCommandParams, } from './commands/commands/set-worksheet-row-height.command';
|
|
111
111
|
export { SetWorksheetShowCommand } from './commands/commands/set-worksheet-show.command';
|
|
112
|
+
export type { ISetWorksheetShowCommandParams } from './commands/commands/set-worksheet-show.command';
|
|
112
113
|
export { AddRangeProtectionMutation, FactoryAddRangeProtectionMutation, type IAddRangeProtectionMutationParams } from './commands/mutations/add-range-protection.mutation';
|
|
113
114
|
export { AddWorksheetMergeMutation, AddMergeUndoMutationFactory } from './commands/mutations/add-worksheet-merge.mutation';
|
|
114
115
|
export { AddWorksheetProtectionMutation, type IAddWorksheetProtectionParams } from './commands/mutations/add-worksheet-protection.mutation';
|