@univerjs/sheets-drawing-ui 0.4.1 → 0.4.2-nightly.202410301606

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