@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/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, InsertColCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, MoveColsCommand, MoveRangeCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, RemoveSheetCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetColWidthMutation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightMutation, SheetInterceptorService, SheetSkeletonService,
|
|
2
|
-
import { ArrangeTypeEnum, CommandType, DependentOn, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, Plugin,
|
|
1
|
+
import { CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, InsertColCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, MoveColsCommand, MoveRangeCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, RemoveSheetCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetColWidthMutation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, UniverSheetsPlugin, attachRangeWithCoord, convertPositionCellToSheetOverGrid, convertPositionSheetOverGridToAbsolute, getSheetCommandTarget } from "@univerjs/sheets";
|
|
2
|
+
import { ArrangeTypeEnum, CommandType, DependentOn, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, Plugin, Rectangle, UniverInstanceType, createIdentifier, merge, sequenceExecute, toDisposable } from "@univerjs/core";
|
|
3
3
|
import { IDrawingManagerService, UnitDrawingService, UniverDrawingPlugin, getOrCreateDrawingCopyPlan, resolveDrawingRotateEnabled } from "@univerjs/drawing";
|
|
4
4
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
5
5
|
|
|
@@ -365,7 +365,7 @@ function getSheetDrawingPlacement(drawing) {
|
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
367
|
function applySheetDrawingPlacement(drawing, input, skeleton) {
|
|
368
|
-
const placement =
|
|
368
|
+
const placement = normalizePlacement(input, skeleton, drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE || drawing.drawingType === DrawingTypeEnum.DRAWING_DOM);
|
|
369
369
|
if (placement.kind === "2") {
|
|
370
370
|
const transform = withExistingTransform(drawing.transform, placement);
|
|
371
371
|
const sheetTransform = absoluteSheetTransform(placement, drawing.sheetTransform);
|
|
@@ -409,15 +409,18 @@ function applySheetDrawingPlacement(drawing, input, skeleton) {
|
|
|
409
409
|
* Position, Both, or None Placement.
|
|
410
410
|
*/
|
|
411
411
|
function normalizeSheetDrawingPlacement(input, skeleton) {
|
|
412
|
+
return normalizePlacement(input, skeleton, false);
|
|
413
|
+
}
|
|
414
|
+
function normalizePlacement(input, skeleton, requiresArea) {
|
|
412
415
|
if (!("bounds" in input)) {
|
|
413
|
-
validatePlacement(input);
|
|
416
|
+
validatePlacement(input, requiresArea);
|
|
414
417
|
if (input.kind === "1" && skeleton) validateBounds(convertPositionSheetOverGridToAbsolute(skeleton.worksheet.getUnitId(), skeleton.worksheet.getSheetId(), {
|
|
415
418
|
from: input.from,
|
|
416
419
|
to: input.to
|
|
417
|
-
}, skeleton));
|
|
420
|
+
}, skeleton), requiresArea);
|
|
418
421
|
return input;
|
|
419
422
|
}
|
|
420
|
-
validateBounds(input.bounds);
|
|
423
|
+
validateBounds(input.bounds, requiresArea);
|
|
421
424
|
if (input.kind === "2") return {
|
|
422
425
|
kind: "2",
|
|
423
426
|
...input.bounds
|
|
@@ -470,10 +473,10 @@ function absoluteSheetTransform(placement, current) {
|
|
|
470
473
|
}
|
|
471
474
|
};
|
|
472
475
|
}
|
|
473
|
-
function validatePlacement(placement) {
|
|
476
|
+
function validatePlacement(placement, requiresArea) {
|
|
474
477
|
if (placement.kind === "0") {
|
|
475
478
|
validateCellPosition(placement.from);
|
|
476
|
-
validateExtent(placement.width, placement.height);
|
|
479
|
+
validateExtent(placement.width, placement.height, requiresArea);
|
|
477
480
|
return;
|
|
478
481
|
}
|
|
479
482
|
if (placement.kind === "1") {
|
|
@@ -483,20 +486,24 @@ function validatePlacement(placement) {
|
|
|
483
486
|
}
|
|
484
487
|
if (placement.kind === "2") {
|
|
485
488
|
if (!Number.isFinite(placement.left) || !Number.isFinite(placement.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
|
|
486
|
-
validateExtent(placement.width, placement.height);
|
|
489
|
+
validateExtent(placement.width, placement.height, requiresArea);
|
|
487
490
|
return;
|
|
488
491
|
}
|
|
489
492
|
throw new Error("SHEET_DRAWING_PLACEMENT_KIND_INVALID");
|
|
490
493
|
}
|
|
491
|
-
function validateBounds(bounds) {
|
|
494
|
+
function validateBounds(bounds, requiresArea) {
|
|
492
495
|
if (!Number.isFinite(bounds.left) || !Number.isFinite(bounds.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
|
|
493
|
-
validateExtent(bounds.width, bounds.height);
|
|
496
|
+
validateExtent(bounds.width, bounds.height, requiresArea);
|
|
494
497
|
}
|
|
495
498
|
function validateCellPosition(position) {
|
|
496
499
|
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");
|
|
497
500
|
}
|
|
498
|
-
function validateExtent(width, height) {
|
|
499
|
-
|
|
501
|
+
function validateExtent(width, height, requiresArea) {
|
|
502
|
+
const hasInvalidZeroExtent = requiresArea ? width === 0 || height === 0 : width === 0 && height === 0;
|
|
503
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width < 0 || height < 0 || hasInvalidZeroExtent) throw Object.assign(/* @__PURE__ */ new Error("SHEET_DRAWING_PLACEMENT_EXTENT_INVALID"), {
|
|
504
|
+
width,
|
|
505
|
+
height
|
|
506
|
+
});
|
|
500
507
|
}
|
|
501
508
|
|
|
502
509
|
//#endregion
|
|
@@ -735,7 +742,7 @@ const SetWorksheetBackgroundImageCommand = {
|
|
|
735
742
|
};
|
|
736
743
|
|
|
737
744
|
//#endregion
|
|
738
|
-
//#region \0@oxc-project+runtime@0.
|
|
745
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
739
746
|
function __decorateParam(paramIndex, decorator) {
|
|
740
747
|
return function(target, key) {
|
|
741
748
|
decorator(target, key, paramIndex);
|
|
@@ -743,7 +750,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
743
750
|
}
|
|
744
751
|
|
|
745
752
|
//#endregion
|
|
746
|
-
//#region \0@oxc-project+runtime@0.
|
|
753
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
747
754
|
function __decorate(decorators, target, key, desc) {
|
|
748
755
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
749
756
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -927,7 +934,7 @@ SheetsDrawingLoadController = __decorate([
|
|
|
927
934
|
//#endregion
|
|
928
935
|
//#region package.json
|
|
929
936
|
var name = "@univerjs/sheets-drawing";
|
|
930
|
-
var version = "1.0
|
|
937
|
+
var version = "1.1.0";
|
|
931
938
|
|
|
932
939
|
//#endregion
|
|
933
940
|
//#region src/config/config.ts
|
|
@@ -951,7 +958,7 @@ const configSymbol = Symbol(SHEETS_DRAWING_PLUGIN_CONFIG_KEY);
|
|
|
951
958
|
const defaultPluginConfig = {};
|
|
952
959
|
|
|
953
960
|
//#endregion
|
|
954
|
-
//#region \0@oxc-project+runtime@0.
|
|
961
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
955
962
|
function _typeof(o) {
|
|
956
963
|
"@babel/helpers - typeof";
|
|
957
964
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -962,7 +969,7 @@ function _typeof(o) {
|
|
|
962
969
|
}
|
|
963
970
|
|
|
964
971
|
//#endregion
|
|
965
|
-
//#region \0@oxc-project+runtime@0.
|
|
972
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
966
973
|
function toPrimitive(t, r) {
|
|
967
974
|
if ("object" != _typeof(t) || !t) return t;
|
|
968
975
|
var e = t[Symbol.toPrimitive];
|
|
@@ -975,14 +982,14 @@ function toPrimitive(t, r) {
|
|
|
975
982
|
}
|
|
976
983
|
|
|
977
984
|
//#endregion
|
|
978
|
-
//#region \0@oxc-project+runtime@0.
|
|
985
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
979
986
|
function toPropertyKey(t) {
|
|
980
987
|
var i = toPrimitive(t, "string");
|
|
981
988
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
982
989
|
}
|
|
983
990
|
|
|
984
991
|
//#endregion
|
|
985
|
-
//#region \0@oxc-project+runtime@0.
|
|
992
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
986
993
|
function _defineProperty(e, r, t) {
|
|
987
994
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
988
995
|
value: t,
|
|
@@ -1061,12 +1068,11 @@ const REFRESH_MUTATIONS = [
|
|
|
1061
1068
|
SetWorksheetColWidthMutation.id
|
|
1062
1069
|
];
|
|
1063
1070
|
let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffectedController extends Disposable {
|
|
1064
|
-
constructor(_commandService, _sheetSkeletonService, _sheetInterceptorService,
|
|
1071
|
+
constructor(_commandService, _sheetSkeletonService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService, _transformPlanService) {
|
|
1065
1072
|
super();
|
|
1066
1073
|
this._commandService = _commandService;
|
|
1067
1074
|
this._sheetSkeletonService = _sheetSkeletonService;
|
|
1068
1075
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
1069
|
-
this._selectionManagerService = _selectionManagerService;
|
|
1070
1076
|
this._sheetDrawingService = _sheetDrawingService;
|
|
1071
1077
|
this._drawingManagerService = _drawingManagerService;
|
|
1072
1078
|
this._univerInstanceService = _univerInstanceService;
|
|
@@ -1127,70 +1133,13 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1127
1133
|
const { range } = params;
|
|
1128
1134
|
return this._getRangeMoveUndo(range, 3);
|
|
1129
1135
|
} else if (id === SetRowHiddenCommand.id || id === SetSpecificRowsVisibleCommand.id) {
|
|
1130
|
-
|
|
1131
|
-
const _params = params;
|
|
1132
|
-
const target = getSheetCommandTarget(this._univerInstanceService, _params);
|
|
1133
|
-
if (!target) return {
|
|
1134
|
-
redos: [],
|
|
1135
|
-
undos: []
|
|
1136
|
-
};
|
|
1137
|
-
const { unitId, subUnitId } = target;
|
|
1138
|
-
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 === RANGE_TYPE.ROW));
|
|
1139
|
-
if (!ranges || ranges.length === 0) return {
|
|
1140
|
-
redos: [],
|
|
1141
|
-
undos: []
|
|
1142
|
-
};
|
|
1136
|
+
const { unitId, subUnitId, ranges } = params;
|
|
1143
1137
|
return this._getDrawingUndoForRowVisible(unitId, subUnitId, ranges);
|
|
1144
1138
|
} else if (id === SetColHiddenCommand.id || id === SetSpecificColsVisibleCommand.id) {
|
|
1145
|
-
|
|
1146
|
-
const _params = params;
|
|
1147
|
-
const target = getSheetCommandTarget(this._univerInstanceService, _params);
|
|
1148
|
-
if (!target) return {
|
|
1149
|
-
redos: [],
|
|
1150
|
-
undos: []
|
|
1151
|
-
};
|
|
1152
|
-
const { unitId, subUnitId } = target;
|
|
1153
|
-
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 === RANGE_TYPE.COLUMN));
|
|
1154
|
-
if (!ranges || ranges.length === 0) return {
|
|
1155
|
-
redos: [],
|
|
1156
|
-
undos: []
|
|
1157
|
-
};
|
|
1139
|
+
const { unitId, subUnitId, ranges } = params;
|
|
1158
1140
|
return this._getDrawingUndoForColVisible(unitId, subUnitId, ranges);
|
|
1159
|
-
} else if (id === DeltaRowHeightCommand.id || id === DeltaColumnWidthCommand.id) {
|
|
1160
|
-
const
|
|
1161
|
-
if (!target) return {
|
|
1162
|
-
redos: [],
|
|
1163
|
-
undos: []
|
|
1164
|
-
};
|
|
1165
|
-
const { unitId, subUnitId, worksheet } = target;
|
|
1166
|
-
const ranges = [];
|
|
1167
|
-
if (id === DeltaRowHeightCommand.id) ranges.push({
|
|
1168
|
-
startRow: params.anchorRow,
|
|
1169
|
-
endRow: params.anchorRow,
|
|
1170
|
-
startColumn: 0,
|
|
1171
|
-
endColumn: worksheet.getColumnCount() - 1
|
|
1172
|
-
});
|
|
1173
|
-
else ranges.push({
|
|
1174
|
-
startRow: 0,
|
|
1175
|
-
endRow: worksheet.getRowCount() - 1,
|
|
1176
|
-
startColumn: params.anchorCol,
|
|
1177
|
-
endColumn: params.anchorCol
|
|
1178
|
-
});
|
|
1179
|
-
return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges);
|
|
1180
|
-
} else if (id === SetRowHeightCommand.id || id === SetColWidthCommand.id) {
|
|
1181
|
-
var _this$_selectionManag3;
|
|
1182
|
-
const _params = params;
|
|
1183
|
-
const target = getSheetCommandTarget(this._univerInstanceService, _params);
|
|
1184
|
-
if (!target) return {
|
|
1185
|
-
redos: [],
|
|
1186
|
-
undos: []
|
|
1187
|
-
};
|
|
1188
|
-
const { unitId, subUnitId } = target;
|
|
1189
|
-
const ranges = _params.ranges || ((_this$_selectionManag3 = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag3 === void 0 ? void 0 : _this$_selectionManag3.map((s) => s.range));
|
|
1190
|
-
if (!ranges || ranges.length === 0) return {
|
|
1191
|
-
redos: [],
|
|
1192
|
-
undos: []
|
|
1193
|
-
};
|
|
1141
|
+
} else if (id === DeltaRowHeightCommand.id || id === DeltaColumnWidthCommand.id || id === SetRowHeightCommand.id || id === SetColWidthCommand.id) {
|
|
1142
|
+
const { unitId, subUnitId, ranges } = params;
|
|
1194
1143
|
return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges);
|
|
1195
1144
|
}
|
|
1196
1145
|
return {
|
|
@@ -1354,7 +1303,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1354
1303
|
const deleteDrawings = [];
|
|
1355
1304
|
const { sheetTransform, anchorType = "0", transform, unitId, subUnitId, drawingId } = drawing;
|
|
1356
1305
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
1357
|
-
if (!sheetTransform || !transform || !sheetSkeletonParam) return {
|
|
1306
|
+
if (anchorType === "2" || !sheetTransform || !transform || !sheetSkeletonParam) return {
|
|
1358
1307
|
updateDrawings,
|
|
1359
1308
|
deleteDrawings
|
|
1360
1309
|
};
|
|
@@ -1694,17 +1643,13 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1694
1643
|
const { sheetTransform, transform, anchorType = "0" } = drawing;
|
|
1695
1644
|
if (anchorType === "2") this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
1696
1645
|
else {
|
|
1697
|
-
const {
|
|
1698
|
-
const { row: fromRow, column: fromColumn } = from;
|
|
1699
|
-
const { row: toRow, column: toColumn } = to;
|
|
1646
|
+
const { row: toRow, column: toColumn } = sheetTransform.to;
|
|
1700
1647
|
for (let i = 0; i < ranges.length; i++) {
|
|
1701
|
-
const { startRow,
|
|
1648
|
+
const { startRow, startColumn } = ranges[i];
|
|
1702
1649
|
if (toRow < startRow || toColumn < startColumn) continue;
|
|
1703
1650
|
if (anchorType === "0") {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
continue;
|
|
1707
|
-
}
|
|
1651
|
+
updateDrawings.push(applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(drawing), skeleton));
|
|
1652
|
+
break;
|
|
1708
1653
|
}
|
|
1709
1654
|
const newTransform = drawingPositionToTransform({ ...sheetTransform }, sheetSkeletonParam);
|
|
1710
1655
|
if (newTransform) {
|
|
@@ -1723,10 +1668,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1723
1668
|
};
|
|
1724
1669
|
return this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
|
|
1725
1670
|
}
|
|
1726
|
-
_getUnitIdAndSubUnitId(params
|
|
1727
|
-
|
|
1728
|
-
if (type === "insert") target = getSheetCommandTarget(this._univerInstanceService, params);
|
|
1729
|
-
else target = getSheetCommandTarget(this._univerInstanceService);
|
|
1671
|
+
_getUnitIdAndSubUnitId(params) {
|
|
1672
|
+
const target = getSheetCommandTarget(this._univerInstanceService, params);
|
|
1730
1673
|
if (!target) return;
|
|
1731
1674
|
const { unitId, subUnitId } = target;
|
|
1732
1675
|
return {
|
|
@@ -1791,7 +1734,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1791
1734
|
return this._finalizePlan(unitId, subUnitId, updateDrawings);
|
|
1792
1735
|
}
|
|
1793
1736
|
_moveRowInterceptor(params, type) {
|
|
1794
|
-
const target = this._getUnitIdAndSubUnitId(params
|
|
1737
|
+
const target = this._getUnitIdAndSubUnitId(params);
|
|
1795
1738
|
if (!target) return {
|
|
1796
1739
|
redos: [],
|
|
1797
1740
|
undos: []
|
|
@@ -1859,7 +1802,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
1859
1802
|
return this._finalizePlan(unitId, subUnitId, updateDrawings, deleteDrawings);
|
|
1860
1803
|
}
|
|
1861
1804
|
_moveColInterceptor(params, type) {
|
|
1862
|
-
const target = this._getUnitIdAndSubUnitId(params
|
|
1805
|
+
const target = this._getUnitIdAndSubUnitId(params);
|
|
1863
1806
|
if (!target) return {
|
|
1864
1807
|
redos: [],
|
|
1865
1808
|
undos: []
|
|
@@ -2254,6 +2197,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
2254
2197
|
}
|
|
2255
2198
|
_refreshDrawingTransform(command, unitId, subUnitId, ranges) {
|
|
2256
2199
|
const sheetSkeletonParam = this._getCalculatedSkeletonParam(unitId, subUnitId);
|
|
2200
|
+
if (!sheetSkeletonParam) return;
|
|
2257
2201
|
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId) ?? {};
|
|
2258
2202
|
const updateDrawings = [];
|
|
2259
2203
|
Object.keys(drawingData).forEach((drawingId) => {
|
|
@@ -2277,7 +2221,10 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
2277
2221
|
startColumn: fromColumn,
|
|
2278
2222
|
endColumn: toColumn
|
|
2279
2223
|
}) || fromRow > endRow || fromColumn > endColumn) {
|
|
2280
|
-
|
|
2224
|
+
if (anchorType === "0") {
|
|
2225
|
+
updateDrawings.push(applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(drawing), sheetSkeletonParam.skeleton));
|
|
2226
|
+
break;
|
|
2227
|
+
}
|
|
2281
2228
|
const newTransform = drawingPositionToTransform(sheetTransform, sheetSkeletonParam);
|
|
2282
2229
|
updateDrawings.push({
|
|
2283
2230
|
...drawing,
|
|
@@ -2285,8 +2232,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
|
|
|
2285
2232
|
...transform,
|
|
2286
2233
|
left: newTransform === null || newTransform === void 0 ? void 0 : newTransform.left,
|
|
2287
2234
|
top: newTransform === null || newTransform === void 0 ? void 0 : newTransform.top,
|
|
2288
|
-
width:
|
|
2289
|
-
height:
|
|
2235
|
+
width: newTransform === null || newTransform === void 0 ? void 0 : newTransform.width,
|
|
2236
|
+
height: newTransform === null || newTransform === void 0 ? void 0 : newTransform.height
|
|
2290
2237
|
}
|
|
2291
2238
|
});
|
|
2292
2239
|
break;
|
|
@@ -2300,11 +2247,10 @@ SheetDrawingTransformAffectedController = __decorate([
|
|
|
2300
2247
|
__decorateParam(0, ICommandService),
|
|
2301
2248
|
__decorateParam(1, Inject(SheetSkeletonService)),
|
|
2302
2249
|
__decorateParam(2, Inject(SheetInterceptorService)),
|
|
2303
|
-
__decorateParam(3,
|
|
2304
|
-
__decorateParam(4,
|
|
2305
|
-
__decorateParam(5,
|
|
2306
|
-
__decorateParam(6,
|
|
2307
|
-
__decorateParam(7, Inject(SheetDrawingTransformPlanService))
|
|
2250
|
+
__decorateParam(3, ISheetDrawingService),
|
|
2251
|
+
__decorateParam(4, IDrawingManagerService),
|
|
2252
|
+
__decorateParam(5, IUniverInstanceService),
|
|
2253
|
+
__decorateParam(6, Inject(SheetDrawingTransformPlanService))
|
|
2308
2254
|
], SheetDrawingTransformAffectedController);
|
|
2309
2255
|
|
|
2310
2256
|
//#endregion
|
package/lib/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
|