@univerjs/sheets-drawing-ui 0.4.1-nightly.202410251606 → 0.4.1-nightly.202410261605

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/es/index.js CHANGED
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "sym
5
5
  import { CommandType, ICommandService, IUndoRedoService, LocaleService, IUniverInstanceService, useDependency, Inject, Injector, IContextService, RxDisposable, UniverInstanceType, connectInjector, toDisposable, FOCUSING_COMMON_DRAWINGS, Disposable, Direction, FOCUSING_FX_BAR_EDITOR, EDITOR_ACTIVATED, Tools, UserManagerService, IPermissionService, Rectangle, DisposableCollection, fromEventSubject, generateRandomId, DependentOn, Plugin, registerDependencies, touchDependencies, IConfigService } from "@univerjs/core";
6
6
  import { IDrawingManagerService, IImageIoService, DrawingTypeEnum, ArrangeTypeEnum, DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, getDrawingShapeKeyByDrawingSearch, UniverDrawingPlugin } from "@univerjs/drawing";
7
7
  import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, DrawingRenderService, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
8
- import { IRenderManagerService, precisionTo, getGroupState, transformObjectOutOfGroup, RENDER_CLASS_TYPE, Rect, DRAWING_OBJECT_LAYER_INDEX, SHEET_VIEWPORT_KEY } from "@univerjs/engine-render";
8
+ import { IRenderManagerService, precisionTo, getGroupState, transformObjectOutOfGroup, RENDER_CLASS_TYPE, Rect, ObjectType, DRAWING_OBJECT_LAYER_INDEX, SHEET_VIEWPORT_KEY } from "@univerjs/engine-render";
9
9
  import { ISheetDrawingService, SetDrawingApplyMutation, DrawingApplyType, SheetDrawingAnchorType, UniverSheetsDrawingPlugin } from "@univerjs/sheets-drawing";
10
10
  import { SheetCanvasPopManagerService, attachRangeWithCoord, ISheetSelectionRenderService, SheetSkeletonManagerService, getCurrentRangeDisable$, COPY_TYPE, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, ISheetClipboardService, SheetPrintInterceptorService, VIEWPORT_KEY, SetZoomRatioOperation } from "@univerjs/sheets-ui";
11
11
  import { ISidebarService, IUIPartsService, BuiltInUIPart, ILocalFileService, IMessageService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, KeyCode, ComponentManager, IMenuManagerService, IShortcutService, CanvasFloatDomService } from "@univerjs/ui";
@@ -2188,6 +2188,8 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2188
2188
  __publicField(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
2189
2189
  __publicField(this, "_transformChange$", new Subject());
2190
2190
  __publicField(this, "transformChange$", this._transformChange$.asObservable());
2191
+ __publicField(this, "_add$", new Subject());
2192
+ __publicField(this, "add$", this._add$.asObservable());
2191
2193
  __publicField(this, "_remove$", new Subject());
2192
2194
  __publicField(this, "remove$", this._remove$.asObservable());
2193
2195
  __publicField(this, "_hooks", []);
@@ -2199,6 +2201,9 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2199
2201
  let subUnitMap = unitMap.get(subUnitId);
2200
2202
  return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
2201
2203
  }
2204
+ getFloatDomInfo(id) {
2205
+ return this._domLayerInfoMap.get(id);
2206
+ }
2202
2207
  _getSceneAndTransformerByDrawingSearch(unitId) {
2203
2208
  if (unitId == null)
2204
2209
  return;
@@ -2247,10 +2252,10 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2247
2252
  width,
2248
2253
  height,
2249
2254
  zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
2250
- };
2251
- drawingType === DrawingTypeEnum.DRAWING_CHART && (imageConfig.fill = "white", imageConfig.rotateEnabled = !1);
2255
+ }, isChart = drawingType === DrawingTypeEnum.DRAWING_CHART;
2256
+ isChart && (imageConfig.fill = "white", imageConfig.rotateEnabled = !1);
2252
2257
  const rect = new Rect(rectShapeKey, imageConfig);
2253
- scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX), floatDomParam.allowTransform !== !1 && scene.attachTransformerTo(rect);
2258
+ isChart && rect.setObjectType(ObjectType.CHART), scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX), floatDomParam.allowTransform !== !1 && scene.attachTransformerTo(rect);
2254
2259
  const map2 = this._ensureMap(unitId, subUnitId), disposableCollection = new DisposableCollection(), initPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet), position$ = new BehaviorSubject(initPosition), info = {
2255
2260
  dispose: disposableCollection,
2256
2261
  rect,
@@ -2383,7 +2388,7 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2383
2388
  })
