@univerjs/sheets-drawing-ui 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
@@ -17,12 +17,15 @@ import { IUniverInstanceService, RxDisposable } from '@univerjs/core';
17
17
  import { IDrawingManagerService } from '@univerjs/drawing';
18
18
  import { IRenderManagerService } from '@univerjs/engine-render';
19
19
  import { IContextMenuService } from '@univerjs/ui';
20
+ import { IDrawingContextMenuService } from '../services/drawing-context-menu.service';
20
21
  export declare class DrawingContextMenuController extends RxDisposable {
21
22
  private readonly _drawingManagerService;
22
23
  private readonly _contextMenuService;
23
24
  private readonly _renderManagerService;
24
25
  private readonly _univerInstanceService;
25
- constructor(_drawingManagerService: IDrawingManagerService, _contextMenuService: IContextMenuService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService);
26
+ private readonly _drawingContextMenuService;
27
+ constructor(_drawingManagerService: IDrawingManagerService, _contextMenuService: IContextMenuService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _drawingContextMenuService: IDrawingContextMenuService);
26
28
  private _init;
27
29
  private _contextMenuListener;
30
+ private _getContextMenuPosition;
28
31
  }
@@ -16,8 +16,8 @@
16
16
  import type { IAccessor, Workbook } from '@univerjs/core';
17
17
  import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
18
18
  import type { ISheetLocationBase } from '@univerjs/sheets';
19
- import { Disposable, ICommandService, IContextService, Injector, IURLImageService, LocaleService } from '@univerjs/core';
20
- import { IDrawingManagerService, IImageIoService } from '@univerjs/drawing';
19
+ import { Disposable, ICommandService, IContextService, IImageIoService, Injector, IURLImageService, LocaleService } from '@univerjs/core';
20
+ import { IDrawingManagerService } from '@univerjs/drawing';
21
21
  import { SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService } from '@univerjs/sheets';
22
22
  import { ISheetDrawingService } from '@univerjs/sheets-drawing';
23
23
  import { ISheetSelectionRenderService } from '@univerjs/sheets-ui';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { registerSheetsDrawingFloatingHostCapability, SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES, touchSheetsDrawingFloatingHostCapabilityWhenReady, } from './register-sheets-drawing-floating-host';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { Dependency, Injector } from '@univerjs/core';
17
+ export declare const SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES: Dependency[];
18
+ export declare function registerSheetsDrawingFloatingHostCapability(injector: Injector): void;
19
+ export declare function touchSheetsDrawingFloatingHostCapabilityWhenReady(injector: Injector): void;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './floating-host';
@@ -26,10 +26,17 @@ export { SidebarSheetDrawingOperation } from './commands/operations/open-drawing
26
26
  export type { IUniverSheetsDrawingUIConfig } from './config/config';
27
27
  export { SheetsDrawingGroupCopyPasteController } from './controllers/sheet-drawing-group-copy-paste.controller';
28
28
  export { SheetDrawingUpdateController } from './controllers/sheet-drawing-update.controller';
29
+ export { registerSheetsDrawingFloatingHostCapability, SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES } from './embed';
29
30
  export { SHEETS_IMAGE_MENU_ID } from './menu/image.menu';
31
+ export { menuSchema as SheetsDrawingUIMenuSchema } from './menu/schema';
30
32
  export { UniverSheetsDrawingUIPlugin } from './plugin';
31
33
  export { BatchSaveImagesService, FileNamePart, IBatchSaveImagesService } from './services/batch-save-images.service';
32
34
  export type { IBatchSaveImagesConfig, ICellImageInfo } from './services/batch-save-images.service';
33
35
  export { calcSheetFloatDomPosition, SHEET_FLOAT_DOM_PREFIX, SheetCanvasFloatDomManagerService, } from './services/canvas-float-dom-manager.service';
34
36
  export type { ICanvasFloatDom, ICanvasFloatDomInfo, IDOMAnchor } from './services/canvas-float-dom-manager.service';
37
+ export { DrawingContextMenuService, IDrawingContextMenuService } from './services/drawing-context-menu.service';
38
+ export type { IDrawingContextMenuProvider, IDrawingContextMenuProviderContext } from './services/drawing-context-menu.service';
39
+ export { SHEET_CHART_RENDER_OBJECT_CONFIG } from './services/sheet-chart-render-object.config';
40
+ export { SheetDrawingHitTestService } from './services/sheet-drawing-hit-test.service';
41
+ export type { ISheetDrawingDoubleClickEvent, ISheetDrawingHitTestResult } from './services/sheet-drawing-hit-test.service';
35
42
  export { SheetDrawingAnchor } from './views/sheet-image-panel/SheetDrawingAnchor';
