@univerjs/sheets-drawing-ui 1.0.4 → 1.2.0

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
@@ -1,5 +1,5 @@
1
- import { BooleanNumber, BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, ICommandService, IConfigService, IContextService, IImageIoService, IPermissionService, IURLImageService, IUndoRedoService, IUniverInstanceService, ImageCacheMap, ImageSourceType, ImageUploadStatusType, Inject, Injector, InterceptorEffectEnum, LifecycleService, LifecycleStages, LocaleService, ObjectMatrix, Optional, Plugin, PositionedObjectLayoutType, RxDisposable, Tools, UniverInstanceType, UserManagerService, WrapTextType, createDocumentModelWithStyle, createIdentifier, fromEventSubject, generateRandomId, merge, mergeOverrideWithDependencies, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, applySheetDrawingPlacement, drawingPositionToTransform, getSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
1
+ import { BooleanNumber, BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, ICommandService, IConfigService, IContextService, IImageIoService, ILogService, IPermissionService, IURLImageService, IUndoRedoService, IUniverInstanceService, ImageCacheMap, ImageSourceType, ImageUploadStatusType, Inject, Injector, InterceptorEffectEnum, LifecycleService, LifecycleStages, LocaleService, ObjectMatrix, Optional, Plugin, PositionedObjectLayoutType, RxDisposable, Tools, UniverInstanceType, UserManagerService, WrapTextType, createDocumentModelWithStyle, createIdentifier, fromEventSubject, generateRandomId, merge, mergeOverrideWithDependencies, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
2
+ import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, drawingPositionToTransform, getSheetDrawingPlacement, refreshSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
3
3
  import { CURSOR_TYPE, DEFAULT_TRANSFORMER_CONFIG, DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Image, ObjectType, Rect, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SheetExtension, UniverRenderEnginePlugin, Vector2, getCurrentTypeOfRenderer, getGroupState, transformObjectOutOfGroup } from "@univerjs/engine-render";
4
4
  import { Button, Checkbox, CheckboxGroup, DropdownMenu, FormLayout, Input, MessageType, MobileSelect, Radio, RadioGroup, Select, borderClassName, clsx, render, unmount } from "@univerjs/design";
5
5
  import { buildDocTransform, docDrawingPositionToTransform } from "@univerjs/docs";
@@ -427,7 +427,7 @@ function readUint32Be(bytes, offset) {
427
427
  }
428
428
 
429
429
  //#endregion
430
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
430
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
431
431
  function _typeof(o) {
432
432
  "@babel/helpers - typeof";
433
433
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -438,7 +438,7 @@ function _typeof(o) {
438
438
  }
439
439
 
440
440
  //#endregion
441
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
441
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
442
442
  function toPrimitive(t, r) {
443
443
  if ("object" != _typeof(t) || !t) return t;
444
444
  var e = t[Symbol.toPrimitive];
@@ -451,14 +451,14 @@ function toPrimitive(t, r) {
451
451
  }
452
452
 
453
453
  //#endregion
454
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
454
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
455
455
  function toPropertyKey(t) {
456
456
  var i = toPrimitive(t, "string");
457
457
  return "symbol" == _typeof(i) ? i : i + "";
458
458
  }
459
459
 
460
460
  //#endregion
461
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
461
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
462
462
  function _defineProperty(e, r, t) {
463
463
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
464
464
  value: t,
@@ -469,7 +469,7 @@ function _defineProperty(e, r, t) {
469
469
  }
470
470
 
471
471
  //#endregion
472
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
472
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
473
473
  function __decorateParam(paramIndex, decorator) {
474
474
  return function(target, key) {
475
475
  decorator(target, key, paramIndex);
@@ -477,7 +477,7 @@ function __decorateParam(paramIndex, decorator) {
477
477
  }
478
478
 
479
479
  //#endregion
480
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
480
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
481
481
  function __decorate(decorators, target, key, desc) {
482
482
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
483
483
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -649,7 +649,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
649
649
  if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
650
650
  const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width;
651
651
  const scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
652
- scale = Math.max(scaleWidth, scaleHeight);
652
+ scale = Math.min(scaleWidth, scaleHeight);
653
653
  }
654
654
  const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
655
655
  if (!sheetSkeletonParam) return;
@@ -3070,7 +3070,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3070
3070
  domAnchor,
3071
3071
  unitId,
3072
3072
  subUnitId,
3073
- id: drawingId
3073
+ id: drawingId,
3074
+ runtimeMetadata: {
3075
+ componentKey,
3076
+ data,
3077
+ allowTransform
3078
+ }
3074
3079
  };
3075
3080
  const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
3076
3081
  const position$ = new BehaviorSubject(initedPosition);
@@ -3274,7 +3279,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3274
3279
  right: viewMain.right
3275
3280
  },
3276
3281
  domAnchor: domLayoutParam,
3277
- scrollDirectionResponse: "HORIZONTAL"
3282
+ scrollDirectionResponse: "HORIZONTAL",
3283
+ runtimeMetadata: {
3284
+ componentKey,
3285
+ data,
3286
+ allowTransform
3287
+ }
3278
3288
  };
3279
3289
  const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
3280
3290
  const position$ = new BehaviorSubject(initedPosition);
@@ -3717,7 +3727,7 @@ const menuSchema = {
3717
3727
  //#endregion
3718
3728
  //#region package.json
3719
3729
  var name = "@univerjs/sheets-drawing-ui";
3720
- var version = "1.0.4";
3730
+ var version = "1.2.0";
3721
3731
 
3722
3732
  //#endregion
3723
3733
  //#region src/config/config.ts
@@ -4221,7 +4231,7 @@ function SheetImageTransparencySlider(props) {
4221
4231
  className: "univer-relative univer-h-1.5 univer-bg-gray-200 dark:!univer-bg-gray-600",
4222
4232
  onPointerDown: handlePointerDown,
4223
4233
  children: [/* @__PURE__ */ jsx("div", {
4224
- className: clsx("univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full", isRtl ? "univer-right-0" : "univer-left-0"),
4234
+ className: clsx("univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500", isRtl ? "univer-right-0" : "univer-left-0"),
4225
4235
  style: { width: `${sliderOffset}%` }
4226
4236
  }), /* @__PURE__ */ jsx("button", {
4227
4237
  className: clsx("univer-absolute univer-top-1/2 univer-size-3.5 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-rounded-full univer-bg-gray-0 univer-shadow-sm focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-100 dark:!univer-bg-gray-800", borderClassName, {
@@ -4263,6 +4273,12 @@ function SheetImageTransparencyInput(props) {
4263
4273
  useEffect(() => {
4264
4274
  if (!isEditingRef.current) setInputValue(`${value}%`);
4265
4275
  }, [value]);
4276
+ function parseTransparency(rawValue) {
4277
+ const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
4278
+ if (normalizedValue === "") return null;
4279
+ const parsedValue = Number(normalizedValue);
4280
+ return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
4281
+ }
4266
4282
  function emitValue(nextValue) {
4267
4283
  const normalizedValue = normalizeTransparency$1(nextValue);
4268
4284
  onChange === null || onChange === void 0 || onChange(normalizedValue);
@@ -4342,12 +4358,6 @@ function SheetImageTransparencyInput(props) {
4342
4358
  })]
4343
4359
  });
4344
4360
  }
4345
- function parseTransparency(rawValue) {
4346
- const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
4347
- if (normalizedValue === "") return null;
4348
- const parsedValue = Number(normalizedValue);
4349
- return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
4350
- }
4351
4361
  function normalizeTransparency$1(value) {
4352
4362
  return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
4353
4363
  }
@@ -4595,12 +4605,13 @@ SheetCellImageHoverRenderController = __decorate([
4595
4605
  //#endregion
4596
4606
  //#region src/controllers/render-controllers/sheet-drawing.render-controller.ts
4597
4607
  let SheetsDrawingRenderController = class SheetsDrawingRenderController extends Disposable {
4598
- constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService) {
4608
+ constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService, _logService) {
4599
4609
  super();
4600
4610
  this._context = _context;
4601
4611
  this._sheetDrawingService = _sheetDrawingService;
4602
4612
  this._drawingManagerService = _drawingManagerService;
4603
4613
  this._sheetSkeletonService = _sheetSkeletonService;
4614
+ this._logService = _logService;
4604
4615
  this._init();
4605
4616
  }
4606
4617
  _init() {
@@ -4609,22 +4620,38 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
4609
4620
  _drawingInitializeListener() {
4610
4621
  this._sheetDrawingService.initializeNotification(this._context.unitId);
4611
4622
  const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
4623
+ const refreshedDrawings = [];
4612
4624
  for (const subUnit in data) {
4613
4625
  const subUnitData = data[subUnit];
4614
4626
  for (const drawingId in subUnitData.data) {
4615
4627
  const drawingData = subUnitData.data[drawingId];
4616
4628
  const { unitId, subUnitId } = drawingData;
4617
4629
  const skeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
4618
- if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== SheetDrawingAnchorType.None) {
4619
- const transform = drawingPositionToTransform(drawingData.sheetTransform, skeletonParam);
4620
- drawingData.transform = transform && drawingData.drawingType === DrawingTypeEnum.DRAWING_GROUP ? {
4621
- ...transform,
4622
- left: (transform.left ?? 0) - skeletonParam.skeleton.rowHeaderWidthAndMarginLeft,
4623
- top: (transform.top ?? 0) - skeletonParam.skeleton.columnHeaderHeightAndMarginTop
4624
- } : transform;
4630
+ if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId && drawingData.anchorType !== SheetDrawingAnchorType.None) try {
4631
+ if (drawingData.drawingType === DrawingTypeEnum.DRAWING_GROUP) {
4632
+ const transform = drawingPositionToTransform(drawingData.sheetTransform, skeletonParam);
4633
+ refreshedDrawings.push({
4634
+ ...drawingData,
4635
+ transform: transform && {
4636
+ ...transform,
4637
+ left: (transform.left ?? 0) - skeletonParam.skeleton.rowHeaderWidthAndMarginLeft,
4638
+ top: (transform.top ?? 0) - skeletonParam.skeleton.columnHeaderHeightAndMarginTop
4639
+ }
4640
+ });
4641
+ } else refreshedDrawings.push(refreshSheetDrawingPlacement(drawingData, skeletonParam.skeleton));
4642
+ } catch (error) {
4643
+ this._logService.warn("[SheetsDrawingRenderController]", "Skipping drawing placement initialization", {
4644
+ unitId,
4645
+ subUnitId,
4646
+ drawingId,
4647
+ transform: drawingData.transform,
4648
+ sheetTransform: drawingData.sheetTransform,
4649
+ error
4650
+ });
4625
4651
  }
4626
4652
  }
4627
4653
  }
4654
+ this._sheetDrawingService.refreshTransform(refreshedDrawings);
4628
4655
  this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));
4629
4656
  this._drawingManagerService.initializeNotification(this._context.unitId);
4630
4657
  }
@@ -4632,7 +4659,8 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
4632
4659
  SheetsDrawingRenderController = __decorate([
4633
4660
  __decorateParam(1, ISheetDrawingService),
4634
4661
  __decorateParam(2, IDrawingManagerService),
4635
- __decorateParam(3, Inject(SheetSkeletonService))
4662
+ __decorateParam(3, Inject(SheetSkeletonService)),
4663
+ __decorateParam(4, ILogService)
4636
4664
  ], SheetsDrawingRenderController);
4637
4665
 
4638
4666
  //#endregion
@@ -4898,13 +4926,14 @@ SheetCellImageCopyPasteController = __decorate([
4898
4926
  //#endregion
4899
4927
  //#region src/controllers/sheet-drawing-active-render.controller.ts
4900
4928
  let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderController extends Disposable {
4901
- constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService) {
4929
+ constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService, _logService) {
4902
4930
  super();
4903
4931
  this._context = _context;
4904
4932
  this._commandService = _commandService;
4905
4933
  this._sheetSkeletonService = _sheetSkeletonService;
4906
4934
  this._sheetDrawingService = _sheetDrawingService;
4907
4935
  this._drawingManagerService = _drawingManagerService;
4936
+ this._logService = _logService;
4908
4937
  _defineProperty(this, "_renderTimeout", void 0);
4909
4938
  this._commandListener();
4910
4939
  }
@@ -4926,64 +4955,57 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
4926
4955
  }, 0);
4927
4956
  }
4928
4957
  _commandListener() {
4958
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
4959
+ if (command.id !== SetWorksheetActiveOperation.id) return;
4960
+ const { unitId, subUnitId } = command.params;
4961
+ const { unit, unitId: contextUnitId } = this._context;
4962
+ if (unitId !== contextUnitId || !unit.getSheetBySheetId(subUnitId) || unit.getActiveSheet().getSheetId() === subUnitId) return;
4963
+ this._clearDrawings(unitId, subUnitId);
4964
+ }));
4929
4965
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
4930
4966
  if (command.id === SetWorksheetActiveOperation.id) {
4931
4967
  const { unitId, subUnitId } = command.params;
4932
- this._updateDrawings(unitId, subUnitId);
4968
+ if (unitId === this._context.unitId && subUnitId === this._context.unit.getActiveSheet().getSheetId()) this._updateDrawings(unitId, subUnitId);
4933
4969
  }
4934
4970
  }));
4935
4971
  this.disposeWithMe(this._context.activated$.subscribe((activated) => {
4936
4972
  const { unit, unitId } = this._context;
4937
- if (activated) this._updateDrawings(unitId, unit.getActiveSheet().getSheetId());
4938
- else this._clearDrawings(unitId);
4973
+ if (activated) {
4974
+ const subUnitId = unit.getActiveSheet().getSheetId();
4975
+ this._clearDrawings(unitId, subUnitId);
4976
+ this._updateDrawings(unitId, subUnitId);
4977
+ } else this._clearDrawings(unitId);
4939
4978
  }));
4940
4979
  }
4941
- _clearDrawings(selfUnitId) {
4942
- this._scheduleRender(() => {
4943
- const drawingMap = this._drawingManagerService.drawingManagerData;
4944
- const removeDrawings = [];
4945
- Object.keys(drawingMap ?? {}).forEach((unitId) => {
4946
- const subUnitMap = drawingMap[unitId] ?? {};
4947
- Object.keys(subUnitMap).forEach((subUnitId) => {
4948
- var _subUnitMap$subUnitId;
4949
- const drawingData = ((_subUnitMap$subUnitId = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId === void 0 ? void 0 : _subUnitMap$subUnitId.data) ?? {};
4950
- Object.keys(drawingData).forEach((drawingId) => {
4951
- if (unitId === selfUnitId) removeDrawings.push(drawingData[drawingId]);
4952
- });
4953
- });
4954
- });
4955
- this._sheetDrawingService.removeNotification(removeDrawings);
4956
- this._drawingManagerService.removeNotification(removeDrawings);
4957
- });
4980
+ _clearDrawings(unitId, keepSubUnitId) {
4981
+ this._cancelPendingRender();
4982
+ const subUnitMap = this._drawingManagerService.drawingManagerData[unitId] ?? {};
4983
+ const removeDrawings = [];
4984
+ for (const subUnitId of Object.keys(subUnitMap)) {
4985
+ var _subUnitMap$subUnitId;
4986
+ if (subUnitId === keepSubUnitId) continue;
4987
+ for (const drawing of Object.values(((_subUnitMap$subUnitId = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId === void 0 ? void 0 : _subUnitMap$subUnitId.data) ?? {})) removeDrawings.push(drawing);
4988
+ }
4989
+ this._sheetDrawingService.removeNotification(removeDrawings);
4990
+ this._drawingManagerService.removeNotification(removeDrawings);
4958
4991
  }
4959
4992
  _updateDrawings(showUnitId, showSubunitId) {
4960
4993
  this._scheduleRender(() => {
4994
+ var _subUnitMap$showSubun;
4961
4995
  const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
4962
- const drawingMap = this._drawingManagerService.drawingManagerData;
4963
- const insertDrawings = [];
4964
- const refreshedDrawings = [];
4965
- const removeDrawings = [];
4966
- Object.keys(drawingMap ?? {}).forEach((unitId) => {
4967
- if (unitId !== showUnitId) return;
4968
- const subUnitMap = drawingMap[unitId] ?? {};
4969
- Object.keys(subUnitMap).forEach((subUnitId) => {
4970
- var _subUnitMap$subUnitId2;
4971
- const drawingData = ((_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) ?? {};
4972
- Object.keys(drawingData).forEach((drawingId) => {
4973
- if (unitId === showUnitId && subUnitId === showSubunitId) {
4974
- const drawing = drawingData[drawingId];
4975
- if (sheetSkeletonParam && drawing.sheetTransform && drawing.anchorType !== SheetDrawingAnchorType.None) refreshedDrawings.push(applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(drawing), sheetSkeletonParam.skeleton));
4976
- insertDrawings.push(drawingData[drawingId]);
4977
- } else removeDrawings.push(drawingData[drawingId]);
4978
- });
4979
- });
4980
- });
4996
+ const drawingData = ((_subUnitMap$showSubun = (this._drawingManagerService.drawingManagerData[showUnitId] ?? {})[showSubunitId]) === null || _subUnitMap$showSubun === void 0 ? void 0 : _subUnitMap$showSubun.data) ?? {};
4997
+ const { successDrawings, refreshedDrawings, removeDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
4981
4998
  this._sheetDrawingService.refreshTransform(refreshedDrawings);
4982
4999
  this._drawingManagerService.refreshTransform(refreshedDrawings);
4983
5000
  this._sheetDrawingService.removeNotification(removeDrawings);
4984
- this._sheetDrawingService.addNotification(insertDrawings);
5001
+ this._sheetDrawingService.addNotification(successDrawings);
4985
5002
  this._drawingManagerService.removeNotification(removeDrawings);
4986
- this._drawingManagerService.addNotification(insertDrawings);
5003
+ this._drawingManagerService.addNotification(successDrawings);
5004
+ if (failures.length) this._logService.error("[SheetDrawingActiveRenderController]", {
5005
+ unitId: showUnitId,
5006
+ subUnitId: showSubunitId,
5007
+ failures
5008
+ });
4987
5009
  });
4988
5010
  }
4989
5011
  };
@@ -4991,8 +5013,42 @@ SheetDrawingActiveRenderController = __decorate([
4991
5013
  __decorateParam(1, ICommandService),
4992
5014
  __decorateParam(2, Inject(SheetSkeletonService)),
4993
5015
  __decorateParam(3, ISheetDrawingService),
4994
- __decorateParam(4, IDrawingManagerService)
5016
+ __decorateParam(4, IDrawingManagerService),
5017
+ __decorateParam(5, ILogService)
4995
5018
  ], SheetDrawingActiveRenderController);
5019
+ function prepareSheetDrawings(drawings, skeleton) {
5020
+ const successDrawings = [];
5021
+ const refreshedDrawings = [];
5022
+ const removeDrawings = [];
5023
+ const failures = [];
5024
+ for (const drawing of drawings) {
5025
+ if (skeleton && drawing.sheetTransform && drawing.anchorType !== SheetDrawingAnchorType.None) try {
5026
+ var _refreshed$transform, _refreshed$transform2;
5027
+ const refreshed = refreshSheetDrawingPlacement(drawing, skeleton);
5028
+ refreshedDrawings.push(refreshed);
5029
+ if ((drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE || drawing.drawingType === DrawingTypeEnum.DRAWING_DOM) && (((_refreshed$transform = refreshed.transform) === null || _refreshed$transform === void 0 ? void 0 : _refreshed$transform.width) === 0 || ((_refreshed$transform2 = refreshed.transform) === null || _refreshed$transform2 === void 0 ? void 0 : _refreshed$transform2.height) === 0)) {
5030
+ removeDrawings.push(drawing);
5031
+ continue;
5032
+ }
5033
+ } catch (error) {
5034
+ removeDrawings.push(drawing);
5035
+ failures.push({
5036
+ drawingId: drawing.drawingId,
5037
+ drawingType: drawing.drawingType,
5038
+ anchorType: drawing.anchorType ?? SheetDrawingAnchorType.Position,
5039
+ error
5040
+ });
5041
+ continue;
5042
+ }
5043
+ successDrawings.push(drawing);
5044
+ }
5045
+ return {
5046
+ successDrawings,
5047
+ refreshedDrawings,
5048
+ removeDrawings,
5049
+ failures
5050
+ };
5051
+ }
4996
5052
 
4997
5053
  //#endregion
4998
5054
  //#region src/controllers/sheet-drawing-copy-paste.controller.ts
package/lib/facade.js CHANGED
@@ -13,16 +13,23 @@ import { IRenderManagerService, getCurrentTypeOfRenderer } from "@univerjs/engin
13
13
  var FWorksheetDrawingUIMixin = class extends FWorksheet {
14
14
  getFloatDomById(id) {
15
15
  const info = this._injector.get(SheetCanvasFloatDomManagerService).getFloatDomInfo(id);
16
- if (!info) return null;
17
- const { unitId, subUnitId } = info;
18
- const { rect } = info;
19
- const { left = 0, top = 0, width = 0, height = 0, flipX = false, flipY = false, angle = 0, skewX = 0, skewY = 0 } = rect.getState();
20
- const drawingParm = this._injector.get(ISheetDrawingService).getDrawingByParam({
21
- drawingId: info.id,
16
+ return info ? this._getFloatDomResult(info) : null;
17
+ }
18
+ getAllFloatDoms() {
19
+ const floatDomService = this._injector.get(SheetCanvasFloatDomManagerService);
20
+ const unitId = this._workbook.getUnitId();
21
+ const subUnitId = this._worksheet.getSheetId();
22
+ return floatDomService.getFloatDomsBySubUnitId(unitId, subUnitId).map((info) => this._getFloatDomResult(info)).filter((dom) => dom != null);
23
+ }
24
+ _getFloatDomResult(info) {
25
+ const { unitId, subUnitId, id, rect, runtimeMetadata } = info;
26
+ const metadata = runtimeMetadata ?? this._injector.get(ISheetDrawingService).getDrawingByParam({
27
+ drawingId: id,
22
28
  unitId,
23
29
  subUnitId
24
30
  });
25
- if (!drawingParm) return null;
31
+ if (!metadata) return null;
32
+ const { left = 0, top = 0, width = 0, height = 0, flipX = false, flipY = false, angle = 0, skewX = 0, skewY = 0 } = rect.getState();
26
33
  return {
27
34
  position: {
28
35
  left,
@@ -35,44 +42,12 @@ var FWorksheetDrawingUIMixin = class extends FWorksheet {
35
42
  skewX,
36
43
  skewY
37
44
  },
38
- componentKey: drawingParm.componentKey,
39
- allowTransform: drawingParm.allowTransform,
40
- data: drawingParm.data,
41
- id: info.id
45
+ componentKey: metadata.componentKey,
46
+ allowTransform: metadata.allowTransform,
47
+ data: metadata.data,
48
+ id
42
49
  };
43
50
  }
44
- getAllFloatDoms() {
45
- const floatDomService = this._injector.get(SheetCanvasFloatDomManagerService);
46
- const unitId = this._workbook.getUnitId();
47
- const subUnitId = this._worksheet.getSheetId();
48
- return Array.from(floatDomService.getFloatDomsBySubUnitId(unitId, subUnitId).values()).map((info) => {
49
- const { rect } = info;
50
- const drawingParm = this._injector.get(ISheetDrawingService).getDrawingByParam({
51
- drawingId: info.id,
52
- unitId,
53
- subUnitId
54
- });
55
- if (!drawingParm) return null;
56
- const { left, top, width, height, flipX, flipY, angle, skewX, skewY } = rect.getState();
57
- return {
58
- position: {
59
- left,
60
- top,
61
- width,
62
- height,
63
- flipX,
64
- flipY,
65
- angle,
66
- skewX,
67
- skewY
68
- },
69
- componentKey: drawingParm.componentKey,
70
- allowTransform: drawingParm.allowTransform,
71
- data: drawingParm.data,
72
- id: info.id
73
- };
74
- }).filter((dom) => dom != null);
75
- }
76
51
  updateFloatDom(id, config) {
77
52
  const sheetSkeletonService = this._injector.get(SheetSkeletonService);
78
53
  const info = this._injector.get(SheetCanvasFloatDomManagerService).getFloatDomInfo(id);
package/lib/index.css CHANGED
@@ -179,6 +179,10 @@
179
179
  background-color: var(--univer-gray-200);
180
180
  }
181
181
 
182
+ .univer-bg-primary-500 {
183
+ background-color: var(--univer-primary-500);
184
+ }
185
+
182
186
  .univer-bg-transparent {
183
187
  background-color: #0000;
184
188
  }