@univerjs/sheets-drawing-ui 0.4.1-nightly.202410271605 → 0.4.1-nightly.202410281606

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
@@ -2,14 +2,14 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
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";
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, LifecycleService, LifecycleStages, 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
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";
12
- import { takeUntil, combineLatest, map, filter, distinctUntilChanged, Subject, BehaviorSubject, switchMap } from "rxjs";
12
+ import { takeUntil, combineLatest, map, filter, distinctUntilChanged, Subject, take, BehaviorSubject, switchMap } from "rxjs";
13
13
  import { getSheetCommandTarget, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, WorkbookViewPermission, WorksheetViewPermission, InsertRowCommand, InsertColCommand, RemoveRowCommand, RemoveColCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, DeltaRowHeightCommand, SetRowHeightCommand, DeltaColumnWidthCommand, SetColWidthCommand, SetRowHiddenCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, SetColHiddenCommand, MoveColsCommand, MoveRowsCommand, MoveRangeCommand, SetRowVisibleMutation, SetRowHiddenMutation, SetColVisibleMutation, SetColHiddenMutation, SetWorksheetRowHeightMutation, SetWorksheetColWidthMutation, SheetInterceptorService, SetWorksheetActiveOperation, SetFrozenMutation } from "@univerjs/sheets";
14
14
  import React, { useEffect, forwardRef, useRef, createElement, useState } from "react";
15
15
  import { MessageType, RadioGroup, Radio } from "@univerjs/design";
@@ -2182,7 +2182,7 @@ const calcPosition = /* @__PURE__ */ __name((targetObject, currentRender, skelet
2182
2182
  }, "calcPosition");
2183
2183
  var _a9;
2184
2184
  let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2185
- constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService) {
2185
+ constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService, _lifecycleService) {
2186
2186
  super();
2187
2187
  __publicField(this, "_domLayerMap", /* @__PURE__ */ new Map());
2188
2188
  __publicField(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
@@ -2193,7 +2193,12 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2193
2193
  __publicField(this, "_remove$", new Subject());
2194
2194
  __publicField(this, "remove$", this._remove$.asObservable());
2195
2195
  __publicField(this, "_hooks", []);
2196
- this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._canvasFloatDomService = _canvasFloatDomService, this._sheetDrawingService = _sheetDrawingService, this._drawingAddListener(), this._scrollUpdateListener(), this._featureUpdateListener(), this._deleteListener();
2196
+ 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();
2197
+ }
2198
+ _bindScrollEvent() {
2199
+ this._lifecycleService.lifecycle$.pipe(filter((s) => s === LifecycleStages.Rendered), take(1)).subscribe(() => {
2200
+ this._scrollUpdateListener();
2201
+ });
2197
2202
  }
2198
2203
  _ensureMap(unitId, subUnitId) {
2199
2204
  let unitMap = this._domLayerMap.get(unitId);
@@ -2253,7 +2258,7 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2253
2258
  height,
2254
2259
  zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
2255
2260
  }, isChart = drawingType === DrawingTypeEnum.DRAWING_CHART;
2256
- isChart && (imageConfig.fill = "white", imageConfig.rotateEnabled = !1);
2261
+ isChart && (imageConfig.fill = "white", imageConfig.rotateEnabled = !1, data && data.border && (imageConfig.stroke = data.border), imageConfig.paintFirst = "stroke", imageConfig.strokeWidth = 1, imageConfig.borderEnabled = !1);
2257
2262
  const rect = new Rect(rectShapeKey, imageConfig);
2258
2263
  isChart && rect.setObjectType(ObjectType.CHART), scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX), floatDomParam.allowTransform !== !1 && scene.attachTransformerTo(rect);
2259
2264
  const map2 = this._ensureMap(unitId, subUnitId), disposableCollection = new DisposableCollection(), initPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet), position$ = new BehaviorSubject(initPosition), info = {
@@ -2296,6 +2301,16 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2296
2301
  });
2297
2302
  });
2298
2303
  })