@@ -13,14 +13,15 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IDisposable, IPosition, IRange, ITransformState, Serializable, Worksheet } from '@univerjs/core';
16
+ import type { IDisposable, IPosition, IRange, ITransformState, Nullable, Serializable, Worksheet } from '@univerjs/core';
17
17
  import type { BaseObject, IBoundRectNoAngle, IRectProps, Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';
18
- import type { IFloatDomLayout } from '@univerjs/ui';
18
+ import type { IFloatDomData } from '@univerjs/sheets-drawing';
19
+ import type { IFloatDom, IFloatDomLayout } from '@univerjs/ui';
19
20
  import { Disposable, DrawingTypeEnum, ICommandService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
20
21
  import { IDrawingManagerService } from '@univerjs/drawing';
21
22
  import { IRenderManagerService, Rect } from '@univerjs/engine-render';
22
23
  import { ISheetDrawingService } from '@univerjs/sheets-drawing';
23
- import { CanvasFloatDomService } from '@univerjs/ui';
24
+ import { CanvasFloatDomPreviewService, CanvasFloatDomService } from '@univerjs/ui';
24
25
  import { BehaviorSubject } from 'rxjs';
25
26
  export interface ICanvasFloatDom {
26
27
  /**
@@ -62,7 +63,7 @@ export declare const SHEET_FLOAT_DOM_PREFIX = "univer-sheet-float-dom-";
62
63
  export interface ICanvasFloatDomInfo {
63
64
  position$: BehaviorSubject<IFloatDomLayout>;
64
65
  dispose: IDisposable;
65
- rect: Rect;
66
+ rect: BaseObject;
66
67
  unitId: string;
67
68
  subUnitId: string;
68
69
  boundsOfViewArea?: IBoundRectNoAngle;
@@ -70,6 +71,10 @@ export interface ICanvasFloatDomInfo {
70
71
  domAnchor?: IDOMAnchor;
71
72
  id: string;
72
73
  domId?: string;
74
+ floatDomConfig?: IFloatDom;
75
+ runtimeMounted?: boolean;
76
+ runtimeStage?: 'inactive' | 'stage1' | 'stage2';
77
+ previewObjectKey?: string;
73
78
  }
74
79
  /**
75
80
  * Context passed to a sheet float-dom render object factory.
@@ -107,6 +112,99 @@ export interface IDOMAnchor {
107
112
  marginX?: number | string;
108
113
  marginY?: number | string;
109
114
  }
115
+ /**
116
+ * Keep a chart selection outline outside the chart's own rounded frame.
117
+ * Charts retain resize handles but do not expose a rotation control.
118
+ */
119
+ export declare const SHEET_CHART_TRANSFORMER_CONFIG: {
120
+ readonly borderEnabled: true;
121
+ readonly borderStroke: "#4086f4";
122
+ readonly borderStrokeWidth: 1;
123
+ readonly borderSpacing: 2;
124
+ readonly anchorFill: "#ffffff";
125
+ readonly anchorStroke: "#4086f4";
126
+ readonly anchorStrokeWidth: 1.5;
127
+ readonly anchorSize: 8;
128
+ readonly anchorCornerRadius: 2;
129
+ readonly anchorStyle: "canva";
130
+ readonly rotateEnabled: false;
131
+ readonly resizeEnabled: true;
132
+ readonly keepRatio: false;
133
+ readonly moveBoundaryEnabled: false;
134
+ };
135
+ export declare const EMBED_FLOAT_DRAG_HANDLE_POINTER_DOWN_EVENT = "univer:embed-float-drag-handle:pointerdown";
136
+ export interface IFloatDomHostClickIntent {
137
+ pointerId?: number;
138
+ startOffsetX: number;
139
+ startOffsetY: number;
140
+ startedAt: number;
141
+ }
142
+ export interface IEmbedFloatDragHandlePointerDownDetail {
143
+ embedId?: string;
144
+ hostUnitId?: string;
145
+ hostAnchorId?: string;
146
+ pointerId?: number;
147
+ clientX?: number;
148
+ clientY?: number;
149
+ button?: number;
150
+ }
151
+ export interface IFloatDomMoveDragState {
152
+ pointerId?: number;
153
+ startClientX: number;
154
+ startClientY: number;
155
+ startLeft: number;
156
+ startTop: number;
157
+ }
158
+ export declare function shouldStartFloatDomMoveFromHandle(info: Pick<ICanvasFloatDomInfo, 'id' | 'unitId'>, detail: IEmbedFloatDragHandlePointerDownDetail): boolean;
159
+ export declare function createFloatDomMoveDragState(info: Pick<ICanvasFloatDomInfo, 'rect'>, detail: IEmbedFloatDragHandlePointerDownDetail): IFloatDomMoveDragState | undefined;
160
+ export declare function resolveFloatDomMoveDragTransform(state: IFloatDomMoveDragState, event: Pick<PointerEvent, 'clientX' | 'clientY'>, scene: Pick<Scene, 'getAncestorScale'>): Pick<ITransformState, 'left' | 'top'>;
161
+ export declare function applyFloatDomTransformerConfig(rect: BaseObject, floatDomParam: IFloatDomData): void;
162
+ export declare function applySheetChartTransformerConfig(rect: BaseObject): void;
163
+ export declare function isEmbedFloatDomData(floatDomParam: Pick<IFloatDomData, 'data'>): boolean;
164
+ export declare function isSheetHostedEmbedFloatDom(floatDomParam: Pick<IFloatDomData, 'data'>): boolean;
165
+ export declare function resolveSheetFloatDomRuntimePolicy(floatDomParam: Pick<IFloatDomData, 'data'>, stage?: ICanvasFloatDomInfo['runtimeStage']): {
166
+ autoMountRuntime: boolean;
167
+ passThroughRuntimeEvents: boolean;
168
+ preserveOnFocusChange: boolean;
169
+ usePreviewObject: boolean;
170
+ };
171
+ export declare function shouldAutoMountFloatDomRuntime(floatDomParam: Pick<IFloatDomData, 'data'>): boolean;
172
+ export declare function shouldPreserveFloatDomOnFocusChange(floatDomParam: Pick<IFloatDomData, 'data'>): boolean;
173
+ export declare function shouldUseFloatDomPreviewObject(floatDomParam: Pick<IFloatDomData, 'data'>): boolean;
174
+ export declare function shouldPassThroughFloatDomRuntimeEvents(floatDomParam: Pick<IFloatDomData, 'data'>, stage?: ICanvasFloatDomInfo['runtimeStage']): boolean;
175
+ export declare function shouldUpdateFloatDomLayerOnRuntimeStageChange(floatDomParam: Pick<IFloatDomData, 'data'>): boolean;
176
+ export declare function shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam: Pick<IFloatDomData, 'data'>, event: Pick<Event, 'target'>): boolean;
177
+ export declare function shouldPassThroughFloatDomActivationEvent(nextStage: ICanvasFloatDomInfo['runtimeStage'] | undefined): boolean;
178
+ export declare function syncFloatDomHostSelectionOnStageEnter(stage: ICanvasFloatDomInfo['runtimeStage'] | undefined, renderObject: {
179
+ transformer: {
180
+ clearControlByIds: (ids: string[]) => void;
181
+ };
182
+ scene: {
183
+ attachTransformerTo?: (object: BaseObject) => void;
184
+ getTransformer?: () => Nullable<{
185
+ clearSelectedObjects?: () => void;
186
+ }>;
187
+ };
188
+ } | null | undefined, rect: BaseObject & {
189
+ oKey?: string;
190
+ }): void;
191
+ export declare function isCanvasFloatDomDrawingType(drawingType: DrawingTypeEnum): boolean;
192
+ export declare function shouldActivateStage2FromHostPointer(info: Pick<ICanvasFloatDomInfo, 'position$' | 'rect' | 'runtimeMounted' | 'runtimeStage'>, event: {
193
+ offsetX?: number;
194
+ offsetY?: number;
195
+ }): boolean;
196
+ export declare function createFloatDomHostClickIntent(info: Pick<ICanvasFloatDomInfo, 'position$' | 'rect' | 'runtimeMounted' | 'runtimeStage'>, event: {
197
+ type?: string;
198
+ pointerId?: number;
199
+ offsetX?: number;
200
+ offsetY?: number;
201
+ }): IFloatDomHostClickIntent | undefined;
202
+ export declare function shouldActivateStage2FromHostClickIntent(info: Pick<ICanvasFloatDomInfo, 'position$' | 'rect' | 'runtimeMounted' | 'runtimeStage'>, intent: IFloatDomHostClickIntent | undefined, event: {
203
+ type?: string;
204
+ pointerId?: number;
205
+ offsetX?: number;
206
+ offsetY?: number;
207
+ }): boolean;
110
208
  export interface ILimitBound extends IBoundRectNoAngle {
111
209
  /**
112
210
  * Actually, it means fixed.
@@ -144,6 +242,7 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
144
242
  private readonly _canvasFloatDomService;
145
243
  private readonly _sheetDrawingService;
146
244
  protected readonly _lifecycleService: LifecycleService;
245
+ private readonly _canvasFloatDomPreviewService?;
147
246
  /**
148
247
  * for update dom container position when scrolling and zoom
149
248
  */
@@ -167,7 +266,7 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
167
266
  id: string;
168
267
  }>;
169
268
  private readonly _renderObjectFactories;
170
- constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService, _lifecycleService: LifecycleService);
269
+ constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService, _lifecycleService: LifecycleService, _canvasFloatDomPreviewService?: CanvasFloatDomPreviewService | undefined);
171
270
  /**
172
271
  * Register a factory that creates the canvas-side render object for a sheet
173
272
  * float-dom drawing type. The latest registered factory wins; disposing the
@@ -179,6 +278,20 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
179
278
  private _bindScrollEvent;
180
279
  getFloatDomInfo(id: string): ICanvasFloatDomInfo | undefined;
181
280
  getFloatDomsBySubUnitId(unitId: string, subUnitId: string): ICanvasFloatDomInfo[];
281
+ private static _disposeExternalFloatDom;
282
+ private _createFloatDomDisposable;
283
+ private _bindEmbedFloatDragHandleEvent;
284
+ private _handleEmbedFloatDragHandlePointerDown;
285
+ private _commitFloatDomMove;
286
+ isFloatDomRuntimeMounted(id: string): boolean;
287
+ private _getFloatDomPreviewObjectKey;
288
+ private _syncPreviewObjectTransform;
289
+ private _requestFloatDomPreview;
290
+ private _upsertFloatDomPreviewObject;
291
+ mountFloatDomRuntime(id: string): boolean;
292
+ unmountFloatDomRuntime(id: string): void;
293
+ private _syncFloatDomVisibilityForActiveSheet;
294
+ promoteFloatDomRuntimeStage(id: string): ICanvasFloatDomInfo['runtimeStage'] | undefined;
182
295
  private _getSceneAndTransformerByDrawingSearch;
183
296
  private _drawingAddListener;
184
297
  private _scrollUpdateListener;
@@ -192,20 +305,17 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
192
305
  private _getPosition;
193
306
  private _featureUpdateListener;
194
307
  private _deleteListener;
195
- addFloatDomToPosition(layer: ICanvasFloatDom, propId?: string): {
308
+ addFloatDomToPosition(layer: ICanvasFloatDom, propId?: string): (IDisposable & {
196
309
  id: string;
197
- dispose: () => void;
198
- } | undefined;
310
+ }) | undefined;
199
311
  private _removeDom;
200
312
  removeFloatDom(id: string, removeDrawing?: boolean): void;
201
- addFloatDomToRange(range: IRange, config: ICanvasFloatDom, domAnchor: Partial<IDOMAnchor>, propId?: string): {
313
+ addFloatDomToRange(range: IRange, config: ICanvasFloatDom, domAnchor: Partial<IDOMAnchor>, propId?: string): (IDisposable & {
202
314
  id: string;
203
- dispose: () => void;
204
- } | undefined;
205
- addFloatDomToColumnHeader(column: number, config: ICanvasFloatDom, domLayoutParam: IDOMAnchor, propId?: string): {
315
+ }) | undefined;
316
+ addFloatDomToColumnHeader(column: number, config: ICanvasFloatDom, domLayoutParam: IDOMAnchor, propId?: string): (IDisposable & {
206
317
  id: string;
207
- dispose: () => void;
208
- } | undefined;
318
+ }) | undefined;
209
319
  /**
210
320
  * Unlike _createCellPositionObserver, this accept a range not a single cell.
211
321
  *
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { DrawingTypeEnum, IDisposable, IDrawingParam } from '@univerjs/core';
17
+ import { Disposable } from '@univerjs/core';
18
+ export interface IDrawingContextMenuProviderContext {
19
+ unitId: string;
20
+ subUnitId: string;
21
+ drawingId: string;
22
+ drawingType: DrawingTypeEnum;
23
+ drawing: IDrawingParam;
24
+ }
25
+ export interface IDrawingContextMenuProvider {
26
+ getContextMenuPosition(context: IDrawingContextMenuProviderContext): string | undefined;
27
+ }
28
+ export interface IDrawingContextMenuService {
29
+ registerProvider(drawingType: DrawingTypeEnum, provider: IDrawingContextMenuProvider): IDisposable;
30
+ getContextMenuPosition(context: IDrawingContextMenuProviderContext): string | undefined;
31
+ }
32
+ export declare const IDrawingContextMenuService: import("@wendellhu/redi").IdentifierDecorator<IDrawingContextMenuService>;
33
+ export declare class DrawingContextMenuService extends Disposable implements IDrawingContextMenuService {
34
+ private readonly _providers;
35
+ registerProvider(drawingType: DrawingTypeEnum, provider: IDrawingContextMenuProvider): IDisposable;
36
+ getContextMenuPosition(context: IDrawingContextMenuProviderContext): string | undefined;
37
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /** Shared Chart frame config for editor and isolated print Scene objects. */
17
+ export declare const SHEET_CHART_RENDER_OBJECT_CONFIG: Readonly<{
18
+ borderEnabled: false;
19
+ paintFirst: "stroke";
20
+ radius: number;
21
+ rotateEnabled: false;
22
+ strokeWidth: number;
23
+ }>;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IDrawingParam } from '@univerjs/core';
17
+ import type { IMouseEvent, IPointerEvent } from '@univerjs/engine-render';
18
+ import type { Observable } from 'rxjs';
19
+ import { Disposable, IUniverInstanceService } from '@univerjs/core';
20
+ import { IDrawingManagerService } from '@univerjs/drawing';
21
+ import { IRenderManagerService } from '@univerjs/engine-render';
22
+ export interface ISheetDrawingHitTestResult {
23
+ drawing: IDrawingParam;
24
+ oKey: string;
25
+ offsetX: number;
26
+ offsetY: number;
27
+ }
28
+ export interface ISheetDrawingDoubleClickEvent extends ISheetDrawingHitTestResult {
29
+ nativeEvent: IPointerEvent | IMouseEvent;
30
+ }
31
+ /**
32
+ * Resolves sheet canvas pointer coordinates to drawing objects.
33
+ *
34
+ * Callers consume drawing-level events and should not depend on renderer object
35
+ * keys, scene picking, or active sheet filtering.
36
+ */
37
+ export declare class SheetDrawingHitTestService extends Disposable {
38
+ private readonly _drawingManagerService;
39
+ private readonly _univerInstanceService;
40
+ private readonly _renderManagerService;
41
+ private readonly _onDoubleClick$;
42
+ readonly onDoubleClick$: Observable<ISheetDrawingDoubleClickEvent>;
43
+ private _doubleClickDisposable;
44
+ private _boundRender;
45
+ private _boundScene;
46
+ constructor(_drawingManagerService: IDrawingManagerService, _univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService);
47
+ dispose(): void;
48
+ hitTestCurrentSheet(offsetX: number, offsetY: number): ISheetDrawingHitTestResult | null;
49
+ hitTest(unitId: string, subUnitId: string, offsetX: number, offsetY: number): ISheetDrawingHitTestResult | null;
50
+ private _init;
51
+ private _bindDoubleClickListener;
52
+ private _disposeDoubleClickListener;
53
+ private _hitTestScene;
54
+ private _getActiveSheetContext;
55
+ }
@@ -16,11 +16,15 @@
16
16
  import type { Injector, Worksheet } from '@univerjs/core';
