@univerjs/sheets-drawing-ui 0.4.2-nightly.202411061606 → 0.4.2-nightly.202411081606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/facade.js +420 -18
- package/lib/es/index.js +1904 -1512
- package/lib/{locale → es/locale}/en-US.js +2 -2
- package/lib/{locale → es/locale}/fa-IR.js +2 -2
- package/lib/{locale → es/locale}/ru-RU.js +2 -2
- package/lib/{locale → es/locale}/vi-VN.js +2 -2
- package/lib/{locale → es/locale}/zh-CN.js +2 -2
- package/lib/{locale → es/locale}/zh-TW.js +2 -2
- package/lib/umd/index.js +1 -9
- package/package.json +27 -19
- package/lib/canvas-float-dom-manager.service-t4WyJLnC.mjs +0 -416
|
@@ -1,416 +0,0 @@
|
|
|
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, sequenceExecute, Inject, LifecycleService, Disposable, LifecycleStages, DisposableCollection, UniverInstanceType, fromEventSubject, generateRandomId, IUniverInstanceService } from "@univerjs/core";
|
|
6
|
-
import { DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, IDrawingManagerService } from "@univerjs/drawing";
|
|
7
|
-
import { IRenderManagerService, Rect, ObjectType, DRAWING_OBJECT_LAYER_INDEX, SHEET_VIEWPORT_KEY } from "@univerjs/engine-render";
|
|
8
|
-
import { SheetInterceptorService, getSheetCommandTarget, SetFrozenMutation } from "@univerjs/sheets";
|
|
9
|
-
import { ISheetDrawingService, SetDrawingApplyMutation, DrawingApplyType } from "@univerjs/sheets-drawing";
|
|
10
|
-
import { SheetSkeletonManagerService, VIEWPORT_KEY, SetZoomRatioOperation, ISheetSelectionRenderService } from "@univerjs/sheets-ui";
|
|
11
|
-
import { CanvasFloatDomService } from "@univerjs/ui";
|
|
12
|
-
import { Subject, filter, take, BehaviorSubject, map, switchMap } from "rxjs";
|
|
13
|
-
const ClearSheetDrawingTransformerOperation = {
|
|
14
|
-
id: "sheet.operation.clear-drawing-transformer",
|
|
15
|
-
type: CommandType.MUTATION,
|
|
16
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
17
|
-
const renderManagerService = accessor.get(IRenderManagerService);
|
|
18
|
-
return params.forEach((unitId) => {
|
|
19
|
-
var _a2, _b;
|
|
20
|
-
(_b = (_a2 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a2.scene.getTransformer()) == null || _b.debounceRefreshControls();
|
|
21
|
-
}), !0;
|
|
22
|
-
}, "handler")
|
|
23
|
-
}, InsertSheetDrawingCommand = {
|
|
24
|
-
id: "sheet.command.insert-sheet-image",
|
|
25
|
-
type: CommandType.COMMAND,
|
|
26
|
-
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
27
|
-
var _a2, _b, _c;
|
|
28
|
-
const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService), sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
29
|
-
if (!params) return !1;
|
|
30
|
-
const drawings = params.drawings, unitIds = drawings.map((param) => param.unitId), jsonOp = sheetDrawingService.getBatchAddOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp, intercepted = sheetInterceptorService.onCommandExecute({ id: InsertSheetDrawingCommand.id, params }), insertMutation = { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } }, undoInsertMutation = { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } };
|
|
31
|
-
return sequenceExecute([...(_a2 = intercepted.preRedos) != null ? _a2 : [], insertMutation, ...intercepted.redos], commandService) ? (undoRedoService.pushUndoRedo({
|
|
32
|
-
unitID: unitId,
|
|
33
|
-
undoMutations: [
|
|
34
|
-
...(_b = intercepted.preUndos) != null ? _b : [],
|
|
35
|
-
undoInsertMutation,
|
|
36
|
-
...intercepted.undos,
|
|
37
|
-
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
38
|
-
],
|
|
39
|
-
redoMutations: [
|
|
40
|
-
...(_c = intercepted.preRedos) != null ? _c : [],
|
|
41
|
-
insertMutation,
|
|
42
|
-
...intercepted.redos,
|
|
43
|
-
{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
|
|
44
|
-
]
|
|
45
|
-
}), !0) : !1;
|
|
46
|
-
}, "handler")
|
|
47
|
-
};
|
|
48
|
-
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
49
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
50
|
-
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
51
|
-
return kind && result && __defProp2(target, key, result), result;
|
|
52
|
-
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
53
|
-
function transformBound2DOMBound(originBound, scene, skeleton, worksheet) {
|
|
54
|
-
const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN), absolute = {
|
|
55
|
-
left: !0,
|
|
56
|
-
top: !0
|
|
57
|
-
};
|
|
58
|
-
if (!viewMain)
|
|
59
|
-
return {
|
|
60
|
-
...originBound,
|
|
61
|
-
absolute
|
|
62
|
-
};
|
|
63
|
-
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;
|
|
64
|
-
let offsetLeft, offsetRight;
|
|
65
|
-
left < freezeLeft ? (absolute.left = !0, offsetLeft = (freezeWidth + rowHeaderWidth + (left - freezeLeft)) * scaleX, offsetRight = Math.max(
|
|
66
|
-
Math.min(
|
|
67
|
-
(freezeWidth + rowHeaderWidth + (right - freezeLeft)) * scaleX,
|
|
68
|
-
(freezeWidth + rowHeaderWidth) * scaleX
|
|
69
|
-
),
|
|
70
|
-
(right - actualScrollX) * scaleX
|
|
71
|
-
)) : (absolute.left = !1, offsetLeft = Math.max((left - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX), offsetRight = Math.max((right - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX));
|
|
72
|
-
let offsetTop, offsetBottom;
|
|
73
|
-
return top < freezeTop ? (absolute.top = !0, offsetTop = (freezeHeight + columnHeaderHeight + (top - freezeTop)) * scaleY, offsetBottom = Math.max(
|
|
74
|
-
Math.min(
|
|
75
|
-
(freezeHeight + columnHeaderHeight + (right - freezeTop)) * scaleY,
|
|
76
|
-
(freezeHeight + columnHeaderHeight) * scaleY
|
|
77
|
-
),
|
|
78
|
-
(bottom - actualScrollY) * scaleY
|
|
79
|
-
)) : (absolute.top = !1, offsetTop = Math.max((top - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY), offsetBottom = Math.max((bottom - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY)), {
|
|
80
|
-
left: offsetLeft,
|
|
81
|
-
right: offsetRight,
|
|
82
|
-
top: offsetTop,
|
|
83
|
-
bottom: offsetBottom,
|
|
84
|
-
absolute
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
__name(transformBound2DOMBound, "transformBound2DOMBound");
|
|
88
|
-
const calcPosition = /* @__PURE__ */ __name((targetObject, currentRender, skeleton, worksheet) => {
|
|
89
|
-
const { scene } = currentRender, { left, top, width, height, angle } = targetObject, bound = {
|
|
90
|
-
left,
|
|
91
|
-
right: left + width,
|
|
92
|
-
top,
|
|
93
|
-
bottom: top + height
|
|
94
|
-
}, offsetBound = transformBound2DOMBound(bound, scene, skeleton, worksheet), { scaleX, scaleY } = scene.getAncestorScale();
|
|
95
|
-
return {
|
|
96
|
-
startX: offsetBound.left,
|
|
97
|
-
endX: offsetBound.right,
|
|
98
|
-
startY: offsetBound.top,
|
|
99
|
-
endY: offsetBound.bottom,
|
|
100
|
-
rotate: angle,
|
|
101
|
-
width: width * scaleX,
|
|
102
|
-
height: height * scaleY,
|
|
103
|
-
absolute: offsetBound.absolute
|
|
104
|
-
};
|
|
105
|
-
}, "calcPosition");
|
|
106
|
-
var _a;
|
|
107
|
-
let SheetCanvasFloatDomManagerService = (_a = class extends Disposable {
|
|
108
|
-
constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService, _lifecycleService) {
|
|
109
|
-
super();
|
|
110
|
-
__publicField(this, "_domLayerMap", /* @__PURE__ */ new Map());
|
|
111
|
-
__publicField(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
|
|
112
|
-
__publicField(this, "_transformChange$", new Subject());
|
|
113
|
-
__publicField(this, "transformChange$", this._transformChange$.asObservable());
|
|
114
|
-
__publicField(this, "_add$", new Subject());
|
|
115
|
-
__publicField(this, "add$", this._add$.asObservable());
|
|
116
|
-
__publicField(this, "_remove$", new Subject());
|
|
117
|
-
__publicField(this, "remove$", this._remove$.asObservable());
|
|
118
|
-
__publicField(this, "_hooks", []);
|
|
119
|
-
this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._canvasFloatDomService = _canvasFloatDomService, this._sheetDrawingService = _sheetDrawingService, this._lifecycleService = _lifecycleService, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent();
|
|
120
|
-
}
|
|
121
|
-
_bindScrollEvent() {
|
|
122
|
-
this._lifecycleService.lifecycle$.pipe(filter((s) => s === LifecycleStages.Rendered), take(1)).subscribe(() => {
|
|
123
|
-
this._scrollUpdateListener();
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
_ensureMap(unitId, subUnitId) {
|
|
127
|
-
let unitMap = this._domLayerMap.get(unitId);
|
|
128
|
-
unitMap || (unitMap = /* @__PURE__ */ new Map(), this._domLayerMap.set(unitId, unitMap));
|
|
129
|
-
let subUnitMap = unitMap.get(subUnitId);
|
|
130
|
-
return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
|
|
131
|
-
}
|
|
132
|
-
getFloatDomInfo(id) {
|
|
133
|
-
return this._domLayerInfoMap.get(id);
|
|
134
|
-
}
|
|
135
|
-
_getSceneAndTransformerByDrawingSearch(unitId) {
|
|
136
|
-
if (unitId == null)
|
|
137
|
-
return;
|
|
138
|
-
const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
|
|
139
|
-
if (renderObject == null || scene == null)
|
|
140
|
-
return null;
|
|
141
|
-
const transformer = scene.getTransformerByCreate(), canvas = renderObject.engine.getCanvasElement();
|
|
142
|
-
return { scene, transformer, renderObject, canvas };
|
|
143
|
-
}
|
|
144
|
-
_getFloatDomProps(id) {
|
|
145
|
-
let props;
|
|
146
|
-
return this._hooks.forEach((hook) => {
|
|
147
|
-
props = hook.onGetFloatDomProps(id);
|
|
148
|
-
}), props;
|
|
149
|
-
}
|
|
150
|
-
// eslint-disable-next-line max-lines-per-function
|
|
151
|
-
_drawingAddListener() {
|
|
152
|
-
this.disposeWithMe(
|
|
153
|
-
// eslint-disable-next-line max-lines-per-function
|
|
154
|
-
this._drawingManagerService.add$.subscribe((params) => {
|
|
155
|
-
params.forEach((param) => {
|
|
156
|
-
var _a2, _b, _c;
|
|
157
|
-
const { unitId, subUnitId, drawingId } = param, target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), floatDomParam = this._drawingManagerService.getDrawingByParam(param), workbook = this._univerInstanceService.getUnit(unitId);
|
|
158
|
-
if (!workbook)
|
|
159
|
-
return;
|
|
160
|
-
const activeSheetId = workbook.getActiveSheet().getSheetId();
|
|
161
|
-
if (!floatDomParam || !target)
|
|
162
|
-
return;
|
|
163
|
-
const skeleton = (_a2 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a2.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
|
|
164
|
-
if (!skeleton)
|
|
165
|
-
return;
|
|
166
|
-
const { transform, drawingType, data } = floatDomParam;
|
|
167
|
-
if (drawingType !== DrawingTypeEnum.DRAWING_DOM && drawingType !== DrawingTypeEnum.DRAWING_CHART)
|
|
168
|
-
return;
|
|
169
|
-
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
170
|
-
if (renderObject == null)
|
|
171
|
-
return;
|
|
172
|
-
const { scene, canvas } = renderObject;
|
|
173
|
-
if (transform == null)
|
|
174
|
-
return !0;
|
|
175
|
-
if (activeSheetId !== subUnitId)
|
|
176
|
-
return;
|
|
177
|
-
const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), rectShape = scene.getObject(rectShapeKey);
|
|
178
|
-
if (rectShape != null) {
|
|
179
|
-
rectShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
const imageConfig = {
|
|
183
|
-
left,
|
|
184
|
-
top,
|
|
185
|
-
width,
|
|
186
|
-
height,
|
|
187
|
-
zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
|
|
188
|
-
}, isChart = drawingType === DrawingTypeEnum.DRAWING_CHART;
|
|
189
|
-
isChart && (imageConfig.fill = "white", imageConfig.rotateEnabled = !1, data && data.border && (imageConfig.stroke = data.border), imageConfig.paintFirst = "stroke", imageConfig.strokeWidth = 1, imageConfig.borderEnabled = !1, imageConfig.radius = 8);
|
|
190
|
-
const rect = new Rect(rectShapeKey, imageConfig);
|
|
191
|
-
isChart && rect.setObjectType(ObjectType.CHART), scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX), floatDomParam.allowTransform !== !1 && scene.attachTransformerTo(rect);
|
|
192
|
-
const map2 = this._ensureMap(unitId, subUnitId), disposableCollection = new DisposableCollection(), initPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet), position$ = new BehaviorSubject(initPosition), info = {
|
|
193
|
-
dispose: disposableCollection,
|
|
194
|
-
rect,
|
|
195
|
-
position$,
|
|
196
|
-
unitId,
|
|
197
|
-
subUnitId
|
|
198
|
-
};
|
|
199
|
-
this._canvasFloatDomService.addFloatDom({
|
|
200
|
-
position$,
|
|
201
|
-
id: drawingId,
|
|
202
|
-
componentKey: floatDomParam.componentKey,
|
|
203
|
-
onPointerDown: /* @__PURE__ */ __name((evt) => {
|
|
204
|
-
canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
205
|
-
}, "onPointerDown"),
|
|
206
|
-
onPointerMove: /* @__PURE__ */ __name((evt) => {
|
|
207
|
-
canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
208
|
-
}, "onPointerMove"),
|
|
209
|
-
onPointerUp: /* @__PURE__ */ __name((evt) => {
|
|
210
|
-
canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
211
|
-
}, "onPointerUp"),
|
|
212
|
-
onWheel: /* @__PURE__ */ __name((evt) => {
|
|
213
|
-
canvas.dispatchEvent(new WheelEvent(evt.type, evt));
|
|
214
|
-
}, "onWheel"),
|
|
215
|
-
props: (_c = (_b = map2.get(drawingId)) == null ? void 0 : _b.props) != null ? _c : this._getFloatDomProps(drawingId),
|
|
216
|
-
data,
|
|
217
|
-
unitId
|
|
218
|
-
});
|
|
219
|
-
const listener = rect.onTransformChange$.subscribeEvent(() => {
|
|
220
|
-
const newPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
|
|
221
|
-
position$.next(
|
|
222
|
-
newPosition
|
|
223
|
-
);
|
|
224
|
-
});
|
|
225
|
-
disposableCollection.add(() => {
|
|
226
|
-
this._canvasFloatDomService.removeFloatDom(drawingId);
|
|
227
|
-
}), listener && disposableCollection.add(listener), this._domLayerInfoMap.set(drawingId, info), map2.set(drawingId, {
|
|
228
|
-
...map2.get(drawingId)
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
})
|
|
232
|
-
), this.disposeWithMe(
|
|
233
|
-
this._drawingManagerService.remove$.subscribe((params) => {
|
|
234
|
-
params.forEach((param) => {
|
|
235
|
-
const { unitId, subUnitId, drawingId } = param, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
236
|
-
if (renderObject == null)
|
|
237
|
-
return;
|
|
238
|
-
const { transformer, scene } = renderObject, rectShape = scene.getObject(rectShapeKey);
|
|
239
|
-
rectShape != null && rectShape.oKey && transformer.clearControlByIds([rectShape == null ? void 0 : rectShape.oKey]);
|
|
240
|
-
});
|
|
241
|
-
})
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
_scrollUpdateListener() {
|
|
245
|
-
const updateSheet = /* @__PURE__ */ __name((unitId, subUnitId) => {
|
|
246
|
-
var _a2;
|
|
247
|
-
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId), map2 = this._ensureMap(unitId, subUnitId), ids = Array.from(map2.keys()), target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), skeleton = (_a2 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a2.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
|
|
248
|
-
!renderObject || !target || !skeleton || ids.forEach((id) => {
|
|
249
|
-
const info = this._domLayerInfoMap.get(id);
|
|
250
|
-
if (info) {
|
|
251
|
-
const position = calcPosition(info.rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
|
|
252
|
-
info.position$.next(position);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}, "updateSheet");
|
|
256
|
-
this.disposeWithMe(
|
|
257
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
|
|
258
|
-
filter((sheet) => !!sheet),
|
|
259
|
-
map((sheet) => {
|
|
260
|
-
const render = this._renderManagerService.getRenderById(sheet.getUnitId());
|
|
261
|
-
return render ? { render, unitId: sheet.getUnitId(), subUnitId: sheet.getActiveSheet().getSheetId() } : null;
|
|
262
|
-
}),
|
|
263
|
-
filter((render) => !!render),
|
|
264
|
-
switchMap(
|
|
265
|
-
(render) => fromEventSubject(render.render.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(map(() => ({ unitId: render.unitId, subUnitId: render.subUnitId })))
|
|
266
|
-
)
|
|
267
|
-
).subscribe(({ unitId, subUnitId }) => {
|
|
268
|
-
updateSheet(unitId, subUnitId);
|
|
269
|
-
})
|
|
270
|
-
), this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
271
|
-
var _a2, _b;
|
|
272
|
-
if (commandInfo.id === SetZoomRatioOperation.id) {
|
|
273
|
-
const params = commandInfo.params, { unitId } = params;
|
|
274
|
-
Array.from((_b = (_a2 = this._domLayerMap.get(unitId)) == null ? void 0 : _a2.keys()) != null ? _b : []).forEach((subUnitId) => {
|
|
275
|
-
updateSheet(unitId, subUnitId);
|
|
276
|
-
});
|
|
277
|
-
} else if (commandInfo.id === SetFrozenMutation.id) {
|
|
278
|
-
const { unitId, subUnitId } = commandInfo.params;
|
|
279
|
-
updateSheet(unitId, subUnitId);
|
|
280
|
-
}
|
|
281
|
-
}));
|
|
282
|
-
}
|
|
283
|
-
_getPosition(position, unitId) {
|
|
284
|
-
var _a2;
|
|
285
|
-
const { startX, endX, startY, endY } = position, selectionRenderService = (_a2 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a2.with(ISheetSelectionRenderService);
|
|
286
|
-
if (selectionRenderService == null)
|
|
287
|
-
return;
|
|
288
|
-
const start = selectionRenderService.getSelectionCellByPosition(startX, startY);
|
|
289
|
-
if (start == null)
|
|
290
|
-
return;
|
|
291
|
-
const from = {
|
|
292
|
-
column: start.actualColumn,
|
|
293
|
-
columnOffset: startX - start.startX,
|
|
294
|
-
row: start.actualRow,
|
|
295
|
-
rowOffset: startY - start.startY
|
|
296
|
-
}, end = selectionRenderService.getSelectionCellByPosition(endX, endY);
|
|
297
|
-
if (end == null)
|
|
298
|
-
return;
|
|
299
|
-
const to = {
|
|
300
|
-
column: end.actualColumn,
|
|
301
|
-
columnOffset: endX - end.startX,
|
|
302
|
-
row: end.actualRow,
|
|
303
|
-
rowOffset: endY - end.startY
|
|
304
|
-
};
|
|
305
|
-
return {
|
|
306
|
-
from,
|
|
307
|
-
to
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
_featureUpdateListener() {
|
|
311
|
-
this.disposeWithMe(
|
|
312
|
-
this._drawingManagerService.update$.subscribe((params) => {
|
|
313
|
-
params.forEach((data) => {
|
|
314
|
-
const sheetDrawing = this._drawingManagerService.getDrawingByParam(data);
|
|
315
|
-
if (!sheetDrawing || sheetDrawing.drawingType !== DrawingTypeEnum.DRAWING_DOM && sheetDrawing.drawingType !== DrawingTypeEnum.DRAWING_CHART)
|
|
316
|
-
return;
|
|
317
|
-
const newValue = {
|
|
318
|
-
...sheetDrawing.transform
|
|
319
|
-
};
|
|
320
|
-
this._transformChange$.next({ id: data.drawingId, value: newValue });
|
|
321
|
-
});
|
|
322
|
-
})
|
|
323
|
-
);
|
|
324
|
-
}
|
|
325
|
-
_deleteListener() {
|
|
326
|
-
this.disposeWithMe(
|
|
327
|
-
this._drawingManagerService.remove$.subscribe((params) => {
|
|
328
|
-
params.forEach((param) => {
|
|
329
|
-
this._removeDom(param.drawingId);
|
|
330
|
-
});
|
|
331
|
-
})
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
updateFloatDomProps(unitId, subUnitId, id, props) {
|
|
335
|
-
const info = this._domLayerInfoMap.get(id), renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
336
|
-
if (info && renderObject) {
|
|
337
|
-
const { scene } = renderObject, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId: id }), rectShape = scene.getObject(rectShapeKey);
|
|
338
|
-
rectShape && rectShape instanceof Rect && rectShape.setProps(props);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
addFloatDomToPosition(layer, propId) {
|
|
342
|
-
const target = getSheetCommandTarget(this._univerInstanceService, {
|
|
343
|
-
unitId: layer.unitId,
|
|
344
|
-
subUnitId: layer.subUnitId
|
|
345
|
-
});
|
|
346
|
-
if (!target)
|
|
347
|
-
throw new Error("cannot find current target!");
|
|
348
|
-
const { unitId, subUnitId } = target, { initPosition, componentKey, data, allowTransform = !0 } = layer, id = propId != null ? propId : generateRandomId(), sheetTransform = this._getPosition(initPosition, unitId);
|
|
349
|
-
if (sheetTransform == null)
|
|
350
|
-
return;
|
|
351
|
-
this._ensureMap(unitId, subUnitId).set(id, layer);
|
|
352
|
-
const sheetDrawingParam = {
|
|
353
|
-
unitId,
|
|
354
|
-
subUnitId,
|
|
355
|
-
drawingId: id,
|
|
356
|
-
drawingType: layer.type || DrawingTypeEnum.DRAWING_DOM,
|
|
357
|
-
componentKey,
|
|
358
|
-
sheetTransform,
|
|
359
|
-
transform: {
|
|
360
|
-
left: initPosition.startX,
|
|
361
|
-
top: initPosition.startY,
|
|
362
|
-
width: initPosition.endX - initPosition.startX,
|
|
363
|
-
height: initPosition.endY - initPosition.startY
|
|
364
|
-
},
|
|
365
|
-
data,
|
|
366
|
-
allowTransform
|
|
367
|
-
};
|
|
368
|
-
return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
|
|
369
|
-
unitId,
|
|
370
|
-
drawings: [sheetDrawingParam]
|
|
371
|
-
}), this._add$.next({ unitId, subUnitId, id }), {
|
|
372
|
-
id,
|
|
373
|
-
dispose: /* @__PURE__ */ __name(() => {
|
|
374
|
-
this._removeDom(id, !0);
|
|
375
|
-
}, "dispose")
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
_removeDom(id, removeDrawing = !1) {
|
|
379
|
-
const info = this._domLayerInfoMap.get(id);
|
|
380
|
-
if (!info)
|
|
381
|
-
return;
|
|
382
|
-
const { unitId, subUnitId } = info;
|
|
383
|
-
this._domLayerInfoMap.delete(id), info.dispose.dispose();
|
|
384
|
-
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
385
|
-
if (renderObject && renderObject.scene.removeObject(info.rect), removeDrawing) {
|
|
386
|
-
this._ensureMap(unitId, subUnitId).delete(id);
|
|
387
|
-
const param = this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId: id });
|
|
388
|
-
if (!param)
|
|
389
|
-
return;
|
|
390
|
-
const jsonOp = this._sheetDrawingService.getBatchRemoveOp([param]), { redo, objects } = jsonOp;
|
|
391
|
-
this._commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE });
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
addHook(hook) {
|
|
395
|
-
return this._hooks.push(hook), {
|
|
396
|
-
dispose: /* @__PURE__ */ __name(() => {
|
|
397
|
-
const index = this._hooks.findIndex((h) => h === hook);
|
|
398
|
-
this._hooks.splice(index, 1);
|
|
399
|
-
}, "dispose")
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
}, __name(_a, "SheetCanvasFloatDomManagerService"), _a);
|
|
403
|
-
SheetCanvasFloatDomManagerService = __decorateClass([
|
|
404
|
-
__decorateParam(0, Inject(IRenderManagerService)),
|
|
405
|
-
__decorateParam(1, IUniverInstanceService),
|
|
406
|
-
__decorateParam(2, Inject(ICommandService)),
|
|
407
|
-
__decorateParam(3, IDrawingManagerService),
|
|
408
|
-
__decorateParam(4, Inject(CanvasFloatDomService)),
|
|
409
|
-
__decorateParam(5, ISheetDrawingService),
|
|
410
|
-
__decorateParam(6, Inject(LifecycleService))
|
|
411
|
-
], SheetCanvasFloatDomManagerService);
|
|
412
|
-
export {
|
|
413
|
-
ClearSheetDrawingTransformerOperation as C,
|
|
414
|
-
InsertSheetDrawingCommand as I,
|
|
415
|
-
SheetCanvasFloatDomManagerService as S
|
|
416
|
-
};
|