2304
+ ), this.disposeWithMe(
2305
+ this._drawingManagerService.remove$.subscribe((params) => {
2306
+ params.forEach((param) => {
2307
+ const { unitId, subUnitId, drawingId } = param, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2308
+ if (renderObject == null)
2309
+ return;
2310
+ const { transformer, scene } = renderObject, rectShape = scene.getObject(rectShapeKey);
2311
+ rectShape != null && rectShape.oKey && transformer.clearControlByIds([rectShape == null ? void 0 : rectShape.oKey]);
2312
+ });
2313
+ })
2299
2314
  );
2300
2315
  }
2301
2316
  _scrollUpdateListener() {
@@ -2388,6 +2403,13 @@ let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2388
2403
  })
2389
2404
  );
2390
2405
  }
2406
+ updateFloatDomProps(unitId, subUnitId, id, props) {
2407
+ const info = this._domLayerInfoMap.get(id), renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2408
+ if (info && renderObject) {
2409
+ const { scene } = renderObject, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId: id }), rectShape = scene.getObject(rectShapeKey);
2410
+ rectShape && rectShape instanceof Rect && rectShape.setProps(props);
2411
+ }
2412
+ }
2391
2413
  addFloatDomToPosition(layer, propId, executeCommand = !0) {
2392
2414
  const target = getSheetCommandTarget(this._univerInstanceService, {
2393
2415
  unitId: layer.unitId,
@@ -2457,7 +2479,8 @@ SheetCanvasFloatDomManagerService = __decorateClass$1([
2457
2479
  __decorateParam$1(2, Inject(ICommandService)),
2458
2480
  __decorateParam$1(3, IDrawingManagerService),
2459
2481
  __decorateParam$1(4, Inject(CanvasFloatDomService)),
2460
- __decorateParam$1(5, ISheetDrawingService)
2482
+ __decorateParam$1(5, ISheetDrawingService),
2483
+ __decorateParam$1(6, Inject(LifecycleService))
2461
2484
  ], SheetCanvasFloatDomManagerService);
2462
2485
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2463
2486
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -1,4 +1,4 @@
1
- import { IDisposable, IPosition, ITransformState, Serializable, Worksheet, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
1
+ import { IDisposable, IPosition, ITransformState, Serializable, Worksheet, Disposable, ICommandService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
2
2
  import { IBoundRectNoAngle, Scene, SpreadsheetSkeleton, IRenderManagerService, Rect } from '@univerjs/engine-render';
3
3
  import { ISheetFloatDom, ISheetDrawingService } from '@univerjs/sheets-drawing';
4
4
  import { IFloatDomLayout, CanvasFloatDomService } from '@univerjs/ui';
@@ -62,6 +62,7 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
62
62
  private _drawingManagerService;
63
63
  private readonly _canvasFloatDomService;
64
64
  private readonly _sheetDrawingService;
65
+ protected readonly _lifecycleService: LifecycleService;
65
66
  private _domLayerMap;
66
67
  private _domLayerInfoMap;
67
68
  private _transformChange$;
@@ -74,6 +75,7 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
74
75
  unitId: string;
75
76
  subUnitId: string;
76
77
  id: string;
78
+ data?: Record<string, any>;
77
79
  }>;
78
80
  private _remove$;
79
81
  remove$: import('rxjs').Observable<{
@@ -82,7 +84,8 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
82
84
  id: string;
83
85
  }>;
84
86
  private _hooks;
85
- constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService);
87
+ constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService, _lifecycleService: LifecycleService);
88
+ private _bindScrollEvent;
86
89
  private _ensureMap;
87
90
  getFloatDomInfo(id: string): ICanvasFloatDomInfo | undefined;
88
91
  private _getSceneAndTransformerByDrawingSearch;
@@ -92,6 +95,7 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
92
95
  private _getPosition;
93
96
  private _featureUpdateListener;
94
97
  private _deleteListener;
98
+ updateFloatDomProps(unitId: string, subUnitId: string, id: string, props: Record<string, any>): void;
95
99
  addFloatDomToPosition(layer: ICanvasFloatDom, propId?: string, executeCommand?: boolean): {
96
100
  id: string;
97
101
  dispose: () => void;