17
17
  import type { Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';
18
18
  import type { IFloatDomData } from '@univerjs/sheets-drawing';
19
+ import type { IFloatDom, IFloatDomLayout } from '@univerjs/ui';
19
20
  export interface IPrintingFloatDomProps {
20
21
  floatDomInfos: IFloatDomData[];
21
22
  scene: Scene;
22
23
  skeleton: SpreadsheetSkeleton;
23
24
  worksheet: Worksheet;
24
25
  }
26
+ export declare function createPrintingFloatDom(info: IFloatDomData, scene: Scene, skeleton: SpreadsheetSkeleton, worksheet: Worksheet): readonly [string, IFloatDom & {
27
+ position: IFloatDomLayout;
28
+ }];
25
29
  export declare const PrintingFloatDom: (props: IPrintingFloatDomProps) => import("react").JSX.Element;
26
30
  export declare function mountPrintingFloatDom(props: IPrintingFloatDomProps, root: HTMLElement, injector: Injector): () => void;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/sheets"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-drawing-ui"),require("@univerjs/sheets-ui/facade"),require("@univerjs/sheets/facade"),require("@univerjs/ui"),require("@univerjs/core/facade"),require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render")):typeof define==`function`&&define.amd?define([`@univerjs/sheets`,`@univerjs/sheets-drawing`,`@univerjs/sheets-drawing-ui`,`@univerjs/sheets-ui/facade`,`@univerjs/sheets/facade`,`@univerjs/ui`,`@univerjs/core/facade`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/engine-render`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheets,e.UniverSheetsDrawing,e.UniverSheetsDrawingUi,e.UniverSheetsUiFacade,e.UniverSheetsFacade,e.UniverUi,e.UniverCoreFacade,e.UniverCore,e.UniverDrawing,e.UniverEngineRender))})(this,function(e,t,n,r,i,a,o,s,c,l){var u=class extends i.FWorksheet{getFloatDomById(e){let r=this._injector.get(n.SheetCanvasFloatDomManagerService).getFloatDomInfo(e);if(!r)return null;let{unitId:i,subUnitId:a}=r,{rect:o}=r,{left:s=0,top:c=0,width:l=0,height:u=0,flipX:d=!1,flipY:f=!1,angle:p=0,skewX:m=0,skewY:h=0}=o.getState(),g=this._injector.get(t.ISheetDrawingService).getDrawingByParam({drawingId:r.id,unitId:i,subUnitId:a});return g?{position:{left:s,top:c,width:l,height:u,flipX:d,flipY:f,angle:p,skewX:m,skewY:h},componentKey:g.componentKey,allowTransform:g.allowTransform,data:g.data,id:r.id}:null}getAllFloatDoms(){let e=this._injector.get(n.SheetCanvasFloatDomManagerService),r=this._workbook.getUnitId(),i=this._worksheet.getSheetId();return Array.from(e.getFloatDomsBySubUnitId(r,i).values()).map(e=>{let{rect:n}=e,a=this._injector.get(t.ISheetDrawingService).getDrawingByParam({drawingId:e.id,unitId:r,subUnitId:i}),{left:o,top:s,width:c,height:l,flipX:u,flipY:d,angle:f,skewX:p,skewY:m}=n.getState();return{position:{left:o,top:s,width:c,height:l,flipX:u,flipY:d,angle:f,skewX:p,skewY:m},componentKey:a.componentKey,allowTransform:a.allowTransform,data:a.data,id:e.id}})}updateFloatDom(r,i){var a,o;let s=this._injector.get(e.SheetSkeletonService),c=this._injector.get(n.SheetCanvasFloatDomManagerService).getFloatDomInfo(r);if(!c)return this;let{unitId:l,subUnitId:u}=c,d=s.getSkeleton(l,u);if(!d)return this;let f=this._injector.get(t.ISheetDrawingService).getDrawingByParam({unitId:l,subUnitId:u,drawingId:r}),p={...f,componentKey:i.componentKey||f.componentKey,allowTransform:i.allowTransform===void 0?f.allowTransform:i.allowTransform,data:i.data||f.data,sheetTransform:i.position?(a=(0,t.transformToDrawingPosition)(i.position,d))==null?f.sheetTransform:a:f.sheetTransform,transform:{...f.transform,...i.position},axisAlignSheetTransform:i.position?(o=(0,t.transformToAxisAlignPosition)(i.position,d))==null?f.sheetTransform:o:f.sheetTransform};if(!this._commandService.syncExecuteCommand(t.SetSheetDrawingCommand.id,{unitId:l,subUnitId:u,drawings:[p]}))throw Error(`updateFloatDom failed`);return this}batchUpdateFloatDoms(r){let i=this._injector.get(n.SheetCanvasFloatDomManagerService),a=this._injector.get(t.ISheetDrawingService),o=this._injector.get(e.SheetSkeletonService),s=[];for(let e of r){var c,l;let n=i.getFloatDomInfo(e.id);if(!n)continue;let{unitId:r,subUnitId:u}=n,d=o.getSkeleton(r,u);if(!d)continue;let f=a.getDrawingByParam({unitId:r,subUnitId:u,drawingId:e.id});if(!f)continue;let p={...f,componentKey:e.config.componentKey||f.componentKey,allowTransform:e.config.allowTransform===void 0?f.allowTransform:e.config.allowTransform,data:e.config.data||f.data,sheetTransform:e.config.position?(c=(0,t.transformToDrawingPosition)(e.config.position,d))==null?f.sheetTransform:c:f.sheetTransform,transform:{...f.transform,...e.config.position},axisAlignSheetTransform:e.config.position?(l=(0,t.transformToAxisAlignPosition)(e.config.position,d))==null?f.sheetTransform:l:f.sheetTransform};s.push(p)}if(s.length>0){let e=this._workbook.getUnitId(),n=this._worksheet.getSheetId();if(!this._commandService.syncExecuteCommand(t.SetSheetDrawingCommand.id,{unitId:e,subUnitId:n,drawings:s}))throw Error(`batchUpdateFloatDoms failed`)}return this}removeFloatDom(e){return this._injector.get(n.SheetCanvasFloatDomManagerService).removeFloatDom(e),this}addFloatDomToPosition(e,t){let i=this._workbook.getUnitId(),o=this._worksheet.getSheetId(),{key:s,disposableCollection:c}=(0,r.transformComponentKey)(e,this._injector.get(a.ComponentManager)),l=this._injector.get(n.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...e,componentKey:s,unitId:i,subUnitId:o},t);return l?(c.add(l.dispose),{id:l.id,dispose:()=>{c.dispose(),l.dispose()}}):(c.dispose(),null)}addFloatDomToRange(e,t,i,o){let s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),{key:l,disposableCollection:u}=(0,r.transformComponentKey)(t,this._injector.get(a.ComponentManager)),d=this._injector.get(n.SheetCanvasFloatDomManagerService).addFloatDomToRange(e.getRange(),{...t,componentKey:l,unitId:s,subUnitId:c},i,o);return d?(u.add(d.dispose),{id:d.id,dispose:()=>{u.dispose(),d.dispose()}}):(u.dispose(),null)}addFloatDomToColumnHeader(e,t,i,o){let s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),{key:l,disposableCollection:u}=(0,r.transformComponentKey)(t,this._injector.get(a.ComponentManager)),d=this._injector.get(n.SheetCanvasFloatDomManagerService).addFloatDomToColumnHeader(e,{...t,componentKey:l,unitId:s,subUnitId:c},i,o);return d?(u.add(d.dispose),{id:d.id,dispose:()=>{u.dispose(),d.dispose()}}):(u.dispose(),null)}async saveCellImagesAsync(e,t){var r;let i=this._injector.get(n.IBatchSaveImagesService),a=this._fWorkbook.getId(),o=this.getSheetId(),s=t?t.map(e=>e.getRange()):[this._worksheet.getCellMatrix().getDataRange()],c=i.getCellImagesFromRanges(a,o,s);if(c.length===0)return!1;if(c.length===1)try{return await i.downloadSingleImage(c[0]),!0}catch(e){return console.error(`Failed to download image:`,e),!1}let l=[],u=(r=e==null?void 0:e.useCellAddress)==null?!0:r,d=e==null?void 0:e.useColumnIndex;u&&l.push(n.FileNamePart.CELL_ADDRESS),d!==void 0&&l.push(n.FileNamePart.COLUMN_VALUE),l.length===0&&l.push(n.FileNamePart.CELL_ADDRESS);try{return await i.saveImagesWithContext(c,{fileNameParts:l,columnIndex:d},a,o),!0}catch(e){return console.error(`Failed to save images:`,e),!1}}};i.FWorksheet.extend(u);var d=class extends o.FEventName{get BeforeFloatDomAdd(){return`BeforeFloatDomAdd`}get FloatDomAdded(){return`FloatDomAdded`}get BeforeFloatDomUpdate(){return`BeforeFloatDomUpdate`}get FloatDomUpdated(){return`FloatDomUpdated`}get BeforeFloatDomDelete(){return`BeforeFloatDomDelete`}get FloatDomDeleted(){return`FloatDomDeleted`}};o.FEventName.extend(d);var f=class extends o.FUniver{_initialize(e){let n=e.get(s.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeFloatDomAdd,()=>n.beforeCommandExecuted(e=>{if(e.id!==t.InsertSheetDrawingCommand.id)return;let n=e.params,r=this.getActiveWorkbook();if(r==null||n==null)return;let{drawings:i}=n,a=i.filter(e=>e.drawingType===s.DrawingTypeEnum.DRAWING_DOM);if(a.length===0)return;let o={workbook:r,drawings:a};if(this.fireEvent(this.Event.BeforeFloatDomAdd,o),o.cancel)throw new s.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.FloatDomAdded,()=>n.onCommandExecuted(e=>{if(e.id!==t.InsertSheetDrawingCommand.id)return;let n=e.params,r=this.getActiveWorkbook();if(r==null||n==null)return;let{drawings:i}=n,a=i.filter(e=>e.drawingType===s.DrawingTypeEnum.DRAWING_DOM);if(a.length===0)return;let o={workbook:r,drawings:a};this.fireEvent(this.Event.FloatDomAdded,o)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeFloatDomUpdate,()=>n.beforeCommandExecuted(n=>{if(n.id!==t.SetSheetDrawingCommand.id)return;let r=n.params,i=this.getActiveWorkbook();if(i==null||r==null)return;let{drawings:a}=r,o=e.get(c.IDrawingManagerService),l=[];if(a.forEach(e=>{let t=o.getDrawingByParam(e);(t==null?void 0:t.drawingType)===s.DrawingTypeEnum.DRAWING_DOM&&l.push(t)}),l.length===0)return;let u={workbook:i,drawings:l};if(this.fireEvent(this.Event.BeforeFloatDomUpdate,u),u.cancel)throw o.updateNotification(a),new s.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.FloatDomUpdated,()=>n.onCommandExecuted(n=>{if(n.id!==t.SetSheetDrawingCommand.id)return;let r=n.params,i=this.getActiveWorkbook();if(i==null||r==null)return;let{drawings:a}=r,o=e.get(c.IDrawingManagerService),l=[];if(a.forEach(e=>{let t=o.getDrawingByParam(e);(t==null?void 0:t.drawingType)===s.DrawingTypeEnum.DRAWING_DOM&&l.push(t)}),l.length===0)return;let u={workbook:i,drawings:l};this.fireEvent(this.Event.FloatDomUpdated,u)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeFloatDomDelete,()=>n.beforeCommandExecuted(n=>{if(n.id!==t.RemoveSheetDrawingCommand.id)return;let r=n.params,i=this.getActiveWorkbook();if(i==null||r==null)return;let a=e.get(c.IDrawingManagerService),{drawings:o}=r,l=o.map(e=>a.getDrawingByParam(e)).filter(e=>(e==null?void 0:e.drawingType)===s.DrawingTypeEnum.DRAWING_DOM);if(l.length===0)return;let u={workbook:i,drawings:l};if(this.fireEvent(this.Event.BeforeFloatDomDelete,u),u.cancel)throw new s.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.FloatDomDeleted,()=>n.onCommandExecuted(e=>{if(e.id!==t.RemoveSheetDrawingCommand.id)return;let n=e.params,r=this.getActiveWorkbook();if(r==null||n==null)return;let{drawings:i}=n,a=[];for(let e=0;e<i.length;e++){let t=i[e];t.drawingType===s.DrawingTypeEnum.DRAWING_DOM&&a.push(t.drawingId)}if(a.length===0)return;let o={workbook:r,drawings:a};this.fireEvent(this.Event.FloatDomDeleted,o)})))}registerURLImageDownloader(e){return this._injector.get(s.IURLImageService).registerURLImageDownloader(e)}};o.FUniver.extend(f);var p=class extends i.FRange{async insertCellImageAsync(e){var t;let r=this._injector.get(l.IRenderManagerService),i=(t=(0,l.getCurrentTypeOfRenderer)(s.UniverInstanceType.UNIVER_SHEET,this._injector.get(s.IUniverInstanceService),r))==null?void 0:t.with(n.SheetDrawingUpdateController);if(!i)return!1;let a={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this.getRow(),col:this.getColumn()};return typeof e==`string`?i.insertCellImageByUrl(e,a):i.insertCellImageByFile(e,a)}async saveCellImagesAsync(e){var t;let r=this._injector.get(n.IBatchSaveImagesService),i=this._workbook.getUnitId(),a=this._worksheet.getSheetId(),o=this.getRange(),s=r.getCellImagesFromRanges(i,a,[o]);if(s.length===0)return!1;if(s.length===1)try{return await r.downloadSingleImage(s[0]),!0}catch(e){return console.error(`Failed to download image:`,e),!1}let c=[],l=(t=e==null?void 0:e.useCellAddress)==null?!0:t,u=e==null?void 0:e.useColumnIndex;l&&c.push(n.FileNamePart.CELL_ADDRESS),u!==void 0&&c.push(n.FileNamePart.COLUMN_VALUE),c.length===0&&c.push(n.FileNamePart.CELL_ADDRESS);try{return await r.saveImagesWithContext(s,{fileNameParts:c,columnIndex:u},i,a),!0}catch(e){return console.error(`Failed to save images:`,e),!1}}};i.FRange.extend(p)});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/sheets"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-drawing-ui"),require("@univerjs/sheets-ui/facade"),require("@univerjs/sheets/facade"),require("@univerjs/ui"),require("@univerjs/core/facade"),require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render")):typeof define==`function`&&define.amd?define([`@univerjs/sheets`,`@univerjs/sheets-drawing`,`@univerjs/sheets-drawing-ui`,`@univerjs/sheets-ui/facade`,`@univerjs/sheets/facade`,`@univerjs/ui`,`@univerjs/core/facade`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/engine-render`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheets,e.UniverSheetsDrawing,e.UniverSheetsDrawingUi,e.UniverSheetsUiFacade,e.UniverSheetsFacade,e.UniverUi,e.UniverCoreFacade,e.UniverCore,e.UniverDrawing,e.UniverEngineRender))})(this,function(e,t,n,r,i,a,o,s,c,l){var u=class extends i.FWorksheet{getFloatDomById(e){let r=this._injector.get(n.SheetCanvasFloatDomManagerService).getFloatDomInfo(e);if(!r)return null;let{unitId:i,subUnitId:a}=r,{rect:o}=r,{left:s=0,top:c=0,width:l=0,height:u=0,flipX:d=!1,flipY:f=!1,angle:p=0,skewX:m=0,skewY:h=0}=o.getState(),g=this._injector.get(t.ISheetDrawingService).getDrawingByParam({drawingId:r.id,unitId:i,subUnitId:a});return g?{position:{left:s,top:c,width:l,height:u,flipX:d,flipY:f,angle:p,skewX:m,skewY:h},componentKey:g.componentKey,allowTransform:g.allowTransform,data:g.data,id:r.id}:null}getAllFloatDoms(){let e=this._injector.get(n.SheetCanvasFloatDomManagerService),r=this._workbook.getUnitId(),i=this._worksheet.getSheetId();return Array.from(e.getFloatDomsBySubUnitId(r,i).values()).map(e=>{let{rect:n}=e,a=this._injector.get(t.ISheetDrawingService).getDrawingByParam({drawingId:e.id,unitId:r,subUnitId:i});if(!a)return null;let{left:o,top:s,width:c,height:l,flipX:u,flipY:d,angle:f,skewX:p,skewY:m}=n.getState();return{position:{left:o,top:s,width:c,height:l,flipX:u,flipY:d,angle:f,skewX:p,skewY:m},componentKey:a.componentKey,allowTransform:a.allowTransform,data:a.data,id:e.id}}).filter(e=>e!=null)}updateFloatDom(r,i){var a,o;let s=this._injector.get(e.SheetSkeletonService),c=this._injector.get(n.SheetCanvasFloatDomManagerService).getFloatDomInfo(r);if(!c)return this;let{unitId:l,subUnitId:u}=c,d=s.getSkeleton(l,u);if(!d)return this;let f=this._injector.get(t.ISheetDrawingService).getDrawingByParam({unitId:l,subUnitId:u,drawingId:r}),p={...f,componentKey:i.componentKey||f.componentKey,allowTransform:i.allowTransform===void 0?f.allowTransform:i.allowTransform,data:i.data||f.data,sheetTransform:i.position?(a=(0,t.transformToDrawingPosition)(i.position,d))==null?f.sheetTransform:a:f.sheetTransform,transform:{...f.transform,...i.position},axisAlignSheetTransform:i.position?(o=(0,t.transformToAxisAlignPosition)(i.position,d))==null?f.sheetTransform:o:f.sheetTransform};if(!this._commandService.syncExecuteCommand(t.SetSheetDrawingCommand.id,{unitId:l,subUnitId:u,drawings:[p]}))throw Error(`updateFloatDom failed`);return this}batchUpdateFloatDoms(r){let i=this._injector.get(n.SheetCanvasFloatDomManagerService),a=this._injector.get(t.ISheetDrawingService),o=this._injector.get(e.SheetSkeletonService),s=[];for(let e of r){var c,l;let n=i.getFloatDomInfo(e.id);if(!n)continue;let{unitId:r,subUnitId:u}=n,d=o.getSkeleton(r,u);if(!d)continue;let f=a.getDrawingByParam({unitId:r,subUnitId:u,drawingId:e.id});if(!f)continue;let p={...f,componentKey:e.config.componentKey||f.componentKey,allowTransform:e.config.allowTransform===void 0?f.allowTransform:e.config.allowTransform,data:e.config.data||f.data,sheetTransform:e.config.position?(c=(0,t.transformToDrawingPosition)(e.config.position,d))==null?f.sheetTransform:c:f.sheetTransform,transform:{...f.transform,...e.config.position},axisAlignSheetTransform:e.config.position?(l=(0,t.transformToAxisAlignPosition)(e.config.position,d))==null?f.sheetTransform:l:f.sheetTransform};s.push(p)}if(s.length>0){let e=this._workbook.getUnitId(),n=this._worksheet.getSheetId();if(!this._commandService.syncExecuteCommand(t.SetSheetDrawingCommand.id,{unitId:e,subUnitId:n,drawings:s}))throw Error(`batchUpdateFloatDoms failed`)}return this}removeFloatDom(e){return this._injector.get(n.SheetCanvasFloatDomManagerService).removeFloatDom(e),this}addFloatDomToPosition(e,t){let i=this._workbook.getUnitId(),o=this._worksheet.getSheetId(),{key:s,disposableCollection:c}=(0,r.transformComponentKey)(e,this._injector.get(a.ComponentManager)),l=this._injector.get(n.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...e,componentKey:s,unitId:i,subUnitId:o},t);return l?(c.add(l.dispose),{id:l.id,dispose:()=>{c.dispose(),l.dispose()}}):(c.dispose(),null)}addFloatDomToRange(e,t,i,o){let s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),{key:l,disposableCollection:u}=(0,r.transformComponentKey)(t,this._injector.get(a.ComponentManager)),d=this._injector.get(n.SheetCanvasFloatDomManagerService).addFloatDomToRange(e.getRange(),{...t,componentKey:l,unitId:s,subUnitId:c},i,o);return d?(u.add(d.dispose),{id:d.id,dispose:()=>{u.dispose(),d.dispose()}}):(u.dispose(),null)}addFloatDomToColumnHeader(e,t,i,o){let s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),{key:l,disposableCollection:u}=(0,r.transformComponentKey)(t,this._injector.get(a.ComponentManager)),d=this._injector.get(n.SheetCanvasFloatDomManagerService).addFloatDomToColumnHeader(e,{...t,componentKey:l,unitId:s,subUnitId:c},i,o);return d?(u.add(d.dispose),{id:d.id,dispose:()=>{u.dispose(),d.dispose()}}):(u.dispose(),null)}async saveCellImagesAsync(e,t){var r;let i=this._injector.get(n.IBatchSaveImagesService),a=this._fWorkbook.getId(),o=this.getSheetId(),s=t?t.map(e=>e.getRange()):[this._worksheet.getCellMatrix().getDataRange()],c=i.getCellImagesFromRanges(a,o,s);if(c.length===0)return!1;if(c.length===1)try{return await i.downloadSingleImage(c[0]),!0}catch(e){return console.error(`Failed to download image:`,e),!1}let l=[],u=(r=e==null?void 0:e.useCellAddress)==null?!0:r,d=e==null?void 0:e.useColumnIndex;u&&l.push(n.FileNamePart.CELL_ADDRESS),d!==void 0&&l.push(n.FileNamePart.COLUMN_VALUE),l.length===0&&l.push(n.FileNamePart.CELL_ADDRESS);try{return await i.saveImagesWithContext(c,{fileNameParts:l,columnIndex:d},a,o),!0}catch(e){return console.error(`Failed to save images:`,e),!1}}};i.FWorksheet.extend(u);var d=class extends o.FEventName{get BeforeFloatDomAdd(){return`BeforeFloatDomAdd`}get FloatDomAdded(){return`FloatDomAdded`}get BeforeFloatDomUpdate(){return`BeforeFloatDomUpdate`}get FloatDomUpdated(){return`FloatDomUpdated`}get BeforeFloatDomDelete(){return`BeforeFloatDomDelete`}get FloatDomDeleted(){return`FloatDomDeleted`}};o.FEventName.extend(d);var f=class extends o.FUniver{_initialize(e){let n=e.get(s.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeFloatDomAdd,()=>n.beforeCommandExecuted(e=>{if(e.id!==t.InsertSheetDrawingCommand.id)return;let n=e.params,r=this.getActiveWorkbook();if(r==null||n==null)return;let{drawings:i}=n,a=i.filter(e=>e.drawingType===s.DrawingTypeEnum.DRAWING_DOM);if(a.length===0)return;let o={workbook:r,drawings:a};if(this.fireEvent(this.Event.BeforeFloatDomAdd,o),o.cancel)throw new s.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.FloatDomAdded,()=>n.onCommandExecuted(e=>{if(e.id!==t.InsertSheetDrawingCommand.id)return;let n=e.params,r=this.getActiveWorkbook();if(r==null||n==null)return;let{drawings:i}=n,a=i.filter(e=>e.drawingType===s.DrawingTypeEnum.DRAWING_DOM);if(a.length===0)return;let o={workbook:r,drawings:a};this.fireEvent(this.Event.FloatDomAdded,o)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeFloatDomUpdate,()=>n.beforeCommandExecuted(n=>{if(n.id!==t.SetSheetDrawingCommand.id)return;let r=n.params,i=this.getActiveWorkbook();if(i==null||r==null)return;let{drawings:a}=r,o=e.get(c.IDrawingManagerService),l=[];if(a.forEach(e=>{let t=o.getDrawingByParam(e);(t==null?void 0:t.drawingType)===s.DrawingTypeEnum.DRAWING_DOM&&l.push(t)}),l.length===0)return;let u={workbook:i,drawings:l};if(this.fireEvent(this.Event.BeforeFloatDomUpdate,u),u.cancel)throw o.updateNotification(a),new s.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.FloatDomUpdated,()=>n.onCommandExecuted(n=>{if(n.id!==t.SetSheetDrawingCommand.id)return;let r=n.params,i=this.getActiveWorkbook();if(i==null||r==null)return;let{drawings:a}=r,o=e.get(c.IDrawingManagerService),l=[];if(a.forEach(e=>{let t=o.getDrawingByParam(e);(t==null?void 0:t.drawingType)===s.DrawingTypeEnum.DRAWING_DOM&&l.push(t)}),l.length===0)return;let u={workbook:i,drawings:l};this.fireEvent(this.Event.FloatDomUpdated,u)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeFloatDomDelete,()=>n.beforeCommandExecuted(n=>{if(n.id!==t.RemoveSheetDrawingCommand.id)return;let r=n.params,i=this.getActiveWorkbook();if(i==null||r==null)return;let a=e.get(c.IDrawingManagerService),{drawings:o}=r,l=o.map(e=>a.getDrawingByParam(e)).filter(e=>(e==null?void 0:e.drawingType)===s.DrawingTypeEnum.DRAWING_DOM);if(l.length===0)return;let u={workbook:i,drawings:l};if(this.fireEvent(this.Event.BeforeFloatDomDelete,u),u.cancel)throw new s.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.FloatDomDeleted,()=>n.onCommandExecuted(e=>{if(e.id!==t.RemoveSheetDrawingCommand.id)return;let n=e.params,r=this.getActiveWorkbook();if(r==null||n==null)return;let{drawings:i}=n,a=[];for(let e=0;e<i.length;e++){let t=i[e];t.drawingType===s.DrawingTypeEnum.DRAWING_DOM&&a.push(t.drawingId)}if(a.length===0)return;let o={workbook:r,drawings:a};this.fireEvent(this.Event.FloatDomDeleted,o)})))}registerURLImageDownloader(e){return this._injector.get(s.IURLImageService).registerURLImageDownloader(e)}};o.FUniver.extend(f);var p=class extends i.FRange{async insertCellImageAsync(e){var t;let r=this._injector.get(l.IRenderManagerService),i=(t=(0,l.getCurrentTypeOfRenderer)(s.UniverInstanceType.UNIVER_SHEET,this._injector.get(s.IUniverInstanceService),r))==null?void 0:t.with(n.SheetDrawingUpdateController);if(!i)return!1;let a={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this.getRow(),col:this.getColumn()};return typeof e==`string`?i.insertCellImageByUrl(e,a):i.insertCellImageByFile(e,a)}async saveCellImagesAsync(e){var t;let r=this._injector.get(n.IBatchSaveImagesService),i=this._workbook.getUnitId(),a=this._worksheet.getSheetId(),o=this.getRange(),s=r.getCellImagesFromRanges(i,a,[o]);if(s.length===0)return!1;if(s.length===1)try{return await r.downloadSingleImage(s[0]),!0}catch(e){return console.error(`Failed to download image:`,e),!1}let c=[],l=(t=e==null?void 0:e.useCellAddress)==null?!0:t,u=e==null?void 0:e.useColumnIndex;l&&c.push(n.FileNamePart.CELL_ADDRESS),u!==void 0&&c.push(n.FileNamePart.COLUMN_VALUE),c.length===0&&c.push(n.FileNamePart.CELL_ADDRESS);try{return await r.saveImagesWithContext(s,{fileNameParts:c,columnIndex:u},i,a),!0}catch(e){return console.error(`Failed to save images:`,e),!1}}};i.FRange.extend(p)});