@univerjs/sheets-drawing 1.3.1 → 1.5.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/README.md +6 -5
- package/lib/cjs/facade.js +20 -27
- package/lib/cjs/index.js +161 -90
- package/lib/es/facade.js +20 -27
- package/lib/es/index.js +163 -93
- package/lib/facade.js +20 -27
- package/lib/index.js +163 -93
- package/lib/types/commands/commands/remove-sheet-drawing.command.d.ts +2 -1
- package/lib/types/facade/f-over-grid-image.d.ts +4 -0
- package/lib/types/facade/f-worksheet.d.ts +13 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/sheet-drawing-placement.d.ts +6 -4
- package/lib/types/services/sheet-drawing.service.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -10
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
|
-
|
|
9
|
+
// \0@oxc-project+runtime@0.157.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) {
|
|
@@ -16,28 +16,25 @@ function _typeof(o) {
|
|
|
16
16
|
}, _typeof(o);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function toPrimitive(t, r) {
|
|
19
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
20
|
+
function toPrimitive(t, e) {
|
|
22
21
|
if ("object" != _typeof(t) || !t) return t;
|
|
23
|
-
var
|
|
24
|
-
if (void 0 !==
|
|
25
|
-
var i =
|
|
22
|
+
var r;
|
|
23
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
24
|
+
var i = r.call(t, e || "default");
|
|
26
25
|
if ("object" != _typeof(i)) return i;
|
|
27
26
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
28
27
|
}
|
|
29
|
-
return ("string" ===
|
|
28
|
+
return ("string" === e ? String : Number)(t);
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
31
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
34
32
|
function toPropertyKey(t) {
|
|
35
33
|
var i = toPrimitive(t, "string");
|
|
36
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
37
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
41
38
|
function _defineProperty(e, r, t) {
|
|
42
39
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
43
40
|
value: t,
|
|
@@ -47,16 +44,14 @@ function _defineProperty(e, r, t) {
|
|
|
47
44
|
}) : e[r] = t, e;
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
47
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
52
48
|
function __decorateParam(paramIndex, decorator) {
|
|
53
49
|
return function(target, key) {
|
|
54
50
|
decorator(target, key, paramIndex);
|
|
55
51
|
};
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
54
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
60
55
|
function __decorate(decorators, target, key, desc) {
|
|
61
56
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
62
57
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -64,8 +59,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
64
59
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
65
60
|
}
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
//#region src/facade/f-over-grid-image.ts
|
|
62
|
+
// src/facade/f-over-grid-image.ts
|
|
69
63
|
/**
|
|
70
64
|
* Convert the image parameter to a FOverGridImage
|
|
71
65
|
* @param {ISheetImage} sheetImage The image parameter
|
|
@@ -915,6 +909,10 @@ let FOverGridImage = class FOverGridImage extends FBase {
|
|
|
915
909
|
}
|
|
916
910
|
/**
|
|
917
911
|
* Remove the image from the sheet
|
|
912
|
+
*
|
|
913
|
+
* For multiple images on the same worksheet, prefer {@link FWorksheet.deleteImages} with the image
|
|
914
|
+
* handles instead of calling this method on each image.
|
|
915
|
+
*
|
|
918
916
|
* @returns {boolean} true if the image is removed successfully, otherwise false
|
|
919
917
|
* @example
|
|
920
918
|
* ```ts
|
|
@@ -1155,8 +1153,7 @@ function validateImageOpacity(opacity) {
|
|
|
1155
1153
|
if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1) throw new RangeError("Sheet image opacity must be between 0 and 1.");
|
|
1156
1154
|
}
|
|
1157
1155
|
|
|
1158
|
-
|
|
1159
|
-
//#region src/facade/f-worksheet.ts
|
|
1156
|
+
// src/facade/f-worksheet.ts
|
|
1160
1157
|
var FWorksheetDrawingMixin = class extends FWorksheet {
|
|
1161
1158
|
get _sheetDrawingService() {
|
|
1162
1159
|
return this._injector.get(ISheetDrawingService);
|
|
@@ -1550,8 +1547,7 @@ function getDrawingBounds(drawing) {
|
|
|
1550
1547
|
}
|
|
1551
1548
|
FWorksheet.extend(FWorksheetDrawingMixin);
|
|
1552
1549
|
|
|
1553
|
-
|
|
1554
|
-
//#region src/facade/f-enum.ts
|
|
1550
|
+
// src/facade/f-enum.ts
|
|
1555
1551
|
/**
|
|
1556
1552
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1557
1553
|
*
|
|
@@ -1577,8 +1573,7 @@ var FSheetsDrawingEnumMixin = class extends FEnum {
|
|
|
1577
1573
|
};
|
|
1578
1574
|
FEnum.extend(FSheetsDrawingEnumMixin);
|
|
1579
1575
|
|
|
1580
|
-
|
|
1581
|
-
//#region src/facade/f-event.ts
|
|
1576
|
+
// src/facade/f-event.ts
|
|
1582
1577
|
var FSheetsDrawingEventNameMixin = class extends FEventName {
|
|
1583
1578
|
get BeforeFloatDomAdd() {
|
|
1584
1579
|
return "BeforeFloatDomAdd";
|
|
@@ -1625,8 +1620,7 @@ var FSheetsDrawingEventNameMixin = class extends FEventName {
|
|
|
1625
1620
|
};
|
|
1626
1621
|
FEventName.extend(FSheetsDrawingEventNameMixin);
|
|
1627
1622
|
|
|
1628
|
-
|
|
1629
|
-
//#region src/facade/f-univer.ts
|
|
1623
|
+
// src/facade/f-univer.ts
|
|
1630
1624
|
/**
|
|
1631
1625
|
* @ignore
|
|
1632
1626
|
*/
|
|
@@ -1773,5 +1767,4 @@ var FUniverSheetsDrawingMixin = class extends FUniver {
|
|
|
1773
1767
|
};
|
|
1774
1768
|
FUniver.extend(FUniverSheetsDrawingMixin);
|
|
1775
1769
|
|
|
1776
|
-
//#endregion
|
|
1777
1770
|
export { FOverGridImage };
|
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
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, ILogService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, Plugin, Rectangle, UniverInstanceType, createIdentifier, merge, sequenceExecute, toDisposable } from "@univerjs/core";
|
|
2
|
+
import { ArrangeTypeEnum, CommandType, CustomCommandExecutionError, DependentOn, Disposable, DrawingTypeEnum, ICommandService, IConfigService, ILogService, 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
|
-
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
4
|
+
import { IRenderManagerService, Transform, Vector2, getGroupState } from "@univerjs/engine-render";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/basics/transform-position.ts
|
|
7
7
|
function drawingPositionToTransform(position, sheetSkeletonParam) {
|
|
8
8
|
if (!sheetSkeletonParam) return;
|
|
9
9
|
const { unitId, sheetId, skeleton } = sheetSkeletonParam;
|
|
@@ -68,8 +68,7 @@ function transformToAxisAlignPosition(transform, skeleton) {
|
|
|
68
68
|
}, skeleton);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
//#region src/services/sheet-drawing.service.ts
|
|
71
|
+
// src/services/sheet-drawing.service.ts
|
|
73
72
|
let SheetDrawingAnchorType = /* @__PURE__ */ function(SheetDrawingAnchorType) {
|
|
74
73
|
/**
|
|
75
74
|
* Only the position of the drawing follows the cell changes. When rows or columns are inserted or deleted, the position of the drawing changes, but the size remains the same.
|
|
@@ -88,8 +87,7 @@ let SheetDrawingAnchorType = /* @__PURE__ */ function(SheetDrawingAnchorType) {
|
|
|
88
87
|
var SheetDrawingService = class extends UnitDrawingService {};
|
|
89
88
|
const ISheetDrawingService = createIdentifier("sheets-drawing.sheet-drawing.service");
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
//#region src/commands/mutations/set-drawing-apply.mutation.ts
|
|
90
|
+
// src/commands/mutations/set-drawing-apply.mutation.ts
|
|
93
91
|
let DrawingApplyType = /* @__PURE__ */ function(DrawingApplyType) {
|
|
94
92
|
DrawingApplyType[DrawingApplyType["INSERT"] = 0] = "INSERT";
|
|
95
93
|
DrawingApplyType[DrawingApplyType["REMOVE"] = 1] = "REMOVE";
|
|
@@ -137,8 +135,7 @@ const SetDrawingApplyMutation = {
|
|
|
137
135
|
}
|
|
138
136
|
};
|
|
139
137
|
|
|
140
|
-
|
|
141
|
-
//#region src/commands/operations/clear-drawing-transformer.operation.ts
|
|
138
|
+
// src/commands/operations/clear-drawing-transformer.operation.ts
|
|
142
139
|
const ClearSheetDrawingTransformerOperation = {
|
|
143
140
|
id: "sheet.operation.clear-drawing-transformer",
|
|
144
141
|
type: CommandType.MUTATION,
|
|
@@ -152,8 +149,7 @@ const ClearSheetDrawingTransformerOperation = {
|
|
|
152
149
|
}
|
|
153
150
|
};
|
|
154
151
|
|
|
155
|
-
|
|
156
|
-
//#region src/commands/commands/insert-sheet-drawing.command.ts
|
|
152
|
+
// src/commands/commands/insert-sheet-drawing.command.ts
|
|
157
153
|
const InsertSheetDrawingCommand = {
|
|
158
154
|
id: "sheet.command.insert-sheet-image",
|
|
159
155
|
type: CommandType.COMMAND,
|
|
@@ -217,8 +213,33 @@ const InsertSheetDrawingCommand = {
|
|
|
217
213
|
}
|
|
218
214
|
};
|
|
219
215
|
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
// src/commands/commands/remove-sheet-drawing.command.ts
|
|
217
|
+
function expandDrawingRemovalParams(service, requested) {
|
|
218
|
+
const drawings = [];
|
|
219
|
+
const visit = (search, ancestors) => {
|
|
220
|
+
if (ancestors.has(search.drawingId)) throw new CustomCommandExecutionError(RemoveSheetDrawingCommand.id);
|
|
221
|
+
if (drawings.some((drawing) => drawing.unitId === search.unitId && drawing.subUnitId === search.subUnitId && drawing.drawingId === search.drawingId)) return;
|
|
222
|
+
const current = service.getDrawingByParam(search);
|
|
223
|
+
drawings.push({
|
|
224
|
+
unitId: search.unitId,
|
|
225
|
+
subUnitId: search.subUnitId,
|
|
226
|
+
drawingId: search.drawingId,
|
|
227
|
+
drawingType: (current === null || current === void 0 ? void 0 : current.drawingType) ?? search.drawingType
|
|
228
|
+
});
|
|
229
|
+
if (!current) return;
|
|
230
|
+
const children = Object.values(service.getDrawingData(search.unitId, search.subUnitId)).filter((drawing) => current.drawingType === DrawingTypeEnum.DRAWING_GROUP && drawing.groupId === search.drawingId);
|
|
231
|
+
const nextAncestors = new Set(ancestors);
|
|
232
|
+
nextAncestors.add(search.drawingId);
|
|
233
|
+
children.forEach((drawing) => visit({
|
|
234
|
+
unitId: search.unitId,
|
|
235
|
+
subUnitId: search.subUnitId,
|
|
236
|
+
drawingId: drawing.drawingId,
|
|
237
|
+
drawingType: drawing.drawingType
|
|
238
|
+
}, nextAncestors));
|
|
239
|
+
};
|
|
240
|
+
requested.forEach((drawing) => visit(drawing, /* @__PURE__ */ new Set()));
|
|
241
|
+
return drawings;
|
|
242
|
+
}
|
|
222
243
|
const RemoveSheetDrawingCommand = {
|
|
223
244
|
id: "sheet.command.remove-sheet-image",
|
|
224
245
|
type: CommandType.COMMAND,
|
|
@@ -228,13 +249,20 @@ const RemoveSheetDrawingCommand = {
|
|
|
228
249
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
229
250
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
230
251
|
const sheetDrawingService = accessor.get(ISheetDrawingService);
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
252
|
+
const normalizedParams = {
|
|
253
|
+
...params,
|
|
254
|
+
drawings: expandDrawingRemovalParams(sheetDrawingService, params.drawings)
|
|
255
|
+
};
|
|
256
|
+
if (!accessor.get(IDrawingManagerService).canExecuteCommand({
|
|
257
|
+
id: RemoveSheetDrawingCommand.id,
|
|
258
|
+
params: normalizedParams
|
|
259
|
+
})) return false;
|
|
234
260
|
const intercepted = sheetInterceptorService.onCommandExecute({
|
|
235
261
|
id: RemoveSheetDrawingCommand.id,
|
|
236
|
-
params
|
|
262
|
+
params: normalizedParams
|
|
237
263
|
});
|
|
264
|
+
const { unitId, subUnitId, undo, redo, objects } = sheetDrawingService.getBatchRemoveOp(normalizedParams.drawings);
|
|
265
|
+
if (Array.isArray(objects) && objects.length === 0) return false;
|
|
238
266
|
const redoMutations = [
|
|
239
267
|
...intercepted.preRedos ?? [],
|
|
240
268
|
{
|
|
@@ -283,8 +311,7 @@ const RemoveSheetDrawingCommand = {
|
|
|
283
311
|
}
|
|
284
312
|
};
|
|
285
313
|
|
|
286
|
-
|
|
287
|
-
//#region src/commands/commands/set-drawing-arrange.command.ts
|
|
314
|
+
// src/commands/commands/set-drawing-arrange.command.ts
|
|
288
315
|
const SetDrawingArrangeCommand = {
|
|
289
316
|
id: "sheet.command.set-drawing-arrange",
|
|
290
317
|
type: CommandType.COMMAND,
|
|
@@ -343,8 +370,7 @@ const SetDrawingArrangeCommand = {
|
|
|
343
370
|
}
|
|
344
371
|
};
|
|
345
372
|
|
|
346
|
-
|
|
347
|
-
//#region src/services/sheet-drawing-placement.ts
|
|
373
|
+
// src/services/sheet-drawing-placement.ts
|
|
348
374
|
const PLACEMENT_ERROR = {
|
|
349
375
|
CELL_INVALID: "SHEET_DRAWING_PLACEMENT_CELL_INVALID",
|
|
350
376
|
EXTENT_INVALID: "SHEET_DRAWING_PLACEMENT_EXTENT_INVALID",
|
|
@@ -379,6 +405,47 @@ function getSheetDrawingPlacement(drawing) {
|
|
|
379
405
|
function applySheetDrawingPlacement(drawing, input, skeleton) {
|
|
380
406
|
return resolveSheetDrawingPlacement(drawing, normalizePlacement(input, skeleton, requiresDrawingArea(drawing)), skeleton);
|
|
381
407
|
}
|
|
408
|
+
/** Place a batch at the logical start corner of a Chart Sheet, preserving its relative geometry. */
|
|
409
|
+
function transformDrawingsToChartSheet(drawings, chartSheetBounds, rightToLeft) {
|
|
410
|
+
if (validateBounds(chartSheetBounds, true)) return null;
|
|
411
|
+
if (!drawings.length) return [];
|
|
412
|
+
const bounds = [];
|
|
413
|
+
for (const drawing of drawings) {
|
|
414
|
+
const state = drawing.transform;
|
|
415
|
+
if (!state || validateBounds(state, requiresDrawingArea(drawing)) || [
|
|
416
|
+
state.angle,
|
|
417
|
+
state.skewX,
|
|
418
|
+
state.skewY,
|
|
419
|
+
state.scaleX,
|
|
420
|
+
state.scaleY
|
|
421
|
+
].some((value) => value !== void 0 && !Number.isFinite(value))) return null;
|
|
422
|
+
const { width = 0, height = 0, angle = 0 } = state;
|
|
423
|
+
const matrix = Transform.create().composeMatrix(state);
|
|
424
|
+
if (angle) matrix.rotate(-angle).translate(width / 2, height / 2).rotate(angle).translate(-width / 2, -height / 2);
|
|
425
|
+
const box = matrix.makeBoundingBoxFromPoints([
|
|
426
|
+
new Vector2(0, 0),
|
|
427
|
+
new Vector2(width, 0),
|
|
428
|
+
new Vector2(width, height),
|
|
429
|
+
new Vector2(0, height)
|
|
430
|
+
]);
|
|
431
|
+
bounds.push({
|
|
432
|
+
left: box.left,
|
|
433
|
+
top: box.top,
|
|
434
|
+
width: box.width,
|
|
435
|
+
height: box.height
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
const group = getGroupState(0, 0, bounds);
|
|
439
|
+
const scale = Math.min(1, group.width ? chartSheetBounds.width / group.width : 1, group.height ? chartSheetBounds.height / group.height : 1);
|
|
440
|
+
const left = rightToLeft ? chartSheetBounds.left + chartSheetBounds.width - group.width * scale : chartSheetBounds.left;
|
|
441
|
+
return drawings.map((drawing) => applySheetDrawingPlacement(drawing, {
|
|
442
|
+
kind: "2",
|
|
443
|
+
left: left + (drawing.transform.left - group.left) * scale,
|
|
444
|
+
top: chartSheetBounds.top + (drawing.transform.top - group.top) * scale,
|
|
445
|
+
width: drawing.transform.width * scale,
|
|
446
|
+
height: drawing.transform.height * scale
|
|
447
|
+
}));
|
|
448
|
+
}
|
|
382
449
|
/** Refresh layout-derived geometry without changing the drawing's anchor semantics. */
|
|
383
450
|
function refreshSheetDrawingPlacement(drawing, skeleton) {
|
|
384
451
|
const result = tryRefreshSheetDrawingPlacement(drawing, skeleton);
|
|
@@ -596,15 +663,17 @@ function createPlacementError(failure) {
|
|
|
596
663
|
return Object.assign(error, failure.details);
|
|
597
664
|
}
|
|
598
665
|
|
|
599
|
-
|
|
600
|
-
//#region src/commands/commands/set-sheet-drawing-placement.command.ts
|
|
666
|
+
// src/commands/commands/set-sheet-drawing-placement.command.ts
|
|
601
667
|
const SetSheetDrawingPlacementCommand = {
|
|
602
668
|
id: "sheet.command.set-drawing-placement",
|
|
603
669
|
type: CommandType.COMMAND,
|
|
604
670
|
handler: (accessor, params) => {
|
|
605
671
|
if (!(params === null || params === void 0 ? void 0 : params.drawings.length)) return false;
|
|
672
|
+
if (!accessor.get(IDrawingManagerService).canExecuteCommand({
|
|
673
|
+
id: SetSheetDrawingPlacementCommand.id,
|
|
674
|
+
params
|
|
675
|
+
})) return false;
|
|
606
676
|
const commandService = accessor.get(ICommandService);
|
|
607
|
-
const undoRedoService = accessor.get(IUndoRedoService);
|
|
608
677
|
const drawingService = accessor.get(ISheetDrawingService);
|
|
609
678
|
const skeleton = params.drawings.every(({ placement }) => placement.kind === "2") ? void 0 : accessor.get(SheetSkeletonService).ensureSkeleton(params.unitId, params.subUnitId);
|
|
610
679
|
const updatedDrawings = [];
|
|
@@ -617,45 +686,58 @@ const SetSheetDrawingPlacementCommand = {
|
|
|
617
686
|
if (!drawing) return false;
|
|
618
687
|
updatedDrawings.push(applySheetDrawingPlacement(drawing, placement, skeleton));
|
|
619
688
|
}
|
|
689
|
+
const intercepted = accessor.get(SheetInterceptorService).onCommandExecute({
|
|
690
|
+
id: SetSheetDrawingPlacementCommand.id,
|
|
691
|
+
params
|
|
692
|
+
});
|
|
620
693
|
const { unitId, subUnitId, undo, redo, objects } = drawingService.getBatchUpdateOp(updatedDrawings);
|
|
621
|
-
const redoMutations = [
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
694
|
+
const redoMutations = [
|
|
695
|
+
...intercepted.preRedos ?? [],
|
|
696
|
+
{
|
|
697
|
+
id: SetDrawingApplyMutation.id,
|
|
698
|
+
params: {
|
|
699
|
+
unitId,
|
|
700
|
+
subUnitId,
|
|
701
|
+
op: redo,
|
|
702
|
+
objects,
|
|
703
|
+
type: 2
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
id: ClearSheetDrawingTransformerOperation.id,
|
|
708
|
+
params: [unitId]
|
|
709
|
+
},
|
|
710
|
+
...intercepted.redos
|
|
711
|
+
];
|
|
712
|
+
const undoMutations = [
|
|
713
|
+
...intercepted.preUndos ?? [],
|
|
714
|
+
{
|
|
715
|
+
id: SetDrawingApplyMutation.id,
|
|
716
|
+
params: {
|
|
717
|
+
unitId,
|
|
718
|
+
subUnitId,
|
|
719
|
+
op: undo,
|
|
720
|
+
objects,
|
|
721
|
+
type: 2
|
|
722
|
+
}
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
id: ClearSheetDrawingTransformerOperation.id,
|
|
726
|
+
params: [unitId]
|
|
727
|
+
},
|
|
728
|
+
...intercepted.undos
|
|
729
|
+
];
|
|
647
730
|
if (!sequenceExecute(redoMutations, commandService).result) return false;
|
|
648
|
-
|
|
731
|
+
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
649
732
|
unitID: unitId,
|
|
650
|
-
|
|
651
|
-
|
|
733
|
+
redoMutations,
|
|
734
|
+
undoMutations
|
|
652
735
|
});
|
|
653
736
|
return true;
|
|
654
737
|
}
|
|
655
738
|
};
|
|
656
739
|
|
|
657
|
-
|
|
658
|
-
//#region src/common/rotate-enabled.ts
|
|
740
|
+
// src/common/rotate-enabled.ts
|
|
659
741
|
function isKnownSheetNonRotatableDrawingType(drawingType) {
|
|
660
742
|
return drawingType === DrawingTypeEnum.DRAWING_CHART;
|
|
661
743
|
}
|
|
@@ -666,8 +748,7 @@ function resolveSheetDrawingRotateEnabled(drawing, drawingService, getChildren)
|
|
|
666
748
|
});
|
|
667
749
|
}
|
|
668
750
|
|
|
669
|
-
|
|
670
|
-
//#region src/commands/commands/set-sheet-drawing.command.ts
|
|
751
|
+
// src/commands/commands/set-sheet-drawing.command.ts
|
|
671
752
|
function hasIncomingAngle(drawing) {
|
|
672
753
|
var _drawing$transform, _drawing$sheetTransfo, _drawing$axisAlignShe;
|
|
673
754
|
return ((_drawing$transform = drawing.transform) === null || _drawing$transform === void 0 ? void 0 : _drawing$transform.angle) !== void 0 || ((_drawing$sheetTransfo = drawing.sheetTransform) === null || _drawing$sheetTransfo === void 0 ? void 0 : _drawing$sheetTransfo.angle) !== void 0 || ((_drawing$axisAlignShe = drawing.axisAlignSheetTransform) === null || _drawing$axisAlignShe === void 0 ? void 0 : _drawing$axisAlignShe.angle) !== void 0;
|
|
@@ -722,6 +803,10 @@ const SetSheetDrawingCommand = {
|
|
|
722
803
|
...params,
|
|
723
804
|
drawings: normalizedDrawings
|
|
724
805
|
};
|
|
806
|
+
if (!accessor.get(IDrawingManagerService).canExecuteCommand({
|
|
807
|
+
id: SetSheetDrawingCommand.id,
|
|
808
|
+
params: normalizedParams
|
|
809
|
+
})) return false;
|
|
725
810
|
const { unitId, subUnitId, undo, redo, objects } = sheetDrawingService.getBatchUpdateOp(normalizedDrawings);
|
|
726
811
|
const intercepted = sheetInterceptorService.onCommandExecute({
|
|
727
812
|
id: SetSheetDrawingCommand.id,
|
|
@@ -775,8 +860,7 @@ const SetSheetDrawingCommand = {
|
|
|
775
860
|
}
|
|
776
861
|
};
|
|
777
862
|
|
|
778
|
-
|
|
779
|
-
//#region src/commands/mutations/set-worksheet-background-image.mutation.ts
|
|
863
|
+
// src/commands/mutations/set-worksheet-background-image.mutation.ts
|
|
780
864
|
const SetWorksheetBackgroundImageMutation = {
|
|
781
865
|
id: "sheet.mutation.set-worksheet-background-image",
|
|
782
866
|
type: CommandType.MUTATION,
|
|
@@ -790,8 +874,7 @@ const SetWorksheetBackgroundImageMutation = {
|
|
|
790
874
|
}
|
|
791
875
|
};
|
|
792
876
|
|
|
793
|
-
|
|
794
|
-
//#region src/commands/commands/set-worksheet-background-image.command.ts
|
|
877
|
+
// src/commands/commands/set-worksheet-background-image.command.ts
|
|
795
878
|
const SetWorksheetBackgroundImageCommand = {
|
|
796
879
|
id: "sheet.command.set-worksheet-background-image",
|
|
797
880
|
type: CommandType.COMMAND,
|
|
@@ -831,16 +914,14 @@ const SetWorksheetBackgroundImageCommand = {
|
|
|
831
914
|
}
|
|
832
915
|
};
|
|
833
916
|
|
|
834
|
-
|
|
835
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
917
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
836
918
|
function __decorateParam(paramIndex, decorator) {
|
|
837
919
|
return function(target, key) {
|
|
838
920
|
decorator(target, key, paramIndex);
|
|
839
921
|
};
|
|
840
922
|
}
|
|
841
923
|
|
|
842
|
-
|
|
843
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
924
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
844
925
|
function __decorate(decorators, target, key, desc) {
|
|
845
926
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
846
927
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -848,8 +929,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
848
929
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
849
930
|
}
|
|
850
931
|
|
|
851
|
-
|
|
852
|
-
//#region src/controllers/sheet-drawing.controller.ts
|
|
932
|
+
// src/controllers/sheet-drawing.controller.ts
|
|
853
933
|
const SHEET_DRAWING_PLUGIN = "SHEET_DRAWING_PLUGIN";
|
|
854
934
|
function getDrawingsInOrder(drawingData, drawingOrder) {
|
|
855
935
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -1021,13 +1101,11 @@ SheetsDrawingLoadController = __decorate([
|
|
|
1021
1101
|
__decorateParam(5, IResourceManagerService)
|
|
1022
1102
|
], SheetsDrawingLoadController);
|
|
1023
1103
|
|
|
1024
|
-
|
|
1025
|
-
//#region package.json
|
|
1104
|
+
// package.json
|
|
1026
1105
|
var name = "@univerjs/sheets-drawing";
|
|
1027
|
-
var version = "1.
|
|
1106
|
+
var version = "1.5.0";
|
|
1028
1107
|
|
|
1029
|
-
|
|
1030
|
-
//#region src/config/config.ts
|
|
1108
|
+
// src/config/config.ts
|
|
1031
1109
|
/**
|
|
1032
1110
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1033
1111
|
*
|
|
@@ -1047,8 +1125,7 @@ const SHEETS_DRAWING_PLUGIN_CONFIG_KEY = "sheets-drawing.config";
|
|
|
1047
1125
|
const configSymbol = Symbol(SHEETS_DRAWING_PLUGIN_CONFIG_KEY);
|
|
1048
1126
|
const defaultPluginConfig = {};
|
|
1049
1127
|
|
|
1050
|
-
|
|
1051
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
1128
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
1052
1129
|
function _typeof(o) {
|
|
1053
1130
|
"@babel/helpers - typeof";
|
|
1054
1131
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -1058,28 +1135,25 @@ function _typeof(o) {
|
|
|
1058
1135
|
}, _typeof(o);
|
|
1059
1136
|
}
|
|
1060
1137
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
function toPrimitive(t, r) {
|
|
1138
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
1139
|
+
function toPrimitive(t, e) {
|
|
1064
1140
|
if ("object" != _typeof(t) || !t) return t;
|
|
1065
|
-
var
|
|
1066
|
-
if (void 0 !==
|
|
1067
|
-
var i =
|
|
1141
|
+
var r;
|
|
1142
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
1143
|
+
var i = r.call(t, e || "default");
|
|
1068
1144
|
if ("object" != _typeof(i)) return i;
|
|
1069
1145
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1070
1146
|
}
|
|
1071
|
-
return ("string" ===
|
|
1147
|
+
return ("string" === e ? String : Number)(t);
|
|
1072
1148
|
}
|
|
1073
1149
|
|
|
1074
|
-
|
|
1075
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
1150
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
1076
1151
|
function toPropertyKey(t) {
|
|
1077
1152
|
var i = toPrimitive(t, "string");
|
|
1078
1153
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
1079
1154
|
}
|
|
1080
1155
|
|
|
1081
|
-
|
|
1082
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
1156
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
1083
1157
|
function _defineProperty(e, r, t) {
|
|
1084
1158
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1085
1159
|
value: t,
|
|
@@ -1089,8 +1163,7 @@ function _defineProperty(e, r, t) {
|
|
|
1089
1163
|
}) : e[r] = t, e;
|
|
1090
1164
|
}
|
|
1091
1165
|
|
|
1092
|
-
|
|
1093
|
-
//#region src/services/sheet-drawing-transform-plan.service.ts
|
|
1166
|
+
// src/services/sheet-drawing-transform-plan.service.ts
|
|
1094
1167
|
function createEmptyResult() {
|
|
1095
1168
|
return {
|
|
1096
1169
|
preRedos: [],
|
|
@@ -1124,8 +1197,7 @@ var SheetDrawingTransformPlanService = class {
|
|
|
1124
1197
|
}
|
|
1125
1198
|
};
|
|
1126
1199
|
|
|
1127
|
-
|
|
1128
|
-
//#region src/controllers/sheet-drawing-transform-affected.controller.ts
|
|
1200
|
+
// src/controllers/sheet-drawing-transform-affected.controller.ts
|
|
1129
1201
|
const UPDATE_COMMANDS = [
|
|
1130
1202
|
InsertRowCommand.id,
|
|
1131
1203
|
InsertColCommand.id,
|
|
@@ -2070,8 +2142,7 @@ SheetDrawingTransformAffectedController = __decorate([
|
|
|
2070
2142
|
__decorateParam(7, ILogService)
|
|
2071
2143
|
], SheetDrawingTransformAffectedController);
|
|
2072
2144
|
|
|
2073
|
-
|
|
2074
|
-
//#region src/plugin.ts
|
|
2145
|
+
// src/plugin.ts
|
|
2075
2146
|
let UniverSheetsDrawingPlugin = class UniverSheetsDrawingPlugin extends Plugin {
|
|
2076
2147
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
2077
2148
|
super();
|
|
@@ -2102,5 +2173,4 @@ UniverSheetsDrawingPlugin = __decorate([
|
|
|
2102
2173
|
__decorateParam(2, IConfigService)
|
|
2103
2174
|
], UniverSheetsDrawingPlugin);
|
|
2104
2175
|
|
|
2105
|
-
|
|
2106
|
-
export { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SHEET_DRAWING_PLUGIN, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, SheetDrawingService, SheetDrawingTransformPlanService, UniverSheetsDrawingPlugin, applySheetDrawingPlacement, drawingPositionToTransform, getSheetDrawingPlacement, isKnownSheetNonRotatableDrawingType, normalizeSheetDrawingPlacement, refreshSheetDrawingPlacement, resolveSheetDrawingRotateEnabled, transformToAxisAlignPosition, transformToDrawingPosition };
|
|
2176
|
+
export { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SHEET_DRAWING_PLUGIN, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, SheetDrawingService, SheetDrawingTransformPlanService, UniverSheetsDrawingPlugin, applySheetDrawingPlacement, drawingPositionToTransform, getSheetDrawingPlacement, isKnownSheetNonRotatableDrawingType, normalizeSheetDrawingPlacement, refreshSheetDrawingPlacement, resolveSheetDrawingRotateEnabled, transformDrawingsToChartSheet, transformToAxisAlignPosition, transformToDrawingPosition };
|