@univerjs/sheets-drawing-ui 0.2.5 → 0.2.7
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 +1 -1
- package/lib/es/index.js +1732 -1756
- package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +8 -8
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +8 -9
- package/lib/types/index.d.ts +1 -0
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +2 -2
- package/lib/types/views/menu/image.menu.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +24 -24
package/lib/es/index.js
CHANGED
|
@@ -1,2173 +1,2154 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { CommandType, ICommandService, IUndoRedoService, LocaleService, IUniverInstanceService, useDependency, RxDisposable, UniverInstanceType, connectInjector, toDisposable, FOCUSING_COMMON_DRAWINGS, OnLifecycle, LifecycleStages, Inject, Injector, IContextService, Disposable, Direction, FOCUSING_FX_BAR_EDITOR, EDITOR_ACTIVATED, Rectangle, DrawingTypeEnum as DrawingTypeEnum$1, DisposableCollection, generateRandomId, Tools, UserManagerService, IPermissionService, Plugin, DependentOn } from "@univerjs/core";
|
|
6
|
+
import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, DrawingRenderService, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
|
|
7
|
+
import { ISheetDrawingService, SetDrawingApplyMutation, DrawingApplyType, SheetDrawingAnchorType, UniverSheetsDrawingPlugin } from "@univerjs/sheets-drawing";
|
|
8
|
+
import { IDrawingManagerService, IImageIoService, ArrangeTypeEnum, DrawingTypeEnum, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_ALLOW_IMAGE_LIST, getDrawingShapeKeyByDrawingSearch, UniverDrawingPlugin } from "@univerjs/drawing";
|
|
9
|
+
import { IRenderManagerService, getGroupState, transformObjectOutOfGroup, precisionTo, Rect, DRAWING_OBJECT_LAYER_INDEX, pxToNum, SHEET_VIEWPORT_KEY, RENDER_CLASS_TYPE } from "@univerjs/engine-render";
|
|
10
|
+
import { SheetCanvasPopManagerService, attachRangeWithCoord, SheetSkeletonManagerService, ISheetSelectionRenderService, getCurrentRangeDisable$, SetScrollOperation, SetZoomRatioOperation, SheetPrintInterceptorService, COPY_TYPE, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, ISheetClipboardService } from "@univerjs/sheets-ui";
|
|
11
|
+
import { takeUntil, Subject, BehaviorSubject, combineLatest, map, filter, distinctUntilChanged } from "rxjs";
|
|
12
|
+
import { ISidebarService, BuiltInUIPart, IUIPartsService, IMessageService, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, KeyCode, ComponentManager, IMenuService, IShortcutService, CanvasFloatDomService } from "@univerjs/ui";
|
|
13
|
+
import { getSheetCommandTarget, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, InsertRowCommand, InsertColCommand, RemoveRowCommand, RemoveColCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, DeltaRowHeightCommand, SetRowHeightCommand, DeltaColumnWidthCommand, SetColWidthCommand, SetRowHiddenCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, SetColHiddenCommand, SetRowVisibleMutation, SetRowHiddenMutation, SetColVisibleMutation, SetColHiddenMutation, SetWorksheetRowHeightMutation, SetWorksheetColWidthMutation, SetWorksheetActiveOperation, SheetInterceptorService, SetFrozenMutation, WorkbookViewPermission, WorksheetViewPermission } from "@univerjs/sheets";
|
|
14
|
+
import React, { useEffect, forwardRef, useRef, createElement, useState } from "react";
|
|
15
|
+
import { MessageType, RadioGroup, Radio } from "@univerjs/design";
|
|
16
|
+
import clsx from "clsx";
|
|
17
|
+
const ClearSheetDrawingTransformerOperation = {
|
|
17
18
|
id: "sheet.operation.clear-drawing-transformer",
|
|
18
|
-
type:
|
|
19
|
-
handler: (
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
var
|
|
23
|
-
(
|
|
19
|
+
type: CommandType.MUTATION,
|
|
20
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
21
|
+
const renderManagerService = accessor.get(IRenderManagerService);
|
|
22
|
+
return params.forEach((unitId) => {
|
|
23
|
+
var _a10, _b;
|
|
24
|
+
(_b = (_a10 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.scene.getTransformer()) == null || _b.debounceRefreshControls();
|
|
24
25
|
}), !0;
|
|
25
|
-
}
|
|
26
|
-
},
|
|
26
|
+
}, "handler")
|
|
27
|
+
}, RemoveSheetDrawingCommand = {
|
|
27
28
|
id: "sheet.command.remove-sheet-image",
|
|
28
|
-
type:
|
|
29
|
-
handler: (
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
32
|
-
const { drawings
|
|
33
|
-
|
|
34
|
-
const { unitId:
|
|
35
|
-
|
|
29
|
+
type: CommandType.COMMAND,
|
|
30
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
31
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
|
|
32
|
+
if (!params) return !1;
|
|
33
|
+
const { drawings } = params, unitIds = [];
|
|
34
|
+
drawings.forEach((param) => {
|
|
35
|
+
const { unitId: unitId2 } = param;
|
|
36
|
+
unitIds.push(unitId2);
|
|
36
37
|
});
|
|
37
|
-
const
|
|
38
|
-
return
|
|
39
|
-
unitID:
|
|
38
|
+
const jsonOp = sheetDrawingService.getBatchRemoveOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
|
|
39
|
+
return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE }) ? (undoRedoService.pushUndoRedo({
|
|
40
|
+
unitID: unitId,
|
|
40
41
|
undoMutations: [
|
|
41
|
-
{ id:
|
|
42
|
-
{ id:
|
|
42
|
+
{ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.INSERT } },
|
|
43
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
43
44
|
],
|
|
44
45
|
redoMutations: [
|
|
45
|
-
{ id:
|
|
46
|
-
{ id:
|
|
46
|
+
{ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE } },
|
|
47
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
47
48
|
]
|
|
48
49
|
}), !0) : !1;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
50
|
+
}, "handler")
|
|
51
|
+
}, COMPONENT_SHEET_DRAWING_PANEL = "COMPONENT_SHEET_DRAWING_PANEL", SidebarSheetDrawingOperation = {
|
|
51
52
|
id: "sidebar.operation.sheet-image",
|
|
52
|
-
type:
|
|
53
|
-
handler: async (
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
switch (
|
|
53
|
+
type: CommandType.COMMAND,
|
|
54
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
55
|
+
const sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService), univerInstanceService = accessor.get(IUniverInstanceService), drawingManagerService = accessor.get(IDrawingManagerService);
|
|
56
|
+
if (!getSheetCommandTarget(univerInstanceService)) return !1;
|
|
57
|
+
switch (params.value) {
|
|
57
58
|
case "open":
|
|
58
|
-
|
|
59
|
-
header: { title:
|
|
60
|
-
children: { label:
|
|
61
|
-
onClose: () => {
|
|
62
|
-
|
|
63
|
-
},
|
|
59
|
+
sidebarService.open({
|
|
60
|
+
header: { title: localeService.t("sheetImage.panel.title") },
|
|
61
|
+
children: { label: COMPONENT_SHEET_DRAWING_PANEL },
|
|
62
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
63
|
+
drawingManagerService.focusDrawing(null);
|
|
64
|
+
}, "onClose"),
|
|
64
65
|
width: 360
|
|
65
66
|
});
|
|
66
67
|
break;
|
|
67
68
|
case "close":
|
|
68
69
|
default:
|
|
69
|
-
|
|
70
|
+
sidebarService.close();
|
|
70
71
|
break;
|
|
71
72
|
}
|
|
72
73
|
return !0;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
74
|
+
}, "handler")
|
|
75
|
+
}, EditSheetDrawingOperation = {
|
|
75
76
|
id: "sheet.operation.edit-sheet-image",
|
|
76
|
-
type:
|
|
77
|
-
handler: (
|
|
78
|
-
const
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
uploadLoading
|
|
83
|
-
uploadLoadingBody
|
|
84
|
-
uploadLoadingBodyAnimation
|
|
85
|
-
univerCircleAnimation
|
|
86
|
-
uploadLoadingBodyText
|
|
87
|
-
},
|
|
88
|
-
const
|
|
89
|
-
return
|
|
90
|
-
const
|
|
91
|
-
|
|
77
|
+
type: CommandType.OPERATION,
|
|
78
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
79
|
+
const drawingManagerService = accessor.get(IDrawingManagerService), commandService = accessor.get(ICommandService);
|
|
80
|
+
return params == null ? !1 : (drawingManagerService.focusDrawing([params]), commandService.executeCommand(SidebarSheetDrawingOperation.id, { value: "open" }), !0);
|
|
81
|
+
}, "handler")
|
|
82
|
+
}, uploadLoading = "univer-upload-loading", uploadLoadingBody = "univer-upload-loading-body", uploadLoadingBodyAnimation = "univer-upload-loading-body-animation", univerCircleAnimation = "univer-UniverCircleAnimation", uploadLoadingBodyText = "univer-upload-loading-body-text", styles$2 = {
|
|
83
|
+
uploadLoading,
|
|
84
|
+
uploadLoadingBody,
|
|
85
|
+
uploadLoadingBodyAnimation,
|
|
86
|
+
univerCircleAnimation,
|
|
87
|
+
uploadLoadingBodyText
|
|
88
|
+
}, UploadLoading = /* @__PURE__ */ __name(() => {
|
|
89
|
+
const imageIoService = useDependency(IImageIoService), localeService = useDependency(LocaleService), [remain, setRemain] = React.useState(0);
|
|
90
|
+
return useEffect(() => {
|
|
91
|
+
const sub = imageIoService.change$.subscribe((count) => {
|
|
92
|
+
setRemain(count);
|
|
92
93
|
});
|
|
93
94
|
return () => {
|
|
94
|
-
|
|
95
|
+
sub.unsubscribe();
|
|
95
96
|
};
|
|
96
|
-
}, [
|
|
97
|
-
};
|
|
98
|
-
var
|
|
99
|
-
for (var
|
|
100
|
-
(
|
|
101
|
-
return
|
|
102
|
-
},
|
|
103
|
-
let
|
|
104
|
-
constructor(
|
|
97
|
+
}, [imageIoService]), /* @__PURE__ */ React.createElement("div", { style: { display: remain > 0 ? "block" : "none" }, className: styles$2.uploadLoading }, /* @__PURE__ */ React.createElement("div", { className: styles$2.uploadLoadingBody }, /* @__PURE__ */ React.createElement("div", { className: styles$2.uploadLoadingBodyAnimation }), /* @__PURE__ */ React.createElement("div", { className: styles$2.uploadLoadingBodyText }, `${localeService.t("uploadLoading.loading")}: ${remain}`)));
|
|
98
|
+
}, "UploadLoading");
|
|
99
|
+
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
100
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
101
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
102
|
+
return kind && result && __defProp$8(target, key, result), result;
|
|
103
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a;
|
|
104
|
+
let DrawingPopupMenuController = (_a = class extends RxDisposable {
|
|
105
|
+
constructor(_injector, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _uiPartsService) {
|
|
105
106
|
super();
|
|
106
|
-
|
|
107
|
-
this._injector =
|
|
107
|
+
__publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
108
|
+
this._injector = _injector, this._drawingManagerService = _drawingManagerService, this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._uiPartsService = _uiPartsService, this._init();
|
|
108
109
|
}
|
|
109
110
|
_init() {
|
|
110
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
111
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._create(workbook)), this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._dispose(workbook)), this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._create(workbook)), this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(UploadLoading, this._injector));
|
|
111
112
|
}
|
|
112
|
-
_dispose(
|
|
113
|
-
const
|
|
114
|
-
this._renderManagerService.removeRender(
|
|
113
|
+
_dispose(workbook) {
|
|
114
|
+
const unitId = workbook.getUnitId();
|
|
115
|
+
this._renderManagerService.removeRender(unitId);
|
|
115
116
|
}
|
|
116
|
-
_create(
|
|
117
|
-
if (!
|
|
117
|
+
_create(workbook) {
|
|
118
|
+
if (!workbook)
|
|
118
119
|
return;
|
|
119
|
-
const
|
|
120
|
-
this._renderManagerService.has(
|
|
120
|
+
const unitId = workbook.getUnitId();
|
|
121
|
+
this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
|
|
121
122
|
}
|
|
122
|
-
_hasCropObject(
|
|
123
|
-
const
|
|
124
|
-
for (const
|
|
125
|
-
if (
|
|
123
|
+
_hasCropObject(scene) {
|
|
124
|
+
const objects = scene.getAllObjects();
|
|
125
|
+
for (const object of objects)
|
|
126
|
+
if (object instanceof ImageCropperObject)
|
|
126
127
|
return !0;
|
|
127
128
|
return !1;
|
|
128
129
|
}
|
|
129
|
-
_popupMenuListener(
|
|
130
|
-
var
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
130
|
+
_popupMenuListener(unitId) {
|
|
131
|
+
var _a10;
|
|
132
|
+
const scene = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.scene;
|
|
133
|
+
if (!scene)
|
|
133
134
|
return;
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
135
|
+
const transformer = scene.getTransformerByCreate();
|
|
136
|
+
if (!transformer)
|
|
136
137
|
return;
|
|
137
|
-
let
|
|
138
|
+
let singletonPopupDisposer;
|
|
138
139
|
this.disposeWithMe(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (this._contextService.setContextValue(
|
|
140
|
+
toDisposable(
|
|
141
|
+
transformer.createControl$.subscribe(() => {
|
|
142
|
+
if (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._hasCropObject(scene))
|
|
142
143
|
return;
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
|
|
144
|
+
const selectedObjects = transformer.getSelectedObjectMap();
|
|
145
|
+
if (selectedObjects.size > 1) {
|
|
146
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose();
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
|
-
const
|
|
149
|
-
if (!
|
|
149
|
+
const object = selectedObjects.values().next().value;
|
|
150
|
+
if (!object)
|
|
150
151
|
return;
|
|
151
|
-
const
|
|
152
|
-
if (!
|
|
152
|
+
const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
|
|
153
|
+
if (!drawingParam)
|
|
153
154
|
return;
|
|
154
|
-
const { unitId:
|
|
155
|
-
|
|
156
|
-
componentKey:
|
|
155
|
+
const { unitId: unitId2, subUnitId, drawingId } = drawingParam;
|
|
156
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
|
|
157
|
+
componentKey: COMPONENT_IMAGE_POPUP_MENU,
|
|
157
158
|
direction: "horizontal",
|
|
158
159
|
offset: [2, 0],
|
|
159
160
|
extraProps: {
|
|
160
|
-
menuItems: this._getImageMenuItems(
|
|
161
|
+
menuItems: this._getImageMenuItems(unitId2, subUnitId, drawingId)
|
|
161
162
|
}
|
|
162
163
|
})), this._drawingManagerService.focusDrawing([{
|
|
163
|
-
unitId:
|
|
164
|
-
subUnitId
|
|
165
|
-
drawingId
|
|
164
|
+
unitId: unitId2,
|
|
165
|
+
subUnitId,
|
|
166
|
+
drawingId
|
|
166
167
|
}]);
|
|
167
168
|
})
|
|
168
169
|
)
|
|
169
170
|
), this.disposeWithMe(
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
transformer.clearControl$.subscribe(() => {
|
|
172
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose(), this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._drawingManagerService.focusDrawing(null);
|
|
172
173
|
})
|
|
173
174
|
), this.disposeWithMe(
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
transformer.changing$.subscribe(() => {
|
|
176
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose();
|
|
176
177
|
})
|
|
177
178
|
);
|
|
178
179
|
}
|
|
179
|
-
_getImageMenuItems(
|
|
180
|
+
_getImageMenuItems(unitId, subUnitId, drawingId) {
|
|
180
181
|
return [
|
|
181
182
|
{
|
|
182
183
|
label: "image-popup.edit",
|
|
183
184
|
index: 0,
|
|
184
|
-
commandId:
|
|
185
|
-
commandParams: { unitId
|
|
185
|
+
commandId: EditSheetDrawingOperation.id,
|
|
186
|
+
commandParams: { unitId, subUnitId, drawingId },
|
|
186
187
|
disable: !1
|
|
187
188
|
},
|
|
188
189
|
{
|
|
189
190
|
label: "image-popup.delete",
|
|
190
191
|
index: 1,
|
|
191
|
-
commandId:
|
|
192
|
-
commandParams: { unitId
|
|
192
|
+
commandId: RemoveSheetDrawingCommand.id,
|
|
193
|
+
commandParams: { unitId, drawings: [{ unitId, subUnitId, drawingId }] },
|
|
193
194
|
disable: !1
|
|
194
195
|
},
|
|
195
196
|
{
|
|
196
197
|
label: "image-popup.crop",
|
|
197
198
|
index: 2,
|
|
198
|
-
commandId:
|
|
199
|
-
commandParams: { unitId
|
|
199
|
+
commandId: OpenImageCropOperation.id,
|
|
200
|
+
commandParams: { unitId, subUnitId, drawingId },
|
|
200
201
|
disable: !1
|
|
201
202
|
},
|
|
202
203
|
{
|
|
203
204
|
label: "image-popup.reset",
|
|
204
205
|
index: 3,
|
|
205
|
-
commandId:
|
|
206
|
-
commandParams: [{ unitId
|
|
206
|
+
commandId: ImageResetSizeOperation.id,
|
|
207
|
+
commandParams: [{ unitId, subUnitId, drawingId }],
|
|
207
208
|
disable: !1
|
|
208
209
|
}
|
|
209
210
|
];
|
|
210
211
|
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
],
|
|
222
|
-
const
|
|
212
|
+
}, __name(_a, "DrawingPopupMenuController"), _a);
|
|
213
|
+
DrawingPopupMenuController = __decorateClass$8([
|
|
214
|
+
OnLifecycle(LifecycleStages.Steady, DrawingPopupMenuController),
|
|
215
|
+
__decorateParam$8(0, Inject(Injector)),
|
|
216
|
+
__decorateParam$8(1, IDrawingManagerService),
|
|
217
|
+
__decorateParam$8(2, Inject(SheetCanvasPopManagerService)),
|
|
218
|
+
__decorateParam$8(3, IRenderManagerService),
|
|
219
|
+
__decorateParam$8(4, IUniverInstanceService),
|
|
220
|
+
__decorateParam$8(5, IContextService),
|
|
221
|
+
__decorateParam$8(6, Inject(IUIPartsService))
|
|
222
|
+
], DrawingPopupMenuController);
|
|
223
|
+
const InsertFloatImageOperation = {
|
|
223
224
|
id: "sheet.operation.insert-float-image",
|
|
224
|
-
type:
|
|
225
|
-
handler: (
|
|
226
|
-
},
|
|
225
|
+
type: CommandType.OPERATION,
|
|
226
|
+
handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
|
|
227
|
+
}, InsertCellImageOperation = {
|
|
227
228
|
id: "sheet.operation.insert-cell-image",
|
|
228
|
-
type:
|
|
229
|
-
handler: (
|
|
230
|
-
},
|
|
229
|
+
type: CommandType.OPERATION,
|
|
230
|
+
handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
|
|
231
|
+
}, InsertSheetDrawingCommand = {
|
|
231
232
|
id: "sheet.command.insert-sheet-image",
|
|
232
|
-
type:
|
|
233
|
-
handler: (
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
236
|
-
const
|
|
237
|
-
return
|
|
238
|
-
unitID:
|
|
233
|
+
type: CommandType.COMMAND,
|
|
234
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
235
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
|
|
236
|
+
if (!params) return !1;
|
|
237
|
+
const drawings = params.drawings, unitIds = drawings.map((param) => param.unitId), jsonOp = sheetDrawingService.getBatchAddOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
|
|
238
|
+
return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT }) ? (undoRedoService.pushUndoRedo({
|
|
239
|
+
unitID: unitId,
|
|
239
240
|
undoMutations: [
|
|
240
|
-
{ id:
|
|
241
|
-
{ id:
|
|
241
|
+
{ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } },
|
|
242
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
242
243
|
],
|
|
243
244
|
redoMutations: [
|
|
244
|
-
{ id:
|
|
245
|
-
{ id:
|
|
245
|
+
{ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } },
|
|
246
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
246
247
|
]
|
|
247
248
|
}), !0) : !1;
|
|
248
|
-
}
|
|
249
|
-
},
|
|
249
|
+
}, "handler")
|
|
250
|
+
}, SetSheetDrawingCommand = {
|
|
250
251
|
id: "sheet.command.set-sheet-image",
|
|
251
|
-
type:
|
|
252
|
-
handler: (
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
const { drawings
|
|
256
|
-
return
|
|
257
|
-
unitID:
|
|
252
|
+
type: CommandType.COMMAND,
|
|
253
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
254
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
|
|
255
|
+
if (!params) return !1;
|
|
256
|
+
const { drawings } = params, jsonOp = sheetDrawingService.getBatchUpdateOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
|
|
257
|
+
return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE }) ? (undoRedoService.pushUndoRedo({
|
|
258
|
+
unitID: unitId,
|
|
258
259
|
undoMutations: [
|
|
259
|
-
{ id:
|
|
260
|
-
{ id:
|
|
260
|
+
{ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
|
|
261
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
|
|
261
262
|
],
|
|
262
263
|
redoMutations: [
|
|
263
|
-
{ id:
|
|
264
|
-
{ id:
|
|
264
|
+
{ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
|
|
265
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
|
|
265
266
|
]
|
|
266
267
|
}), !0) : !1;
|
|
267
|
-
}
|
|
268
|
-
},
|
|
268
|
+
}, "handler")
|
|
269
|
+
}, SetDrawingArrangeCommand = {
|
|
269
270
|
id: "sheet.command.set-drawing-arrange",
|
|
270
|
-
type:
|
|
271
|
-
handler: (
|
|
272
|
-
const
|
|
273
|
-
if (!
|
|
274
|
-
const
|
|
275
|
-
let
|
|
276
|
-
if (
|
|
271
|
+
type: CommandType.COMMAND,
|
|
272
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
273
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
274
|
+
if (!params) return !1;
|
|
275
|
+
const sheetDrawingService = accessor.get(ISheetDrawingService), { unitId, subUnitId, drawingIds, arrangeType } = params, drawingOrderMapParam = { unitId, subUnitId, drawingIds };
|
|
276
|
+
let jsonOp;
|
|
277
|
+
if (arrangeType === ArrangeTypeEnum.forward ? jsonOp = sheetDrawingService.getForwardDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.backward ? jsonOp = sheetDrawingService.getBackwardDrawingOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.front ? jsonOp = sheetDrawingService.getFrontDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.back && (jsonOp = sheetDrawingService.getBackDrawingsOp(drawingOrderMapParam)), jsonOp == null)
|
|
277
278
|
return !1;
|
|
278
|
-
const { objects
|
|
279
|
-
return
|
|
280
|
-
unitID:
|
|
279
|
+
const { objects, redo, undo } = jsonOp;
|
|
280
|
+
return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE }) ? (undoRedoService.pushUndoRedo({
|
|
281
|
+
unitID: unitId,
|
|
281
282
|
undoMutations: [
|
|
282
|
-
{ id:
|
|
283
|
+
{ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
|
|
283
284
|
],
|
|
284
285
|
redoMutations: [
|
|
285
|
-
{ id:
|
|
286
|
+
{ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
|
|
286
287
|
]
|
|
287
288
|
}), !0) : !1;
|
|
288
|
-
}
|
|
289
|
+
}, "handler")
|
|
289
290
|
};
|
|
290
|
-
function
|
|
291
|
-
const
|
|
292
|
-
return
|
|
293
|
-
const { parent
|
|
294
|
-
const
|
|
291
|
+
function ungroupToGroup(ungroupParams) {
|
|
292
|
+
const newGroupParams = [];
|
|
293
|
+
return ungroupParams.forEach((ungroupParam) => {
|
|
294
|
+
const { parent, children } = ungroupParam, { unitId, subUnitId, drawingId: groupId } = parent, groupTransform = getGroupState(0, 0, children.map((o) => o.transform || {})), newChildren = children.map((drawing) => {
|
|
295
|
+
const transform = drawing.transform || { left: 0, top: 0 }, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = drawing;
|
|
295
296
|
return {
|
|
296
|
-
unitId:
|
|
297
|
-
subUnitId:
|
|
298
|
-
drawingId
|
|
297
|
+
unitId: unitId2,
|
|
298
|
+
subUnitId: subUnitId2,
|
|
299
|
+
drawingId,
|
|
299
300
|
transform: {
|
|
300
|
-
...
|
|
301
|
-
left:
|
|
302
|
-
top:
|
|
301
|
+
...transform,
|
|
302
|
+
left: transform.left - groupTransform.left,
|
|
303
|
+
top: transform.top - groupTransform.top
|
|
303
304
|
},
|
|
304
|
-
groupId
|
|
305
|
+
groupId
|
|
305
306
|
};
|
|
306
|
-
}),
|
|
307
|
-
unitId
|
|
308
|
-
subUnitId
|
|
309
|
-
drawingId:
|
|
310
|
-
drawingType:
|
|
311
|
-
transform:
|
|
307
|
+
}), groupParam = {
|
|
308
|
+
unitId,
|
|
309
|
+
subUnitId,
|
|
310
|
+
drawingId: groupId,
|
|
311
|
+
drawingType: DrawingTypeEnum.DRAWING_GROUP,
|
|
312
|
+
transform: groupTransform
|
|
312
313
|
};
|
|
313
|
-
|
|
314
|
-
parent:
|
|
315
|
-
children:
|
|
314
|
+
newGroupParams.push({
|
|
315
|
+
parent: groupParam,
|
|
316
|
+
children: newChildren
|
|
316
317
|
});
|
|
317
|
-
}),
|
|
318
|
+
}), newGroupParams;
|
|
318
319
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
320
|
+
__name(ungroupToGroup, "ungroupToGroup");
|
|
321
|
+
function groupToUngroup(groupParams) {
|
|
322
|
+
const newGroupParams = [];
|
|
323
|
+
return groupParams.forEach((groupParam) => {
|
|
324
|
+
const { parent, children } = groupParam, { unitId, subUnitId, drawingId: groupId, transform: groupTransform = { width: 0, height: 0 } } = parent;
|
|
325
|
+
if (groupTransform == null)
|
|
324
326
|
return;
|
|
325
|
-
const
|
|
326
|
-
const { transform
|
|
327
|
+
const newChildren = children.map((object) => {
|
|
328
|
+
const { transform } = object, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = object, newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
|
|
327
329
|
return {
|
|
328
|
-
unitId:
|
|
329
|
-
subUnitId:
|
|
330
|
-
drawingId
|
|
331
|
-
transform:
|
|
330
|
+
unitId: unitId2,
|
|
331
|
+
subUnitId: subUnitId2,
|
|
332
|
+
drawingId,
|
|
333
|
+
transform: newTransform,
|
|
332
334
|
groupId: void 0
|
|
333
335
|
};
|
|
334
|
-
}),
|
|
335
|
-
unitId
|
|
336
|
-
subUnitId
|
|
337
|
-
drawingId:
|
|
338
|
-
drawingType:
|
|
336
|
+
}), ungroupParam = {
|
|
337
|
+
unitId,
|
|
338
|
+
subUnitId,
|
|
339
|
+
drawingId: groupId,
|
|
340
|
+
drawingType: DrawingTypeEnum.DRAWING_GROUP,
|
|
339
341
|
transform: {
|
|
340
342
|
left: 0,
|
|
341
343
|
top: 0
|
|
342
344
|
}
|
|
343
345
|
};
|
|
344
|
-
|
|
345
|
-
parent:
|
|
346
|
-
children:
|
|
346
|
+
newGroupParams.push({
|
|
347
|
+
parent: ungroupParam,
|
|
348
|
+
children: newChildren
|
|
347
349
|
});
|
|
348
|
-
}),
|
|
350
|
+
}), newGroupParams;
|
|
349
351
|
}
|
|
350
|
-
|
|
352
|
+
__name(groupToUngroup, "groupToUngroup");
|
|
353
|
+
const GroupSheetDrawingCommand = {
|
|
351
354
|
id: "sheet.command.group-sheet-image",
|
|
352
|
-
type:
|
|
353
|
-
handler: (
|
|
354
|
-
const
|
|
355
|
-
if (!
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
type: CommandType.COMMAND,
|
|
356
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
357
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
|
|
358
|
+
if (!params) return !1;
|
|
359
|
+
const unitIds = [];
|
|
360
|
+
params.forEach(({ parent, children }) => {
|
|
361
|
+
unitIds.push(parent.unitId), children.forEach((child) => {
|
|
362
|
+
unitIds.push(child.unitId);
|
|
360
363
|
});
|
|
361
364
|
});
|
|
362
|
-
const
|
|
363
|
-
return
|
|
364
|
-
unitID:
|
|
365
|
+
const jsonOp = sheetDrawingService.getGroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
|
|
366
|
+
return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP }) ? (undoRedoService.pushUndoRedo({
|
|
367
|
+
unitID: unitId,
|
|
365
368
|
undoMutations: [
|
|
366
|
-
{ id:
|
|
367
|
-
{ id:
|
|
369
|
+
{ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: groupToUngroup(objects), type: DrawingApplyType.UNGROUP } },
|
|
370
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
368
371
|
],
|
|
369
372
|
redoMutations: [
|
|
370
|
-
{ id:
|
|
371
|
-
{ id:
|
|
373
|
+
{ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP } },
|
|
374
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
372
375
|
]
|
|
373
376
|
}), !0) : !1;
|
|
374
|
-
}
|
|
375
|
-
},
|
|
377
|
+
}, "handler")
|
|
378
|
+
}, UngroupSheetDrawingCommand = {
|
|
376
379
|
id: "sheet.command.ungroup-sheet-image",
|
|
377
|
-
type:
|
|
378
|
-
handler: (
|
|
379
|
-
const
|
|
380
|
-
if (!
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
380
|
+
type: CommandType.COMMAND,
|
|
381
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
382
|
+
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
|
|
383
|
+
if (!params) return !1;
|
|
384
|
+
const unitIds = [];
|
|
385
|
+
params.forEach(({ parent, children }) => {
|
|
386
|
+
unitIds.push(parent.unitId), children.forEach((child) => {
|
|
387
|
+
unitIds.push(child.unitId);
|
|
385
388
|
});
|
|
386
389
|
});
|
|
387
|
-
const
|
|
388
|
-
return
|
|
389
|
-
unitID:
|
|
390
|
+
const jsonOp = sheetDrawingService.getUngroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
|
|
391
|
+
return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP }) ? (undoRedoService.pushUndoRedo({
|
|
392
|
+
unitID: unitId,
|
|
390
393
|
undoMutations: [
|
|
391
|
-
{ id:
|
|
392
|
-
{ id:
|
|
394
|
+
{ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: ungroupToGroup(objects), type: DrawingApplyType.GROUP } },
|
|
395
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
393
396
|
],
|
|
394
397
|
redoMutations: [
|
|
395
|
-
{ id:
|
|
396
|
-
{ id:
|
|
398
|
+
{ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP } },
|
|
399
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
397
400
|
]
|
|
398
401
|
}), !0) : !1;
|
|
399
|
-
}
|
|
402
|
+
}, "handler")
|
|
400
403
|
};
|
|
401
|
-
function
|
|
402
|
-
const { from
|
|
403
|
-
startColumn:
|
|
404
|
-
endColumn:
|
|
405
|
-
startRow:
|
|
406
|
-
endRow:
|
|
404
|
+
function drawingPositionToTransform(position, selectionRenderService, sheetSkeletonManagerService) {
|
|
405
|
+
const { from, to, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = position, { column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset } = from, { column: toColumn, columnOffset: toColumnOffset, row: toRow, rowOffset: toRowOffset } = to, startSelectionCell = sheetSkeletonManagerService.attachRangeWithCoord({
|
|
406
|
+
startColumn: fromColumn,
|
|
407
|
+
endColumn: fromColumn,
|
|
408
|
+
startRow: fromRow,
|
|
409
|
+
endRow: fromRow
|
|
407
410
|
});
|
|
408
|
-
if (
|
|
411
|
+
if (startSelectionCell == null)
|
|
409
412
|
return;
|
|
410
|
-
const
|
|
411
|
-
startColumn:
|
|
412
|
-
endColumn:
|
|
413
|
-
startRow:
|
|
414
|
-
endRow:
|
|
413
|
+
const endSelectionCell = sheetSkeletonManagerService.attachRangeWithCoord({
|
|
414
|
+
startColumn: toColumn,
|
|
415
|
+
endColumn: toColumn,
|
|
416
|
+
startRow: toRow,
|
|
417
|
+
endRow: toRow
|
|
415
418
|
});
|
|
416
|
-
if (
|
|
419
|
+
if (endSelectionCell == null)
|
|
417
420
|
return;
|
|
418
|
-
const { startX:
|
|
419
|
-
let
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
return
|
|
423
|
-
flipY
|
|
424
|
-
flipX
|
|
425
|
-
angle
|
|
426
|
-
skewX
|
|
427
|
-
skewY
|
|
428
|
-
left
|
|
429
|
-
top
|
|
430
|
-
width
|
|
431
|
-
height
|
|
421
|
+
const { startX: startSelectionX, startY: startSelectionY } = startSelectionCell, { startX: endSelectionX, startY: endSelectionY } = endSelectionCell;
|
|
422
|
+
let left = precisionTo(startSelectionX + fromColumnOffset, 1), top = precisionTo(startSelectionY + fromRowOffset, 1), width = precisionTo(endSelectionX + toColumnOffset - left, 1), height = precisionTo(endSelectionY + toRowOffset - top, 1);
|
|
423
|
+
startSelectionCell.startX === endSelectionCell.endX && (width = 0), startSelectionCell.startY === endSelectionCell.endY && (height = 0);
|
|
424
|
+
const skeleton = sheetSkeletonManagerService.getCurrentSkeleton(), sheetWidth = skeleton.rowHeaderWidth + skeleton.columnTotalWidth, sheetHeight = skeleton.columnHeaderHeight + skeleton.rowTotalHeight;
|
|
425
|
+
return left + width > sheetWidth && (left = sheetWidth - width), top + height > sheetHeight && (top = sheetHeight - height), {
|
|
426
|
+
flipY,
|
|
427
|
+
flipX,
|
|
428
|
+
angle,
|
|
429
|
+
skewX,
|
|
430
|
+
skewY,
|
|
431
|
+
left,
|
|
432
|
+
top,
|
|
433
|
+
width,
|
|
434
|
+
height
|
|
432
435
|
};
|
|
433
436
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
+
__name(drawingPositionToTransform, "drawingPositionToTransform");
|
|
438
|
+
function transformToDrawingPosition(transform, selectionRenderService) {
|
|
439
|
+
const { left = 0, top = 0, width = 0, height = 0, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = transform, startSelectionCell = selectionRenderService.getSelectionCellByPosition(left, top);
|
|
440
|
+
if (startSelectionCell == null)
|
|
437
441
|
return;
|
|
438
|
-
const
|
|
439
|
-
column:
|
|
440
|
-
columnOffset:
|
|
441
|
-
row:
|
|
442
|
-
rowOffset:
|
|
443
|
-
},
|
|
444
|
-
if (
|
|
442
|
+
const from = {
|
|
443
|
+
column: startSelectionCell.actualColumn,
|
|
444
|
+
columnOffset: precisionTo(left - startSelectionCell.startX, 1),
|
|
445
|
+
row: startSelectionCell.actualRow,
|
|
446
|
+
rowOffset: precisionTo(top - startSelectionCell.startY, 1)
|
|
447
|
+
}, endSelectionCell = selectionRenderService.getSelectionCellByPosition(left + width, top + height);
|
|
448
|
+
if (endSelectionCell == null)
|
|
445
449
|
return;
|
|
446
|
-
const
|
|
447
|
-
column:
|
|
448
|
-
columnOffset:
|
|
449
|
-
row:
|
|
450
|
-
rowOffset:
|
|
450
|
+
const to = {
|
|
451
|
+
column: endSelectionCell.actualColumn,
|
|
452
|
+
columnOffset: precisionTo(left + width - endSelectionCell.startX, 1),
|
|
453
|
+
row: endSelectionCell.actualRow,
|
|
454
|
+
rowOffset: precisionTo(top + height - endSelectionCell.startY, 1)
|
|
451
455
|
};
|
|
452
456
|
return {
|
|
453
|
-
flipY
|
|
454
|
-
flipX
|
|
455
|
-
angle
|
|
456
|
-
skewX
|
|
457
|
-
skewY
|
|
458
|
-
from
|
|
459
|
-
to
|
|
457
|
+
flipY,
|
|
458
|
+
flipX,
|
|
459
|
+
angle,
|
|
460
|
+
skewX,
|
|
461
|
+
skewY,
|
|
462
|
+
from,
|
|
463
|
+
to
|
|
460
464
|
};
|
|
461
465
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
get _selectionRenderService() {
|
|
474
|
-
return this._renderManagerService.getRenderById(
|
|
475
|
-
this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
|
|
476
|
-
).with(xe);
|
|
477
|
-
}
|
|
478
|
-
get _skeletonManagerService() {
|
|
479
|
-
return this._renderManagerService.getRenderById(
|
|
480
|
-
this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
|
|
481
|
-
).with(se);
|
|
482
|
-
}
|
|
483
|
-
_init() {
|
|
484
|
-
this._initCommandListeners(), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._drawingAddListener();
|
|
466
|
+
__name(transformToDrawingPosition, "transformToDrawingPosition");
|
|
467
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
468
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
469
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
470
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
471
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a2;
|
|
472
|
+
let SheetDrawingUpdateController = (_a2 = class extends Disposable {
|
|
473
|
+
constructor(_context, _skeletonManagerService, _commandService, _selectionRenderService, _imageIoService, _sheetDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, selectionManagerService) {
|
|
474
|
+
super();
|
|
475
|
+
__publicField(this, "_workbookSelections");
|
|
476
|
+
this._context = _context, this._skeletonManagerService = _skeletonManagerService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._imageIoService = _imageIoService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._contextService = _contextService, this._messageService = _messageService, this._localeService = _localeService, this._workbookSelections = selectionManagerService.getWorkbookSelections(this._context.unitId), this._initCommandListeners(), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._drawingAddListener();
|
|
485
477
|
}
|
|
486
478
|
/**
|
|
487
479
|
* Upload image to cell or float image
|
|
488
480
|
*/
|
|
489
481
|
_initCommandListeners() {
|
|
490
482
|
this.disposeWithMe(
|
|
491
|
-
this._commandService.onCommandExecuted(async (
|
|
492
|
-
if (
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
483
|
+
this._commandService.onCommandExecuted(async (command) => {
|
|
484
|
+
if (command.id === InsertCellImageOperation.id || command.id === InsertFloatImageOperation.id) {
|
|
485
|
+
const params = command.params;
|
|
486
|
+
if (params.files == null)
|
|
495
487
|
return;
|
|
496
|
-
const
|
|
497
|
-
if (
|
|
488
|
+
const fileLength = params.files.length;
|
|
489
|
+
if (fileLength > DRAWING_IMAGE_COUNT_LIMIT) {
|
|
498
490
|
this._messageService.show({
|
|
499
|
-
type:
|
|
500
|
-
content: this._localeService.t("update-status.exceedMaxCount", String(
|
|
491
|
+
type: MessageType.Error,
|
|
492
|
+
content: this._localeService.t("update-status.exceedMaxCount", String(DRAWING_IMAGE_COUNT_LIMIT))
|
|
501
493
|
});
|
|
502
494
|
return;
|
|
503
495
|
}
|
|
504
|
-
this._imageIoService.setWaitCount(
|
|
505
|
-
await this._insertCellImage(
|
|
506
|
-
}) :
|
|
507
|
-
await this._insertFloatImage(
|
|
496
|
+
this._imageIoService.setWaitCount(fileLength), command.id === InsertCellImageOperation.id ? params.files.forEach(async (file) => {
|
|
497
|
+
await this._insertCellImage(file);
|
|
498
|
+
}) : params.files.forEach(async (file) => {
|
|
499
|
+
await this._insertFloatImage(file);
|
|
508
500
|
});
|
|
509
501
|
}
|
|
510
502
|
})
|
|
511
503
|
);
|
|
512
504
|
}
|
|
513
|
-
async _insertCellImage(
|
|
505
|
+
async _insertCellImage(file) {
|
|
514
506
|
}
|
|
515
|
-
async _insertFloatImage(
|
|
516
|
-
let
|
|
507
|
+
async _insertFloatImage(file) {
|
|
508
|
+
let imageParam;
|
|
517
509
|
try {
|
|
518
|
-
|
|
519
|
-
} catch (
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
type:
|
|
523
|
-
content: this._localeService.t("update-status.exceedMaxSize", String(
|
|
524
|
-
}) :
|
|
525
|
-
type:
|
|
510
|
+
imageParam = await this._imageIoService.saveImage(file);
|
|
511
|
+
} catch (error) {
|
|
512
|
+
const type = error.message;
|
|
513
|
+
type === ImageUploadStatusType.ERROR_EXCEED_SIZE ? this._messageService.show({
|
|
514
|
+
type: MessageType.Error,
|
|
515
|
+
content: this._localeService.t("update-status.exceedMaxSize", String(DRAWING_IMAGE_ALLOW_SIZE / (1024 * 1024)))
|
|
516
|
+
}) : type === ImageUploadStatusType.ERROR_IMAGE_TYPE ? this._messageService.show({
|
|
517
|
+
type: MessageType.Error,
|
|
526
518
|
content: this._localeService.t("update-status.invalidImageType")
|
|
527
|
-
}) :
|
|
528
|
-
type:
|
|
519
|
+
}) : type === ImageUploadStatusType.ERROR_IMAGE && this._messageService.show({
|
|
520
|
+
type: MessageType.Error,
|
|
529
521
|
content: this._localeService.t("update-status.invalidImage")
|
|
530
522
|
});
|
|
531
523
|
}
|
|
532
|
-
if (
|
|
533
|
-
return;
|
|
534
|
-
const n = this._getUnitInfo();
|
|
535
|
-
if (n == null)
|
|
524
|
+
if (imageParam == null)
|
|
536
525
|
return;
|
|
537
|
-
const
|
|
538
|
-
if (
|
|
526
|
+
const info = this._getUnitInfo();
|
|
527
|
+
if (info == null)
|
|
539
528
|
return;
|
|
540
|
-
const { width:
|
|
541
|
-
this._imageIoService.addImageSourceCache(
|
|
542
|
-
let
|
|
543
|
-
if (
|
|
544
|
-
const
|
|
545
|
-
|
|
529
|
+
const { unitId, subUnitId } = info, { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), { width: sceneWidth, height: sceneHeight } = this._context.scene;
|
|
530
|
+
this._imageIoService.addImageSourceCache(source, imageSourceType, image);
|
|
531
|
+
let scale = 1;
|
|
532
|
+
if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
|
|
533
|
+
const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width, scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
|
|
534
|
+
scale = Math.max(scaleWidth, scaleHeight);
|
|
546
535
|
}
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
536
|
+
const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight);
|
|
537
|
+
if (sheetTransform == null)
|
|
549
538
|
return;
|
|
550
|
-
const
|
|
551
|
-
unitId
|
|
552
|
-
subUnitId
|
|
553
|
-
drawingId:
|
|
554
|
-
drawingType:
|
|
555
|
-
imageSourceType
|
|
556
|
-
source
|
|
557
|
-
transform:
|
|
558
|
-
sheetTransform
|
|
539
|
+
const sheetDrawingParam = {
|
|
540
|
+
unitId,
|
|
541
|
+
subUnitId,
|
|
542
|
+
drawingId: imageId,
|
|
543
|
+
drawingType: DrawingTypeEnum.DRAWING_IMAGE,
|
|
544
|
+
imageSourceType,
|
|
545
|
+
source,
|
|
546
|
+
transform: drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService),
|
|
547
|
+
sheetTransform
|
|
559
548
|
};
|
|
560
|
-
this._commandService.executeCommand(
|
|
561
|
-
unitId
|
|
562
|
-
drawings: [
|
|
549
|
+
this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
|
|
550
|
+
unitId,
|
|
551
|
+
drawings: [sheetDrawingParam]
|
|
563
552
|
});
|
|
564
553
|
}
|
|
565
554
|
_getUnitInfo() {
|
|
566
|
-
const
|
|
567
|
-
if (i == null)
|
|
568
|
-
return;
|
|
569
|
-
const e = i.getActiveSheet();
|
|
570
|
-
if (e == null)
|
|
571
|
-
return;
|
|
572
|
-
const n = i.getUnitId(), t = e.getSheetId();
|
|
555
|
+
const workbook = this._context.unit, worksheet = workbook.getActiveSheet(), unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId();
|
|
573
556
|
return {
|
|
574
|
-
unitId
|
|
575
|
-
subUnitId
|
|
557
|
+
unitId,
|
|
558
|
+
subUnitId
|
|
576
559
|
};
|
|
577
560
|
}
|
|
578
|
-
_getImagePosition(
|
|
579
|
-
const
|
|
580
|
-
let
|
|
561
|
+
_getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight) {
|
|
562
|
+
const selections = this._workbookSelections.getCurrentSelections();
|
|
563
|
+
let range = {
|
|
581
564
|
startRow: 0,
|
|
582
565
|
endRow: 0,
|
|
583
566
|
startColumn: 0,
|
|
584
567
|
endColumn: 0
|
|
585
568
|
};
|
|
586
|
-
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
569
|
+
selections && selections.length > 0 && (range = selections[selections.length - 1].range);
|
|
570
|
+
const rangeWithCoord = attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton, range);
|
|
571
|
+
if (rangeWithCoord == null)
|
|
589
572
|
return;
|
|
590
|
-
let { startColumn
|
|
591
|
-
if (
|
|
592
|
-
const
|
|
593
|
-
if (
|
|
573
|
+
let { startColumn, startRow, startX, startY } = rangeWithCoord, isChangeStart = !1;
|
|
574
|
+
if (startX + imageWidth > sceneWidth && (startX = sceneWidth - imageWidth, startX < 0 && (startX = 0, imageWidth = sceneWidth), isChangeStart = !0), startY + imageHeight > sceneHeight && (startY = sceneHeight - imageHeight, startY < 0 && (startY = 0, imageHeight = sceneHeight), isChangeStart = !0), isChangeStart) {
|
|
575
|
+
const newCoord = this._selectionRenderService.getSelectionCellByPosition(startX, startY);
|
|
576
|
+
if (newCoord == null)
|
|
594
577
|
return;
|
|
595
|
-
|
|
578
|
+
startX = newCoord.startX, startY = newCoord.startY, startColumn = newCoord.actualColumn, startRow = newCoord.actualRow;
|
|
596
579
|
}
|
|
597
|
-
const
|
|
598
|
-
column:
|
|
580
|
+
const from = {
|
|
581
|
+
column: startColumn,
|
|
599
582
|
columnOffset: 0,
|
|
600
|
-
row:
|
|
583
|
+
row: startRow,
|
|
601
584
|
rowOffset: 0
|
|
602
|
-
},
|
|
603
|
-
if (
|
|
585
|
+
}, endSelectionCell = this._selectionRenderService.getSelectionCellByPosition(startX + imageWidth, startY + imageHeight);
|
|
586
|
+
if (endSelectionCell == null)
|
|
604
587
|
return;
|
|
605
|
-
const
|
|
606
|
-
column:
|
|
607
|
-
columnOffset:
|
|
608
|
-
row:
|
|
609
|
-
rowOffset:
|
|
588
|
+
const to = {
|
|
589
|
+
column: endSelectionCell.actualColumn,
|
|
590
|
+
columnOffset: startX + imageWidth - endSelectionCell.startX,
|
|
591
|
+
row: endSelectionCell.actualRow,
|
|
592
|
+
rowOffset: startY + imageHeight - endSelectionCell.startY
|
|
610
593
|
};
|
|
611
594
|
return {
|
|
612
|
-
from
|
|
613
|
-
to
|
|
595
|
+
from,
|
|
596
|
+
to
|
|
614
597
|
};
|
|
615
598
|
}
|
|
616
599
|
_updateOrderListener() {
|
|
617
|
-
this._drawingManagerService.featurePluginOrderUpdate$.subscribe((
|
|
618
|
-
const { unitId
|
|
619
|
-
this._commandService.executeCommand(
|
|
620
|
-
unitId
|
|
621
|
-
subUnitId
|
|
622
|
-
drawingIds
|
|
623
|
-
arrangeType
|
|
600
|
+
this._drawingManagerService.featurePluginOrderUpdate$.subscribe((params) => {
|
|
601
|
+
const { unitId, subUnitId, drawingIds, arrangeType } = params;
|
|
602
|
+
this._commandService.executeCommand(SetDrawingArrangeCommand.id, {
|
|
603
|
+
unitId,
|
|
604
|
+
subUnitId,
|
|
605
|
+
drawingIds,
|
|
606
|
+
arrangeType
|
|
624
607
|
});
|
|
625
608
|
});
|
|
626
609
|
}
|
|
627
610
|
_updateImageListener() {
|
|
628
|
-
this._drawingManagerService.featurePluginUpdate$.subscribe((
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
const { unitId
|
|
632
|
-
if (
|
|
611
|
+
this._drawingManagerService.featurePluginUpdate$.subscribe((params) => {
|
|
612
|
+
const drawings = [];
|
|
613
|
+
params.length !== 0 && (params.forEach((param) => {
|
|
614
|
+
const { unitId, subUnitId, drawingId, drawingType, transform } = param;
|
|
615
|
+
if (transform == null)
|
|
633
616
|
return;
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
617
|
+
const sheetDrawing = this._sheetDrawingService.getDrawingByParam({ unitId, subUnitId, drawingId });
|
|
618
|
+
if (sheetDrawing == null)
|
|
636
619
|
return;
|
|
637
|
-
const
|
|
638
|
-
if (
|
|
620
|
+
const sheetTransform = transformToDrawingPosition({ ...sheetDrawing.transform, ...transform }, this._selectionRenderService);
|
|
621
|
+
if (sheetTransform == null)
|
|
639
622
|
return;
|
|
640
|
-
const
|
|
641
|
-
...
|
|
642
|
-
transform: { ...
|
|
643
|
-
sheetTransform: { ...
|
|
623
|
+
const newDrawing = {
|
|
624
|
+
...param,
|
|
625
|
+
transform: { ...sheetDrawing.transform, ...transform, ...drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService) },
|
|
626
|
+
sheetTransform: { ...sheetTransform }
|
|
644
627
|
};
|
|
645
|
-
|
|
646
|
-
}),
|
|
647
|
-
unitId:
|
|
648
|
-
drawings
|
|
628
|
+
drawings.push(newDrawing);
|
|
629
|
+
}), drawings.length > 0 && this._commandService.executeCommand(SetSheetDrawingCommand.id, {
|
|
630
|
+
unitId: params[0].unitId,
|
|
631
|
+
drawings
|
|
649
632
|
}));
|
|
650
633
|
});
|
|
651
634
|
}
|
|
652
635
|
_groupDrawingListener() {
|
|
653
|
-
this._drawingManagerService.featurePluginGroupUpdate$.subscribe((
|
|
654
|
-
this._commandService.executeCommand(
|
|
655
|
-
const { unitId
|
|
656
|
-
this._drawingManagerService.focusDrawing([{ unitId
|
|
657
|
-
}), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((
|
|
658
|
-
this._commandService.executeCommand(
|
|
636
|
+
this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
|
|
637
|
+
this._commandService.executeCommand(GroupSheetDrawingCommand.id, params);
|
|
638
|
+
const { unitId, subUnitId, drawingId } = params[0].parent;
|
|
639
|
+
this._drawingManagerService.focusDrawing([{ unitId, subUnitId, drawingId }]);
|
|
640
|
+
}), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((params) => {
|
|
641
|
+
this._commandService.executeCommand(UngroupSheetDrawingCommand.id, params);
|
|
659
642
|
});
|
|
660
643
|
}
|
|
661
644
|
_focusDrawingListener() {
|
|
662
645
|
this.disposeWithMe(
|
|
663
|
-
this._drawingManagerService.focus$.subscribe((
|
|
664
|
-
|
|
646
|
+
this._drawingManagerService.focus$.subscribe((params) => {
|
|
647
|
+
params == null || params.length === 0 ? (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._sheetDrawingService.focusDrawing(params));
|
|
665
648
|
})
|
|
666
649
|
);
|
|
667
650
|
}
|
|
668
651
|
_drawingAddListener() {
|
|
669
652
|
this.disposeWithMe(
|
|
670
|
-
this._sheetDrawingService.add$.subscribe((
|
|
671
|
-
this._registerDrawing(
|
|
653
|
+
this._sheetDrawingService.add$.subscribe((params) => {
|
|
654
|
+
this._registerDrawing(params);
|
|
672
655
|
})
|
|
673
656
|
);
|
|
674
657
|
}
|
|
675
|
-
_registerDrawing(
|
|
676
|
-
|
|
677
|
-
const
|
|
678
|
-
if (
|
|
658
|
+
_registerDrawing(params) {
|
|
659
|
+
params.forEach((param) => {
|
|
660
|
+
const drawingParam = this._sheetDrawingService.getDrawingByParam(param);
|
|
661
|
+
if (drawingParam == null)
|
|
679
662
|
return;
|
|
680
|
-
const { sheetTransform
|
|
681
|
-
|
|
663
|
+
const { sheetTransform } = drawingParam;
|
|
664
|
+
drawingParam.transform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
682
665
|
});
|
|
683
|
-
const
|
|
684
|
-
this._drawingManagerService.registerDrawingData(
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
|
|
666
|
+
const unitId = params[0].unitId;
|
|
667
|
+
this._drawingManagerService.registerDrawingData(unitId, this._sheetDrawingService.getDrawingDataForUnit(unitId)), this._drawingManagerService.initializeNotification(unitId);
|
|
668
|
+
}
|
|
669
|
+
}, __name(_a2, "SheetDrawingUpdateController"), _a2);
|
|
670
|
+
SheetDrawingUpdateController = __decorateClass$7([
|
|
671
|
+
__decorateParam$7(1, Inject(SheetSkeletonManagerService)),
|
|
672
|
+
__decorateParam$7(2, ICommandService),
|
|
673
|
+
__decorateParam$7(3, ISheetSelectionRenderService),
|
|
674
|
+
__decorateParam$7(4, IImageIoService),
|
|
675
|
+
__decorateParam$7(5, ISheetDrawingService),
|
|
676
|
+
__decorateParam$7(6, IDrawingManagerService),
|
|
677
|
+
__decorateParam$7(7, IContextService),
|
|
678
|
+
__decorateParam$7(8, IMessageService),
|
|
679
|
+
__decorateParam$7(9, Inject(LocaleService)),
|
|
680
|
+
__decorateParam$7(10, Inject(SheetsSelectionsService))
|
|
681
|
+
], SheetDrawingUpdateController);
|
|
682
|
+
var __assign = function() {
|
|
683
|
+
return __assign = Object.assign || function(t) {
|
|
684
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
685
|
+
s = arguments[i];
|
|
686
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
705
687
|
}
|
|
706
|
-
return
|
|
707
|
-
},
|
|
708
|
-
},
|
|
709
|
-
var
|
|
710
|
-
for (var
|
|
711
|
-
if (
|
|
712
|
-
for (var
|
|
713
|
-
e.indexOf(
|
|
714
|
-
return
|
|
715
|
-
},
|
|
716
|
-
var
|
|
717
|
-
return
|
|
688
|
+
return t;
|
|
689
|
+
}, __assign.apply(this, arguments);
|
|
690
|
+
}, __rest = function(s, e) {
|
|
691
|
+
var t = {};
|
|
692
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
693
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
694
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
695
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
696
|
+
return t;
|
|
697
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
698
|
+
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
699
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
718
700
|
});
|
|
719
|
-
function
|
|
720
|
-
return
|
|
721
|
-
return
|
|
701
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
702
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
703
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
722
704
|
}));
|
|
723
705
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
706
|
+
__name(render, "render");
|
|
707
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
708
|
+
var attrs = __assign({}, node.attrs);
|
|
709
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
710
|
+
var defIds = runtimeProps.defIds;
|
|
711
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a10) {
|
|
712
|
+
var key = _a10[0], value = _a10[1];
|
|
713
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
714
|
+
})), attrs;
|
|
732
715
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
716
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
717
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
718
|
+
var _a10, defIds = runtimeProps.defIds;
|
|
719
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a10 = node.children) === null || _a10 === void 0) && _a10.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
720
|
+
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
721
|
+
}) }) : node;
|
|
738
722
|
}
|
|
739
|
-
|
|
723
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
724
|
+
function generateShortUuid() {
|
|
740
725
|
return Math.random().toString(36).substring(2, 8);
|
|
741
726
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
727
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
728
|
+
IconBase.displayName = "UniverIcon";
|
|
729
|
+
var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef(function(props, ref) {
|
|
730
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
745
731
|
id: "add-image-single",
|
|
746
|
-
ref
|
|
747
|
-
icon:
|
|
732
|
+
ref,
|
|
733
|
+
icon: element
|
|
748
734
|
}));
|
|
749
735
|
});
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
uploadFileMenu
|
|
753
|
-
uploadFileMenuInput
|
|
754
|
-
},
|
|
755
|
-
var
|
|
756
|
-
const
|
|
757
|
-
const { type
|
|
758
|
-
var
|
|
759
|
-
(
|
|
760
|
-
},
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
736
|
+
AddImageSingle.displayName = "AddImageSingle";
|
|
737
|
+
const uploadFileMenu = "univer-upload-file-menu", uploadFileMenuInput = "univer-upload-file-menu-input", styles$1 = {
|
|
738
|
+
uploadFileMenu,
|
|
739
|
+
uploadFileMenuInput
|
|
740
|
+
}, COMPONENT_UPLOAD_FILE_MENU = "COMPONENT_UPLOAD_FILE_MENU";
|
|
741
|
+
var UploadFileType = /* @__PURE__ */ ((UploadFileType2) => (UploadFileType2[UploadFileType2.cellImage = 0] = "cellImage", UploadFileType2[UploadFileType2.floatImage = 1] = "floatImage", UploadFileType2))(UploadFileType || {});
|
|
742
|
+
const UploadFileMenu = /* @__PURE__ */ __name((props) => {
|
|
743
|
+
const { type } = props, commandService = useDependency(ICommandService), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
|
|
744
|
+
var _a10;
|
|
745
|
+
(_a10 = fileInputRef.current) == null || _a10.click();
|
|
746
|
+
}, "handleButtonClick"), imageAccept = DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(","), handleFileChange = /* @__PURE__ */ __name((event) => {
|
|
747
|
+
const fileList = event.target.files;
|
|
748
|
+
if (fileList == null)
|
|
763
749
|
return;
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
};
|
|
767
|
-
return /* @__PURE__ */
|
|
750
|
+
const files = Array.from(fileList);
|
|
751
|
+
type === UploadFileType.floatImage ? commandService.executeCommand(InsertFloatImageOperation.id, { files }) : type === UploadFileType.cellImage && commandService.executeCommand(InsertCellImageOperation.id, { files }), fileInputRef.current && (fileInputRef.current.value = "");
|
|
752
|
+
}, "handleFileChange");
|
|
753
|
+
return /* @__PURE__ */ React.createElement("div", { onClick: handleButtonClick, className: styles$1.uploadFileMenu }, /* @__PURE__ */ React.createElement(
|
|
768
754
|
"input",
|
|
769
755
|
{
|
|
770
756
|
type: "file",
|
|
771
|
-
className:
|
|
772
|
-
ref:
|
|
773
|
-
onChange:
|
|
774
|
-
accept:
|
|
757
|
+
className: styles$1.uploadFileMenuInput,
|
|
758
|
+
ref: fileInputRef,
|
|
759
|
+
onChange: handleFileChange,
|
|
760
|
+
accept: imageAccept,
|
|
775
761
|
multiple: !0
|
|
776
762
|
}
|
|
777
763
|
));
|
|
778
|
-
},
|
|
779
|
-
function
|
|
764
|
+
}, "UploadFileMenu"), IMAGE_UPLOAD_ICON = "addition-and-subtraction-single", IMAGE_MENU_ID = "sheet.menu.image";
|
|
765
|
+
function ImageMenuFactory(accessor) {
|
|
780
766
|
return {
|
|
781
|
-
id:
|
|
782
|
-
type:
|
|
783
|
-
positions: [
|
|
784
|
-
group:
|
|
785
|
-
icon:
|
|
767
|
+
id: IMAGE_MENU_ID,
|
|
768
|
+
type: MenuItemType.SUBITEMS,
|
|
769
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
770
|
+
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
771
|
+
icon: IMAGE_UPLOAD_ICON,
|
|
786
772
|
tooltip: "sheetImage.title",
|
|
787
|
-
hidden$:
|
|
788
|
-
disabled$:
|
|
773
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
774
|
+
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
789
775
|
};
|
|
790
776
|
}
|
|
791
|
-
|
|
777
|
+
__name(ImageMenuFactory, "ImageMenuFactory");
|
|
778
|
+
function UploadFloatImageMenuFactory(_accessor) {
|
|
792
779
|
return {
|
|
793
|
-
id:
|
|
780
|
+
id: InsertFloatImageOperation.id,
|
|
794
781
|
title: "sheetImage.upload.float",
|
|
795
|
-
type:
|
|
782
|
+
type: MenuItemType.SELECTOR,
|
|
796
783
|
label: {
|
|
797
|
-
name:
|
|
784
|
+
name: COMPONENT_UPLOAD_FILE_MENU,
|
|
798
785
|
props: {
|
|
799
|
-
type:
|
|
786
|
+
type: UploadFileType.floatImage
|
|
800
787
|
}
|
|
801
788
|
},
|
|
802
|
-
positions: [
|
|
803
|
-
hidden$:
|
|
789
|
+
positions: [IMAGE_MENU_ID],
|
|
790
|
+
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SHEET)
|
|
804
791
|
};
|
|
805
792
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
793
|
+
__name(UploadFloatImageMenuFactory, "UploadFloatImageMenuFactory");
|
|
794
|
+
const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
|
|
795
|
+
imageCommonPanel,
|
|
796
|
+
imageCommonPanelGrid,
|
|
797
|
+
imageCommonPanelBorder,
|
|
798
|
+
imageCommonPanelTitle,
|
|
799
|
+
imageCommonPanelSubtitle,
|
|
800
|
+
imageCommonPanelRow,
|
|
801
|
+
imageCommonPanelRowVertical,
|
|
802
|
+
imageCommonPanelColumn,
|
|
803
|
+
imageCommonPanelColumnCenter,
|
|
804
|
+
imageCommonPanelInline,
|
|
805
|
+
imageCommonPanelSpan2,
|
|
806
|
+
imageCommonPanelSpan3,
|
|
807
|
+
imageCommonPanelInput,
|
|
808
|
+
sheetImageMenu,
|
|
809
|
+
sheetImageMenuInput
|
|
810
|
+
}, SheetDrawingAnchor = /* @__PURE__ */ __name((props) => {
|
|
811
|
+
var _a10;
|
|
812
|
+
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), { drawings } = props, drawingParam = drawings[0];
|
|
813
|
+
if (drawingParam == null)
|
|
826
814
|
return;
|
|
827
|
-
const { unitId
|
|
828
|
-
if (
|
|
815
|
+
const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
|
|
816
|
+
if (scene == null)
|
|
829
817
|
return;
|
|
830
|
-
const
|
|
831
|
-
function
|
|
832
|
-
const
|
|
833
|
-
return
|
|
834
|
-
const { oKey
|
|
835
|
-
if (
|
|
836
|
-
return
|
|
837
|
-
const { unitId:
|
|
838
|
-
|
|
839
|
-
unitId:
|
|
840
|
-
subUnitId
|
|
841
|
-
drawingId
|
|
842
|
-
anchorType
|
|
843
|
-
sheetTransform
|
|
844
|
-
drawingType
|
|
818
|
+
const transformer = scene.getTransformerByCreate(), [anchorShow, setAnchorShow] = useState(!0), type = (_a10 = drawingParam.anchorType) != null ? _a10 : SheetDrawingAnchorType.Position, [value, setValue] = useState(type);
|
|
819
|
+
function getUpdateParams(objects, drawingManagerService2) {
|
|
820
|
+
const params = [];
|
|
821
|
+
return objects.forEach((object) => {
|
|
822
|
+
const { oKey } = object, searchParam = drawingManagerService2.getDrawingOKey(oKey);
|
|
823
|
+
if (searchParam == null)
|
|
824
|
+
return params.push(null), !0;
|
|
825
|
+
const { unitId: unitId2, subUnitId, drawingId, drawingType, anchorType, sheetTransform } = searchParam;
|
|
826
|
+
params.push({
|
|
827
|
+
unitId: unitId2,
|
|
828
|
+
subUnitId,
|
|
829
|
+
drawingId,
|
|
830
|
+
anchorType,
|
|
831
|
+
sheetTransform,
|
|
832
|
+
drawingType
|
|
845
833
|
});
|
|
846
|
-
}),
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
}),
|
|
852
|
-
var
|
|
853
|
-
const { objects
|
|
854
|
-
if (
|
|
855
|
-
|
|
856
|
-
else if (
|
|
857
|
-
|
|
858
|
-
const
|
|
859
|
-
|
|
834
|
+
}), params;
|
|
835
|
+
}
|
|
836
|
+
__name(getUpdateParams, "getUpdateParams"), useEffect(() => {
|
|
837
|
+
const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
|
|
838
|
+
changeSelf === !0 && setAnchorShow(!1);
|
|
839
|
+
}), onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
|
|
840
|
+
var _a11;
|
|
841
|
+
const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
|
|
842
|
+
if (params.length === 0)
|
|
843
|
+
setAnchorShow(!1);
|
|
844
|
+
else if (params.length >= 1) {
|
|
845
|
+
setAnchorShow(!0);
|
|
846
|
+
const anchorType = ((_a11 = params[0]) == null ? void 0 : _a11.anchorType) || SheetDrawingAnchorType.Position;
|
|
847
|
+
setValue(anchorType);
|
|
860
848
|
}
|
|
861
849
|
});
|
|
862
850
|
return () => {
|
|
863
|
-
|
|
851
|
+
onChangeStartObserver.unsubscribe(), onClearControlObserver.unsubscribe();
|
|
864
852
|
};
|
|
865
853
|
}, []);
|
|
866
|
-
function
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
854
|
+
function handleChange(value2) {
|
|
855
|
+
setValue(value2);
|
|
856
|
+
const focusDrawings = drawingManagerService.getFocusDrawings();
|
|
857
|
+
if (focusDrawings.length === 0)
|
|
870
858
|
return;
|
|
871
|
-
const
|
|
872
|
-
unitId:
|
|
873
|
-
subUnitId:
|
|
874
|
-
drawingId:
|
|
875
|
-
anchorType:
|
|
859
|
+
const updateParams = focusDrawings.map((drawing) => ({
|
|
860
|
+
unitId: drawing.unitId,
|
|
861
|
+
subUnitId: drawing.subUnitId,
|
|
862
|
+
drawingId: drawing.drawingId,
|
|
863
|
+
anchorType: value2
|
|
876
864
|
}));
|
|
877
|
-
|
|
878
|
-
unitId:
|
|
879
|
-
drawings:
|
|
865
|
+
commandService.executeCommand(SetSheetDrawingCommand.id, {
|
|
866
|
+
unitId: focusDrawings[0].unitId,
|
|
867
|
+
drawings: updateParams
|
|
880
868
|
});
|
|
881
869
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
},
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
870
|
+
__name(handleChange, "handleChange");
|
|
871
|
+
const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
|
|
872
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: gridDisplay(anchorShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("drawing-anchor.title")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value, onChange: handleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Both }, localeService.t("drawing-anchor.both")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Position }, localeService.t("drawing-anchor.position")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.None }, localeService.t("drawing-anchor.none"))))));
|
|
873
|
+
}, "SheetDrawingAnchor"), SheetDrawingPanel = /* @__PURE__ */ __name(() => {
|
|
874
|
+
const drawingManagerService = useDependency(IDrawingManagerService), focusDrawings = drawingManagerService.getFocusDrawings(), [drawings, setDrawings] = useState(focusDrawings);
|
|
875
|
+
return useEffect(() => {
|
|
876
|
+
const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
|
|
877
|
+
setDrawings(drawings2);
|
|
889
878
|
});
|
|
890
879
|
return () => {
|
|
891
|
-
|
|
880
|
+
focusDispose.unsubscribe();
|
|
892
881
|
};
|
|
893
|
-
}, []), !!(
|
|
894
|
-
},
|
|
882
|
+
}, []), !!(drawings != null && drawings.length) && /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanel }, /* @__PURE__ */ React.createElement(DrawingCommonPanel, { drawings }), /* @__PURE__ */ React.createElement(SheetDrawingAnchor, { drawings }));
|
|
883
|
+
}, "SheetDrawingPanel"), MoveDrawingsCommand = {
|
|
895
884
|
id: "sheet.command.move-drawing",
|
|
896
|
-
type:
|
|
897
|
-
handler: (
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
885
|
+
type: CommandType.COMMAND,
|
|
886
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
887
|
+
const commandService = accessor.get(ICommandService), drawingManagerService = accessor.get(ISheetDrawingService), selectionRenderService = accessor.get(ISheetSelectionRenderService), { direction } = params, drawings = drawingManagerService.getFocusDrawings();
|
|
888
|
+
if (drawings.length === 0)
|
|
900
889
|
return !1;
|
|
901
|
-
const
|
|
902
|
-
const { transform
|
|
903
|
-
if (
|
|
890
|
+
const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
|
|
891
|
+
const { transform } = drawing;
|
|
892
|
+
if (transform == null)
|
|
904
893
|
return null;
|
|
905
|
-
const
|
|
906
|
-
return
|
|
907
|
-
...
|
|
908
|
-
transform:
|
|
909
|
-
sheetTransform:
|
|
894
|
+
const newTransform = { ...transform }, { left = 0, top = 0 } = transform;
|
|
895
|
+
return direction === Direction.UP ? newTransform.top = top - 1 : direction === Direction.DOWN ? newTransform.top = top + 1 : direction === Direction.LEFT ? newTransform.left = left - 1 : direction === Direction.RIGHT && (newTransform.left = left + 1), {
|
|
896
|
+
...drawing,
|
|
897
|
+
transform: newTransform,
|
|
898
|
+
sheetTransform: transformToDrawingPosition(newTransform, selectionRenderService)
|
|
910
899
|
};
|
|
911
|
-
}).filter((
|
|
912
|
-
return
|
|
913
|
-
unitId
|
|
914
|
-
drawings:
|
|
915
|
-
}) ? (
|
|
916
|
-
}
|
|
917
|
-
},
|
|
900
|
+
}).filter((drawing) => drawing != null);
|
|
901
|
+
return commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
|
|
902
|
+
unitId,
|
|
903
|
+
drawings: newDrawings
|
|
904
|
+
}) ? (commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]), !0) : !1;
|
|
905
|
+
}, "handler")
|
|
906
|
+
}, DeleteDrawingsCommand = {
|
|
918
907
|
id: "sheet.command.delete-drawing",
|
|
919
|
-
type:
|
|
920
|
-
handler: (
|
|
921
|
-
const
|
|
922
|
-
if (
|
|
908
|
+
type: CommandType.COMMAND,
|
|
909
|
+
handler: /* @__PURE__ */ __name((accessor) => {
|
|
910
|
+
const commandService = accessor.get(ICommandService), drawings = accessor.get(ISheetDrawingService).getFocusDrawings();
|
|
911
|
+
if (drawings.length === 0)
|
|
923
912
|
return !1;
|
|
924
|
-
const
|
|
925
|
-
const { unitId:
|
|
913
|
+
const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
|
|
914
|
+
const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawing;
|
|
926
915
|
return {
|
|
927
|
-
unitId:
|
|
928
|
-
subUnitId
|
|
929
|
-
drawingId
|
|
930
|
-
drawingType
|
|
916
|
+
unitId: unitId2,
|
|
917
|
+
subUnitId,
|
|
918
|
+
drawingId,
|
|
919
|
+
drawingType
|
|
931
920
|
};
|
|
932
921
|
});
|
|
933
|
-
return
|
|
934
|
-
unitId
|
|
935
|
-
drawings:
|
|
922
|
+
return commandService.executeCommand(RemoveSheetDrawingCommand.id, {
|
|
923
|
+
unitId,
|
|
924
|
+
drawings: newDrawings
|
|
936
925
|
});
|
|
937
|
-
}
|
|
926
|
+
}, "handler")
|
|
938
927
|
};
|
|
939
|
-
function
|
|
940
|
-
return !
|
|
928
|
+
function whenSheetDrawingFocused(contextService) {
|
|
929
|
+
return !contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) && !contextService.getContextValue(EDITOR_ACTIVATED) && contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
|
|
941
930
|
}
|
|
942
|
-
|
|
943
|
-
|
|
931
|
+
__name(whenSheetDrawingFocused, "whenSheetDrawingFocused");
|
|
932
|
+
const MoveDrawingDownShortcutItem = {
|
|
933
|
+
id: MoveDrawingsCommand.id,
|
|
944
934
|
description: "shortcut.sheet.drawing-move-down",
|
|
945
935
|
group: "4_sheet-drawing-view",
|
|
946
|
-
binding:
|
|
936
|
+
binding: KeyCode.ARROW_DOWN,
|
|
947
937
|
priority: 100,
|
|
948
|
-
preconditions:
|
|
938
|
+
preconditions: whenSheetDrawingFocused,
|
|
949
939
|
staticParameters: {
|
|
950
|
-
direction:
|
|
940
|
+
direction: Direction.DOWN
|
|
951
941
|
}
|
|
952
|
-
},
|
|
953
|
-
id:
|
|
942
|
+
}, MoveDrawingUpShortcutItem = {
|
|
943
|
+
id: MoveDrawingsCommand.id,
|
|
954
944
|
description: "shortcut.sheet.drawing-move-up",
|
|
955
945
|
group: "4_sheet-drawing-view",
|
|
956
|
-
binding:
|
|
946
|
+
binding: KeyCode.ARROW_UP,
|
|
957
947
|
priority: 100,
|
|
958
|
-
preconditions:
|
|
948
|
+
preconditions: whenSheetDrawingFocused,
|
|
959
949
|
staticParameters: {
|
|
960
|
-
direction:
|
|
950
|
+
direction: Direction.UP
|
|
961
951
|
}
|
|
962
|
-
},
|
|
963
|
-
id:
|
|
952
|
+
}, MoveDrawingLeftShortcutItem = {
|
|
953
|
+
id: MoveDrawingsCommand.id,
|
|
964
954
|
description: "shortcut.sheet.drawing-move-left",
|
|
965
955
|
group: "4_sheet-drawing-view",
|
|
966
|
-
binding:
|
|
956
|
+
binding: KeyCode.ARROW_LEFT,
|
|
967
957
|
priority: 100,
|
|
968
|
-
preconditions:
|
|
958
|
+
preconditions: whenSheetDrawingFocused,
|
|
969
959
|
staticParameters: {
|
|
970
|
-
direction:
|
|
960
|
+
direction: Direction.LEFT
|
|
971
961
|
}
|
|
972
|
-
},
|
|
973
|
-
id:
|
|
962
|
+
}, MoveDrawingRightShortcutItem = {
|
|
963
|
+
id: MoveDrawingsCommand.id,
|
|
974
964
|
description: "shortcut.sheet.drawing-move-right",
|
|
975
965
|
group: "4_sheet-drawing-view",
|
|
976
|
-
binding:
|
|
966
|
+
binding: KeyCode.ARROW_RIGHT,
|
|
977
967
|
priority: 100,
|
|
978
|
-
preconditions:
|
|
968
|
+
preconditions: whenSheetDrawingFocused,
|
|
979
969
|
staticParameters: {
|
|
980
|
-
direction:
|
|
970
|
+
direction: Direction.RIGHT
|
|
981
971
|
}
|
|
982
|
-
},
|
|
983
|
-
id:
|
|
972
|
+
}, DeleteDrawingsShortcutItem = {
|
|
973
|
+
id: DeleteDrawingsCommand.id,
|
|
984
974
|
description: "shortcut.sheet.drawing-delete",
|
|
985
975
|
group: "4_sheet-drawing-view",
|
|
986
976
|
// when focusing on any other input tag do not trigger this shortcut
|
|
987
|
-
preconditions:
|
|
988
|
-
binding:
|
|
989
|
-
mac:
|
|
977
|
+
preconditions: whenSheetDrawingFocused,
|
|
978
|
+
binding: KeyCode.DELETE,
|
|
979
|
+
mac: KeyCode.BACKSPACE
|
|
990
980
|
};
|
|
991
|
-
var
|
|
992
|
-
for (var
|
|
993
|
-
(
|
|
994
|
-
return
|
|
995
|
-
},
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
981
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
982
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
983
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
984
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
985
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
|
|
986
|
+
const DefaultSheetsDrawingConfig = {};
|
|
987
|
+
var _a3;
|
|
988
|
+
let SheetDrawingUIController = (_a3 = class extends Disposable {
|
|
989
|
+
constructor(_config, _injector, _componentManager, _menuService, _commandService, _shortcutService) {
|
|
990
|
+
super(), this._config = _config, this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
|
|
1000
991
|
}
|
|
1001
992
|
_initCustomComponents() {
|
|
1002
|
-
const
|
|
1003
|
-
this.disposeWithMe(
|
|
993
|
+
const componentManager = this._componentManager;
|
|
994
|
+
this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_UPLOAD_FILE_MENU, UploadFileMenu)), this.disposeWithMe(componentManager.register(COMPONENT_SHEET_DRAWING_PANEL, SheetDrawingPanel));
|
|
1004
995
|
}
|
|
1005
996
|
_initMenus() {
|
|
1006
|
-
const { menu
|
|
997
|
+
const { menu = {} } = this._config;
|
|
1007
998
|
[
|
|
1008
|
-
|
|
1009
|
-
|
|
999
|
+
ImageMenuFactory,
|
|
1000
|
+
UploadFloatImageMenuFactory
|
|
1010
1001
|
// UploadCellImageMenuFactory,
|
|
1011
|
-
].forEach((
|
|
1012
|
-
this._menuService.addMenuItem(
|
|
1002
|
+
].forEach((menuFactory) => {
|
|
1003
|
+
this._menuService.addMenuItem(menuFactory(this._injector), menu);
|
|
1013
1004
|
});
|
|
1014
1005
|
}
|
|
1015
1006
|
_initCommands() {
|
|
1016
1007
|
[
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
].forEach((
|
|
1008
|
+
InsertFloatImageOperation,
|
|
1009
|
+
InsertCellImageOperation,
|
|
1010
|
+
InsertSheetDrawingCommand,
|
|
1011
|
+
RemoveSheetDrawingCommand,
|
|
1012
|
+
SetSheetDrawingCommand,
|
|
1013
|
+
SidebarSheetDrawingOperation,
|
|
1014
|
+
ClearSheetDrawingTransformerOperation,
|
|
1015
|
+
EditSheetDrawingOperation,
|
|
1016
|
+
GroupSheetDrawingCommand,
|
|
1017
|
+
UngroupSheetDrawingCommand,
|
|
1018
|
+
MoveDrawingsCommand,
|
|
1019
|
+
DeleteDrawingsCommand,
|
|
1020
|
+
SetDrawingArrangeCommand
|
|
1021
|
+
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
1031
1022
|
}
|
|
1032
1023
|
_initShortcuts() {
|
|
1033
1024
|
[
|
|
1034
1025
|
// sheet drawing shortcuts
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
].forEach((
|
|
1041
|
-
this.disposeWithMe(this._shortcutService.registerShortcut(
|
|
1026
|
+
MoveDrawingDownShortcutItem,
|
|
1027
|
+
MoveDrawingUpShortcutItem,
|
|
1028
|
+
MoveDrawingLeftShortcutItem,
|
|
1029
|
+
MoveDrawingRightShortcutItem,
|
|
1030
|
+
DeleteDrawingsShortcutItem
|
|
1031
|
+
].forEach((item) => {
|
|
1032
|
+
this.disposeWithMe(this._shortcutService.registerShortcut(item));
|
|
1042
1033
|
});
|
|
1043
1034
|
}
|
|
1044
1035
|
_init() {
|
|
1045
1036
|
this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
|
|
1046
1037
|
}
|
|
1047
|
-
};
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
],
|
|
1056
|
-
var
|
|
1057
|
-
for (var
|
|
1058
|
-
(
|
|
1059
|
-
return
|
|
1060
|
-
},
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
],
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1038
|
+
}, __name(_a3, "SheetDrawingUIController"), _a3);
|
|
1039
|
+
SheetDrawingUIController = __decorateClass$6([
|
|
1040
|
+
OnLifecycle(LifecycleStages.Rendered, SheetDrawingUIController),
|
|
1041
|
+
__decorateParam$6(1, Inject(Injector)),
|
|
1042
|
+
__decorateParam$6(2, Inject(ComponentManager)),
|
|
1043
|
+
__decorateParam$6(3, IMenuService),
|
|
1044
|
+
__decorateParam$6(4, ICommandService),
|
|
1045
|
+
__decorateParam$6(5, IShortcutService)
|
|
1046
|
+
], SheetDrawingUIController);
|
|
1047
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1048
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1049
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1050
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
1051
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
|
|
1052
|
+
const UPDATE_COMMANDS = [
|
|
1053
|
+
InsertRowCommand.id,
|
|
1054
|
+
InsertColCommand.id,
|
|
1055
|
+
RemoveRowCommand.id,
|
|
1056
|
+
RemoveColCommand.id,
|
|
1057
|
+
DeleteRangeMoveLeftCommand.id,
|
|
1058
|
+
DeleteRangeMoveUpCommand.id,
|
|
1059
|
+
InsertRangeMoveDownCommand.id,
|
|
1060
|
+
InsertRangeMoveRightCommand.id,
|
|
1061
|
+
DeltaRowHeightCommand.id,
|
|
1062
|
+
SetRowHeightCommand.id,
|
|
1063
|
+
DeltaColumnWidthCommand.id,
|
|
1064
|
+
SetColWidthCommand.id,
|
|
1065
|
+
SetRowHiddenCommand.id,
|
|
1066
|
+
SetSpecificRowsVisibleCommand.id,
|
|
1067
|
+
SetSpecificColsVisibleCommand.id,
|
|
1068
|
+
SetColHiddenCommand.id
|
|
1069
|
+
], REFRESH_MUTATIONS = [
|
|
1070
|
+
SetRowVisibleMutation.id,
|
|
1071
|
+
SetRowHiddenMutation.id,
|
|
1072
|
+
SetColVisibleMutation.id,
|
|
1073
|
+
SetColHiddenMutation.id,
|
|
1074
|
+
SetWorksheetRowHeightMutation.id,
|
|
1075
|
+
SetWorksheetColWidthMutation.id
|
|
1085
1076
|
];
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
// TODO@wzhudev: selection render service would be a render unit, we we cannot
|
|
1091
|
-
// easily access it here.
|
|
1092
|
-
get _selectionRenderService() {
|
|
1093
|
-
return this._renderManagerService.getRenderById(
|
|
1094
|
-
this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
|
|
1095
|
-
).with(xe);
|
|
1096
|
-
}
|
|
1097
|
-
get _skeletonManagerService() {
|
|
1098
|
-
return this._renderManagerService.getRenderById(
|
|
1099
|
-
this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
|
|
1100
|
-
).with(se);
|
|
1101
|
-
}
|
|
1102
|
-
_init() {
|
|
1103
|
-
this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
|
|
1077
|
+
var _a4;
|
|
1078
|
+
let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
|
|
1079
|
+
constructor(_context, _commandService, _selectionRenderService, _skeletonManagerService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService) {
|
|
1080
|
+
super(), this._context = _context, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._skeletonManagerService = _skeletonManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._univerInstanceService = _univerInstanceService, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
|
|
1104
1081
|
}
|
|
1105
1082
|
_sheetInterceptorListener() {
|
|
1106
1083
|
this.disposeWithMe(
|
|
1107
1084
|
this._sheetInterceptorService.interceptCommand({
|
|
1108
|
-
getMutations: (
|
|
1109
|
-
if (!
|
|
1085
|
+
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
1086
|
+
if (!UPDATE_COMMANDS.includes(commandInfo.id))
|
|
1110
1087
|
return { redos: [], undos: [] };
|
|
1111
|
-
if (
|
|
1088
|
+
if (commandInfo.params == null)
|
|
1112
1089
|
return { redos: [], undos: [] };
|
|
1113
|
-
const
|
|
1114
|
-
if (
|
|
1115
|
-
return this._moveRowInterceptor(
|
|
1116
|
-
if (
|
|
1117
|
-
return this._moveColInterceptor(
|
|
1118
|
-
if (
|
|
1119
|
-
return this._moveRowInterceptor(
|
|
1120
|
-
if (
|
|
1121
|
-
return this._moveColInterceptor(
|
|
1122
|
-
if (
|
|
1123
|
-
const { range
|
|
1090
|
+
const cId = commandInfo.id;
|
|
1091
|
+
if (cId === InsertRowCommand.id)
|
|
1092
|
+
return this._moveRowInterceptor(commandInfo.params, "insert");
|
|
1093
|
+
if (cId === InsertColCommand.id)
|
|
1094
|
+
return this._moveColInterceptor(commandInfo.params, "insert");
|
|
1095
|
+
if (cId === RemoveRowCommand.id)
|
|
1096
|
+
return this._moveRowInterceptor(commandInfo.params, "remove");
|
|
1097
|
+
if (cId === RemoveColCommand.id)
|
|
1098
|
+
return this._moveColInterceptor(commandInfo.params, "remove");
|
|
1099
|
+
if (cId === DeleteRangeMoveLeftCommand.id) {
|
|
1100
|
+
const { range } = commandInfo.params;
|
|
1124
1101
|
return this._getRangeMoveUndo(
|
|
1125
|
-
|
|
1102
|
+
range,
|
|
1126
1103
|
0
|
|
1127
1104
|
/* deleteLeft */
|
|
1128
1105
|
);
|
|
1129
|
-
} else if (
|
|
1130
|
-
const { range
|
|
1106
|
+
} else if (cId === DeleteRangeMoveUpCommand.id) {
|
|
1107
|
+
const { range } = commandInfo.params;
|
|
1131
1108
|
return this._getRangeMoveUndo(
|
|
1132
|
-
|
|
1109
|
+
range,
|
|
1133
1110
|
1
|
|
1134
1111
|
/* deleteUp */
|
|
1135
1112
|
);
|
|
1136
|
-
} else if (
|
|
1137
|
-
const { range
|
|
1113
|
+
} else if (cId === InsertRangeMoveDownCommand.id) {
|
|
1114
|
+
const { range } = commandInfo.params;
|
|
1138
1115
|
return this._getRangeMoveUndo(
|
|
1139
|
-
|
|
1116
|
+
range,
|
|
1140
1117
|
2
|
|
1141
1118
|
/* insertDown */
|
|
1142
1119
|
);
|
|
1143
|
-
} else if (
|
|
1144
|
-
const { range
|
|
1120
|
+
} else if (cId === InsertRangeMoveRightCommand.id) {
|
|
1121
|
+
const { range } = commandInfo.params;
|
|
1145
1122
|
return this._getRangeMoveUndo(
|
|
1146
|
-
|
|
1123
|
+
range,
|
|
1147
1124
|
3
|
|
1148
1125
|
/* insertRight */
|
|
1149
1126
|
);
|
|
1150
|
-
} else if (
|
|
1151
|
-
const
|
|
1152
|
-
return this._getDrawingUndoForRowVisible(
|
|
1153
|
-
} else if (
|
|
1154
|
-
const
|
|
1155
|
-
return this._getDrawingUndoForColVisible(
|
|
1156
|
-
} else if (
|
|
1157
|
-
const
|
|
1158
|
-
return this._getDrawingUndoForRowAndColSize(
|
|
1127
|
+
} else if (cId === SetRowHiddenCommand.id || cId === SetSpecificRowsVisibleCommand.id) {
|
|
1128
|
+
const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
|
|
1129
|
+
return this._getDrawingUndoForRowVisible(unitId, subUnitId, ranges);
|
|
1130
|
+
} else if (cId === SetSpecificColsVisibleCommand.id || cId === SetColHiddenCommand.id) {
|
|
1131
|
+
const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
|
|
1132
|
+
return this._getDrawingUndoForColVisible(unitId, subUnitId, ranges);
|
|
1133
|
+
} else if (cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id || cId === DeltaColumnWidthCommand.id || cId === SetColWidthCommand.id) {
|
|
1134
|
+
const params = commandInfo.params, { unitId, subUnitId, ranges } = params, isRow = cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id;
|
|
1135
|
+
return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow);
|
|
1159
1136
|
}
|
|
1160
1137
|
return { redos: [], undos: [] };
|
|
1161
|
-
}
|
|
1138
|
+
}, "getMutations")
|
|
1162
1139
|
})
|
|
1163
1140
|
);
|
|
1164
1141
|
}
|
|
1165
|
-
_getRangeMoveUndo(
|
|
1166
|
-
const
|
|
1167
|
-
if (
|
|
1142
|
+
_getRangeMoveUndo(range, type) {
|
|
1143
|
+
const newParams = getSheetCommandTarget(this._univerInstanceService);
|
|
1144
|
+
if (newParams == null)
|
|
1168
1145
|
return { redos: [], undos: [] };
|
|
1169
|
-
const
|
|
1170
|
-
if (Object.keys(
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
}),
|
|
1146
|
+
const unitId = newParams.unitId, subUnitId = newParams.subUnitId, redos = [], undos = [], drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
|
|
1147
|
+
if (Object.keys(drawingData).forEach((drawingId) => {
|
|
1148
|
+
const drawing = drawingData[drawingId], { updateDrawings: updateDrawingsPart, deleteDrawings: deleteDrawingsPart } = this._getUpdateOrDeleteDrawings(range, type, drawing);
|
|
1149
|
+
updateDrawings.push(...updateDrawingsPart), deleteDrawings.push(...deleteDrawingsPart);
|
|
1150
|
+
}), updateDrawings.length === 0 && deleteDrawings.length === 0)
|
|
1174
1151
|
return { redos: [], undos: [] };
|
|
1175
|
-
if (
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1152
|
+
if (updateDrawings.length > 0) {
|
|
1153
|
+
const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
|
|
1154
|
+
redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
|
|
1178
1155
|
}
|
|
1179
|
-
if (
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1156
|
+
if (deleteDrawings.length > 0) {
|
|
1157
|
+
const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
|
|
1158
|
+
redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
|
|
1182
1159
|
}
|
|
1183
|
-
return
|
|
1184
|
-
redos
|
|
1185
|
-
undos
|
|
1160
|
+
return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
|
|
1161
|
+
redos,
|
|
1162
|
+
undos
|
|
1186
1163
|
};
|
|
1187
1164
|
}
|
|
1188
|
-
_getUpdateOrDeleteDrawings(
|
|
1189
|
-
const
|
|
1190
|
-
if (
|
|
1165
|
+
_getUpdateOrDeleteDrawings(range, type, drawing) {
|
|
1166
|
+
const updateDrawings = [], deleteDrawings = [], { sheetTransform, anchorType = SheetDrawingAnchorType.Position, transform, unitId, subUnitId, drawingId } = drawing, { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
|
|
1167
|
+
if (sheetTransform == null || transform == null)
|
|
1191
1168
|
return {
|
|
1192
|
-
updateDrawings
|
|
1193
|
-
deleteDrawings
|
|
1169
|
+
updateDrawings,
|
|
1170
|
+
deleteDrawings
|
|
1194
1171
|
};
|
|
1195
|
-
const { startRow
|
|
1196
|
-
let
|
|
1197
|
-
if (
|
|
1198
|
-
if (
|
|
1199
|
-
|
|
1172
|
+
const { startRow, endRow, startColumn, endColumn } = range;
|
|
1173
|
+
let newSheetTransform = null, newTransform = null;
|
|
1174
|
+
if (type === 0 && fromRow >= startRow && toRow <= endRow)
|
|
1175
|
+
if (fromColumn >= startColumn && toColumn <= endColumn)
|
|
1176
|
+
deleteDrawings.push({ unitId, subUnitId, drawingId });
|
|
1200
1177
|
else {
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1178
|
+
const param = this._shrinkCol(sheetTransform, transform, startColumn, endColumn, anchorType);
|
|
1179
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1203
1180
|
}
|
|
1204
|
-
else if (
|
|
1205
|
-
if (
|
|
1206
|
-
|
|
1181
|
+
else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn)
|
|
1182
|
+
if (fromRow >= startRow && toRow <= endRow)
|
|
1183
|
+
deleteDrawings.push({ unitId, subUnitId, drawingId });
|
|
1207
1184
|
else {
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1185
|
+
const param = this._shrinkRow(sheetTransform, transform, startRow, endRow, anchorType);
|
|
1186
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1210
1187
|
}
|
|
1211
|
-
else if (
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1214
|
-
} else if (
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1188
|
+
else if (type === 2) {
|
|
1189
|
+
const param = this._expandRow(sheetTransform, transform, startRow, endRow, anchorType);
|
|
1190
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1191
|
+
} else if (type === 3) {
|
|
1192
|
+
const param = this._expandCol(sheetTransform, transform, startColumn, endColumn, anchorType);
|
|
1193
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1217
1194
|
}
|
|
1218
|
-
if (
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1195
|
+
if (newSheetTransform != null && newTransform != null) {
|
|
1196
|
+
const newTransform2 = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1197
|
+
updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform2 });
|
|
1221
1198
|
}
|
|
1222
|
-
return { updateDrawings
|
|
1199
|
+
return { updateDrawings, deleteDrawings };
|
|
1223
1200
|
}
|
|
1224
|
-
_remainDrawingSize(
|
|
1225
|
-
const
|
|
1226
|
-
|
|
1227
|
-
...
|
|
1228
|
-
sheetTransform:
|
|
1201
|
+
_remainDrawingSize(transform, updateDrawings, drawing) {
|
|
1202
|
+
const newSheetTransform = transformToDrawingPosition({ ...transform }, this._selectionRenderService);
|
|
1203
|
+
newSheetTransform != null && updateDrawings.push({
|
|
1204
|
+
...drawing,
|
|
1205
|
+
sheetTransform: newSheetTransform
|
|
1229
1206
|
});
|
|
1230
1207
|
}
|
|
1231
1208
|
// eslint-disable-next-line max-lines-per-function
|
|
1232
|
-
_getDrawingUndoForColVisible(
|
|
1233
|
-
const
|
|
1234
|
-
if (Object.keys(
|
|
1235
|
-
const
|
|
1236
|
-
if (
|
|
1237
|
-
this._remainDrawingSize(
|
|
1209
|
+
_getDrawingUndoForColVisible(unitId, subUnitId, ranges) {
|
|
1210
|
+
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
|
|
1211
|
+
if (Object.keys(drawingData).forEach((drawingId) => {
|
|
1212
|
+
const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
1213
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1214
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1238
1215
|
else {
|
|
1239
|
-
const { from
|
|
1240
|
-
for (let
|
|
1241
|
-
const
|
|
1242
|
-
if (
|
|
1216
|
+
const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
|
|
1217
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
1218
|
+
const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
|
|
1219
|
+
if (toColumn < startColumn)
|
|
1243
1220
|
continue;
|
|
1244
|
-
if (
|
|
1245
|
-
let
|
|
1246
|
-
if (
|
|
1247
|
-
const
|
|
1248
|
-
if (
|
|
1221
|
+
if (anchorType === SheetDrawingAnchorType.Position) {
|
|
1222
|
+
let newSheetTransform2 = null, newTransform2 = null;
|
|
1223
|
+
if (fromColumn >= startColumn && fromColumn <= endColumn) {
|
|
1224
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
|
|
1225
|
+
if (selectionCell == null)
|
|
1249
1226
|
return;
|
|
1250
|
-
|
|
1227
|
+
newTransform2 = { ...transform, left: selectionCell.startX };
|
|
1251
1228
|
}
|
|
1252
|
-
if (
|
|
1253
|
-
|
|
1229
|
+
if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
|
|
1230
|
+
updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
|
|
1254
1231
|
break;
|
|
1255
1232
|
}
|
|
1256
|
-
this._remainDrawingSize(
|
|
1233
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1257
1234
|
continue;
|
|
1258
1235
|
}
|
|
1259
|
-
if (
|
|
1236
|
+
if (fromColumn >= startColumn && toColumn <= endColumn)
|
|
1260
1237
|
continue;
|
|
1261
|
-
let
|
|
1262
|
-
if (
|
|
1263
|
-
const
|
|
1264
|
-
if (
|
|
1238
|
+
let newSheetTransform = null, newTransform = null;
|
|
1239
|
+
if (fromColumn >= startColumn && fromColumn <= endColumn) {
|
|
1240
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
|
|
1241
|
+
if (selectionCell == null)
|
|
1265
1242
|
return;
|
|
1266
|
-
|
|
1267
|
-
...
|
|
1268
|
-
left: (
|
|
1269
|
-
width: ((
|
|
1243
|
+
newTransform = {
|
|
1244
|
+
...transform,
|
|
1245
|
+
left: (selectionCell == null ? void 0 : selectionCell.startX) || 0,
|
|
1246
|
+
width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
|
|
1270
1247
|
};
|
|
1271
|
-
} else if (
|
|
1272
|
-
const
|
|
1273
|
-
if (
|
|
1248
|
+
} else if (toColumn >= startColumn && toColumn <= endColumn) {
|
|
1249
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn: toColumn, startRow: from.row, endRow: to.row });
|
|
1250
|
+
if (selectionCell == null)
|
|
1274
1251
|
return;
|
|
1275
|
-
|
|
1276
|
-
...
|
|
1277
|
-
left:
|
|
1252
|
+
newTransform = {
|
|
1253
|
+
...transform,
|
|
1254
|
+
left: selectionCell.startX - ((transform == null ? void 0 : transform.width) || 0)
|
|
1278
1255
|
};
|
|
1279
1256
|
} else {
|
|
1280
|
-
const
|
|
1281
|
-
if (
|
|
1257
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn, startRow: from.row, endRow: to.row });
|
|
1258
|
+
if (selectionCell == null)
|
|
1282
1259
|
return;
|
|
1283
|
-
if (
|
|
1284
|
-
...
|
|
1285
|
-
width: ((
|
|
1286
|
-
},
|
|
1287
|
-
|
|
1260
|
+
if (newTransform = {
|
|
1261
|
+
...transform,
|
|
1262
|
+
width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
|
|
1263
|
+
}, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
|
|
1264
|
+
preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
|
|
1288
1265
|
break;
|
|
1289
1266
|
}
|
|
1290
1267
|
}
|
|
1291
|
-
if (
|
|
1292
|
-
|
|
1268
|
+
if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
|
|
1269
|
+
updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
|
|
1293
1270
|
break;
|
|
1294
1271
|
} else
|
|
1295
|
-
this._remainDrawingSize(
|
|
1272
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1296
1273
|
}
|
|
1297
1274
|
}
|
|
1298
|
-
}),
|
|
1275
|
+
}), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
|
|
1299
1276
|
return { redos: [], undos: [] };
|
|
1300
|
-
const { redos
|
|
1301
|
-
if (
|
|
1302
|
-
const { redos:
|
|
1303
|
-
|
|
1277
|
+
const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
|
|
1278
|
+
if (preUpdateDrawings.length > 0) {
|
|
1279
|
+
const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
|
|
1280
|
+
preRedos.push(...redos2), preUndos.push(...undos2);
|
|
1304
1281
|
}
|
|
1305
1282
|
return {
|
|
1306
|
-
redos
|
|
1307
|
-
undos
|
|
1308
|
-
preRedos
|
|
1309
|
-
preUndos
|
|
1283
|
+
redos,
|
|
1284
|
+
undos,
|
|
1285
|
+
preRedos,
|
|
1286
|
+
preUndos
|
|
1310
1287
|
};
|
|
1311
1288
|
}
|
|
1312
|
-
_createUndoAndRedoMutation(
|
|
1313
|
-
const
|
|
1314
|
-
{ id:
|
|
1315
|
-
{ id:
|
|
1316
|
-
],
|
|
1317
|
-
{ id:
|
|
1318
|
-
{ id:
|
|
1289
|
+
_createUndoAndRedoMutation(unitId, subUnitId, updateDrawings) {
|
|
1290
|
+
const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp, redos = [
|
|
1291
|
+
{ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
|
|
1292
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
|
|
1293
|
+
], undos = [
|
|
1294
|
+
{ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
|
|
1295
|
+
{ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
|
|
1319
1296
|
];
|
|
1320
1297
|
return {
|
|
1321
|
-
redos
|
|
1322
|
-
undos
|
|
1298
|
+
redos,
|
|
1299
|
+
undos
|
|
1323
1300
|
};
|
|
1324
1301
|
}
|
|
1325
1302
|
// eslint-disable-next-line max-lines-per-function
|
|
1326
|
-
_getDrawingUndoForRowVisible(
|
|
1327
|
-
const
|
|
1328
|
-
if (Object.keys(
|
|
1329
|
-
const
|
|
1330
|
-
if (
|
|
1331
|
-
this._remainDrawingSize(
|
|
1303
|
+
_getDrawingUndoForRowVisible(unitId, subUnitId, ranges) {
|
|
1304
|
+
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
|
|
1305
|
+
if (Object.keys(drawingData).forEach((drawingId) => {
|
|
1306
|
+
const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
1307
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1308
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1332
1309
|
else {
|
|
1333
|
-
const { from
|
|
1334
|
-
for (let
|
|
1335
|
-
const
|
|
1336
|
-
if (
|
|
1310
|
+
const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
|
|
1311
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
1312
|
+
const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
|
|
1313
|
+
if (toRow < startRow)
|
|
1337
1314
|
continue;
|
|
1338
|
-
if (
|
|
1339
|
-
let
|
|
1340
|
-
if (
|
|
1341
|
-
const
|
|
1342
|
-
if (
|
|
1315
|
+
if (anchorType === SheetDrawingAnchorType.Position) {
|
|
1316
|
+
let newSheetTransform2 = null, newTransform2 = null;
|
|
1317
|
+
if (fromRow >= startRow && fromRow <= endRow) {
|
|
1318
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
|
|
1319
|
+
if (selectionCell == null)
|
|
1343
1320
|
return;
|
|
1344
|
-
|
|
1321
|
+
newTransform2 = { ...transform, top: selectionCell.startY };
|
|
1345
1322
|
}
|
|
1346
|
-
if (
|
|
1347
|
-
|
|
1323
|
+
if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
|
|
1324
|
+
updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
|
|
1348
1325
|
break;
|
|
1349
1326
|
}
|
|
1350
|
-
this._remainDrawingSize(
|
|
1327
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1351
1328
|
continue;
|
|
1352
1329
|
}
|
|
1353
|
-
if (
|
|
1330
|
+
if (fromRow >= startRow && toRow <= endRow)
|
|
1354
1331
|
continue;
|
|
1355
|
-
let
|
|
1356
|
-
if (
|
|
1357
|
-
const
|
|
1358
|
-
if (
|
|
1332
|
+
let newSheetTransform = null, newTransform = null;
|
|
1333
|
+
if (fromRow >= startRow && fromRow <= endRow) {
|
|
1334
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
|
|
1335
|
+
if (selectionCell == null)
|
|
1359
1336
|
return;
|
|
1360
|
-
|
|
1361
|
-
...
|
|
1362
|
-
top: (
|
|
1363
|
-
height: ((
|
|
1337
|
+
newTransform = {
|
|
1338
|
+
...transform,
|
|
1339
|
+
top: (selectionCell == null ? void 0 : selectionCell.startY) || 0,
|
|
1340
|
+
height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
|
|
1364
1341
|
};
|
|
1365
|
-
} else if (
|
|
1366
|
-
const
|
|
1367
|
-
if (
|
|
1342
|
+
} else if (toRow >= startRow && toRow <= endRow) {
|
|
1343
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow: toRow });
|
|
1344
|
+
if (selectionCell == null)
|
|
1368
1345
|
return;
|
|
1369
|
-
|
|
1370
|
-
...
|
|
1371
|
-
top:
|
|
1346
|
+
newTransform = {
|
|
1347
|
+
...transform,
|
|
1348
|
+
top: selectionCell.startY - ((transform == null ? void 0 : transform.height) || 0)
|
|
1372
1349
|
};
|
|
1373
1350
|
} else {
|
|
1374
|
-
const
|
|
1375
|
-
if (
|
|
1351
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow });
|
|
1352
|
+
if (selectionCell == null)
|
|
1376
1353
|
return;
|
|
1377
|
-
if (
|
|
1378
|
-
...
|
|
1379
|
-
height: ((
|
|
1380
|
-
},
|
|
1381
|
-
|
|
1354
|
+
if (newTransform = {
|
|
1355
|
+
...transform,
|
|
1356
|
+
height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
|
|
1357
|
+
}, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
|
|
1358
|
+
preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
|
|
1382
1359
|
break;
|
|
1383
1360
|
}
|
|
1384
1361
|
}
|
|
1385
|
-
if (
|
|
1386
|
-
|
|
1362
|
+
if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
|
|
1363
|
+
updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
|
|
1387
1364
|
break;
|
|
1388
1365
|
} else
|
|
1389
|
-
this._remainDrawingSize(
|
|
1366
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1390
1367
|
}
|
|
1391
1368
|
}
|
|
1392
|
-
}),
|
|
1369
|
+
}), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
|
|
1393
1370
|
return { redos: [], undos: [] };
|
|
1394
|
-
const { redos
|
|
1395
|
-
if (
|
|
1396
|
-
const { redos:
|
|
1397
|
-
|
|
1371
|
+
const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
|
|
1372
|
+
if (preUpdateDrawings.length > 0) {
|
|
1373
|
+
const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
|
|
1374
|
+
preRedos.push(...redos2), preUndos.push(...undos2);
|
|
1398
1375
|
}
|
|
1399
1376
|
return {
|
|
1400
|
-
redos
|
|
1401
|
-
undos
|
|
1402
|
-
preRedos
|
|
1403
|
-
preUndos
|
|
1377
|
+
redos,
|
|
1378
|
+
undos,
|
|
1379
|
+
preRedos,
|
|
1380
|
+
preUndos
|
|
1404
1381
|
};
|
|
1405
1382
|
}
|
|
1406
|
-
_getDrawingUndoForRowAndColSize(
|
|
1407
|
-
const
|
|
1408
|
-
return Object.keys(
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1411
|
-
this._remainDrawingSize(
|
|
1383
|
+
_getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow) {
|
|
1384
|
+
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
|
|
1385
|
+
return Object.keys(drawingData).forEach((drawingId) => {
|
|
1386
|
+
const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
1387
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1388
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1412
1389
|
else {
|
|
1413
|
-
const { from
|
|
1414
|
-
for (let
|
|
1415
|
-
const
|
|
1416
|
-
if (
|
|
1390
|
+
const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
|
|
1391
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
1392
|
+
const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
|
|
1393
|
+
if (toRow < startRow || toColumn < startColumn)
|
|
1417
1394
|
continue;
|
|
1418
|
-
if (
|
|
1419
|
-
this._remainDrawingSize(
|
|
1395
|
+
if (anchorType === SheetDrawingAnchorType.Position && (fromRow <= startRow && toRow >= endRow || fromColumn <= startColumn && toColumn >= endColumn)) {
|
|
1396
|
+
this._remainDrawingSize(transform, updateDrawings, drawing);
|
|
1420
1397
|
continue;
|
|
1421
1398
|
}
|
|
1422
|
-
const
|
|
1423
|
-
{ ...
|
|
1399
|
+
const newTransform = drawingPositionToTransform(
|
|
1400
|
+
{ ...sheetTransform },
|
|
1424
1401
|
this._selectionRenderService,
|
|
1425
1402
|
this._skeletonManagerService
|
|
1426
1403
|
);
|
|
1427
|
-
if (
|
|
1428
|
-
|
|
1429
|
-
...
|
|
1430
|
-
transform:
|
|
1404
|
+
if (newTransform != null) {
|
|
1405
|
+
updateDrawings.push({
|
|
1406
|
+
...drawing,
|
|
1407
|
+
transform: newTransform
|
|
1431
1408
|
});
|
|
1432
1409
|
break;
|
|
1433
1410
|
}
|
|
1434
1411
|
}
|
|
1435
1412
|
}
|
|
1436
|
-
}),
|
|
1413
|
+
}), updateDrawings.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
|
|
1437
1414
|
}
|
|
1438
|
-
_getUnitIdAndSubUnitId(
|
|
1439
|
-
let
|
|
1440
|
-
if (
|
|
1441
|
-
|
|
1415
|
+
_getUnitIdAndSubUnitId(params, type) {
|
|
1416
|
+
let unitId, subUnitId;
|
|
1417
|
+
if (type === "insert")
|
|
1418
|
+
unitId = params.unitId, subUnitId = params.subUnitId;
|
|
1442
1419
|
else {
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
1420
|
+
const newParams = getSheetCommandTarget(this._univerInstanceService);
|
|
1421
|
+
if (newParams == null)
|
|
1445
1422
|
return;
|
|
1446
|
-
|
|
1423
|
+
unitId = newParams.unitId, subUnitId = newParams.subUnitId;
|
|
1447
1424
|
}
|
|
1448
|
-
return { unitId
|
|
1425
|
+
return { unitId, subUnitId };
|
|
1449
1426
|
}
|
|
1450
|
-
_moveRowInterceptor(
|
|
1451
|
-
const
|
|
1452
|
-
if (
|
|
1427
|
+
_moveRowInterceptor(params, type) {
|
|
1428
|
+
const ids = this._getUnitIdAndSubUnitId(params, type);
|
|
1429
|
+
if (ids == null)
|
|
1453
1430
|
return { redos: [], undos: [] };
|
|
1454
|
-
const { unitId
|
|
1455
|
-
if (Object.keys(
|
|
1456
|
-
const
|
|
1457
|
-
if (
|
|
1431
|
+
const { unitId, subUnitId } = ids, { range } = params, rowStartIndex = range.startRow, rowEndIndex = range.endRow, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
|
|
1432
|
+
if (Object.keys(data).forEach((drawingId) => {
|
|
1433
|
+
const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
1434
|
+
if (sheetTransform == null || transform == null)
|
|
1458
1435
|
return;
|
|
1459
|
-
let
|
|
1460
|
-
if (
|
|
1461
|
-
const
|
|
1462
|
-
|
|
1436
|
+
let newSheetTransform, newTransform;
|
|
1437
|
+
if (type === "insert") {
|
|
1438
|
+
const param = this._expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
|
|
1439
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1463
1440
|
} else {
|
|
1464
|
-
const { from
|
|
1465
|
-
if (
|
|
1466
|
-
|
|
1441
|
+
const { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
|
|
1442
|
+
if (fromRow >= rowStartIndex && toRow <= rowEndIndex)
|
|
1443
|
+
deleteDrawings.push({ unitId, subUnitId, drawingId });
|
|
1467
1444
|
else {
|
|
1468
|
-
const
|
|
1469
|
-
|
|
1445
|
+
const param = this._shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
|
|
1446
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1470
1447
|
}
|
|
1471
1448
|
}
|
|
1472
|
-
if (!
|
|
1449
|
+
if (!newSheetTransform || !newTransform)
|
|
1473
1450
|
return;
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
}),
|
|
1451
|
+
const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
|
|
1452
|
+
updateDrawings.push(params2);
|
|
1453
|
+
}), updateDrawings.length === 0 && deleteDrawings.length === 0)
|
|
1477
1454
|
return { redos: [], undos: [] };
|
|
1478
|
-
if (
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1455
|
+
if (updateDrawings.length > 0) {
|
|
1456
|
+
const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
|
|
1457
|
+
redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
|
|
1481
1458
|
}
|
|
1482
|
-
if (
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1459
|
+
if (deleteDrawings.length > 0) {
|
|
1460
|
+
const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
|
|
1461
|
+
redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
|
|
1485
1462
|
}
|
|
1486
|
-
return
|
|
1487
|
-
redos
|
|
1488
|
-
undos
|
|
1463
|
+
return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
|
|
1464
|
+
redos,
|
|
1465
|
+
undos
|
|
1489
1466
|
};
|
|
1490
1467
|
}
|
|
1491
|
-
_moveColInterceptor(
|
|
1492
|
-
const
|
|
1493
|
-
if (
|
|
1468
|
+
_moveColInterceptor(params, type) {
|
|
1469
|
+
const ids = this._getUnitIdAndSubUnitId(params, type);
|
|
1470
|
+
if (ids == null)
|
|
1494
1471
|
return { redos: [], undos: [] };
|
|
1495
|
-
const { unitId
|
|
1496
|
-
if (Object.keys(
|
|
1497
|
-
const
|
|
1498
|
-
if (
|
|
1472
|
+
const { unitId, subUnitId } = ids, { range } = params, colStartIndex = range.startColumn, colEndIndex = range.endColumn, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
|
|
1473
|
+
if (Object.keys(data).forEach((drawingId) => {
|
|
1474
|
+
const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
1475
|
+
if (sheetTransform == null || transform == null)
|
|
1499
1476
|
return;
|
|
1500
|
-
let
|
|
1501
|
-
if (
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1477
|
+
let newSheetTransform, newTransform;
|
|
1478
|
+
if (type === "insert") {
|
|
1479
|
+
const param = this._expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
|
|
1480
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1504
1481
|
} else {
|
|
1505
|
-
const { from
|
|
1506
|
-
if (
|
|
1507
|
-
|
|
1482
|
+
const { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
|
|
1483
|
+
if (fromColumn >= colStartIndex && toColumn <= colEndIndex)
|
|
1484
|
+
deleteDrawings.push({ unitId, subUnitId, drawingId });
|
|
1508
1485
|
else {
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1486
|
+
const param = this._shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
|
|
1487
|
+
newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
|
|
1511
1488
|
}
|
|
1512
1489
|
}
|
|
1513
|
-
if (!
|
|
1490
|
+
if (!newSheetTransform || !newTransform)
|
|
1514
1491
|
return;
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1517
|
-
}),
|
|
1492
|
+
const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
|
|
1493
|
+
updateDrawings.push(params2);
|
|
1494
|
+
}), updateDrawings.length === 0 && deleteDrawings.length === 0)
|
|
1518
1495
|
return { redos: [], undos: [] };
|
|
1519
|
-
if (
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1496
|
+
if (updateDrawings.length > 0) {
|
|
1497
|
+
const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
|
|
1498
|
+
redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
|
|
1522
1499
|
}
|
|
1523
|
-
if (
|
|
1524
|
-
const
|
|
1525
|
-
|
|
1500
|
+
if (deleteDrawings.length > 0) {
|
|
1501
|
+
const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
|
|
1502
|
+
redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
|
|
1526
1503
|
}
|
|
1527
|
-
return
|
|
1504
|
+
return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), { redos, undos };
|
|
1528
1505
|
}
|
|
1529
|
-
_expandCol(
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1506
|
+
_expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
|
|
1507
|
+
const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
|
|
1508
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1532
1509
|
return {
|
|
1533
|
-
newSheetTransform:
|
|
1534
|
-
newTransform:
|
|
1510
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1511
|
+
newTransform: transform
|
|
1535
1512
|
};
|
|
1536
|
-
let
|
|
1537
|
-
if (
|
|
1538
|
-
const
|
|
1539
|
-
if (
|
|
1513
|
+
let newSheetTransform = null, newTransform = null;
|
|
1514
|
+
if (fromColumn >= colStartIndex) {
|
|
1515
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: colEndIndex, startRow: from.row, endRow: to.row });
|
|
1516
|
+
if (selectionCell == null)
|
|
1540
1517
|
return;
|
|
1541
|
-
|
|
1542
|
-
} else if (
|
|
1543
|
-
if (
|
|
1544
|
-
|
|
1545
|
-
from: { ...
|
|
1546
|
-
to: { ...
|
|
1547
|
-
},
|
|
1518
|
+
newTransform = { ...transform, left: (transform.left || 0) + selectionCell.endX - selectionCell.startX }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
|
|
1519
|
+
} else if (toColumn >= colEndIndex)
|
|
1520
|
+
if (anchorType === SheetDrawingAnchorType.Both)
|
|
1521
|
+
newSheetTransform = {
|
|
1522
|
+
from: { ...from },
|
|
1523
|
+
to: { ...to, column: toColumn + colCount }
|
|
1524
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1548
1525
|
else
|
|
1549
1526
|
return {
|
|
1550
|
-
newSheetTransform:
|
|
1551
|
-
newTransform:
|
|
1527
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1528
|
+
newTransform: transform
|
|
1552
1529
|
};
|
|
1553
|
-
return
|
|
1554
|
-
newSheetTransform
|
|
1555
|
-
newTransform
|
|
1530
|
+
return newSheetTransform != null && newTransform != null ? {
|
|
1531
|
+
newSheetTransform,
|
|
1532
|
+
newTransform
|
|
1556
1533
|
} : null;
|
|
1557
1534
|
}
|
|
1558
|
-
_shrinkCol(
|
|
1559
|
-
const
|
|
1560
|
-
if (
|
|
1535
|
+
_shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
|
|
1536
|
+
const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
|
|
1537
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1561
1538
|
return {
|
|
1562
|
-
newSheetTransform:
|
|
1563
|
-
newTransform:
|
|
1539
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1540
|
+
newTransform: transform
|
|
1564
1541
|
};
|
|
1565
|
-
let
|
|
1566
|
-
if (
|
|
1567
|
-
|
|
1568
|
-
from: { ...
|
|
1569
|
-
to: { ...
|
|
1570
|
-
},
|
|
1542
|
+
let newSheetTransform = null, newTransform = null;
|
|
1543
|
+
if (fromColumn > colEndIndex)
|
|
1544
|
+
newSheetTransform = {
|
|
1545
|
+
from: { ...from, column: fromColumn - colCount },
|
|
1546
|
+
to: { ...to, column: toColumn - colCount }
|
|
1547
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1571
1548
|
else {
|
|
1572
|
-
if (
|
|
1549
|
+
if (fromColumn >= colStartIndex && toColumn <= colEndIndex)
|
|
1573
1550
|
return null;
|
|
1574
|
-
if (
|
|
1575
|
-
if (
|
|
1576
|
-
|
|
1577
|
-
from: { ...
|
|
1578
|
-
to: { ...
|
|
1579
|
-
},
|
|
1551
|
+
if (fromColumn < colStartIndex && toColumn > colEndIndex)
|
|
1552
|
+
if (anchorType === SheetDrawingAnchorType.Both)
|
|
1553
|
+
newSheetTransform = {
|
|
1554
|
+
from: { ...from },
|
|
1555
|
+
to: { ...to, column: toColumn - colCount }
|
|
1556
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1580
1557
|
else
|
|
1581
1558
|
return {
|
|
1582
|
-
newSheetTransform:
|
|
1583
|
-
newTransform:
|
|
1559
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1560
|
+
newTransform: transform
|
|
1584
1561
|
};
|
|
1585
|
-
else if (
|
|
1586
|
-
if (
|
|
1587
|
-
|
|
1562
|
+
else if (fromColumn >= colStartIndex && fromColumn <= colEndIndex) {
|
|
1563
|
+
if (fromColumn === colStartIndex)
|
|
1564
|
+
newTransform = { ...transform, left: (transform.left || 0) - sheetTransform.from.columnOffset };
|
|
1588
1565
|
else {
|
|
1589
|
-
const
|
|
1590
|
-
if (
|
|
1566
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: fromColumn - 1, startRow: from.row, endRow: to.row });
|
|
1567
|
+
if (selectionCell == null)
|
|
1591
1568
|
return;
|
|
1592
|
-
|
|
1569
|
+
newTransform = { ...transform, left: (transform.left || 0) - selectionCell.endX + selectionCell.startX - sheetTransform.from.columnOffset };
|
|
1593
1570
|
}
|
|
1594
|
-
|
|
1595
|
-
} else if (
|
|
1596
|
-
const
|
|
1597
|
-
startColumn:
|
|
1598
|
-
endColumn:
|
|
1599
|
-
startRow:
|
|
1600
|
-
endRow:
|
|
1571
|
+
newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
|
|
1572
|
+
} else if (toColumn >= colStartIndex && toColumn <= colEndIndex && anchorType === SheetDrawingAnchorType.Both) {
|
|
1573
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({
|
|
1574
|
+
startColumn: colStartIndex - 1,
|
|
1575
|
+
endColumn: colStartIndex - 1,
|
|
1576
|
+
startRow: from.row,
|
|
1577
|
+
endRow: to.row
|
|
1601
1578
|
});
|
|
1602
|
-
if (
|
|
1579
|
+
if (selectionCell == null)
|
|
1603
1580
|
return;
|
|
1604
|
-
|
|
1605
|
-
from: { ...
|
|
1606
|
-
to: { ...
|
|
1607
|
-
},
|
|
1581
|
+
newSheetTransform = {
|
|
1582
|
+
from: { ...from },
|
|
1583
|
+
to: { ...to, column: colStartIndex - 1, columnOffset: selectionCell.endX - selectionCell.startX }
|
|
1584
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1608
1585
|
}
|
|
1609
1586
|
}
|
|
1610
|
-
return
|
|
1611
|
-
newSheetTransform
|
|
1612
|
-
newTransform
|
|
1587
|
+
return newSheetTransform != null && newTransform != null ? {
|
|
1588
|
+
newSheetTransform,
|
|
1589
|
+
newTransform
|
|
1613
1590
|
} : null;
|
|
1614
1591
|
}
|
|
1615
|
-
_expandRow(
|
|
1616
|
-
const
|
|
1617
|
-
if (
|
|
1592
|
+
_expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
|
|
1593
|
+
const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
|
|
1594
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1618
1595
|
return {
|
|
1619
|
-
newSheetTransform:
|
|
1620
|
-
newTransform:
|
|
1596
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1597
|
+
newTransform: transform
|
|
1621
1598
|
};
|
|
1622
|
-
let
|
|
1623
|
-
if (
|
|
1624
|
-
const
|
|
1625
|
-
if (
|
|
1599
|
+
let newSheetTransform = null, newTransform = null;
|
|
1600
|
+
if (fromRow >= rowStartIndex) {
|
|
1601
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: rowEndIndex, startColumn: from.column, endColumn: to.column });
|
|
1602
|
+
if (selectionCell == null)
|
|
1626
1603
|
return;
|
|
1627
|
-
|
|
1628
|
-
} else if (
|
|
1629
|
-
if (
|
|
1630
|
-
|
|
1631
|
-
from: { ...
|
|
1604
|
+
newTransform = { ...transform, top: (transform.top || 0) + selectionCell.endY - selectionCell.startY }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
|
|
1605
|
+
} else if (toRow >= rowEndIndex)
|
|
1606
|
+
if (anchorType === SheetDrawingAnchorType.Both)
|
|
1607
|
+
newSheetTransform = {
|
|
1608
|
+
from: { ...from },
|
|
1632
1609
|
to: {
|
|
1633
|
-
...
|
|
1634
|
-
row:
|
|
1610
|
+
...to,
|
|
1611
|
+
row: toRow + rowCount
|
|
1635
1612
|
}
|
|
1636
|
-
},
|
|
1613
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1637
1614
|
else
|
|
1638
1615
|
return {
|
|
1639
|
-
newSheetTransform:
|
|
1640
|
-
newTransform:
|
|
1616
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1617
|
+
newTransform: transform
|
|
1641
1618
|
};
|
|
1642
|
-
return
|
|
1643
|
-
newSheetTransform
|
|
1644
|
-
newTransform
|
|
1619
|
+
return newSheetTransform != null && newTransform != null ? {
|
|
1620
|
+
newSheetTransform,
|
|
1621
|
+
newTransform
|
|
1645
1622
|
} : null;
|
|
1646
1623
|
}
|
|
1647
|
-
_shrinkRow(
|
|
1648
|
-
const
|
|
1649
|
-
if (
|
|
1624
|
+
_shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
|
|
1625
|
+
const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
|
|
1626
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1650
1627
|
return {
|
|
1651
|
-
newSheetTransform:
|
|
1652
|
-
newTransform:
|
|
1628
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1629
|
+
newTransform: transform
|
|
1653
1630
|
};
|
|
1654
|
-
let
|
|
1655
|
-
if (
|
|
1656
|
-
|
|
1657
|
-
from: { ...
|
|
1658
|
-
to: { ...
|
|
1659
|
-
},
|
|
1631
|
+
let newSheetTransform = null, newTransform = null;
|
|
1632
|
+
if (fromRow > rowEndIndex)
|
|
1633
|
+
newSheetTransform = {
|
|
1634
|
+
from: { ...from, row: fromRow - rowCount },
|
|
1635
|
+
to: { ...to, row: toRow - rowCount }
|
|
1636
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1660
1637
|
else {
|
|
1661
|
-
if (
|
|
1638
|
+
if (fromRow >= rowStartIndex && toRow <= rowEndIndex)
|
|
1662
1639
|
return null;
|
|
1663
|
-
if (
|
|
1664
|
-
if (
|
|
1665
|
-
|
|
1666
|
-
from: { ...
|
|
1667
|
-
to: { ...
|
|
1668
|
-
},
|
|
1640
|
+
if (fromRow < rowStartIndex && toRow > rowEndIndex)
|
|
1641
|
+
if (anchorType === SheetDrawingAnchorType.Both)
|
|
1642
|
+
newSheetTransform = {
|
|
1643
|
+
from: { ...from },
|
|
1644
|
+
to: { ...to, row: toRow - rowCount }
|
|
1645
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1669
1646
|
else
|
|
1670
1647
|
return {
|
|
1671
|
-
newSheetTransform:
|
|
1672
|
-
newTransform:
|
|
1648
|
+
newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
|
|
1649
|
+
newTransform: transform
|
|
1673
1650
|
};
|
|
1674
|
-
else if (
|
|
1675
|
-
if (
|
|
1676
|
-
|
|
1651
|
+
else if (fromRow >= rowStartIndex && fromRow <= rowEndIndex) {
|
|
1652
|
+
if (fromRow === rowStartIndex)
|
|
1653
|
+
newTransform = { ...transform, top: (transform.top || 0) - sheetTransform.from.rowOffset };
|
|
1677
1654
|
else {
|
|
1678
|
-
const
|
|
1679
|
-
if (
|
|
1655
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: fromRow - 1, startColumn: from.column, endColumn: to.column });
|
|
1656
|
+
if (selectionCell == null)
|
|
1680
1657
|
return;
|
|
1681
|
-
|
|
1658
|
+
newTransform = { ...transform, top: (transform.top || 0) - selectionCell.endY + selectionCell.startY - sheetTransform.from.rowOffset };
|
|
1682
1659
|
}
|
|
1683
|
-
|
|
1684
|
-
} else if (
|
|
1685
|
-
const
|
|
1686
|
-
if (
|
|
1660
|
+
newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
|
|
1661
|
+
} else if (toRow >= rowStartIndex && toRow <= rowEndIndex && anchorType === SheetDrawingAnchorType.Both) {
|
|
1662
|
+
const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: from.column, startRow: rowStartIndex - 1, endRow: rowStartIndex - 1 });
|
|
1663
|
+
if (selectionCell == null)
|
|
1687
1664
|
return;
|
|
1688
|
-
|
|
1689
|
-
from: { ...
|
|
1690
|
-
to: { ...
|
|
1691
|
-
},
|
|
1665
|
+
newSheetTransform = {
|
|
1666
|
+
from: { ...from },
|
|
1667
|
+
to: { ...to, row: rowStartIndex - 1, rowOffset: selectionCell.endY - selectionCell.startY }
|
|
1668
|
+
}, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
|
|
1692
1669
|
}
|
|
1693
1670
|
}
|
|
1694
|
-
return
|
|
1695
|
-
newSheetTransform
|
|
1696
|
-
newTransform
|
|
1671
|
+
return newSheetTransform != null && newTransform != null ? {
|
|
1672
|
+
newSheetTransform,
|
|
1673
|
+
newTransform
|
|
1697
1674
|
} : null;
|
|
1698
1675
|
}
|
|
1699
1676
|
_commandListener() {
|
|
1700
1677
|
this.disposeWithMe(
|
|
1701
|
-
this._commandService.onCommandExecuted((
|
|
1702
|
-
|
|
1703
|
-
const
|
|
1704
|
-
Object.keys(
|
|
1705
|
-
const
|
|
1706
|
-
Object.keys(
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
if (
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1678
|
+
this._commandService.onCommandExecuted((command) => {
|
|
1679
|
+
command.id === SetWorksheetActiveOperation.id && setTimeout(() => {
|
|
1680
|
+
const params = command.params, { unitId: showUnitId, subUnitId: showSubunitId } = params, drawingMap = this._drawingManagerService.drawingManagerData, insertDrawings = [], removeDrawings = [];
|
|
1681
|
+
Object.keys(drawingMap).forEach((unitId) => {
|
|
1682
|
+
const subUnitMap = drawingMap[unitId];
|
|
1683
|
+
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
1684
|
+
const drawingData = subUnitMap[subUnitId].data;
|
|
1685
|
+
drawingData != null && Object.keys(drawingData).forEach((drawingId) => {
|
|
1686
|
+
if (unitId === showUnitId && subUnitId === showSubunitId) {
|
|
1687
|
+
const drawing = drawingData[drawingId];
|
|
1688
|
+
drawing.transform = drawingPositionToTransform(drawing.sheetTransform, this._selectionRenderService, this._skeletonManagerService), insertDrawings.push(drawingData[drawingId]);
|
|
1712
1689
|
} else
|
|
1713
|
-
|
|
1690
|
+
removeDrawings.push(drawingData[drawingId]);
|
|
1714
1691
|
});
|
|
1715
1692
|
});
|
|
1716
|
-
}), this._drawingManagerService.removeNotification(
|
|
1693
|
+
}), this._drawingManagerService.removeNotification(removeDrawings), this._drawingManagerService.addNotification(insertDrawings);
|
|
1717
1694
|
}, 0);
|
|
1718
1695
|
})
|
|
1719
1696
|
);
|
|
1720
1697
|
}
|
|
1721
1698
|
_sheetRefreshListener() {
|
|
1722
1699
|
this.disposeWithMe(
|
|
1723
|
-
this._commandService.onCommandExecuted((
|
|
1724
|
-
|
|
1725
|
-
const
|
|
1726
|
-
this._refreshDrawingTransform(
|
|
1700
|
+
this._commandService.onCommandExecuted((command) => {
|
|
1701
|
+
REFRESH_MUTATIONS.includes(command.id) && requestIdleCallback(() => {
|
|
1702
|
+
const params = command.params, { unitId, subUnitId, ranges } = params;
|
|
1703
|
+
this._refreshDrawingTransform(unitId, subUnitId, ranges);
|
|
1727
1704
|
});
|
|
1728
1705
|
})
|
|
1729
1706
|
);
|
|
1730
1707
|
}
|
|
1731
|
-
_refreshDrawingTransform(
|
|
1732
|
-
const
|
|
1733
|
-
Object.keys(
|
|
1734
|
-
const
|
|
1735
|
-
if (
|
|
1708
|
+
_refreshDrawingTransform(unitId, subUnitId, ranges) {
|
|
1709
|
+
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
|
|
1710
|
+
Object.keys(drawingData).forEach((drawingId) => {
|
|
1711
|
+
const drawing = drawingData[drawingId], { sheetTransform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
1712
|
+
if (anchorType === SheetDrawingAnchorType.None)
|
|
1736
1713
|
return !0;
|
|
1737
|
-
const { from
|
|
1738
|
-
for (let
|
|
1739
|
-
const
|
|
1740
|
-
if (
|
|
1714
|
+
const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
|
|
1715
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
1716
|
+
const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
|
|
1717
|
+
if (Rectangle.intersects(
|
|
1741
1718
|
{
|
|
1742
|
-
startRow
|
|
1743
|
-
endRow
|
|
1744
|
-
startColumn
|
|
1745
|
-
endColumn
|
|
1719
|
+
startRow,
|
|
1720
|
+
endRow,
|
|
1721
|
+
startColumn,
|
|
1722
|
+
endColumn
|
|
1746
1723
|
},
|
|
1747
1724
|
{
|
|
1748
|
-
startRow:
|
|
1749
|
-
endRow:
|
|
1750
|
-
startColumn:
|
|
1751
|
-
endColumn:
|
|
1725
|
+
startRow: fromRow,
|
|
1726
|
+
endRow: toRow,
|
|
1727
|
+
startColumn: fromColumn,
|
|
1728
|
+
endColumn: toColumn
|
|
1752
1729
|
}
|
|
1753
|
-
) ||
|
|
1754
|
-
|
|
1755
|
-
...
|
|
1756
|
-
transform:
|
|
1730
|
+
) || fromRow > endRow || fromColumn > endColumn) {
|
|
1731
|
+
updateDrawings.push({
|
|
1732
|
+
...drawing,
|
|
1733
|
+
transform: drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService)
|
|
1757
1734
|
});
|
|
1758
1735
|
break;
|
|
1759
1736
|
}
|
|
1760
1737
|
}
|
|
1761
|
-
}),
|
|
1762
|
-
}
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
],
|
|
1773
|
-
var
|
|
1774
|
-
for (var
|
|
1775
|
-
(
|
|
1776
|
-
return
|
|
1777
|
-
},
|
|
1778
|
-
function
|
|
1779
|
-
const { scaleX
|
|
1738
|
+
}), updateDrawings.length !== 0 && (this._drawingManagerService.refreshTransform(updateDrawings), this._commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]));
|
|
1739
|
+
}
|
|
1740
|
+
}, __name(_a4, "SheetDrawingTransformAffectedController"), _a4);
|
|
1741
|
+
SheetDrawingTransformAffectedController = __decorateClass$5([
|
|
1742
|
+
__decorateParam$5(1, ICommandService),
|
|
1743
|
+
__decorateParam$5(2, ISheetSelectionRenderService),
|
|
1744
|
+
__decorateParam$5(3, Inject(SheetSkeletonManagerService)),
|
|
1745
|
+
__decorateParam$5(4, Inject(SheetInterceptorService)),
|
|
1746
|
+
__decorateParam$5(5, ISheetDrawingService),
|
|
1747
|
+
__decorateParam$5(6, IDrawingManagerService),
|
|
1748
|
+
__decorateParam$5(7, IUniverInstanceService)
|
|
1749
|
+
], SheetDrawingTransformAffectedController);
|
|
1750
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1751
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1752
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1753
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
1754
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
|
|
1755
|
+
function transformBound2DOMBound(originBound, scene, skeleton, worksheet) {
|
|
1756
|
+
const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN), absolute = {
|
|
1780
1757
|
left: !0,
|
|
1781
1758
|
top: !0
|
|
1782
1759
|
};
|
|
1783
|
-
if (!
|
|
1760
|
+
if (!viewMain)
|
|
1784
1761
|
return {
|
|
1785
|
-
...
|
|
1786
|
-
absolute
|
|
1762
|
+
...originBound,
|
|
1763
|
+
absolute
|
|
1787
1764
|
};
|
|
1788
|
-
const { left
|
|
1789
|
-
let
|
|
1790
|
-
|
|
1765
|
+
const { left, right, top, bottom } = originBound, freeze = worksheet.getFreeze(), { startColumn, startRow, xSplit, ySplit } = freeze, startSheetView = skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow - ySplit, startColumn - xSplit), endSheetView = skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow, startColumn), { rowHeaderWidth, columnHeaderHeight } = skeleton, freezeWidth = endSheetView.startX - startSheetView.startX, freezeHeight = endSheetView.startY - startSheetView.startY, { top: freezeTop, left: freezeLeft, viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain;
|
|
1766
|
+
let offsetLeft, offsetRight;
|
|
1767
|
+
left < freezeLeft ? (absolute.left = !0, offsetLeft = (freezeWidth + rowHeaderWidth + (left - freezeLeft)) * scaleX, offsetRight = Math.max(
|
|
1791
1768
|
Math.min(
|
|
1792
|
-
(
|
|
1793
|
-
(
|
|
1769
|
+
(freezeWidth + rowHeaderWidth + (right - freezeLeft)) * scaleX,
|
|
1770
|
+
(freezeWidth + rowHeaderWidth) * scaleX
|
|
1794
1771
|
),
|
|
1795
|
-
(
|
|
1796
|
-
)) : (
|
|
1797
|
-
let
|
|
1798
|
-
return
|
|
1772
|
+
(right - actualScrollX) * scaleX
|
|
1773
|
+
)) : (absolute.left = !1, offsetLeft = Math.max((left - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX), offsetRight = Math.max((right - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX));
|
|
1774
|
+
let offsetTop, offsetBottom;
|
|
1775
|
+
return top < freezeTop ? (absolute.top = !0, offsetTop = (freezeHeight + columnHeaderHeight + (top - freezeTop)) * scaleY, offsetBottom = Math.max(
|
|
1799
1776
|
Math.min(
|
|
1800
|
-
(
|
|
1801
|
-
(
|
|
1777
|
+
(freezeHeight + columnHeaderHeight + (right - freezeTop)) * scaleY,
|
|
1778
|
+
(freezeHeight + columnHeaderHeight) * scaleY
|
|
1802
1779
|
),
|
|
1803
|
-
(
|
|
1804
|
-
)) : (
|
|
1805
|
-
left:
|
|
1806
|
-
right:
|
|
1807
|
-
top:
|
|
1808
|
-
bottom:
|
|
1809
|
-
absolute
|
|
1780
|
+
(bottom - actualScrollY) * scaleY
|
|
1781
|
+
)) : (absolute.top = !1, offsetTop = Math.max((top - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY), offsetBottom = Math.max((bottom - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY)), {
|
|
1782
|
+
left: offsetLeft,
|
|
1783
|
+
right: offsetRight,
|
|
1784
|
+
top: offsetTop,
|
|
1785
|
+
bottom: offsetBottom,
|
|
1786
|
+
absolute
|
|
1810
1787
|
};
|
|
1811
1788
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1789
|
+
__name(transformBound2DOMBound, "transformBound2DOMBound");
|
|
1790
|
+
const calcPosition = /* @__PURE__ */ __name((targetObject, currentRender, skeleton, worksheet) => {
|
|
1791
|
+
const { scene, engine } = currentRender, { left, top, width, height, angle } = targetObject, canvasElement = engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum(canvasElement.style.width), { top: topOffset, left: leftOffset, width: domWidth } = canvasClientRect, scaleAdjust = domWidth / widthOfCanvas, bound = {
|
|
1792
|
+
left,
|
|
1793
|
+
right: left + width,
|
|
1794
|
+
top,
|
|
1795
|
+
bottom: top + height
|
|
1796
|
+
}, offsetBound = transformBound2DOMBound(bound, scene, skeleton, worksheet);
|
|
1819
1797
|
return {
|
|
1820
|
-
startX:
|
|
1821
|
-
endX:
|
|
1822
|
-
startY:
|
|
1823
|
-
endY:
|
|
1824
|
-
rotate:
|
|
1825
|
-
width:
|
|
1826
|
-
height:
|
|
1827
|
-
absolute:
|
|
1798
|
+
startX: offsetBound.left * scaleAdjust + leftOffset,
|
|
1799
|
+
endX: offsetBound.right * scaleAdjust + leftOffset,
|
|
1800
|
+
startY: offsetBound.top * scaleAdjust + topOffset,
|
|
1801
|
+
endY: offsetBound.bottom * scaleAdjust + topOffset,
|
|
1802
|
+
rotate: angle,
|
|
1803
|
+
width: width * scaleAdjust,
|
|
1804
|
+
height: height * scaleAdjust,
|
|
1805
|
+
absolute: offsetBound.absolute
|
|
1828
1806
|
};
|
|
1829
|
-
};
|
|
1830
|
-
|
|
1831
|
-
|
|
1807
|
+
}, "calcPosition");
|
|
1808
|
+
var _a5;
|
|
1809
|
+
let SheetCanvasFloatDomManagerService = (_a5 = class extends Disposable {
|
|
1810
|
+
constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService) {
|
|
1832
1811
|
super();
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
this._renderManagerService =
|
|
1841
|
-
}
|
|
1842
|
-
_ensureMap(
|
|
1843
|
-
let
|
|
1844
|
-
|
|
1845
|
-
let
|
|
1846
|
-
return
|
|
1847
|
-
}
|
|
1848
|
-
_getSceneAndTransformerByDrawingSearch(
|
|
1849
|
-
if (
|
|
1812
|
+
__publicField(this, "_domLayerMap", /* @__PURE__ */ new Map());
|
|
1813
|
+
__publicField(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
|
|
1814
|
+
__publicField(this, "_transformChange$", new Subject());
|
|
1815
|
+
__publicField(this, "transformChange$", this._transformChange$.asObservable());
|
|
1816
|
+
__publicField(this, "_remove$", new Subject());
|
|
1817
|
+
__publicField(this, "remove$", this._remove$.asObservable());
|
|
1818
|
+
__publicField(this, "_hooks", []);
|
|
1819
|
+
this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._canvasFloatDomService = _canvasFloatDomService, this._sheetDrawingService = _sheetDrawingService, this._drawingAddListener(), this._scrollUpdateListener(), this._featureUpdateListener(), this._deleteListener();
|
|
1820
|
+
}
|
|
1821
|
+
_ensureMap(unitId, subUnitId) {
|
|
1822
|
+
let unitMap = this._domLayerMap.get(unitId);
|
|
1823
|
+
unitMap || (unitMap = /* @__PURE__ */ new Map(), this._domLayerMap.set(unitId, unitMap));
|
|
1824
|
+
let subUnitMap = unitMap.get(subUnitId);
|
|
1825
|
+
return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
|
|
1826
|
+
}
|
|
1827
|
+
_getSceneAndTransformerByDrawingSearch(unitId) {
|
|
1828
|
+
if (unitId == null)
|
|
1850
1829
|
return;
|
|
1851
|
-
const
|
|
1852
|
-
if (
|
|
1830
|
+
const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
|
|
1831
|
+
if (renderObject == null || scene == null)
|
|
1853
1832
|
return null;
|
|
1854
|
-
const
|
|
1855
|
-
return { scene
|
|
1833
|
+
const transformer = scene.getTransformerByCreate(), canvas = renderObject.engine.getCanvasElement();
|
|
1834
|
+
return { scene, transformer, renderObject, canvas };
|
|
1856
1835
|
}
|
|
1857
|
-
_getFloatDomProps(
|
|
1858
|
-
let
|
|
1859
|
-
return this._hooks.forEach((
|
|
1860
|
-
|
|
1861
|
-
}),
|
|
1836
|
+
_getFloatDomProps(id) {
|
|
1837
|
+
let props;
|
|
1838
|
+
return this._hooks.forEach((hook) => {
|
|
1839
|
+
props = hook.onGetFloatDomProps(id);
|
|
1840
|
+
}), props;
|
|
1862
1841
|
}
|
|
1863
1842
|
// eslint-disable-next-line max-lines-per-function
|
|
1864
1843
|
_drawingAddListener() {
|
|
1865
1844
|
this.disposeWithMe(
|
|
1866
1845
|
// eslint-disable-next-line max-lines-per-function
|
|
1867
|
-
this._drawingManagerService.add$.subscribe((
|
|
1868
|
-
|
|
1869
|
-
var
|
|
1870
|
-
const { unitId
|
|
1871
|
-
if (
|
|
1846
|
+
this._drawingManagerService.add$.subscribe((params) => {
|
|
1847
|
+
params.forEach((param) => {
|
|
1848
|
+
var _a10, _b, _c;
|
|
1849
|
+
const { unitId, subUnitId, drawingId } = param, target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), floatDomParam = this._drawingManagerService.getDrawingByParam(param), skeleton = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
|
|
1850
|
+
if (floatDomParam == null || target == null || skeleton == null)
|
|
1872
1851
|
return;
|
|
1873
|
-
const { transform
|
|
1874
|
-
if (
|
|
1852
|
+
const { transform, drawingType, data } = floatDomParam;
|
|
1853
|
+
if (drawingType !== DrawingTypeEnum$1.DRAWING_DOM)
|
|
1875
1854
|
return;
|
|
1876
|
-
const
|
|
1877
|
-
if (
|
|
1855
|
+
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
1856
|
+
if (renderObject == null)
|
|
1878
1857
|
return;
|
|
1879
|
-
const { scene
|
|
1880
|
-
if (
|
|
1858
|
+
const { scene, canvas } = renderObject;
|
|
1859
|
+
if (transform == null)
|
|
1881
1860
|
return !0;
|
|
1882
|
-
const { left
|
|
1883
|
-
if (
|
|
1884
|
-
|
|
1861
|
+
const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), rectShape = scene.getObject(rectShapeKey);
|
|
1862
|
+
if (rectShape != null) {
|
|
1863
|
+
rectShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
|
|
1885
1864
|
return;
|
|
1886
1865
|
}
|
|
1887
|
-
const
|
|
1888
|
-
left
|
|
1889
|
-
top
|
|
1890
|
-
width
|
|
1891
|
-
height
|
|
1892
|
-
zIndex: this._drawingManagerService.getDrawingOrder(
|
|
1893
|
-
},
|
|
1894
|
-
|
|
1895
|
-
const
|
|
1896
|
-
dispose:
|
|
1897
|
-
rect
|
|
1898
|
-
position
|
|
1899
|
-
unitId
|
|
1900
|
-
subUnitId
|
|
1866
|
+
const imageConfig = {
|
|
1867
|
+
left,
|
|
1868
|
+
top,
|
|
1869
|
+
width,
|
|
1870
|
+
height,
|
|
1871
|
+
zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
|
|
1872
|
+
}, rect = new Rect(rectShapeKey, imageConfig);
|
|
1873
|
+
scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(rect);
|
|
1874
|
+
const map2 = this._ensureMap(unitId, subUnitId), disposableCollection = new DisposableCollection(), initPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet), position$ = new BehaviorSubject(initPosition), info = {
|
|
1875
|
+
dispose: disposableCollection,
|
|
1876
|
+
rect,
|
|
1877
|
+
position$,
|
|
1878
|
+
unitId,
|
|
1879
|
+
subUnitId
|
|
1901
1880
|
};
|
|
1902
1881
|
this._canvasFloatDomService.addFloatDom({
|
|
1903
|
-
position
|
|
1904
|
-
id:
|
|
1905
|
-
componentKey:
|
|
1906
|
-
onPointerDown: (
|
|
1907
|
-
|
|
1908
|
-
},
|
|
1909
|
-
onPointerMove: (
|
|
1910
|
-
|
|
1911
|
-
},
|
|
1912
|
-
onPointerUp: (
|
|
1913
|
-
|
|
1914
|
-
},
|
|
1915
|
-
onWheel: (
|
|
1916
|
-
|
|
1917
|
-
},
|
|
1918
|
-
props: (
|
|
1919
|
-
data
|
|
1882
|
+
position$,
|
|
1883
|
+
id: drawingId,
|
|
1884
|
+
componentKey: floatDomParam.componentKey,
|
|
1885
|
+
onPointerDown: /* @__PURE__ */ __name((evt) => {
|
|
1886
|
+
canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
1887
|
+
}, "onPointerDown"),
|
|
1888
|
+
onPointerMove: /* @__PURE__ */ __name((evt) => {
|
|
1889
|
+
canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
1890
|
+
}, "onPointerMove"),
|
|
1891
|
+
onPointerUp: /* @__PURE__ */ __name((evt) => {
|
|
1892
|
+
canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
1893
|
+
}, "onPointerUp"),
|
|
1894
|
+
onWheel: /* @__PURE__ */ __name((evt) => {
|
|
1895
|
+
canvas.dispatchEvent(new WheelEvent(evt.type, evt));
|
|
1896
|
+
}, "onWheel"),
|
|
1897
|
+
props: (_c = (_b = map2.get(drawingId)) == null ? void 0 : _b.props) != null ? _c : this._getFloatDomProps(drawingId),
|
|
1898
|
+
data
|
|
1920
1899
|
});
|
|
1921
|
-
const
|
|
1922
|
-
const
|
|
1923
|
-
$.next(
|
|
1924
|
-
|
|
1900
|
+
const listener = rect.onTransformChange$.subscribeEvent(() => {
|
|
1901
|
+
const newPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
|
|
1902
|
+
position$.next(
|
|
1903
|
+
newPosition
|
|
1925
1904
|
);
|
|
1926
1905
|
});
|
|
1927
|
-
|
|
1928
|
-
this._canvasFloatDomService.removeFloatDom(
|
|
1929
|
-
}),
|
|
1906
|
+
disposableCollection.add(() => {
|
|
1907
|
+
this._canvasFloatDomService.removeFloatDom(drawingId);
|
|
1908
|
+
}), listener && disposableCollection.add(listener), this._domLayerInfoMap.set(drawingId, info), map2.set(drawingId, {
|
|
1909
|
+
...map2.get(drawingId)
|
|
1910
|
+
});
|
|
1930
1911
|
});
|
|
1931
1912
|
})
|
|
1932
1913
|
);
|
|
1933
1914
|
}
|
|
1934
1915
|
_scrollUpdateListener() {
|
|
1935
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
1936
|
-
var
|
|
1937
|
-
const
|
|
1938
|
-
var
|
|
1939
|
-
const
|
|
1940
|
-
!
|
|
1941
|
-
const
|
|
1942
|
-
if (
|
|
1943
|
-
const
|
|
1944
|
-
|
|
1916
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
1917
|
+
var _a10, _b;
|
|
1918
|
+
const updateSheet = /* @__PURE__ */ __name((unitId, subUnitId) => {
|
|
1919
|
+
var _a11;
|
|
1920
|
+
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId), map2 = this._ensureMap(unitId, subUnitId), ids = Array.from(map2.keys()), target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), skeleton = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
|
|
1921
|
+
!renderObject || !target || !skeleton || ids.forEach((id) => {
|
|
1922
|
+
const info = this._domLayerInfoMap.get(id);
|
|
1923
|
+
if (info) {
|
|
1924
|
+
const position = calcPosition(info.rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
|
|
1925
|
+
info.position$.next(position);
|
|
1945
1926
|
}
|
|
1946
1927
|
});
|
|
1947
|
-
};
|
|
1948
|
-
if (
|
|
1949
|
-
const
|
|
1950
|
-
|
|
1951
|
-
} else if (
|
|
1952
|
-
const
|
|
1953
|
-
Array.from((
|
|
1954
|
-
|
|
1928
|
+
}, "updateSheet");
|
|
1929
|
+
if (commandInfo.id === SetScrollOperation.id) {
|
|
1930
|
+
const params = commandInfo.params, { unitId, sheetId } = params;
|
|
1931
|
+
updateSheet(unitId, sheetId);
|
|
1932
|
+
} else if (commandInfo.id === SetZoomRatioOperation.id) {
|
|
1933
|
+
const params = commandInfo.params, { unitId } = params;
|
|
1934
|
+
Array.from((_b = (_a10 = this._domLayerMap.get(unitId)) == null ? void 0 : _a10.keys()) != null ? _b : []).forEach((subUnitId) => {
|
|
1935
|
+
updateSheet(unitId, subUnitId);
|
|
1955
1936
|
});
|
|
1956
|
-
} else if (
|
|
1957
|
-
const { unitId
|
|
1958
|
-
|
|
1937
|
+
} else if (commandInfo.id === SetFrozenMutation.id) {
|
|
1938
|
+
const { unitId, subUnitId } = commandInfo.params;
|
|
1939
|
+
updateSheet(unitId, subUnitId);
|
|
1959
1940
|
}
|
|
1960
1941
|
}));
|
|
1961
1942
|
}
|
|
1962
|
-
_getPosition(
|
|
1963
|
-
var
|
|
1964
|
-
const { startX
|
|
1965
|
-
if (
|
|
1943
|
+
_getPosition(position, unitId) {
|
|
1944
|
+
var _a10;
|
|
1945
|
+
const { startX, endX, startY, endY } = position, selectionRenderService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(ISheetSelectionRenderService);
|
|
1946
|
+
if (selectionRenderService == null)
|
|
1966
1947
|
return;
|
|
1967
|
-
const
|
|
1968
|
-
if (
|
|
1948
|
+
const start = selectionRenderService.getSelectionCellByPosition(startX, startY);
|
|
1949
|
+
if (start == null)
|
|
1969
1950
|
return;
|
|
1970
|
-
const
|
|
1971
|
-
column:
|
|
1972
|
-
columnOffset:
|
|
1973
|
-
row:
|
|
1974
|
-
rowOffset:
|
|
1975
|
-
},
|
|
1976
|
-
if (
|
|
1951
|
+
const from = {
|
|
1952
|
+
column: start.actualColumn,
|
|
1953
|
+
columnOffset: startX - start.startX,
|
|
1954
|
+
row: start.actualRow,
|
|
1955
|
+
rowOffset: startY - start.startY
|
|
1956
|
+
}, end = selectionRenderService.getSelectionCellByPosition(endX, endY);
|
|
1957
|
+
if (end == null)
|
|
1977
1958
|
return;
|
|
1978
|
-
const
|
|
1979
|
-
column:
|
|
1980
|
-
columnOffset:
|
|
1981
|
-
row:
|
|
1982
|
-
rowOffset:
|
|
1959
|
+
const to = {
|
|
1960
|
+
column: end.actualColumn,
|
|
1961
|
+
columnOffset: endX - end.startX,
|
|
1962
|
+
row: end.actualRow,
|
|
1963
|
+
rowOffset: endY - end.startY
|
|
1983
1964
|
};
|
|
1984
1965
|
return {
|
|
1985
|
-
from
|
|
1986
|
-
to
|
|
1966
|
+
from,
|
|
1967
|
+
to
|
|
1987
1968
|
};
|
|
1988
1969
|
}
|
|
1989
1970
|
_featureUpdateListener() {
|
|
1990
1971
|
this.disposeWithMe(
|
|
1991
|
-
this._drawingManagerService.update$.subscribe((
|
|
1992
|
-
|
|
1993
|
-
const
|
|
1994
|
-
if (!
|
|
1972
|
+
this._drawingManagerService.update$.subscribe((params) => {
|
|
1973
|
+
params.forEach((data) => {
|
|
1974
|
+
const sheetDrawing = this._drawingManagerService.getDrawingByParam(data);
|
|
1975
|
+
if (!sheetDrawing || sheetDrawing.drawingType !== DrawingTypeEnum$1.DRAWING_DOM)
|
|
1995
1976
|
return;
|
|
1996
|
-
const
|
|
1997
|
-
...
|
|
1977
|
+
const newValue = {
|
|
1978
|
+
...sheetDrawing.transform
|
|
1998
1979
|
};
|
|
1999
|
-
this._transformChange$.next({ id:
|
|
1980
|
+
this._transformChange$.next({ id: data.drawingId, value: newValue });
|
|
2000
1981
|
});
|
|
2001
1982
|
})
|
|
2002
1983
|
);
|
|
2003
1984
|
}
|
|
2004
1985
|
_deleteListener() {
|
|
2005
1986
|
this.disposeWithMe(
|
|
2006
|
-
this._drawingManagerService.remove$.subscribe((
|
|
2007
|
-
|
|
2008
|
-
this._removeDom(
|
|
1987
|
+
this._drawingManagerService.remove$.subscribe((params) => {
|
|
1988
|
+
params.forEach((param) => {
|
|
1989
|
+
this._removeDom(param.drawingId);
|
|
2009
1990
|
});
|
|
2010
1991
|
})
|
|
2011
1992
|
);
|
|
2012
1993
|
}
|
|
2013
|
-
addFloatDomToPosition(
|
|
2014
|
-
const
|
|
2015
|
-
unitId:
|
|
2016
|
-
subUnitId:
|
|
1994
|
+
addFloatDomToPosition(layer, propId) {
|
|
1995
|
+
const target = getSheetCommandTarget(this._univerInstanceService, {
|
|
1996
|
+
unitId: layer.unitId,
|
|
1997
|
+
subUnitId: layer.subUnitId
|
|
2017
1998
|
});
|
|
2018
|
-
if (!
|
|
1999
|
+
if (!target)
|
|
2019
2000
|
throw new Error("cannot find current target!");
|
|
2020
|
-
const { unitId
|
|
2021
|
-
if (
|
|
2001
|
+
const { unitId, subUnitId } = target, { initPosition, componentKey, data } = layer, id = propId != null ? propId : generateRandomId(), sheetTransform = this._getPosition(initPosition, unitId);
|
|
2002
|
+
if (sheetTransform == null)
|
|
2022
2003
|
return;
|
|
2023
|
-
this._ensureMap(
|
|
2024
|
-
const
|
|
2025
|
-
unitId
|
|
2026
|
-
subUnitId
|
|
2027
|
-
drawingId:
|
|
2028
|
-
drawingType:
|
|
2029
|
-
componentKey
|
|
2030
|
-
sheetTransform
|
|
2004
|
+
this._ensureMap(unitId, subUnitId).set(id, layer);
|
|
2005
|
+
const sheetDrawingParam = {
|
|
2006
|
+
unitId,
|
|
2007
|
+
subUnitId,
|
|
2008
|
+
drawingId: id,
|
|
2009
|
+
drawingType: DrawingTypeEnum$1.DRAWING_DOM,
|
|
2010
|
+
componentKey,
|
|
2011
|
+
sheetTransform,
|
|
2031
2012
|
transform: {
|
|
2032
|
-
left:
|
|
2033
|
-
top:
|
|
2034
|
-
width:
|
|
2035
|
-
height:
|
|
2013
|
+
left: initPosition.startX,
|
|
2014
|
+
top: initPosition.startY,
|
|
2015
|
+
width: initPosition.endX - initPosition.startX,
|
|
2016
|
+
height: initPosition.endY - initPosition.startY
|
|
2036
2017
|
},
|
|
2037
|
-
data
|
|
2018
|
+
data
|
|
2038
2019
|
};
|
|
2039
|
-
return this._commandService.executeCommand(
|
|
2040
|
-
unitId
|
|
2041
|
-
drawings: [
|
|
2020
|
+
return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
|
|
2021
|
+
unitId,
|
|
2022
|
+
drawings: [sheetDrawingParam]
|
|
2042
2023
|
}), {
|
|
2043
|
-
id
|
|
2044
|
-
dispose: () => {
|
|
2045
|
-
this._removeDom(
|
|
2046
|
-
}
|
|
2024
|
+
id,
|
|
2025
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
2026
|
+
this._removeDom(id, !0);
|
|
2027
|
+
}, "dispose")
|
|
2047
2028
|
};
|
|
2048
2029
|
}
|
|
2049
|
-
_removeDom(
|
|
2050
|
-
const
|
|
2051
|
-
if (!
|
|
2030
|
+
_removeDom(id, removeDrawing = !1) {
|
|
2031
|
+
const info = this._domLayerInfoMap.get(id);
|
|
2032
|
+
if (!info)
|
|
2052
2033
|
return;
|
|
2053
|
-
const { unitId
|
|
2054
|
-
this._domLayerInfoMap.delete(
|
|
2055
|
-
const
|
|
2056
|
-
if (
|
|
2057
|
-
this._ensureMap(
|
|
2058
|
-
const
|
|
2059
|
-
if (!
|
|
2034
|
+
const { unitId, subUnitId } = info;
|
|
2035
|
+
this._domLayerInfoMap.delete(id), info.dispose.dispose();
|
|
2036
|
+
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
2037
|
+
if (renderObject && renderObject.scene.removeObject(info.rect), removeDrawing) {
|
|
2038
|
+
this._ensureMap(unitId, subUnitId).delete(id);
|
|
2039
|
+
const param = this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId: id });
|
|
2040
|
+
if (!param)
|
|
2060
2041
|
return;
|
|
2061
|
-
const
|
|
2062
|
-
this._commandService.syncExecuteCommand(
|
|
2042
|
+
const jsonOp = this._sheetDrawingService.getBatchRemoveOp([param]), { redo, objects } = jsonOp;
|
|
2043
|
+
this._commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE });
|
|
2063
2044
|
}
|
|
2064
2045
|
}
|
|
2065
|
-
addHook(
|
|
2066
|
-
return this._hooks.push(
|
|
2067
|
-
dispose: () => {
|
|
2068
|
-
const
|
|
2069
|
-
this._hooks.splice(
|
|
2070
|
-
}
|
|
2046
|
+
addHook(hook) {
|
|
2047
|
+
return this._hooks.push(hook), {
|
|
2048
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
2049
|
+
const index = this._hooks.findIndex((h) => h === hook);
|
|
2050
|
+
this._hooks.splice(index, 1);
|
|
2051
|
+
}, "dispose")
|
|
2071
2052
|
};
|
|
2072
2053
|
}
|
|
2073
|
-
};
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
],
|
|
2083
|
-
var
|
|
2084
|
-
for (var
|
|
2085
|
-
(
|
|
2086
|
-
return
|
|
2087
|
-
},
|
|
2088
|
-
let
|
|
2089
|
-
constructor(
|
|
2090
|
-
super(), this._sheetPrintInterceptorService =
|
|
2054
|
+
}, __name(_a5, "SheetCanvasFloatDomManagerService"), _a5);
|
|
2055
|
+
SheetCanvasFloatDomManagerService = __decorateClass$4([
|
|
2056
|
+
OnLifecycle(LifecycleStages.Starting, SheetCanvasFloatDomManagerService),
|
|
2057
|
+
__decorateParam$4(0, Inject(IRenderManagerService)),
|
|
2058
|
+
__decorateParam$4(1, IUniverInstanceService),
|
|
2059
|
+
__decorateParam$4(2, Inject(ICommandService)),
|
|
2060
|
+
__decorateParam$4(3, IDrawingManagerService),
|
|
2061
|
+
__decorateParam$4(4, Inject(CanvasFloatDomService)),
|
|
2062
|
+
__decorateParam$4(5, ISheetDrawingService)
|
|
2063
|
+
], SheetCanvasFloatDomManagerService);
|
|
2064
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2065
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2066
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2067
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
2068
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a6;
|
|
2069
|
+
let SheetDrawingPrintingController = (_a6 = class extends Disposable {
|
|
2070
|
+
constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService) {
|
|
2071
|
+
super(), this._sheetPrintInterceptorService = _sheetPrintInterceptorService, this._drawingRenderService = _drawingRenderService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._initPrinting();
|
|
2091
2072
|
}
|
|
2092
2073
|
_initPrinting() {
|
|
2093
2074
|
this.disposeWithMe(
|
|
2094
2075
|
this._sheetPrintInterceptorService.interceptor.intercept(
|
|
2095
2076
|
this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,
|
|
2096
2077
|
{
|
|
2097
|
-
handler: (
|
|
2098
|
-
const { unitId
|
|
2099
|
-
return
|
|
2100
|
-
this._drawingRenderService.renderDrawing(
|
|
2101
|
-
}),
|
|
2102
|
-
}
|
|
2078
|
+
handler: /* @__PURE__ */ __name((_param, pos, next) => {
|
|
2079
|
+
const { unitId, scene, subUnitId } = pos, unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[subUnitId];
|
|
2080
|
+
return subUnitData && subUnitData.order.forEach((id) => {
|
|
2081
|
+
this._drawingRenderService.renderDrawing(subUnitData.data[id], scene);
|
|
2082
|
+
}), next();
|
|
2083
|
+
}, "handler")
|
|
2103
2084
|
}
|
|
2104
2085
|
)
|
|
2105
2086
|
), this.disposeWithMe(
|
|
2106
2087
|
this._sheetPrintInterceptorService.interceptor.intercept(
|
|
2107
2088
|
this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,
|
|
2108
2089
|
{
|
|
2109
|
-
handler: (
|
|
2110
|
-
const { unitId
|
|
2111
|
-
if (!
|
|
2112
|
-
return
|
|
2113
|
-
const
|
|
2114
|
-
if (!
|
|
2115
|
-
return
|
|
2116
|
-
const
|
|
2117
|
-
if (!
|
|
2118
|
-
return
|
|
2119
|
-
const { scaleX
|
|
2120
|
-
return
|
|
2121
|
-
if (!
|
|
2122
|
-
const
|
|
2123
|
-
|
|
2090
|
+
handler: /* @__PURE__ */ __name((range, pos, next) => {
|
|
2091
|
+
const { unitId, subUnitId } = pos, renderer = this._renderManagerService.getRenderById(unitId);
|
|
2092
|
+
if (!renderer)
|
|
2093
|
+
return next(range);
|
|
2094
|
+
const skeleton = renderer.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
|
|
2095
|
+
if (!skeleton)
|
|
2096
|
+
return next(range);
|
|
2097
|
+
const unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[pos.subUnitId];
|
|
2098
|
+
if (!subUnitData)
|
|
2099
|
+
return next(range);
|
|
2100
|
+
const { scaleX, scaleY } = renderer.scene, newRange = range ? { ...range } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, data = subUnitData.order.map((key) => subUnitData.data[key]).filter((item) => item.drawingType !== DrawingTypeEnum.DRAWING_DOM);
|
|
2101
|
+
return data.length ? (data.forEach((param) => {
|
|
2102
|
+
if (!param.groupId && param.transform && Tools.isDefine(param.transform.left) && Tools.isDefine(param.transform.top) && Tools.isDefine(param.transform.width) && Tools.isDefine(param.transform.height)) {
|
|
2103
|
+
const start = skeleton.skeleton.getCellPositionByOffset(param.transform.left, param.transform.top, scaleX, scaleY, { x: 0, y: 0 }), end = skeleton.skeleton.getCellPositionByOffset(param.transform.left + param.transform.width, param.transform.top + param.transform.height, scaleX, scaleY, { x: 0, y: 0 });
|
|
2104
|
+
start.column < newRange.startColumn && (newRange.startColumn = start.column), start.row < newRange.startRow && (newRange.startRow = start.row), newRange.endRow < end.row && (newRange.endRow = end.row), newRange.endColumn < end.column && (newRange.endColumn = end.column);
|
|
2124
2105
|
}
|
|
2125
|
-
}),
|
|
2126
|
-
}
|
|
2106
|
+
}), next(newRange)) : next(range);
|
|
2107
|
+
}, "handler")
|
|
2127
2108
|
}
|
|
2128
2109
|
)
|
|
2129
2110
|
);
|
|
2130
2111
|
}
|
|
2131
|
-
};
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
],
|
|
2139
|
-
var
|
|
2140
|
-
for (var
|
|
2141
|
-
(
|
|
2142
|
-
return
|
|
2143
|
-
},
|
|
2144
|
-
let
|
|
2145
|
-
constructor(
|
|
2146
|
-
super(), this._drawingManagerService =
|
|
2112
|
+
}, __name(_a6, "SheetDrawingPrintingController"), _a6);
|
|
2113
|
+
SheetDrawingPrintingController = __decorateClass$3([
|
|
2114
|
+
OnLifecycle(LifecycleStages.Rendered, SheetDrawingPrintingController),
|
|
2115
|
+
__decorateParam$3(0, Inject(SheetPrintInterceptorService)),
|
|
2116
|
+
__decorateParam$3(1, Inject(DrawingRenderService)),
|
|
2117
|
+
__decorateParam$3(2, IDrawingManagerService),
|
|
2118
|
+
__decorateParam$3(3, IRenderManagerService)
|
|
2119
|
+
], SheetDrawingPrintingController);
|
|
2120
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2121
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2122
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2123
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
2124
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a7;
|
|
2125
|
+
let SheetDrawingPermissionController = (_a7 = class extends Disposable {
|
|
2126
|
+
constructor(_drawingManagerService, _renderManagerService, _permissionService, _univerInstanceService, _userManagerService) {
|
|
2127
|
+
super(), this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._userManagerService = _userManagerService, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
|
|
2147
2128
|
}
|
|
2148
2129
|
_initDrawingVisible() {
|
|
2149
|
-
const
|
|
2130
|
+
const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
|
|
2150
2131
|
this.disposeWithMe(
|
|
2151
|
-
|
|
2152
|
-
if (!
|
|
2132
|
+
combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
|
|
2133
|
+
if (!workbook) {
|
|
2153
2134
|
this._drawingManagerService.setDrawingVisible(!1);
|
|
2154
2135
|
return;
|
|
2155
2136
|
}
|
|
2156
|
-
|
|
2157
|
-
if (!
|
|
2137
|
+
workbook.activeSheet$.subscribe((sheet) => {
|
|
2138
|
+
if (!sheet) {
|
|
2158
2139
|
this._drawingManagerService.setDrawingVisible(!1);
|
|
2159
2140
|
return;
|
|
2160
2141
|
}
|
|
2161
|
-
const
|
|
2162
|
-
if (this._permissionService.composePermission([new
|
|
2142
|
+
const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
|
|
2143
|
+
if (this._permissionService.composePermission([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).every((permission) => permission.value))
|
|
2163
2144
|
this._drawingManagerService.setDrawingVisible(!0);
|
|
2164
2145
|
else {
|
|
2165
2146
|
this._drawingManagerService.setDrawingVisible(!1);
|
|
2166
|
-
const
|
|
2167
|
-
if (
|
|
2147
|
+
const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
|
|
2148
|
+
if (scene == null)
|
|
2168
2149
|
return;
|
|
2169
|
-
|
|
2170
|
-
|
|
2150
|
+
scene.getAllObjects().forEach((object) => {
|
|
2151
|
+
object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
|
|
2171
2152
|
});
|
|
2172
2153
|
}
|
|
2173
2154
|
});
|
|
@@ -2175,28 +2156,28 @@ let Le = class extends oe {
|
|
|
2175
2156
|
);
|
|
2176
2157
|
}
|
|
2177
2158
|
_initDrawingEditable() {
|
|
2178
|
-
const
|
|
2159
|
+
const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
|
|
2179
2160
|
this.disposeWithMe(
|
|
2180
|
-
|
|
2181
|
-
if (!
|
|
2161
|
+
combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
|
|
2162
|
+
if (!workbook) {
|
|
2182
2163
|
this._drawingManagerService.setDrawingEditable(!1);
|
|
2183
2164
|
return;
|
|
2184
2165
|
}
|
|
2185
|
-
|
|
2186
|
-
if (!
|
|
2166
|
+
workbook.activeSheet$.subscribe((sheet) => {
|
|
2167
|
+
if (!sheet) {
|
|
2187
2168
|
this._drawingManagerService.setDrawingEditable(!1);
|
|
2188
2169
|
return;
|
|
2189
2170
|
}
|
|
2190
|
-
const
|
|
2191
|
-
if (this._permissionService.composePermission([new
|
|
2171
|
+
const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
|
|
2172
|
+
if (this._permissionService.composePermission([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).every((permission) => permission.value))
|
|
2192
2173
|
this._drawingManagerService.setDrawingEditable(!0);
|
|
2193
2174
|
else {
|
|
2194
2175
|
this._drawingManagerService.setDrawingEditable(!1);
|
|
2195
|
-
const
|
|
2196
|
-
if (
|
|
2176
|
+
const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
|
|
2177
|
+
if (scene == null)
|
|
2197
2178
|
return;
|
|
2198
|
-
|
|
2199
|
-
|
|
2179
|
+
scene.getAllObjects().forEach((object) => {
|
|
2180
|
+
object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
|
|
2200
2181
|
});
|
|
2201
2182
|
}
|
|
2202
2183
|
});
|
|
@@ -2204,303 +2185,298 @@ let Le = class extends oe {
|
|
|
2204
2185
|
);
|
|
2205
2186
|
}
|
|
2206
2187
|
_initViewPermissionChange() {
|
|
2207
|
-
const
|
|
2188
|
+
const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
|
|
2208
2189
|
this.disposeWithMe(
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
var
|
|
2212
|
-
if (!
|
|
2190
|
+
combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
|
|
2191
|
+
workbook && workbook.activeSheet$.subscribe((sheet) => {
|
|
2192
|
+
var _a10;
|
|
2193
|
+
if (!sheet)
|
|
2213
2194
|
return;
|
|
2214
|
-
const
|
|
2215
|
-
let
|
|
2216
|
-
const
|
|
2217
|
-
if (
|
|
2195
|
+
const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
|
|
2196
|
+
let initialViewPermission = !0;
|
|
2197
|
+
const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
|
|
2198
|
+
if (scene == null)
|
|
2218
2199
|
return;
|
|
2219
|
-
const
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2200
|
+
const transformer = scene.getTransformerByCreate(), worksheetViewPermission$ = this._permissionService.composePermission$([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
|
|
2201
|
+
worksheetViewPermission$ == null || worksheetViewPermission$.pipe(
|
|
2202
|
+
filter((permission) => permission !== initialViewPermission),
|
|
2203
|
+
distinctUntilChanged()
|
|
2223
2204
|
).subscribe({
|
|
2224
|
-
next: (
|
|
2225
|
-
|
|
2226
|
-
const
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
}),
|
|
2230
|
-
}
|
|
2231
|
-
}), (
|
|
2232
|
-
|
|
2233
|
-
|
|
2205
|
+
next: /* @__PURE__ */ __name((permission) => {
|
|
2206
|
+
initialViewPermission = permission, this._drawingManagerService.setDrawingVisible(permission);
|
|
2207
|
+
const objects = scene.getAllObjects(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
|
|
2208
|
+
permission ? this._drawingManagerService.addNotification(drawingDataValues) : (objects.forEach((object) => {
|
|
2209
|
+
object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
|
|
2210
|
+
}), transformer.clearSelectedObjects());
|
|
2211
|
+
}, "next")
|
|
2212
|
+
}), (_a10 = this._permissionService.getPermissionPoint$(new WorksheetViewPermission(unitId, subUnitId).id)) == null || _a10.pipe(
|
|
2213
|
+
filter((permission) => permission.value !== initialViewPermission),
|
|
2214
|
+
distinctUntilChanged()
|
|
2234
2215
|
).subscribe({
|
|
2235
|
-
complete: () => {
|
|
2236
|
-
|
|
2237
|
-
const
|
|
2238
|
-
this._drawingManagerService.addNotification(
|
|
2239
|
-
}
|
|
2216
|
+
complete: /* @__PURE__ */ __name(() => {
|
|
2217
|
+
initialViewPermission = !0, this._drawingManagerService.setDrawingVisible(!0);
|
|
2218
|
+
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
|
|
2219
|
+
this._drawingManagerService.addNotification(drawingDataValues);
|
|
2220
|
+
}, "complete")
|
|
2240
2221
|
});
|
|
2241
2222
|
});
|
|
2242
2223
|
})
|
|
2243
2224
|
);
|
|
2244
2225
|
}
|
|
2245
2226
|
_initEditPermissionChange() {
|
|
2246
|
-
const
|
|
2227
|
+
const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
|
|
2247
2228
|
this.disposeWithMe(
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
var
|
|
2251
|
-
if (!
|
|
2229
|
+
combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
|
|
2230
|
+
workbook && workbook.activeSheet$.subscribe((sheet) => {
|
|
2231
|
+
var _a10;
|
|
2232
|
+
if (!sheet)
|
|
2252
2233
|
return;
|
|
2253
|
-
const
|
|
2254
|
-
let
|
|
2255
|
-
const
|
|
2256
|
-
if (
|
|
2234
|
+
const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
|
|
2235
|
+
let initialEditPermission = !0;
|
|
2236
|
+
const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
|
|
2237
|
+
if (scene == null)
|
|
2257
2238
|
return;
|
|
2258
|
-
const
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2239
|
+
const transformer = scene.getTransformerByCreate(), composeWorksheetEditPermission = this._permissionService.composePermission$([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
|
|
2240
|
+
composeWorksheetEditPermission == null || composeWorksheetEditPermission.pipe(
|
|
2241
|
+
filter((permission) => permission !== initialEditPermission),
|
|
2242
|
+
distinctUntilChanged()
|
|
2262
2243
|
).subscribe({
|
|
2263
|
-
next: (
|
|
2264
|
-
|
|
2265
|
-
const
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
}), this._drawingManagerService.addNotification(
|
|
2269
|
-
|
|
2270
|
-
}),
|
|
2271
|
-
}
|
|
2272
|
-
}), (
|
|
2273
|
-
|
|
2274
|
-
|
|
2244
|
+
next: /* @__PURE__ */ __name((permission) => {
|
|
2245
|
+
initialEditPermission = permission, this._drawingManagerService.setDrawingEditable(permission);
|
|
2246
|
+
const objects = scene.getAllObjects(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
|
|
2247
|
+
permission ? (objects.forEach((object) => {
|
|
2248
|
+
object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.attachTransformerTo(object);
|
|
2249
|
+
}), this._drawingManagerService.addNotification(drawingDataValues)) : (objects.forEach((object) => {
|
|
2250
|
+
object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
|
|
2251
|
+
}), transformer.clearSelectedObjects());
|
|
2252
|
+
}, "next")
|
|
2253
|
+
}), (_a10 = this._permissionService.getPermissionPoint$(new WorksheetEditPermission(unitId, subUnitId).id)) == null || _a10.pipe(
|
|
2254
|
+
filter((permission) => permission.value !== initialEditPermission),
|
|
2255
|
+
distinctUntilChanged()
|
|
2275
2256
|
).subscribe({
|
|
2276
|
-
complete: () => {
|
|
2277
|
-
|
|
2278
|
-
const
|
|
2279
|
-
if (
|
|
2257
|
+
complete: /* @__PURE__ */ __name(() => {
|
|
2258
|
+
initialEditPermission = !0;
|
|
2259
|
+
const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject2 = this._renderManagerService.getRenderById(unitId2), scene2 = renderObject2 == null ? void 0 : renderObject2.scene;
|
|
2260
|
+
if (scene2 == null)
|
|
2280
2261
|
return;
|
|
2281
|
-
this._drawingManagerService.setDrawingEditable(!0),
|
|
2282
|
-
|
|
2262
|
+
this._drawingManagerService.setDrawingEditable(!0), scene2.getAllObjects().forEach((object) => {
|
|
2263
|
+
object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene2.detachTransformerFrom(object);
|
|
2283
2264
|
});
|
|
2284
|
-
}
|
|
2265
|
+
}, "complete")
|
|
2285
2266
|
});
|
|
2286
2267
|
});
|
|
2287
2268
|
})
|
|
2288
2269
|
);
|
|
2289
2270
|
}
|
|
2290
|
-
};
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
],
|
|
2299
|
-
var
|
|
2300
|
-
for (var
|
|
2301
|
-
(
|
|
2302
|
-
return
|
|
2303
|
-
},
|
|
2304
|
-
let
|
|
2305
|
-
constructor(
|
|
2271
|
+
}, __name(_a7, "SheetDrawingPermissionController"), _a7);
|
|
2272
|
+
SheetDrawingPermissionController = __decorateClass$2([
|
|
2273
|
+
OnLifecycle(LifecycleStages.Rendered, SheetDrawingPermissionController),
|
|
2274
|
+
__decorateParam$2(0, IDrawingManagerService),
|
|
2275
|
+
__decorateParam$2(1, IRenderManagerService),
|
|
2276
|
+
__decorateParam$2(2, IPermissionService),
|
|
2277
|
+
__decorateParam$2(3, IUniverInstanceService),
|
|
2278
|
+
__decorateParam$2(4, Inject(UserManagerService))
|
|
2279
|
+
], SheetDrawingPermissionController);
|
|
2280
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2281
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2282
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2283
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
2284
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a8;
|
|
2285
|
+
let SheetsDrawingCopyPasteController = (_a8 = class extends Disposable {
|
|
2286
|
+
constructor(_sheetClipboardService, _renderManagerService, _sheetDrawingService) {
|
|
2306
2287
|
super();
|
|
2307
|
-
|
|
2308
|
-
this._sheetClipboardService =
|
|
2288
|
+
__publicField(this, "_copyInfo");
|
|
2289
|
+
this._sheetClipboardService = _sheetClipboardService, this._renderManagerService = _renderManagerService, this._sheetDrawingService = _sheetDrawingService, this._initCopyPaste();
|
|
2309
2290
|
}
|
|
2310
2291
|
_initCopyPaste() {
|
|
2311
2292
|
this._sheetClipboardService.addClipboardHook({
|
|
2312
2293
|
id: "SHEET_IMAGE_UI_PLUGIN",
|
|
2313
|
-
onBeforeCopy: (
|
|
2314
|
-
onPasteCells: (
|
|
2315
|
-
const { copyType
|
|
2316
|
-
return this._generateMutations(
|
|
2317
|
-
},
|
|
2318
|
-
onPastePlainText: (
|
|
2294
|
+
onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
|
|
2295
|
+
onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
|
|
2296
|
+
const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
|
|
2297
|
+
return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
|
|
2298
|
+
}, "onPasteCells"),
|
|
2299
|
+
onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => ({ undos: [], redos: [] }), "onPastePlainText")
|
|
2319
2300
|
});
|
|
2320
2301
|
}
|
|
2321
|
-
_collect(
|
|
2322
|
-
var
|
|
2323
|
-
const
|
|
2324
|
-
if (!
|
|
2325
|
-
const
|
|
2326
|
-
if (!
|
|
2302
|
+
_collect(unitId, subUnitId, range) {
|
|
2303
|
+
var _a10;
|
|
2304
|
+
const skeletonManagetService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService);
|
|
2305
|
+
if (!skeletonManagetService) return;
|
|
2306
|
+
const selectionRect = skeletonManagetService.attachRangeWithCoord(range);
|
|
2307
|
+
if (!selectionRect)
|
|
2327
2308
|
return;
|
|
2328
|
-
const { startX
|
|
2329
|
-
Object.keys(
|
|
2330
|
-
const
|
|
2331
|
-
if (
|
|
2309
|
+
const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
|
|
2310
|
+
Object.keys(drawings).forEach((drawingId) => {
|
|
2311
|
+
const drawing = drawings[drawingId], { transform } = drawing;
|
|
2312
|
+
if (drawing.anchorType !== SheetDrawingAnchorType.Both || !transform)
|
|
2332
2313
|
return;
|
|
2333
|
-
const { left
|
|
2334
|
-
drawingStartX:
|
|
2335
|
-
drawingEndX:
|
|
2336
|
-
drawingStartY:
|
|
2337
|
-
drawingEndY:
|
|
2314
|
+
const { left = 0, top = 0, width = 0, height = 0 } = transform, { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
|
|
2315
|
+
drawingStartX: left,
|
|
2316
|
+
drawingEndX: left + width,
|
|
2317
|
+
drawingStartY: top,
|
|
2318
|
+
drawingEndY: top + height
|
|
2338
2319
|
};
|
|
2339
|
-
|
|
2340
|
-
}),
|
|
2341
|
-
drawings:
|
|
2342
|
-
unitId
|
|
2343
|
-
subUnitId
|
|
2320
|
+
startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY && containedDrawings.push(drawing);
|
|
2321
|
+
}), containedDrawings.length && (this._copyInfo = {
|
|
2322
|
+
drawings: containedDrawings,
|
|
2323
|
+
unitId,
|
|
2324
|
+
subUnitId
|
|
2344
2325
|
});
|
|
2345
2326
|
}
|
|
2346
2327
|
// eslint-disable-next-line max-lines-per-function
|
|
2347
|
-
_generateMutations(
|
|
2348
|
-
var
|
|
2328
|
+
_generateMutations(pastedRange, copyInfo) {
|
|
2329
|
+
var _a10;
|
|
2349
2330
|
if (!this._copyInfo)
|
|
2350
2331
|
return { redos: [], undos: [] };
|
|
2351
2332
|
if ([
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2333
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
|
|
2334
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
|
|
2335
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
|
|
2336
|
+
PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
|
|
2356
2337
|
].includes(
|
|
2357
|
-
|
|
2338
|
+
copyInfo.pasteType
|
|
2358
2339
|
))
|
|
2359
2340
|
return { redos: [], undos: [] };
|
|
2360
|
-
const { copyRange
|
|
2361
|
-
if (!
|
|
2341
|
+
const { copyRange } = copyInfo;
|
|
2342
|
+
if (!copyRange)
|
|
2362
2343
|
return { redos: [], undos: [] };
|
|
2363
|
-
const { drawings
|
|
2364
|
-
if (!
|
|
2344
|
+
const { drawings, unitId, subUnitId } = this._copyInfo, { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]), { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn), { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn), skeletonManagetService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService);
|
|
2345
|
+
if (!skeletonManagetService)
|
|
2365
2346
|
return { redos: [], undos: [] };
|
|
2366
|
-
const
|
|
2367
|
-
startRow:
|
|
2368
|
-
endRow:
|
|
2369
|
-
startColumn:
|
|
2370
|
-
endColumn:
|
|
2371
|
-
}),
|
|
2372
|
-
startRow:
|
|
2373
|
-
endRow:
|
|
2374
|
-
startColumn:
|
|
2375
|
-
endColumn:
|
|
2347
|
+
const copyRect = skeletonManagetService.attachRangeWithCoord({
|
|
2348
|
+
startRow: copyRow,
|
|
2349
|
+
endRow: copyRow,
|
|
2350
|
+
startColumn: copyCol,
|
|
2351
|
+
endColumn: copyCol
|
|
2352
|
+
}), pasteRect = skeletonManagetService.attachRangeWithCoord({
|
|
2353
|
+
startRow: pasteRow,
|
|
2354
|
+
endRow: pasteRow,
|
|
2355
|
+
startColumn: pasteCol,
|
|
2356
|
+
endColumn: pasteCol
|
|
2376
2357
|
});
|
|
2377
|
-
if (!
|
|
2358
|
+
if (!copyRect || !pasteRect)
|
|
2378
2359
|
return { redos: [], undos: [] };
|
|
2379
|
-
const
|
|
2380
|
-
return
|
|
2381
|
-
const { transform
|
|
2382
|
-
if (!
|
|
2360
|
+
const redos = [], undos = [], leftOffset = pasteRect.startX - copyRect.startX, topOffset = pasteRect.startY - copyRect.startY, rowOffset = pasteRow - copyRow, columnOffset = pasteCol - copyCol, isCut = copyInfo.copyType === COPY_TYPE.CUT, { _sheetDrawingService } = this;
|
|
2361
|
+
return drawings.forEach((drawing) => {
|
|
2362
|
+
const { transform, sheetTransform } = drawing;
|
|
2363
|
+
if (!transform)
|
|
2383
2364
|
return;
|
|
2384
|
-
const
|
|
2385
|
-
...
|
|
2386
|
-
unitId
|
|
2387
|
-
subUnitId
|
|
2388
|
-
drawingId:
|
|
2365
|
+
const drawingObject = {
|
|
2366
|
+
...drawing,
|
|
2367
|
+
unitId,
|
|
2368
|
+
subUnitId,
|
|
2369
|
+
drawingId: isCut ? drawing.drawingId : Tools.generateRandomId(),
|
|
2389
2370
|
transform: {
|
|
2390
|
-
...
|
|
2391
|
-
left:
|
|
2392
|
-
top:
|
|
2371
|
+
...transform,
|
|
2372
|
+
left: transform.left + leftOffset,
|
|
2373
|
+
top: transform.top + topOffset
|
|
2393
2374
|
},
|
|
2394
2375
|
sheetTransform: {
|
|
2395
|
-
to: { ...
|
|
2396
|
-
from: { ...
|
|
2376
|
+
to: { ...sheetTransform.to, row: sheetTransform.to.row + rowOffset, column: sheetTransform.to.column + columnOffset },
|
|
2377
|
+
from: { ...sheetTransform.from, row: sheetTransform.from.row + rowOffset, column: sheetTransform.from.column + columnOffset }
|
|
2397
2378
|
}
|
|
2398
2379
|
};
|
|
2399
|
-
if (
|
|
2400
|
-
const { undo
|
|
2401
|
-
|
|
2402
|
-
id:
|
|
2380
|
+
if (isCut) {
|
|
2381
|
+
const { undo, redo, objects } = _sheetDrawingService.getBatchUpdateOp([drawingObject]);
|
|
2382
|
+
redos.push({
|
|
2383
|
+
id: SetDrawingApplyMutation.id,
|
|
2403
2384
|
params: {
|
|
2404
|
-
unitId
|
|
2405
|
-
subUnitId
|
|
2406
|
-
type:
|
|
2407
|
-
op:
|
|
2408
|
-
objects
|
|
2385
|
+
unitId,
|
|
2386
|
+
subUnitId,
|
|
2387
|
+
type: DrawingApplyType.UPDATE,
|
|
2388
|
+
op: redo,
|
|
2389
|
+
objects
|
|
2409
2390
|
}
|
|
2410
|
-
}),
|
|
2411
|
-
id:
|
|
2391
|
+
}), undos.push({
|
|
2392
|
+
id: SetDrawingApplyMutation.id,
|
|
2412
2393
|
params: {
|
|
2413
|
-
unitId
|
|
2414
|
-
subUnitId
|
|
2415
|
-
type:
|
|
2416
|
-
op:
|
|
2417
|
-
objects
|
|
2394
|
+
unitId,
|
|
2395
|
+
subUnitId,
|
|
2396
|
+
type: DrawingApplyType.UPDATE,
|
|
2397
|
+
op: undo,
|
|
2398
|
+
objects
|
|
2418
2399
|
}
|
|
2419
2400
|
});
|
|
2420
2401
|
} else {
|
|
2421
|
-
const { undo
|
|
2422
|
-
|
|
2402
|
+
const { undo, redo, objects } = _sheetDrawingService.getBatchAddOp([drawingObject]);
|
|
2403
|
+
redos.push({ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } }), undos.push({ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } });
|
|
2423
2404
|
}
|
|
2424
2405
|
}), {
|
|
2425
|
-
redos
|
|
2426
|
-
undos
|
|
2406
|
+
redos,
|
|
2407
|
+
undos
|
|
2427
2408
|
};
|
|
2428
2409
|
}
|
|
2429
|
-
};
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
],
|
|
2436
|
-
var
|
|
2437
|
-
for (var
|
|
2438
|
-
(
|
|
2439
|
-
return
|
|
2440
|
-
},
|
|
2441
|
-
const
|
|
2442
|
-
|
|
2443
|
-
|
|
2410
|
+
}, __name(_a8, "SheetsDrawingCopyPasteController"), _a8);
|
|
2411
|
+
SheetsDrawingCopyPasteController = __decorateClass$1([
|
|
2412
|
+
OnLifecycle(LifecycleStages.Ready, SheetsDrawingCopyPasteController),
|
|
2413
|
+
__decorateParam$1(0, ISheetClipboardService),
|
|
2414
|
+
__decorateParam$1(1, IRenderManagerService),
|
|
2415
|
+
__decorateParam$1(2, ISheetDrawingService)
|
|
2416
|
+
], SheetsDrawingCopyPasteController);
|
|
2417
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2418
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2419
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2420
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
2421
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
|
|
2422
|
+
const PLUGIN_NAME = "SHEET_IMAGE_UI_PLUGIN";
|
|
2423
|
+
var _a9;
|
|
2424
|
+
let UniverSheetsDrawingUIPlugin = (_a9 = class extends Plugin {
|
|
2425
|
+
constructor(config = {}, _injector, _localeService, _renderManagerService) {
|
|
2444
2426
|
super();
|
|
2445
|
-
|
|
2446
|
-
this._injector =
|
|
2427
|
+
__publicField(this, "_pluginConfig");
|
|
2428
|
+
this._injector = _injector, this._localeService = _localeService, this._renderManagerService = _renderManagerService, this._pluginConfig = Tools.deepMerge({}, DefaultSheetsDrawingConfig, config);
|
|
2447
2429
|
}
|
|
2448
|
-
onStarting(
|
|
2449
|
-
|
|
2430
|
+
onStarting() {
|
|
2431
|
+
this._initDependencies();
|
|
2450
2432
|
}
|
|
2451
2433
|
onRendered() {
|
|
2452
2434
|
this._registerRenderModules();
|
|
2453
2435
|
}
|
|
2454
|
-
_initDependencies(
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
[
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
[Te],
|
|
2466
|
-
[je],
|
|
2467
|
-
[Le]
|
|
2468
|
-
], t = [
|
|
2469
|
-
Ue,
|
|
2470
|
-
Ae
|
|
2471
|
-
];
|
|
2472
|
-
n.forEach((r) => e.add(r)), t.forEach((r) => this._renderManagerService.registerRenderModule(B.UNIVER_SHEET, r));
|
|
2436
|
+
_initDependencies() {
|
|
2437
|
+
[
|
|
2438
|
+
[SheetCanvasFloatDomManagerService],
|
|
2439
|
+
[SheetDrawingUIController, {
|
|
2440
|
+
useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetDrawingUIController, this._pluginConfig), "useFactory")
|
|
2441
|
+
}],
|
|
2442
|
+
[DrawingPopupMenuController],
|
|
2443
|
+
[SheetDrawingPrintingController],
|
|
2444
|
+
[SheetDrawingPermissionController],
|
|
2445
|
+
[SheetsDrawingCopyPasteController]
|
|
2446
|
+
].forEach((dependency) => this._injector.add(dependency));
|
|
2473
2447
|
}
|
|
2474
2448
|
_registerRenderModules() {
|
|
2475
2449
|
[
|
|
2476
|
-
[
|
|
2477
|
-
|
|
2478
|
-
|
|
2450
|
+
[SheetDrawingUpdateController],
|
|
2451
|
+
[SheetDrawingTransformAffectedController]
|
|
2452
|
+
].forEach((m) => {
|
|
2453
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));
|
|
2479
2454
|
});
|
|
2480
2455
|
}
|
|
2481
|
-
};
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
],
|
|
2456
|
+
}, __name(_a9, "UniverSheetsDrawingUIPlugin"), _a9);
|
|
2457
|
+
__publicField2(UniverSheetsDrawingUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
2458
|
+
__publicField2(UniverSheetsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
|
|
2459
|
+
UniverSheetsDrawingUIPlugin = __decorateClass([
|
|
2460
|
+
DependentOn(UniverDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsDrawingPlugin),
|
|
2461
|
+
__decorateParam(1, Inject(Injector)),
|
|
2462
|
+
__decorateParam(2, Inject(LocaleService)),
|
|
2463
|
+
__decorateParam(3, IRenderManagerService)
|
|
2464
|
+
], UniverSheetsDrawingUIPlugin);
|
|
2490
2465
|
export {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2466
|
+
ClearSheetDrawingTransformerOperation,
|
|
2467
|
+
DeleteDrawingsCommand,
|
|
2468
|
+
EditSheetDrawingOperation,
|
|
2469
|
+
GroupSheetDrawingCommand,
|
|
2470
|
+
IMAGE_MENU_ID,
|
|
2471
|
+
InsertCellImageOperation,
|
|
2472
|
+
InsertFloatImageOperation,
|
|
2473
|
+
InsertSheetDrawingCommand,
|
|
2474
|
+
MoveDrawingsCommand,
|
|
2475
|
+
RemoveSheetDrawingCommand,
|
|
2476
|
+
SetDrawingArrangeCommand,
|
|
2477
|
+
SetSheetDrawingCommand,
|
|
2478
|
+
SheetCanvasFloatDomManagerService,
|
|
2479
|
+
SidebarSheetDrawingOperation,
|
|
2480
|
+
UngroupSheetDrawingCommand,
|
|
2481
|
+
UniverSheetsDrawingUIPlugin
|
|
2506
2482
|
};
|