@univerjs/sheets-drawing 1.0.3 → 1.1.0
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 +56 -7
- package/lib/cjs/index.js +51 -105
- package/lib/es/facade.js +55 -6
- package/lib/es/index.js +52 -106
- package/lib/facade.js +55 -6
- package/lib/index.js +52 -106
- package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +2 -3
- package/lib/types/facade/f-over-grid-image.d.ts +22 -0
- package/lib/types/services/sheet-drawing.service.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
package/lib/cjs/facade.js
CHANGED
|
@@ -7,7 +7,7 @@ let _univerjs_sheets_drawing = require("@univerjs/sheets-drawing");
|
|
|
7
7
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
8
8
|
let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
9
9
|
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
11
11
|
function _typeof(o) {
|
|
12
12
|
"@babel/helpers - typeof";
|
|
13
13
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -18,7 +18,7 @@ function _typeof(o) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region \0@oxc-project+runtime@0.
|
|
21
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
22
22
|
function toPrimitive(t, r) {
|
|
23
23
|
if ("object" != _typeof(t) || !t) return t;
|
|
24
24
|
var e = t[Symbol.toPrimitive];
|
|
@@ -31,14 +31,14 @@ function toPrimitive(t, r) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
35
35
|
function toPropertyKey(t) {
|
|
36
36
|
var i = toPrimitive(t, "string");
|
|
37
37
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region \0@oxc-project+runtime@0.
|
|
41
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
42
42
|
function _defineProperty(e, r, t) {
|
|
43
43
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
44
44
|
value: t,
|
|
@@ -49,7 +49,7 @@ function _defineProperty(e, r, t) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
|
-
//#region \0@oxc-project+runtime@0.
|
|
52
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
53
53
|
function __decorateParam(paramIndex, decorator) {
|
|
54
54
|
return function(target, key) {
|
|
55
55
|
decorator(target, key, paramIndex);
|
|
@@ -57,7 +57,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
61
61
|
function __decorate(decorators, target, key, desc) {
|
|
62
62
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
63
63
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -268,6 +268,23 @@ let FOverGridImageBuilder = class FOverGridImageBuilder {
|
|
|
268
268
|
return this._image.imageSourceType;
|
|
269
269
|
}
|
|
270
270
|
/**
|
|
271
|
+
* Set the whole-image opacity from zero (transparent) through one (opaque).
|
|
272
|
+
* @param {number} opacity The opacity from 0 through 1.
|
|
273
|
+
* @returns {FOverGridImageBuilder} This builder.
|
|
274
|
+
*/
|
|
275
|
+
setOpacity(opacity) {
|
|
276
|
+
validateImageOpacity(opacity);
|
|
277
|
+
this._image.opacity = opacity;
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Get the configured whole-image opacity.
|
|
282
|
+
* @returns {number} The opacity from 0 (transparent) through 1 (opaque).
|
|
283
|
+
*/
|
|
284
|
+
getOpacity() {
|
|
285
|
+
return this._image.opacity ?? 1;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
271
288
|
* Set the horizontal position of the image
|
|
272
289
|
* @param {number} column - The column index of the image start position, start at 0
|
|
273
290
|
* @returns {FOverGridImageBuilder} The `FOverGridImageBuilder` for chaining
|
|
@@ -813,6 +830,35 @@ let FOverGridImage = class FOverGridImage extends _univerjs_core_facade.FBase {
|
|
|
813
830
|
return (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(current ?? this._image);
|
|
814
831
|
}
|
|
815
832
|
/**
|
|
833
|
+
* Get the current whole-image opacity.
|
|
834
|
+
* @returns {number} The opacity from 0 (transparent) through 1 (opaque).
|
|
835
|
+
*/
|
|
836
|
+
getOpacity() {
|
|
837
|
+
const current = this._sheetDrawingService.getDrawingByParam({
|
|
838
|
+
unitId: this._image.unitId,
|
|
839
|
+
subUnitId: this._image.subUnitId,
|
|
840
|
+
drawingId: this._image.drawingId
|
|
841
|
+
});
|
|
842
|
+
return (current === null || current === void 0 ? void 0 : current.opacity) ?? this._image.opacity ?? 1;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Set the whole-image opacity from zero (transparent) through one (opaque).
|
|
846
|
+
* @param {number} opacity The opacity from 0 through 1.
|
|
847
|
+
* @returns {boolean} Whether the update succeeded.
|
|
848
|
+
*/
|
|
849
|
+
setOpacity(opacity) {
|
|
850
|
+
validateImageOpacity(opacity);
|
|
851
|
+
return this._commandService.syncExecuteCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
|
|
852
|
+
unitId: this._image.unitId,
|
|
853
|
+
drawings: [{
|
|
854
|
+
unitId: this._image.unitId,
|
|
855
|
+
subUnitId: this._image.subUnitId,
|
|
856
|
+
drawingId: this._image.drawingId,
|
|
857
|
+
opacity
|
|
858
|
+
}]
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
816
862
|
* Set this image's explicit placement through the drawing command.
|
|
817
863
|
* `Position`, `Both`, and `None` correspond to OneCell, TwoCell, and
|
|
818
864
|
* Absolute. Bounds inference is preferable when preserving the current
|
|
@@ -1106,6 +1152,9 @@ FOverGridImage = __decorate([
|
|
|
1106
1152
|
__decorateParam(3, _univerjs_sheets_drawing.ISheetDrawingService),
|
|
1107
1153
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService))
|
|
1108
1154
|
], FOverGridImage);
|
|
1155
|
+
function validateImageOpacity(opacity) {
|
|
1156
|
+
if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1) throw new RangeError("Sheet image opacity must be between 0 and 1.");
|
|
1157
|
+
}
|
|
1109
1158
|
|
|
1110
1159
|
//#endregion
|
|
1111
1160
|
//#region src/facade/f-worksheet.ts
|
|
@@ -1726,7 +1775,7 @@ var FUniverSheetsDrawingMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
1726
1775
|
_univerjs_core_facade.FUniver.extend(FUniverSheetsDrawingMixin);
|
|
1727
1776
|
|
|
1728
1777
|
//#endregion
|
|
1729
|
-
Object.defineProperty(exports,
|
|
1778
|
+
Object.defineProperty(exports, "FOverGridImage", {
|
|
1730
1779
|
enumerable: true,
|
|
1731
1780
|
get: function () {
|
|
1732
1781
|
return FOverGridImage;
|
package/lib/cjs/index.js
CHANGED
|
@@ -366,7 +366,7 @@ function getSheetDrawingPlacement(drawing) {
|
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
368
|
function applySheetDrawingPlacement(drawing, input, skeleton) {
|
|
369
|
-
const placement =
|
|
369
|
+
const placement = normalizePlacement(input, skeleton, drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE || drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_DOM);
|
|
370
370
|
if (placement.kind === "2") {
|
|
371
371
|
const transform = withExistingTransform(drawing.transform, placement);
|
|
372
372
|
const sheetTransform = absoluteSheetTransform(placement, drawing.sheetTransform);
|
|
@@ -410,15 +410,18 @@ function applySheetDrawingPlacement(drawing, input, skeleton) {
|
|
|
410
410
|
* Position, Both, or None Placement.
|
|
411
411
|
*/
|
|
412
412
|
function normalizeSheetDrawingPlacement(input, skeleton) {
|
|
413
|
+
return normalizePlacement(input, skeleton, false);
|
|
414
|
+
}
|
|
415
|
+
function normalizePlacement(input, skeleton, requiresArea) {
|
|
413
416
|
if (!("bounds" in input)) {
|
|
414
|
-
validatePlacement(input);
|
|
417
|
+
validatePlacement(input, requiresArea);
|
|
415
418
|
if (input.kind === "1" && skeleton) validateBounds((0, _univerjs_sheets.convertPositionSheetOverGridToAbsolute)(skeleton.worksheet.getUnitId(), skeleton.worksheet.getSheetId(), {
|
|
416
419
|
from: input.from,
|
|
417
420
|
to: input.to
|
|
418
|
-
}, skeleton));
|
|
421
|
+
}, skeleton), requiresArea);
|
|
419
422
|
return input;
|
|
420
423
|
}
|
|
421
|
-
validateBounds(input.bounds);
|
|
424
|
+
validateBounds(input.bounds, requiresArea);
|
|
422
425
|
if (input.kind === "2") return {
|
|
423
426
|
kind: "2",
|
|
424
427
|
...input.bounds
|
|
@@ -471,10 +474,10 @@ function absoluteSheetTransform(placement, current) {
|
|
|
471
474
|
}
|
|
472
475
|
};
|
|
473
476
|
}
|
|
474
|
-
function validatePlacement(placement) {
|
|
477
|
+
function validatePlacement(placement, requiresArea) {
|
|
475
478
|
if (placement.kind === "0") {
|
|
476
479
|
validateCellPosition(placement.from);
|
|
477
|
-
validateExtent(placement.width, placement.height);
|
|
480
|
+
validateExtent(placement.width, placement.height, requiresArea);
|
|
478
481
|
return;
|
|
479
482
|
}
|
|
480
483
|
if (placement.kind === "1") {
|
|
@@ -484,20 +487,24 @@ function validatePlacement(placement) {
|
|
|
484
487
|
}
|
|
485
488
|
if (placement.kind === "2") {
|
|
486
489
|
if (!Number.isFinite(placement.left) || !Number.isFinite(placement.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
|
|
487
|
-
validateExtent(placement.width, placement.height);
|
|
490
|
+
validateExtent(placement.width, placement.height, requiresArea);
|
|
488
491
|
return;
|
|
489
492
|
}
|
|
490
493
|
throw new Error("SHEET_DRAWING_PLACEMENT_KIND_INVALID");
|
|
491
494
|
}
|
|
492
|
-
function validateBounds(bounds) {
|
|
495
|
+
function validateBounds(bounds, requiresArea) {
|
|
493
496
|
if (!Number.isFinite(bounds.left) || !Number.isFinite(bounds.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
|
|
494
|
-
validateExtent(bounds.width, bounds.height);
|
|
497
|
+
validateExtent(bounds.width, bounds.height, requiresArea);
|
|
495
498
|
}
|
|
496
499
|
function validateCellPosition(position) {
|
|
497
500
|
if (!Number.isInteger(position.row) || !Number.isInteger(position.column) || position.row < 0 || position.column < 0 || !Number.isFinite(position.rowOffset) || !Number.isFinite(position.columnOffset)) throw new Error("SHEET_DRAWING_PLACEMENT_CELL_INVALID");
|
|
498
501
|
}
|
|
499
|
-
function validateExtent(width, height) {
|
|
500
|
-
|
|
502
|
+
function validateExtent(width, height, requiresArea) {
|
|
503
|
+
const hasInvalidZeroExtent = requiresArea ? width === 0 || height === 0 : width === 0 && height === 0;
|
|
504
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width < 0 || height < 0 || hasInvalidZeroExtent) throw Object.assign(/* @__PURE__ */ new Error("SHEET_DRAWING_PLACEMENT_EXTENT_INVALID"), {
|
|
505
|
+
width,
|
|
506
|
+
height
|
|
507
|
+
});
|
|
501
508
|
}
|
|
502
509
|
|
|
503
510
|
//#endregion
|
|
@@ -736,7 +743,7 @@ const SetWorksheetBackgroundImageCommand = {
|
|
|
736
743
|
};
|
|
737
744
|
|
|
738
745
|
//#endregion
|
|
739
|
-
//#region \0@oxc-project+runtime@0.
|
|
746
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
740
747
|
function __decorateParam(paramIndex, decorator) {
|
|
741
748
|
return function(target, key) {
|
|
742
749
|
decorator(target, key, paramIndex);
|
|
@@ -744,7 +751,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
744
751
|
}
|
|
745
752
|
|
|
746
753
|
//#endregion
|
|
747
|
-
//#region \0@oxc-project+runtime@0.
|
|
754
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
748
755
|
function __decorate(decorators, target, key, desc) {
|
|
749
756
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
750
757
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -928,7 +935,7 @@ SheetsDrawingLoadController = __decorate([
|
|
|
928
935
|
//#endregion
|
|
929
936
|
//#region package.json
|
|
930
937
|
var name = "@univerjs/sheets-drawing";
|
|
931
|
-
var version = "1.0
|
|
938
|
+
var version = "1.1.0";
|
|
932
939
|
|
|
933
940
|
//#endregion
|
|
934
941
|
//#region src/config/config.ts
|
|
@@ -952,7 +959,7 @@ const configSymbol = Symbol(SHEETS_DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
952
959
|
const defaultPluginConfig = {};
|
|
953
960
|
|
|
954
961
|
//#endregion
|
|
955
|
-
//#region \0@oxc-project+runtime@0.
|
|
962
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
956
963
|
function _typeof(o) {
|
|
957
964
|
"@babel/helpers - typeof";
|
|
958
965
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -963,7 +970,7 @@ function _typeof(o) {
|
|
|
963
970
|
}
|
|
964
971
|
|
|
965
972
|
//#endregion
|
|
966
|
-
//#region \0@oxc-project+runtime@0.
|
|
973
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
967
974
|
function toPrimitive(t, r) {
|
|
968
975
|
if ("object" != _typeof(t) || !t) return t;
|
|
969
976
|
var e = t[Symbol.toPrimitive];
|
|
@@ -976,14 +983,14 @@ function toPrimitive(t, r) {
|
|
|
976
983
|
}
|
|
977
984
|
|
|
978
985
|
//#endregion
|
|
979
|
-
//#region \0@oxc-project+runtime@0.
|
|
986
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
980
987
|
function toPropertyKey(t) {
|
|
981
988
|
var i = toPrimitive(t, "string");
|
|
982
989
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
983
990
|
}
|
|
984
991
|
|
|
985
992
|
//#endregion
|
|
986
|
-
//#region \0@oxc-project+runtime@0.
|
|
993
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
987
994
|
function _defineProperty(e, r, t) {
|
|
988
995
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
989
996
|
value: t,
|
|
@@ -1062,12 +1069,11 @@ const REFRESH_MUTATIONS = [
|
|
|
1062
1069
|
_univerjs_sheets.SetWorksheetColWidthMutation.id
|
|
1063
1070
|
];
|
|
1064
1071
|
let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffectedController extends _univerjs_core.Disposable {
|
|
1065
|
-
constructor(_commandService, _sheetSkeletonService, _sheetInterceptorService,
|
|
1072
|
+
constructor(_commandService, _sheetSkeletonService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService, _transformPlanService) {
|
|
1066
1073
|
super();
|
|
1067
1074
|
this._commandService = _commandService;
|
|
1068
1075
|
this._sheetSkeletonService = _sheetSkeletonService;
|
|
1069
1076
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
1070
|
-
this._selectionManagerService = _selectionManagerService;
|
|
1071
1077
|
this._sheetDrawingService = _sheetDrawingService;
|
|
1072
1078
|
this._drawingManagerService = _drawingManagerService;
|
|
1073
1079
|
this._univerInstanceService = _univerInstanceService;
|
|
@@ -1128,70 +1134,13 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1128
1134
|
const { range } = params;
|
|
1129
1135
|
return this._getRangeMoveUndo(range, 3);
|
|
1130
1136
|
} else if (id === _univerjs_sheets.SetRowHiddenCommand.id || id === _univerjs_sheets.SetSpecificRowsVisibleCommand.id) {
|
|
1131
|
-
|
|
1132
|
-
const _params = params;
|
|
1133
|
-
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService, _params);
|
|
1134
|
-
if (!target) return {
|
|
1135
|
-
redos: [],
|
|
1136
|
-
undos: []
|
|
1137
|
-
};
|
|
1138
|
-
const { unitId, subUnitId } = target;
|
|
1139
|
-
const ranges = _params.ranges || ((_this$_selectionManag = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag === void 0 ? void 0 : _this$_selectionManag.map((s) => s.range).filter((r) => r.rangeType === _univerjs_core.RANGE_TYPE.ROW));
|
|
1140
|
-
if (!ranges || ranges.length === 0) return {
|
|
1141
|
-
redos: [],
|
|
1142
|
-
undos: []
|
|
1143
|
-
};
|
|
1137
|
+
const { unitId, subUnitId, ranges } = params;
|
|
1144
1138
|
return this._getDrawingUndoForRowVisible(unitId, subUnitId, ranges);
|
|
1145
1139
|
} else if (id === _univerjs_sheets.SetColHiddenCommand.id || id === _univerjs_sheets.SetSpecificColsVisibleCommand.id) {
|
|
1146
|
-
|
|
1147
|
-
const _params = params;
|
|
1148
|
-
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService, _params);
|
|
1149
|
-
if (!target) return {
|
|
1150
|
-
redos: [],
|
|
1151
|
-
undos: []
|
|
1152
|
-
};
|
|
1153
|
-
const { unitId, subUnitId } = target;
|
|
1154
|
-
const ranges = _params.ranges || ((_this$_selectionManag2 = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag2 === void 0 ? void 0 : _this$_selectionManag2.map((s) => s.range).filter((r) => r.rangeType === _univerjs_core.RANGE_TYPE.COLUMN));
|
|
1155
|
-
if (!ranges || ranges.length === 0) return {
|
|
1156
|
-
redos: [],
|
|
1157
|
-
undos: []
|
|
1158
|
-
};
|
|
1140
|
+
const { unitId, subUnitId, ranges } = params;
|
|
1159
1141
|
return this._getDrawingUndoForColVisible(unitId, subUnitId, ranges);
|
|
1160
|
-
} else if (id === _univerjs_sheets.DeltaRowHeightCommand.id || id === _univerjs_sheets.DeltaColumnWidthCommand.id) {
|
|
1161
|
-
const
|
|
1162
|
-
if (!target) return {
|
|
1163
|
-
redos: [],
|
|
1164
|
-
undos: []
|
|
1165
|
-
};
|
|
1166
|
-
const { unitId, subUnitId, worksheet } = target;
|
|
1167
|
-
const ranges = [];
|
|
1168
|
-
if (id === _univerjs_sheets.DeltaRowHeightCommand.id) ranges.push({
|
|
1169
|
-
startRow: params.anchorRow,
|
|
1170
|
-
endRow: params.anchorRow,
|
|
1171
|
-
startColumn: 0,
|
|
1172
|
-
endColumn: worksheet.getColumnCount() - 1
|
|
1173
|
-
});
|
|
1174
|
-
else ranges.push({
|
|
1175
|
-
startRow: 0,
|
|
1176
|
-
endRow: worksheet.getRowCount() - 1,
|
|
1177
|
-
startColumn: params.anchorCol,
|
|
1178
|
-
endColumn: params.anchorCol
|
|
1179
|
-
});
|
|
1180
|
-
return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges);
|
|
1181
|
-
} else if (id === _univerjs_sheets.SetRowHeightCommand.id || id === _univerjs_sheets.SetColWidthCommand.id) {
|
|
1182
|
-
var _this$_selectionManag3;
|
|
1183
|
-
const _params = params;
|
|
1184
|
-
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService, _params);
|
|
1185
|
-
if (!target) return {
|
|
1186
|
-
redos: [],
|
|
1187
|
-
undos: []
|
|
1188
|
-
};
|
|
1189
|
-
const { unitId, subUnitId } = target;
|
|
1190
|
-
const ranges = _params.ranges || ((_this$_selectionManag3 = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag3 === void 0 ? void 0 : _this$_selectionManag3.map((s) => s.range));
|
|
1191
|
-
if (!ranges || ranges.length === 0) return {
|
|
1192
|
-
redos: [],
|
|
1193
|
-
undos: []
|
|
1194
|
-
};
|
|
1142
|
+
} else if (id === _univerjs_sheets.DeltaRowHeightCommand.id || id === _univerjs_sheets.DeltaColumnWidthCommand.id || id === _univerjs_sheets.SetRowHeightCommand.id || id === _univerjs_sheets.SetColWidthCommand.id) {
|
|
1143
|
+
const { unitId, subUnitId, ranges } = params;
|
|
1195
1144
|
return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges);
|
|
1196
1145
|
}
|
|
1197
1146
|
return {
|
|
@@ -1355,7 +1304,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1355
1304
|
const deleteDrawings = [];
|
|
1356
1305
|
const { sheetTransform, anchorType = "0", transform, unitId, subUnitId, drawingId } = drawing;
|
|
1357
1306
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
1358
|
-
if (!sheetTransform || !transform || !sheetSkeletonParam) return {
|
|
1307
|
+
if (anchorType === "2" || !sheetTransform || !transform || !sheetSkeletonParam) return {
|
|
1359
1308
|
updateDrawings,
|
|
1360
1309
|
deleteDrawings
|
|
1361
1310
|
};
|
|
@@ -1695,17 +1644,13 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1695
1644
|
const { sheetTransform, transform, anchorType = "0" } = drawing;
|
|
1696
1645
|
if (anchorType === "2") this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
1697
1646
|
else {
|
|
1698
|
-
const {
|
|
1699
|
-
const { row: fromRow, column: fromColumn } = from;
|
|
1700
|
-
const { row: toRow, column: toColumn } = to;
|
|
1647
|
+
const { row: toRow, column: toColumn } = sheetTransform.to;
|
|
1701
1648
|
for (let i = 0; i < ranges.length; i++) {
|
|
1702
|
-
const { startRow,
|
|
1649
|
+
const { startRow, startColumn } = ranges[i];
|
|
1703
1650
|
if (toRow < startRow || toColumn < startColumn) continue;
|
|
1704
1651
|
if (anchorType === "0") {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
continue;
|
|
1708
|
-
}
|
|
1652
|
+
updateDrawings.push(applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(drawing), skeleton));
|
|
1653
|
+
break;
|
|
1709
1654
|
}
|
|
1710
1655
|
const newTransform = drawingPositionToTransform({ ...sheetTransform }, sheetSkeletonParam);
|
|
1711
1656
|
if (newTransform) {
|
|
@@ -1724,10 +1669,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1724
1669
|
};
|
|
1725
1670
|
return this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
|
|
1726
1671
|
}
|
|
1727
|
-
_getUnitIdAndSubUnitId(params
|
|
1728
|
-
|
|
1729
|
-
if (type === "insert") target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService, params);
|
|
1730
|
-
else target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService);
|
|
1672
|
+
_getUnitIdAndSubUnitId(params) {
|
|
1673
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService, params);
|
|
1731
1674
|
if (!target) return;
|
|
1732
1675
|
const { unitId, subUnitId } = target;
|
|
1733
1676
|
return {
|
|
@@ -1792,7 +1735,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1792
1735
|
return this._finalizePlan(unitId, subUnitId, updateDrawings);
|
|
1793
1736
|
}
|
|
1794
1737
|
_moveRowInterceptor(params, type) {
|
|
1795
|
-
const target = this._getUnitIdAndSubUnitId(params
|
|
1738
|
+
const target = this._getUnitIdAndSubUnitId(params);
|
|
1796
1739
|
if (!target) return {
|
|
1797
1740
|
redos: [],
|
|
1798
1741
|
undos: []
|
|
@@ -1860,7 +1803,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1860
1803
|
return this._finalizePlan(unitId, subUnitId, updateDrawings, deleteDrawings);
|
|
1861
1804
|
}
|
|
1862
1805
|
_moveColInterceptor(params, type) {
|
|
1863
|
-
const target = this._getUnitIdAndSubUnitId(params
|
|
1806
|
+
const target = this._getUnitIdAndSubUnitId(params);
|
|
1864
1807
|
if (!target) return {
|
|
1865
1808
|
redos: [],
|
|
1866
1809
|
undos: []
|
|
@@ -2255,6 +2198,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
2255
2198
|
}
|
|
2256
2199
|
_refreshDrawingTransform(command, unitId, subUnitId, ranges) {
|
|
2257
2200
|
const sheetSkeletonParam = this._getCalculatedSkeletonParam(unitId, subUnitId);
|
|
2201
|
+
if (!sheetSkeletonParam) return;
|
|
2258
2202
|
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId) ?? {};
|
|
2259
2203
|
const updateDrawings = [];
|
|
2260
2204
|
Object.keys(drawingData).forEach((drawingId) => {
|
|
@@ -2278,7 +2222,10 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
2278
2222
|
startColumn: fromColumn,
|
|
2279
2223
|
endColumn: toColumn
|
|
2280
2224
|
}) || fromRow > endRow || fromColumn > endColumn) {
|
|
2281
|
-
|
|
2225
|
+
if (anchorType === "0") {
|
|
2226
|
+
updateDrawings.push(applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(drawing), sheetSkeletonParam.skeleton));
|
|
2227
|
+
break;
|
|
2228
|
+
}
|
|
2282
2229
|
const newTransform = drawingPositionToTransform(sheetTransform, sheetSkeletonParam);
|
|
2283
2230
|
updateDrawings.push({
|
|
2284
2231
|
...drawing,
|
|
@@ -2286,8 +2233,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
2286
2233
|
...transform,
|
|
2287
2234
|
left: newTransform === null || newTransform === void 0 ? void 0 : newTransform.left,
|
|
2288
2235
|
top: newTransform === null || newTransform === void 0 ? void 0 : newTransform.top,
|
|
2289
|
-
width:
|
|
2290
|
-
height:
|
|
2236
|
+
width: newTransform === null || newTransform === void 0 ? void 0 : newTransform.width,
|
|
2237
|
+
height: newTransform === null || newTransform === void 0 ? void 0 : newTransform.height
|
|
2291
2238
|
}
|
|
2292
2239
|
});
|
|
2293
2240
|
break;
|
|
@@ -2301,11 +2248,10 @@ SheetDrawingTransformAffectedController = __decorate([
|
|
|
2301
2248
|
__decorateParam(0, _univerjs_core.ICommandService),
|
|
2302
2249
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService)),
|
|
2303
2250
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2304
|
-
__decorateParam(3,
|
|
2305
|
-
__decorateParam(4,
|
|
2306
|
-
__decorateParam(5,
|
|
2307
|
-
__decorateParam(6, _univerjs_core.
|
|
2308
|
-
__decorateParam(7, (0, _univerjs_core.Inject)(SheetDrawingTransformPlanService))
|
|
2251
|
+
__decorateParam(3, ISheetDrawingService),
|
|
2252
|
+
__decorateParam(4, _univerjs_drawing.IDrawingManagerService),
|
|
2253
|
+
__decorateParam(5, _univerjs_core.IUniverInstanceService),
|
|
2254
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(SheetDrawingTransformPlanService))
|
|
2309
2255
|
], SheetDrawingTransformAffectedController);
|
|
2310
2256
|
|
|
2311
2257
|
//#endregion
|
|
@@ -2356,7 +2302,7 @@ exports.SetWorksheetBackgroundImageMutation = SetWorksheetBackgroundImageMutatio
|
|
|
2356
2302
|
exports.SheetDrawingAnchorType = SheetDrawingAnchorType;
|
|
2357
2303
|
exports.SheetDrawingService = SheetDrawingService;
|
|
2358
2304
|
exports.SheetDrawingTransformPlanService = SheetDrawingTransformPlanService;
|
|
2359
|
-
Object.defineProperty(exports,
|
|
2305
|
+
Object.defineProperty(exports, "UniverSheetsDrawingPlugin", {
|
|
2360
2306
|
enumerable: true,
|
|
2361
2307
|
get: function () {
|
|
2362
2308
|
return UniverSheetsDrawingPlugin;
|
package/lib/es/facade.js
CHANGED
|
@@ -6,7 +6,7 @@ import { DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, Remo
|
|
|
6
6
|
import { getGroupState, transformObjectOutOfGroup } from "@univerjs/engine-render";
|
|
7
7
|
import { FWorksheet } from "@univerjs/sheets/facade";
|
|
8
8
|
|
|
9
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
10
10
|
function _typeof(o) {
|
|
11
11
|
"@babel/helpers - typeof";
|
|
12
12
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -17,7 +17,7 @@ function _typeof(o) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region \0@oxc-project+runtime@0.
|
|
20
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
21
21
|
function toPrimitive(t, r) {
|
|
22
22
|
if ("object" != _typeof(t) || !t) return t;
|
|
23
23
|
var e = t[Symbol.toPrimitive];
|
|
@@ -30,14 +30,14 @@ function toPrimitive(t, r) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
|
-
//#region \0@oxc-project+runtime@0.
|
|
33
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
34
34
|
function toPropertyKey(t) {
|
|
35
35
|
var i = toPrimitive(t, "string");
|
|
36
36
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region \0@oxc-project+runtime@0.
|
|
40
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
41
41
|
function _defineProperty(e, r, t) {
|
|
42
42
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
43
43
|
value: t,
|
|
@@ -48,7 +48,7 @@ function _defineProperty(e, r, t) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region \0@oxc-project+runtime@0.
|
|
51
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
52
52
|
function __decorateParam(paramIndex, decorator) {
|
|
53
53
|
return function(target, key) {
|
|
54
54
|
decorator(target, key, paramIndex);
|
|
@@ -56,7 +56,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
59
|
-
//#region \0@oxc-project+runtime@0.
|
|
59
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
60
60
|
function __decorate(decorators, target, key, desc) {
|
|
61
61
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
62
62
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -267,6 +267,23 @@ let FOverGridImageBuilder = class FOverGridImageBuilder {
|
|
|
267
267
|
return this._image.imageSourceType;
|
|
268
268
|
}
|
|
269
269
|
/**
|
|
270
|
+
* Set the whole-image opacity from zero (transparent) through one (opaque).
|
|
271
|
+
* @param {number} opacity The opacity from 0 through 1.
|
|
272
|
+
* @returns {FOverGridImageBuilder} This builder.
|
|
273
|
+
*/
|
|
274
|
+
setOpacity(opacity) {
|
|
275
|
+
validateImageOpacity(opacity);
|
|
276
|
+
this._image.opacity = opacity;
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get the configured whole-image opacity.
|
|
281
|
+
* @returns {number} The opacity from 0 (transparent) through 1 (opaque).
|
|
282
|
+
*/
|
|
283
|
+
getOpacity() {
|
|
284
|
+
return this._image.opacity ?? 1;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
270
287
|
* Set the horizontal position of the image
|
|
271
288
|
* @param {number} column - The column index of the image start position, start at 0
|
|
272
289
|
* @returns {FOverGridImageBuilder} The `FOverGridImageBuilder` for chaining
|
|
@@ -812,6 +829,35 @@ let FOverGridImage = class FOverGridImage extends FBase {
|
|
|
812
829
|
return getSheetDrawingPlacement(current ?? this._image);
|
|
813
830
|
}
|
|
814
831
|
/**
|
|
832
|
+
* Get the current whole-image opacity.
|
|
833
|
+
* @returns {number} The opacity from 0 (transparent) through 1 (opaque).
|
|
834
|
+
*/
|
|
835
|
+
getOpacity() {
|
|
836
|
+
const current = this._sheetDrawingService.getDrawingByParam({
|
|
837
|
+
unitId: this._image.unitId,
|
|
838
|
+
subUnitId: this._image.subUnitId,
|
|
839
|
+
drawingId: this._image.drawingId
|
|
840
|
+
});
|
|
841
|
+
return (current === null || current === void 0 ? void 0 : current.opacity) ?? this._image.opacity ?? 1;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Set the whole-image opacity from zero (transparent) through one (opaque).
|
|
845
|
+
* @param {number} opacity The opacity from 0 through 1.
|
|
846
|
+
* @returns {boolean} Whether the update succeeded.
|
|
847
|
+
*/
|
|
848
|
+
setOpacity(opacity) {
|
|
849
|
+
validateImageOpacity(opacity);
|
|
850
|
+
return this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
|
|
851
|
+
unitId: this._image.unitId,
|
|
852
|
+
drawings: [{
|
|
853
|
+
unitId: this._image.unitId,
|
|
854
|
+
subUnitId: this._image.subUnitId,
|
|
855
|
+
drawingId: this._image.drawingId,
|
|
856
|
+
opacity
|
|
857
|
+
}]
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
815
861
|
* Set this image's explicit placement through the drawing command.
|
|
816
862
|
* `Position`, `Both`, and `None` correspond to OneCell, TwoCell, and
|
|
817
863
|
* Absolute. Bounds inference is preferable when preserving the current
|
|
@@ -1105,6 +1151,9 @@ FOverGridImage = __decorate([
|
|
|
1105
1151
|
__decorateParam(3, ISheetDrawingService),
|
|
1106
1152
|
__decorateParam(4, Inject(SheetSkeletonService))
|
|
1107
1153
|
], FOverGridImage);
|
|
1154
|
+
function validateImageOpacity(opacity) {
|
|
1155
|
+
if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1) throw new RangeError("Sheet image opacity must be between 0 and 1.");
|
|
1156
|
+
}
|
|
1108
1157
|
|
|
1109
1158
|
//#endregion
|
|
1110
1159
|
//#region src/facade/f-worksheet.ts
|