2384
2389
  );
2385
2390
  }
2386
- addFloatDomToPosition(layer, propId) {
2391
+ addFloatDomToPosition(layer, propId, executeCommand = !0) {
2387
2392
  const target = getSheetCommandTarget(this._univerInstanceService, {
2388
2393
  unitId: layer.unitId,
2389
2394
  subUnitId: layer.subUnitId
@@ -2410,14 +2415,15 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2410
2415
  data,
2411
2416
  allowTransform
2412
2417
  };
2413
- return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
2418
+ return executeCommand && this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
2414
2419
  unitId,
2415
2420
  drawings: [sheetDrawingParam]
2416
- }), {
2421
+ }), this._add$.next({ unitId, subUnitId, id }), {
2417
2422
  id,
2418
2423
  dispose: /* @__PURE__ */ __name(() => {
2419
2424
  this._removeDom(id, !0);
2420
- }, "dispose")
2425
+ }, "dispose"),
2426
+ sheetDrawingParam
2421
2427
  };
2422
2428
  }
2423
2429
  _removeDom(id, removeDrawing = !1) {
@@ -1,8 +1,9 @@
1
1
  import { IDisposable, IPosition, ITransformState, Serializable, Worksheet, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
2
- import { IBoundRectNoAngle, Scene, SpreadsheetSkeleton, IRenderManagerService } from '@univerjs/engine-render';
2
+ import { IBoundRectNoAngle, Scene, SpreadsheetSkeleton, IRenderManagerService, Rect } from '@univerjs/engine-render';
3
+ import { ISheetFloatDom, ISheetDrawingService } from '@univerjs/sheets-drawing';
4
+ import { IFloatDomLayout, CanvasFloatDomService } from '@univerjs/ui';
3
5
  import { DrawingTypeEnum, IDrawingManagerService } from '@univerjs/drawing';
4
- import { ISheetDrawingService } from '@univerjs/sheets-drawing';
5
- import { CanvasFloatDomService } from '@univerjs/ui';
6
+ import { BehaviorSubject } from 'rxjs';
6
7
  export interface ICanvasFloatDom {
7
8
  /**
8
9
  * whether allow transform float-dom
@@ -34,6 +35,13 @@ export interface ICanvasFloatDom {
34
35
  */
35
36
  type?: DrawingTypeEnum;
36
37
  }
38
+ interface ICanvasFloatDomInfo {
39
+ position$: BehaviorSubject<IFloatDomLayout>;
40
+ dispose: IDisposable;
41
+ rect: Rect;
42
+ unitId: string;
43
+ subUnitId: string;
44
+ }
37
45
  export declare function transformBound2DOMBound(originBound: IBoundRectNoAngle, scene: Scene, skeleton: SpreadsheetSkeleton, worksheet: Worksheet): {
38
46
  absolute: {
39
47
  left: boolean;
@@ -61,6 +69,12 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
61
69
  id: string;
62
70
  value: ITransformState;
63
71
  }>;
72
+ private _add$;
73
+ add$: import('rxjs').Observable<{
74
+ unitId: string;
75
+ subUnitId: string;
76
+ id: string;
77
+ }>;
64
78
  private _remove$;
65
79
  remove$: import('rxjs').Observable<{
66
80
  unitId: string;
@@ -70,6 +84,7 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
70
84
  private _hooks;
71
85
  constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService);
72
86
  private _ensureMap;
87
+ getFloatDomInfo(id: string): ICanvasFloatDomInfo | undefined;
73
88
  private _getSceneAndTransformerByDrawingSearch;
74
89
  private _getFloatDomProps;
75
90
  private _drawingAddListener;
@@ -77,10 +92,12 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
77
92
  private _getPosition;
78
93
  private _featureUpdateListener;
79
94
  private _deleteListener;
80
- addFloatDomToPosition(layer: ICanvasFloatDom, propId?: string): {
95
+ addFloatDomToPosition(layer: ICanvasFloatDom, propId?: string, executeCommand?: boolean): {
81
96
  id: string;
82
97
  dispose: () => void;
98
+ sheetDrawingParam: ISheetFloatDom;
83
99
  } | undefined;
84
100
  private _removeDom;
85
101
  addHook(hook: ISheetCanvasFloatDomHook): IDisposable;
86
102
  }
103
+ export {};