@univerjs/drawing-ui 1.0.0-alpha.8 → 1.0.0-beta.1

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.
Files changed (86) hide show
  1. package/lib/cjs/index.js +142 -108
  2. package/lib/cjs/locale/ar-SA.js +1 -19
  3. package/lib/cjs/locale/ca-ES.js +1 -19
  4. package/lib/cjs/locale/de-DE.js +1 -19
  5. package/lib/cjs/locale/en-US.js +1 -19
  6. package/lib/cjs/locale/es-ES.js +1 -19
  7. package/lib/cjs/locale/fa-IR.js +1 -19
  8. package/lib/cjs/locale/fr-FR.js +1 -19
  9. package/lib/cjs/locale/id-ID.js +1 -19
  10. package/lib/cjs/locale/it-IT.js +1 -19
  11. package/lib/cjs/locale/ja-JP.js +1 -19
  12. package/lib/cjs/locale/ko-KR.js +1 -19
  13. package/lib/cjs/locale/pl-PL.js +1 -19
  14. package/lib/cjs/locale/pt-BR.js +1 -19
  15. package/lib/cjs/locale/ru-RU.js +1 -19
  16. package/lib/cjs/locale/sk-SK.js +1 -19
  17. package/lib/cjs/locale/vi-VN.js +1 -19
  18. package/lib/cjs/locale/zh-CN.js +1 -19
  19. package/lib/cjs/locale/zh-HK.js +1 -19
  20. package/lib/cjs/locale/zh-TW.js +1 -19
  21. package/lib/es/index.js +145 -111
  22. package/lib/es/locale/ar-SA.js +1 -19
  23. package/lib/es/locale/ca-ES.js +1 -19
  24. package/lib/es/locale/de-DE.js +1 -19
  25. package/lib/es/locale/en-US.js +1 -19
  26. package/lib/es/locale/es-ES.js +1 -19
  27. package/lib/es/locale/fa-IR.js +1 -19
  28. package/lib/es/locale/fr-FR.js +1 -19
  29. package/lib/es/locale/id-ID.js +1 -19
  30. package/lib/es/locale/it-IT.js +1 -19
  31. package/lib/es/locale/ja-JP.js +1 -19
  32. package/lib/es/locale/ko-KR.js +1 -19
  33. package/lib/es/locale/pl-PL.js +1 -19
  34. package/lib/es/locale/pt-BR.js +1 -19
  35. package/lib/es/locale/ru-RU.js +1 -19
  36. package/lib/es/locale/sk-SK.js +1 -19
  37. package/lib/es/locale/vi-VN.js +1 -19
  38. package/lib/es/locale/zh-CN.js +1 -19
  39. package/lib/es/locale/zh-HK.js +1 -19
  40. package/lib/es/locale/zh-TW.js +1 -19
  41. package/lib/index.css +28 -10
  42. package/lib/index.js +145 -111
  43. package/lib/locale/ar-SA.js +1 -19
  44. package/lib/locale/ca-ES.js +1 -19
  45. package/lib/locale/de-DE.js +1 -19
  46. package/lib/locale/en-US.js +1 -19
  47. package/lib/locale/es-ES.js +1 -19
  48. package/lib/locale/fa-IR.js +1 -19
  49. package/lib/locale/fr-FR.js +1 -19
  50. package/lib/locale/id-ID.js +1 -19
  51. package/lib/locale/it-IT.js +1 -19
  52. package/lib/locale/ja-JP.js +1 -19
  53. package/lib/locale/ko-KR.js +1 -19
  54. package/lib/locale/pl-PL.js +1 -19
  55. package/lib/locale/pt-BR.js +1 -19
  56. package/lib/locale/ru-RU.js +1 -19
  57. package/lib/locale/sk-SK.js +1 -19
  58. package/lib/locale/vi-VN.js +1 -19
  59. package/lib/locale/zh-CN.js +1 -19
  60. package/lib/locale/zh-HK.js +1 -19
  61. package/lib/locale/zh-TW.js +1 -19
  62. package/lib/types/commands/operations/image-crop.operation.d.ts +4 -2
  63. package/lib/types/controllers/image-cropper.controller.d.ts +10 -2
  64. package/lib/types/locale/en-US.d.ts +0 -18
  65. package/lib/types/views/image-popup-menu/ImagePopupMenu.d.ts +1 -0
  66. package/lib/umd/index.js +2 -2
  67. package/lib/umd/locale/ar-SA.js +1 -1
  68. package/lib/umd/locale/ca-ES.js +1 -1
  69. package/lib/umd/locale/de-DE.js +1 -1
  70. package/lib/umd/locale/en-US.js +1 -1
  71. package/lib/umd/locale/es-ES.js +1 -1
  72. package/lib/umd/locale/fa-IR.js +1 -1
  73. package/lib/umd/locale/fr-FR.js +1 -1
  74. package/lib/umd/locale/id-ID.js +1 -1
  75. package/lib/umd/locale/it-IT.js +1 -1
  76. package/lib/umd/locale/ja-JP.js +1 -1
  77. package/lib/umd/locale/ko-KR.js +1 -1
  78. package/lib/umd/locale/pl-PL.js +1 -1
  79. package/lib/umd/locale/pt-BR.js +1 -1
  80. package/lib/umd/locale/ru-RU.js +1 -1
  81. package/lib/umd/locale/sk-SK.js +1 -1
  82. package/lib/umd/locale/vi-VN.js +1 -1
  83. package/lib/umd/locale/zh-CN.js +1 -1
  84. package/lib/umd/locale/zh-HK.js +1 -1
  85. package/lib/umd/locale/zh-TW.js +1 -1
  86. package/package.json +9 -9
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { ArrangeTypeEnum, BooleanNumber, CommandType, DependentOn, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IURLImageService, IUniverInstanceService, ImageSourceType, Inject, Injector, LocaleService, Plugin, PositionedObjectLayoutType, UniverInstanceType, checkIfMove, debounce, generateRandomId, merge, toDisposable } from "@univerjs/core";
1
+ import { ArrangeTypeEnum, BooleanNumber, CommandType, DependentOn, Disposable, DisposableCollection, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IURLImageService, IUniverInstanceService, ImageSourceType, Inject, Injector, LocaleService, Plugin, PositionedObjectLayoutType, UniverInstanceType, checkIfMove, debounce, generateRandomId, merge, toDisposable } from "@univerjs/core";
2
2
  import { DRAWING_GROUPABLE_TYPES, IDrawingManagerService, SetDrawingSelectedOperation, UniverDrawingPlugin, getDrawingShapeKeyByDrawingSearch, isGroupableDrawingType, resolveDrawingRotateEnabled } from "@univerjs/drawing";
3
3
  import { CURSOR_TYPE, Canvas, DRAWING_OBJECT_LAYER_INDEX, DrawingGroupObject, Group, IRenderManagerService, Image, RENDER_CLASS_TYPE, Rect, Shape, UniverRenderEnginePlugin, Vector2, degToRad, getGroupState, precisionTo, transformObjectOutOfGroup } from "@univerjs/engine-render";
4
- import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IGalleryService, IMenuManagerService, IMessageService, IconManager, MenuItemType, UniverUIPlugin, useDependency, useObservable } from "@univerjs/ui";
4
+ import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IGalleryService, IMenuManagerService, IMessageService, IShortcutService, IconManager, KeyCode, MenuItemType, useDependency, useObservable } from "@univerjs/ui";
5
5
  import { BehaviorSubject, Observable, bufferTime, filter, map, merge as merge$1, of, startWith, switchMap } from "rxjs";
6
- import { ArrowDownIcon, ArrowUpIcon, AutofillDoubleIcon, BottomIcon, ChartIcon, CreateCopyIcon, CropIcon, DeleteIcon, DocSettingIcon, EyeIcon, EyelashIcon, GroupIcon, LocateFixedIcon, LockIcon, MoreDownIcon, MoreRightIcon, MoveDownIcon, MoveUpIcon, TextWrapShapeIcon, TopmostIcon, UngroupIcon, UnlockIcon } from "@univerjs/icons";
6
+ import { ArrowDownIcon, ArrowUpIcon, AutofillDoubleIcon, BottomIcon, ChartIcon, CreateCopyIcon, CropIcon, DeleteIcon, DocSettingIcon, EyeIcon, EyelashIcon, GroupIcon, LocateFixedIcon, LockIcon, MoreDownIcon, MoveDownIcon, MoveUpIcon, TextWrapShapeIcon, TopmostIcon, UngroupIcon, UnlockIcon } from "@univerjs/icons";
7
7
  import { Button, Checkbox, Dropdown, DropdownMenu, Input, InputNumber, MessageType, Select, Separator, Tooltip, borderClassName, clsx } from "@univerjs/design";
8
8
  import { useEffect, useMemo, useRef, useState } from "react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -236,21 +236,21 @@ const CancelDrawingGroupOperation = {
236
236
  const OpenImageCropOperation = {
237
237
  id: "sheet.operation.open-image-crop",
238
238
  type: CommandType.OPERATION,
239
- handler: (accessor, params) => {
239
+ handler: (_accessor, _params) => {
240
240
  return true;
241
241
  }
242
242
  };
243
243
  const CloseImageCropOperation = {
244
244
  id: "sheet.operation.close-image-crop",
245
245
  type: CommandType.OPERATION,
246
- handler: (accessor, params) => {
246
+ handler: (_accessor, _params) => {
247
247
  return true;
248
248
  }
249
249
  };
250
250
  const AutoImageCropOperation = {
251
251
  id: "sheet.operation.Auto-image-crop",
252
252
  type: CommandType.OPERATION,
253
- handler: (accessor, params) => {
253
+ handler: (_accessor, _params) => {
254
254
  return true;
255
255
  }
256
256
  };
@@ -271,19 +271,17 @@ function isKnownDrawingUINonRotatableType(drawingType) {
271
271
  return drawingType === DrawingTypeEnum.DRAWING_CHART;
272
272
  }
273
273
  function resolveDrawingUIRotateEnabled(drawing, options = {}) {
274
- var _options$isKnownNonRo;
275
274
  return resolveDrawingRotateEnabled(drawing, {
276
275
  ...options,
277
- isKnownNonRotatableType: (_options$isKnownNonRo = options.isKnownNonRotatableType) !== null && _options$isKnownNonRo !== void 0 ? _options$isKnownNonRo : isKnownDrawingUINonRotatableType
276
+ isKnownNonRotatableType: options.isKnownNonRotatableType ?? isKnownDrawingUINonRotatableType
278
277
  });
279
278
  }
280
279
 
281
280
  //#endregion
282
281
  //#region src/controllers/utils.ts
283
282
  function getDrawingRenderObject(scene, drawingSearch) {
284
- var _scene$getObjectInclu;
285
283
  const key = getDrawingShapeKeyByDrawingSearch(drawingSearch);
286
- return (_scene$getObjectInclu = scene.getObjectIncludeInGroup(key)) !== null && _scene$getObjectInclu !== void 0 ? _scene$getObjectInclu : null;
284
+ return scene.getObjectIncludeInGroup(key) ?? null;
287
285
  }
288
286
  function disposeDrawingRenderObject(scene, drawingSearch) {
289
287
  const object = getDrawingRenderObject(scene, drawingSearch);
@@ -626,7 +624,7 @@ const menuSchema = { [ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]:
626
624
  //#endregion
627
625
  //#region package.json
628
626
  var name = "@univerjs/drawing-ui";
629
- var version = "1.0.0-alpha.8";
627
+ var version = "1.0.0-beta.1";
630
628
 
631
629
  //#endregion
632
630
  //#region src/config/config.ts
@@ -699,11 +697,11 @@ function ImagePopupMenu(props) {
699
697
  open: visible,
700
698
  onOpenChange: onVisibleChange,
701
699
  children: /* @__PURE__ */ jsxs("div", {
702
- className: clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", borderClassName, {
700
+ className: clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 univer-text-gray-900 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", borderClassName, {
703
701
  "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
704
- "univer-bg-white dark:!univer-bg-gray-900": !visible
702
+ "univer-bg-gray-0 dark:!univer-bg-gray-900": !visible
705
703
  }),
706
- children: [/* @__PURE__ */ jsx(AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-white" })]
704
+ children: [/* @__PURE__ */ jsx(AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-gray-0" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
707
705
  })
708
706
  })
709
707
  });
@@ -726,7 +724,7 @@ function ToolbarGroup(props) {
726
724
  }
727
725
  function ToolbarButton(props) {
728
726
  return /* @__PURE__ */ jsx(Tooltip, {
729
- title: useDependency(LocaleService).t(props.titleKey),
727
+ title: props.title,
730
728
  placement: "bottom",
731
729
  children: /* @__PURE__ */ jsx("button", {
732
730
  type: "button",
@@ -738,14 +736,13 @@ function ToolbarButton(props) {
738
736
  });
739
737
  }
740
738
  function ToolbarDropdownButton(props) {
741
- var _props$options$find;
742
739
  const [open, setOpen] = useState(false);
743
- const activeOption = (_props$options$find = props.options.find((option) => option.value === props.value)) !== null && _props$options$find !== void 0 ? _props$options$find : props.options[0];
740
+ const activeOption = props.options.find((option) => option.value === props.value) ?? props.options[0];
744
741
  return /* @__PURE__ */ jsx(Dropdown, {
745
742
  open,
746
743
  onOpenChange: setOpen,
747
744
  overlay: /* @__PURE__ */ jsx("div", {
748
- className: "univer-min-w-32 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900",
745
+ className: "univer-min-w-32 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900",
749
746
  children: props.options.map((option) => /* @__PURE__ */ jsxs("button", {
750
747
  type: "button",
751
748
  onClick: () => {
@@ -774,11 +771,11 @@ function ToolbarDropdownButton(props) {
774
771
  });
775
772
  }
776
773
  function DocImageFloatingToolbar(props) {
777
- var _univerInstanceServic, _wrappingStyleOptions, _wrappingStyleOptions2;
774
+ var _wrappingStyleOptions;
778
775
  const commandService = useDependency(ICommandService);
779
776
  const iconManager = useDependency(IconManager);
780
777
  const localeService = useDependency(LocaleService);
781
- const documentDataModel = (_univerInstanceServic = useDependency(IUniverInstanceService).getUnit(props.unitId, UniverInstanceType.UNIVER_DOC)) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : void 0;
778
+ const documentDataModel = useDependency(IUniverInstanceService).getUnit(props.unitId, UniverInstanceType.UNIVER_DOC) ?? void 0;
782
779
  const [wrappingStyle, setWrappingStyle] = useState(() => getWrappingStyle(documentDataModel, props.drawingId));
783
780
  const [hidden, setHidden] = useState(false);
784
781
  const actionItems = props.menuItems.filter((item) => item.type !== "select" && item.icon).sort((a, b) => a.index - b.index);
@@ -834,16 +831,16 @@ function DocImageFloatingToolbar(props) {
834
831
  event.stopPropagation();
835
832
  event.preventDefault();
836
833
  },
837
- className: clsx("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", borderClassName),
834
+ className: clsx("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-gray-0 univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", borderClassName),
838
835
  children: [/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ToolbarDropdownButton, {
839
- title: (_wrappingStyleOptions = (_wrappingStyleOptions2 = wrappingStyleOptions.find((option) => option.value === wrappingStyle)) === null || _wrappingStyleOptions2 === void 0 ? void 0 : _wrappingStyleOptions2.label) !== null && _wrappingStyleOptions !== void 0 ? _wrappingStyleOptions : localeService.t("drawing-ui.image-text-wrap.inline"),
836
+ title: ((_wrappingStyleOptions = wrappingStyleOptions.find((option) => option.value === wrappingStyle)) === null || _wrappingStyleOptions === void 0 ? void 0 : _wrappingStyleOptions.label) ?? localeService.t("drawing-ui.image-text-wrap.inline"),
840
837
  value: wrappingStyle,
841
838
  options: wrappingStyleOptions,
842
839
  onChange: updateWrappingStyle
843
840
  }) }), actionItems.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Separator, { orientation: "vertical" }), /* @__PURE__ */ jsx(ToolbarGroup, { children: actionItems.map((item) => {
844
841
  const Icon = iconManager.get(item.icon);
845
842
  return /* @__PURE__ */ jsx(ToolbarButton, {
846
- titleKey: item.label,
843
+ title: localeService.t(item.label),
847
844
  disabled: item.disable,
848
845
  onClick: () => executeMenuItem(item),
849
846
  children: /* @__PURE__ */ jsx(Icon, {})
@@ -852,18 +849,21 @@ function DocImageFloatingToolbar(props) {
852
849
  });
853
850
  }
854
851
  function DocChartFloatingToolbar(props) {
855
- var _chartTypeItem$option, _ref, _chartTypeItem$value, _chartTypeOptions$;
852
+ var _chartTypeOptions$;
856
853
  const commandService = useDependency(ICommandService);
857
854
  const iconManager = useDependency(IconManager);
858
855
  const localeService = useDependency(LocaleService);
859
856
  const [hidden, setHidden] = useState(false);
860
857
  const chartTypeItem = props.menuItems.find((item) => item.type === "select");
861
858
  const actionItems = props.menuItems.filter((item) => item.type !== "select" && item.icon).sort((a, b) => a.index - b.index);
862
- const chartTypeOptions = ((_chartTypeItem$option = chartTypeItem === null || chartTypeItem === void 0 ? void 0 : chartTypeItem.options) !== null && _chartTypeItem$option !== void 0 ? _chartTypeItem$option : []).map((option) => ({
863
- label: String(option.label),
864
- value: option.value,
865
- icon: /* @__PURE__ */ jsx(ChartIcon, {})
866
- }));
859
+ const chartTypeOptions = ((chartTypeItem === null || chartTypeItem === void 0 ? void 0 : chartTypeItem.options) ?? []).map((option) => {
860
+ const Icon = option.icon ? iconManager.get(option.icon) : ChartIcon;
861
+ return {
862
+ label: String(option.label),
863
+ value: option.value,
864
+ icon: /* @__PURE__ */ jsx(Icon, {})
865
+ };
866
+ });
867
867
  const executeMenuItem = (item) => {
868
868
  if (!item || item.disable) return;
869
869
  if (item.hideOnClick) setHidden(true);
@@ -876,10 +876,10 @@ function DocChartFloatingToolbar(props) {
876
876
  event.stopPropagation();
877
877
  event.preventDefault();
878
878
  },
879
- className: clsx("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", borderClassName),
879
+ className: clsx("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-gray-0 univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", borderClassName),
880
880
  children: [chartTypeItem && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ToolbarDropdownButton, {
881
881
  title: localeService.t(chartTypeItem.label),
882
- value: (_ref = (_chartTypeItem$value = chartTypeItem.value) !== null && _chartTypeItem$value !== void 0 ? _chartTypeItem$value : (_chartTypeOptions$ = chartTypeOptions[0]) === null || _chartTypeOptions$ === void 0 ? void 0 : _chartTypeOptions$.value) !== null && _ref !== void 0 ? _ref : "",
882
+ value: chartTypeItem.value ?? ((_chartTypeOptions$ = chartTypeOptions[0]) === null || _chartTypeOptions$ === void 0 ? void 0 : _chartTypeOptions$.value) ?? "",
883
883
  options: chartTypeOptions,
884
884
  onChange: (value) => {
885
885
  if (!chartTypeItem.disable) {
@@ -890,7 +890,7 @@ function DocChartFloatingToolbar(props) {
890
890
  }) }), actionItems.length > 0 && /* @__PURE__ */ jsx(Separator, { orientation: "vertical" })] }), actionItems.length > 0 && /* @__PURE__ */ jsx(ToolbarGroup, { children: actionItems.map((item) => {
891
891
  const Icon = iconManager.get(item.icon);
892
892
  return /* @__PURE__ */ jsx(ToolbarButton, {
893
- titleKey: item.label,
893
+ title: localeService.t(item.label),
894
894
  disabled: item.disable,
895
895
  onClick: () => executeMenuItem(item),
896
896
  children: /* @__PURE__ */ jsx(Icon, {})
@@ -1956,7 +1956,7 @@ var ImageCropperObject = class extends Shape {
1956
1956
  //#endregion
1957
1957
  //#region src/controllers/image-cropper.controller.ts
1958
1958
  let ImageCropperController = class ImageCropperController extends Disposable {
1959
- constructor(_commandService, _drawingManagerService, _renderManagerService, _univerInstanceService, _messageService, _localeService) {
1959
+ constructor(_commandService, _drawingManagerService, _renderManagerService, _univerInstanceService, _messageService, _localeService, _shortcutService) {
1960
1960
  super();
1961
1961
  this._commandService = _commandService;
1962
1962
  this._drawingManagerService = _drawingManagerService;
@@ -1964,7 +1964,13 @@ let ImageCropperController = class ImageCropperController extends Disposable {
1964
1964
  this._univerInstanceService = _univerInstanceService;
1965
1965
  this._messageService = _messageService;
1966
1966
  this._localeService = _localeService;
1967
+ this._shortcutService = _shortcutService;
1967
1968
  _defineProperty(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1969
+ _defineProperty(this, "_cropShortcutDisposables", new DisposableCollection());
1970
+ _defineProperty(this, "_cropSnapshots", /* @__PURE__ */ new WeakMap());
1971
+ _defineProperty(this, "_pendingCropSnapshot", null);
1972
+ _defineProperty(this, "_activeCropSession", null);
1973
+ this.disposeWithMe(this._cropShortcutDisposables);
1968
1974
  this._init();
1969
1975
  }
1970
1976
  _init() {
@@ -1999,12 +2005,17 @@ let ImageCropperController = class ImageCropperController extends Disposable {
1999
2005
  return;
2000
2006
  }
2001
2007
  if (imageShape == null) return;
2002
- this._updateCropperObject(cropType, imageShape);
2003
- this._commandService.executeCommand(OpenImageCropOperation.id, {
2004
- unitId,
2005
- subUnitId,
2006
- drawingId
2007
- });
2008
+ this._pendingCropSnapshot = this._captureCropSnapshot(imageShape);
2009
+ try {
2010
+ this._updateCropperObject(cropType, imageShape);
2011
+ this._commandService.syncExecuteCommand(OpenImageCropOperation.id, {
2012
+ unitId,
2013
+ subUnitId,
2014
+ drawingId
2015
+ });
2016
+ } finally {
2017
+ this._pendingCropSnapshot = null;
2018
+ }
2008
2019
  }));
2009
2020
  }
2010
2021
  _calculateSrcRectByRatio(left, top, width, height, numerator, denominator) {
@@ -2072,6 +2083,7 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2072
2083
  if (command.id !== OpenImageCropOperation.id) return;
2073
2084
  const params = command.params;
2074
2085
  if (params == null) return;
2086
+ if (this._activeCropSession != null) this._commandService.syncExecuteCommand(CloseImageCropOperation.id, { isAuto: true });
2075
2087
  const { unitId, subUnitId, drawingId } = params;
2076
2088
  const renderObject = this._renderManagerService.getRenderUnitById(unitId);
2077
2089
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
@@ -2106,12 +2118,20 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2106
2118
  prstGeom: imageShape.prstGeom,
2107
2119
  applyTransform: imageShape.calculateTransformWithSrcRect()
2108
2120
  });
2121
+ this._cropSnapshots.set(imageCropperObject, this._pendingCropSnapshot ?? this._captureCropSnapshot(imageShape));
2122
+ this._pendingCropSnapshot = null;
2109
2123
  scene.addObject(imageCropperObject, imageShape.getLayerIndex() + 1).attachTransformerTo(imageCropperObject);
2124
+ this._activeCropSession = {
2125
+ scene,
2126
+ imageShape,
2127
+ imageCropperObject
2128
+ };
2110
2129
  transformer === null || transformer === void 0 || transformer.createControlForCopper(imageCropperObject);
2111
2130
  this._addHoverForImageCopper(imageCropperObject);
2112
2131
  imageShape.openRenderByCropper();
2113
2132
  transformer === null || transformer === void 0 || transformer.refreshControls();
2114
2133
  imageCropperObject.makeDirty(true);
2134
+ this._registerCropShortcuts();
2115
2135
  this._commandService.syncExecuteCommand(SetDrawingSelectedOperation.id, [{
2116
2136
  unitId,
2117
2137
  subUnitId,
@@ -2126,39 +2146,40 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2126
2146
  _initCloseCrop() {
2127
2147
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
2128
2148
  if (command.id !== CloseImageCropOperation.id) return;
2129
- const currentUnit = this._univerInstanceService.getFocusedUnit();
2130
- if (currentUnit == null) return;
2131
- const unitId = currentUnit.getUnitId();
2132
- const renderObject = this._renderManagerService.getRenderUnitById(unitId);
2133
- const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2134
- if (scene == null) return true;
2135
- const imageCropperObject = this._searchCropObject(scene);
2136
- if (imageCropperObject == null) return;
2137
- const imageShape = this._getApplyObjectByCropObject(imageCropperObject);
2138
- if (imageShape == null) return;
2149
+ const cropSession = this._activeCropSession;
2150
+ if (cropSession == null) return;
2151
+ const { scene, imageShape, imageCropperObject } = cropSession;
2139
2152
  const transformer = scene.getTransformerByCreate();
2140
2153
  transformer.detachFrom(imageCropperObject);
2141
2154
  transformer.clearCopperControl();
2142
- const srcRect = this._getSrcRectByTransformState(imageShape, imageCropperObject);
2143
- const drawingParam = this._drawingManagerService.getDrawingOKey(imageShape.oKey);
2144
- if (drawingParam != null) {
2145
- const { left, top, height, width } = imageCropperObject;
2146
- this._drawingManagerService.featurePluginUpdateNotification([{
2147
- ...drawingParam,
2148
- transform: {
2149
- ...drawingParam.transform,
2150
- left,
2151
- top,
2152
- height,
2153
- width
2154
- },
2155
- srcRect: srcRect.srcRectAngle
2156
- }]);
2155
+ const params = command.params;
2156
+ if (params === null || params === void 0 ? void 0 : params.isCancel) this._restoreCropSnapshot(imageShape, imageCropperObject);
2157
+ else {
2158
+ const srcRect = this._getSrcRectByTransformState(imageShape, imageCropperObject);
2159
+ const drawingParam = this._drawingManagerService.getDrawingOKey(imageShape.oKey);
2160
+ if (drawingParam != null) {
2161
+ const { left, top, height, width } = imageCropperObject;
2162
+ this._drawingManagerService.featurePluginUpdateNotification([{
2163
+ ...drawingParam,
2164
+ transform: {
2165
+ ...drawingParam.transform,
2166
+ left,
2167
+ top,
2168
+ height,
2169
+ width
2170
+ },
2171
+ srcRect: srcRect.srcRectAngle
2172
+ }]);
2173
+ }
2174
+ imageShape.setSrcRect({ ...srcRect.srcRectAngle });
2157
2175
  }
2158
- imageShape.setSrcRect({ ...srcRect.srcRectAngle });
2159
2176
  imageShape.closeRenderByCropper();
2160
2177
  imageShape.makeDirty(true);
2161
- imageCropperObject === null || imageCropperObject === void 0 || imageCropperObject.dispose();
2178
+ transformer.refreshControls();
2179
+ this._cropSnapshots.delete(imageCropperObject);
2180
+ imageCropperObject.dispose();
2181
+ this._activeCropSession = null;
2182
+ this._cropShortcutDisposables.dispose();
2162
2183
  }));
2163
2184
  const sheetUnit$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => workbook ? workbook.activeSheet$ : of(null)));
2164
2185
  this.disposeWithMe(sheetUnit$.subscribe(() => {
@@ -2174,6 +2195,33 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2174
2195
  if (applyObject == null) return null;
2175
2196
  return applyObject;
2176
2197
  }
2198
+ _captureCropSnapshot(imageShape) {
2199
+ return {
2200
+ transform: imageShape.getState(),
2201
+ srcRect: imageShape.srcRect == null ? imageShape.srcRect : { ...imageShape.srcRect }
2202
+ };
2203
+ }
2204
+ _restoreCropSnapshot(imageShape, imageCropperObject) {
2205
+ const snapshot = this._cropSnapshots.get(imageCropperObject);
2206
+ if (snapshot) {
2207
+ imageShape.transformByStateCloseCropper(snapshot.transform);
2208
+ imageShape.setSrcRect(snapshot.srcRect);
2209
+ }
2210
+ }
2211
+ _registerCropShortcuts() {
2212
+ this._cropShortcutDisposables.dispose();
2213
+ this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({
2214
+ id: CloseImageCropOperation.id,
2215
+ binding: KeyCode.ENTER,
2216
+ priority: 1e3
2217
+ }));
2218
+ this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({
2219
+ id: CloseImageCropOperation.id,
2220
+ binding: KeyCode.ESC,
2221
+ priority: 1e3,
2222
+ staticParameters: { isCancel: true }
2223
+ }));
2224
+ }
2177
2225
  _addListenerOnImage(scene) {
2178
2226
  const transformer = scene.getTransformerByCreate();
2179
2227
  let startTransform = null;
@@ -2226,8 +2274,8 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2226
2274
  }));
2227
2275
  }
2228
2276
  _getSrcRectByTransformState(applyObject, imageCropperObject) {
2229
- const { left, top, height, width, strokeWidth, angle: copperAngle } = imageCropperObject;
2230
- const { left: applyLeft, top: applyTop, width: applyWidth, height: applyHeight, angle: applyAngle, strokeWidth: applyStrokeWidth } = applyObject;
2277
+ const { left, top, height, width } = imageCropperObject;
2278
+ const { left: applyLeft, top: applyTop, width: applyWidth, height: applyHeight, angle: applyAngle } = applyObject;
2231
2279
  const newLeft = left - applyLeft;
2232
2280
  const newTop = top - applyTop;
2233
2281
  const srcRect = {
@@ -2263,7 +2311,8 @@ ImageCropperController = __decorate([
2263
2311
  __decorateParam(2, IRenderManagerService),
2264
2312
  __decorateParam(3, IUniverInstanceService),
2265
2313
  __decorateParam(4, IMessageService),
2266
- __decorateParam(5, Inject(LocaleService))
2314
+ __decorateParam(5, Inject(LocaleService)),
2315
+ __decorateParam(6, IShortcutService)
2267
2316
  ], ImageCropperController);
2268
2317
 
2269
2318
  //#endregion
@@ -2535,7 +2584,7 @@ _defineProperty(UniverDrawingUIPlugin, "pluginName", "UNIVER_DRAWING_UI_PLUGIN")
2535
2584
  _defineProperty(UniverDrawingUIPlugin, "packageName", name);
2536
2585
  _defineProperty(UniverDrawingUIPlugin, "version", version);
2537
2586
  UniverDrawingUIPlugin = __decorate([
2538
- DependentOn(UniverDrawingPlugin, UniverRenderEnginePlugin, UniverUIPlugin),
2587
+ DependentOn(UniverDrawingPlugin, UniverRenderEnginePlugin),
2539
2588
  __decorateParam(1, Inject(Injector)),
2540
2589
  __decorateParam(2, IConfigService)
2541
2590
  ], UniverDrawingUIPlugin);
@@ -2604,21 +2653,17 @@ function normalizeText(value) {
2604
2653
  return value.trim();
2605
2654
  }
2606
2655
  function hasCapability(panelCapabilities, item, key, fallback = true) {
2607
- var _ref, _item$capabilities$ke, _item$capabilities;
2608
- return (_ref = (_item$capabilities$ke = item === null || item === void 0 || (_item$capabilities = item.capabilities) === null || _item$capabilities === void 0 ? void 0 : _item$capabilities[key]) !== null && _item$capabilities$ke !== void 0 ? _item$capabilities$ke : panelCapabilities === null || panelCapabilities === void 0 ? void 0 : panelCapabilities[key]) !== null && _ref !== void 0 ? _ref : fallback;
2656
+ var _item$capabilities;
2657
+ return (item === null || item === void 0 || (_item$capabilities = item.capabilities) === null || _item$capabilities === void 0 ? void 0 : _item$capabilities[key]) ?? (panelCapabilities === null || panelCapabilities === void 0 ? void 0 : panelCapabilities[key]) ?? fallback;
2609
2658
  }
2610
2659
  function ObjectListPanelBase(props) {
2611
- var _selectedItem$canMove, _selectedItem$canMove2, _capabilities$reorder;
2612
2660
  const { items, selectedIds, allObjectIds, focusedId, labels, showHeader = true, capabilities, onSelect, onSetVisible, onCommitName, onCommitDescription, onMoveForward, onMoveBackward, onToggleExpanded, onToggleSelectable, onLocate, onReorder } = props;
2613
2661
  const selectedIdSet = useMemo(() => new Set(selectedIds), [selectedIds]);
2614
2662
  const [draggingId, setDraggingId] = useState(null);
2615
2663
  const [searchQuery, setSearchQuery] = useState("");
2616
2664
  const [filterMode, setFilterMode] = useState("all");
2617
2665
  const [collapsedSectionIds, setCollapsedSectionIds] = useState(() => /* @__PURE__ */ new Set());
2618
- const selectedItem = useMemo(() => {
2619
- var _ref2, _items$find;
2620
- return (_ref2 = (_items$find = items.find((item) => item.id === focusedId)) !== null && _items$find !== void 0 ? _items$find : items.find((item) => selectedIdSet.has(item.id))) !== null && _ref2 !== void 0 ? _ref2 : null;
2621
- }, [
2666
+ const selectedItem = useMemo(() => items.find((item) => item.id === focusedId) ?? items.find((item) => selectedIdSet.has(item.id)) ?? null, [
2622
2667
  focusedId,
2623
2668
  items,
2624
2669
  selectedIdSet
@@ -2626,11 +2671,10 @@ function ObjectListPanelBase(props) {
2626
2671
  const visibleItems = useMemo(() => {
2627
2672
  const normalizedQuery = normalizeText(searchQuery).toLocaleLowerCase();
2628
2673
  return items.filter((item) => {
2629
- var _item$description;
2630
2674
  if (filterMode === "hidden" && item.visible !== false) return false;
2631
2675
  if (filterMode === "locked" && item.selectable !== false) return false;
2632
2676
  if (!normalizedQuery) return true;
2633
- return item.name.toLocaleLowerCase().includes(normalizedQuery) || ((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : "").toLocaleLowerCase().includes(normalizedQuery);
2677
+ return item.name.toLocaleLowerCase().includes(normalizedQuery) || (item.description ?? "").toLocaleLowerCase().includes(normalizedQuery);
2634
2678
  });
2635
2679
  }, [
2636
2680
  filterMode,
@@ -2640,8 +2684,7 @@ function ObjectListPanelBase(props) {
2640
2684
  const visibleItemSections = useMemo(() => {
2641
2685
  const sectionMap = /* @__PURE__ */ new Map();
2642
2686
  visibleItems.forEach((item) => {
2643
- var _item$sectionId, _item$sectionTitle;
2644
- const sectionId = (_item$sectionId = item.sectionId) !== null && _item$sectionId !== void 0 ? _item$sectionId : "";
2687
+ const sectionId = item.sectionId ?? "";
2645
2688
  const existingSection = sectionMap.get(sectionId);
2646
2689
  if (existingSection) {
2647
2690
  existingSection.items.push(item);
@@ -2649,35 +2692,30 @@ function ObjectListPanelBase(props) {
2649
2692
  }
2650
2693
  sectionMap.set(sectionId, {
2651
2694
  id: sectionId,
2652
- title: (_item$sectionTitle = item.sectionTitle) !== null && _item$sectionTitle !== void 0 ? _item$sectionTitle : "",
2695
+ title: item.sectionTitle ?? "",
2653
2696
  items: [item]
2654
2697
  });
2655
2698
  });
2656
- return [...sectionMap.values()].sort((a, b) => {
2657
- var _sectionOrder$get, _sectionOrder$get2;
2658
- return ((_sectionOrder$get = sectionOrder.get(a.id)) !== null && _sectionOrder$get !== void 0 ? _sectionOrder$get : 3) - ((_sectionOrder$get2 = sectionOrder.get(b.id)) !== null && _sectionOrder$get2 !== void 0 ? _sectionOrder$get2 : 3);
2659
- });
2699
+ return [...sectionMap.values()].sort((a, b) => (sectionOrder.get(a.id) ?? 3) - (sectionOrder.get(b.id) ?? 3));
2660
2700
  }, [visibleItems]);
2661
2701
  const showSectionHeaders = visibleItemSections.length > 1 || visibleItemSections.some((section) => section.id === "floating");
2662
- const allIds = useMemo(() => allObjectIds !== null && allObjectIds !== void 0 ? allObjectIds : items.map((item) => item.id), [allObjectIds, items]);
2702
+ const allIds = useMemo(() => allObjectIds ?? items.map((item) => item.id), [allObjectIds, items]);
2663
2703
  const selectedIndex = selectedItem ? items.findIndex((item) => item.id === selectedItem.id) : -1;
2664
- const canMoveForward = !!selectedItem && !!onMoveForward && !selectedItem.disabled && ((_selectedItem$canMove = selectedItem.canMoveForward) !== null && _selectedItem$canMove !== void 0 ? _selectedItem$canMove : selectedIndex > 0) && hasCapability(capabilities, selectedItem, "arrange");
2665
- const canMoveBackward = !!selectedItem && !!onMoveBackward && !selectedItem.disabled && ((_selectedItem$canMove2 = selectedItem.canMoveBackward) !== null && _selectedItem$canMove2 !== void 0 ? _selectedItem$canMove2 : selectedIndex >= 0 && selectedIndex < items.length - 1) && hasCapability(capabilities, selectedItem, "arrange");
2704
+ const canMoveForward = !!selectedItem && !!onMoveForward && !selectedItem.disabled && (selectedItem.canMoveForward ?? selectedIndex > 0) && hasCapability(capabilities, selectedItem, "arrange");
2705
+ const canMoveBackward = !!selectedItem && !!onMoveBackward && !selectedItem.disabled && (selectedItem.canMoveBackward ?? (selectedIndex >= 0 && selectedIndex < items.length - 1)) && hasCapability(capabilities, selectedItem, "arrange");
2666
2706
  const showArrangeControls = hasCapability(capabilities, selectedItem, "arrange") && (!!onMoveForward || !!onMoveBackward);
2667
2707
  const showLocateControl = !!onLocate && hasCapability(capabilities, selectedItem, "locate");
2668
- const canReorder = !!onReorder && ((_capabilities$reorder = capabilities === null || capabilities === void 0 ? void 0 : capabilities.reorder) !== null && _capabilities$reorder !== void 0 ? _capabilities$reorder : true);
2708
+ const canReorder = !!onReorder && ((capabilities === null || capabilities === void 0 ? void 0 : capabilities.reorder) ?? true);
2669
2709
  const findItem = (objectId) => {
2670
- var _items$find2;
2671
- return objectId ? (_items$find2 = items.find((item) => item.id === objectId)) !== null && _items$find2 !== void 0 ? _items$find2 : null : null;
2710
+ return objectId ? items.find((item) => item.id === objectId) ?? null : null;
2672
2711
  };
2673
2712
  const handleDrop = (targetId) => {
2674
- var _source$parentId, _target$parentId, _source$sectionId, _target$sectionId;
2675
2713
  const source = findItem(draggingId);
2676
2714
  const target = findItem(targetId);
2677
2715
  setDraggingId(null);
2678
2716
  if (!source || !target || source.id === target.id || source.disabled || target.disabled) return;
2679
- if (((_source$parentId = source.parentId) !== null && _source$parentId !== void 0 ? _source$parentId : "") !== ((_target$parentId = target.parentId) !== null && _target$parentId !== void 0 ? _target$parentId : "")) return;
2680
- if (((_source$sectionId = source.sectionId) !== null && _source$sectionId !== void 0 ? _source$sectionId : "") !== ((_target$sectionId = target.sectionId) !== null && _target$sectionId !== void 0 ? _target$sectionId : "")) return;
2717
+ if ((source.parentId ?? "") !== (target.parentId ?? "")) return;
2718
+ if ((source.sectionId ?? "") !== (target.sectionId ?? "")) return;
2681
2719
  if (source.canReorder === false || target.canReorder === false) return;
2682
2720
  onReorder === null || onReorder === void 0 || onReorder(source.id, target.id);
2683
2721
  };
@@ -2760,7 +2798,7 @@ function ObjectListPanelBase(props) {
2760
2798
  ["locked", labels.filterLocked]
2761
2799
  ].map(([mode, label]) => /* @__PURE__ */ jsx("button", {
2762
2800
  type: "button",
2763
- className: clsx("univer-h-7 univer-min-w-0 univer-flex-1 univer-rounded-md univer-border univer-border-solid univer-px-2 univer-text-xs univer-outline-none univer-transition-colors dark:!univer-border-gray-700", filterMode === mode ? "dark:!univer-bg-primary-900/30 univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600 dark:!univer-text-primary-200" : "univer-border-gray-200 univer-bg-white univer-text-gray-600 hover:univer-bg-gray-50 dark:!univer-bg-gray-900 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800"),
2801
+ className: clsx("univer-h-7 univer-min-w-0 univer-flex-1 univer-rounded-md univer-border univer-border-solid univer-px-2 univer-text-xs univer-outline-none univer-transition-colors dark:!univer-border-gray-700", filterMode === mode ? "dark:!univer-bg-primary-900/30 univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600 dark:!univer-text-primary-200" : "univer-border-gray-200 univer-bg-gray-0 univer-text-gray-600 hover:univer-bg-gray-50 dark:!univer-bg-gray-900 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800"),
2764
2802
  "aria-pressed": filterMode === mode,
2765
2803
  onClick: () => setFilterMode(mode),
2766
2804
  children: /* @__PURE__ */ jsx("span", {
@@ -2790,7 +2828,7 @@ function ObjectListPanelBase(props) {
2790
2828
  children: [
2791
2829
  section.id ? /* @__PURE__ */ jsx("span", {
2792
2830
  className: "univer-flex univer-size-4 univer-shrink-0 univer-items-center univer-justify-center",
2793
- children: sectionCollapsed ? /* @__PURE__ */ jsx(MoreRightIcon, {}) : /* @__PURE__ */ jsx(MoreDownIcon, {})
2831
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { className: clsx({ "-univer-rotate-90 rtl:univer-rotate-90": sectionCollapsed }) })
2794
2832
  }) : /* @__PURE__ */ jsx("span", { className: "univer-size-4 univer-shrink-0" }),
2795
2833
  /* @__PURE__ */ jsx("span", {
2796
2834
  className: "univer-min-w-0 univer-flex-1 univer-truncate univer-text-left",
@@ -2835,12 +2873,11 @@ function ObjectListPanelBase(props) {
2835
2873
  });
2836
2874
  }
2837
2875
  function ObjectListRow(props) {
2838
- var _item$level;
2839
2876
  const { item, selected, labels, showLock, showName, showVisible, draggable, dragging, onSelect, onToggleExpanded, onToggleVisible, onToggleSelectable, onCommitName, onDragStart, onDragEnd, onDrop } = props;
2840
2877
  const [draftName, setDraftName] = useState(item.name);
2841
2878
  const skipCommitOnBlurRef = useRef(false);
2842
2879
  const disabled = item.disabled === true;
2843
- const level = (_item$level = item.level) !== null && _item$level !== void 0 ? _item$level : 0;
2880
+ const level = item.level ?? 0;
2844
2881
  const locked = item.selectable === false;
2845
2882
  useEffect(() => {
2846
2883
  setDraftName(item.name);
@@ -2900,11 +2937,11 @@ function ObjectListRow(props) {
2900
2937
  event.stopPropagation();
2901
2938
  onToggleExpanded();
2902
2939
  },
2903
- children: item.expanded ? /* @__PURE__ */ jsx(MoreDownIcon, {}) : /* @__PURE__ */ jsx(MoreRightIcon, {})
2940
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { className: clsx({ "-univer-rotate-90 rtl:univer-rotate-90": !item.expanded }) })
2904
2941
  }) : /* @__PURE__ */ jsx("span", { className: "univer-size-5 univer-shrink-0" }),
2905
2942
  showName ? /* @__PURE__ */ jsx(Input, {
2906
2943
  className: clsx("univer-h-7 univer-w-0 univer-min-w-0 univer-flex-1", disabled && "univer-cursor-not-allowed"),
2907
- inputClass: clsx("!univer-h-7 univer-min-w-0 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap !univer-rounded !univer-border-transparent !univer-bg-transparent !univer-px-1 univer-text-sm univer-text-gray-900 !univer-shadow-none focus:!univer-border-primary-500 focus:!univer-bg-white focus:!univer-ring-1 focus:!univer-ring-primary-100 disabled:!univer-bg-transparent disabled:univer-opacity-100 dark:!univer-text-gray-100 dark:focus:!univer-bg-gray-900 dark:focus:!univer-ring-primary-900", disabled && "univer-text-gray-400 dark:!univer-text-gray-500"),
2944
+ inputClass: clsx("!univer-h-7 univer-min-w-0 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap !univer-rounded !univer-border-transparent !univer-bg-transparent !univer-px-1 univer-text-sm univer-text-gray-900 !univer-shadow-none focus:!univer-border-primary-500 focus:!univer-bg-gray-0 focus:!univer-ring-1 focus:!univer-ring-primary-100 disabled:!univer-bg-transparent disabled:univer-opacity-100 dark:!univer-text-gray-100 dark:focus:!univer-bg-gray-900 dark:focus:!univer-ring-primary-900", disabled && "univer-text-gray-400 dark:!univer-text-gray-500"),
2908
2945
  inputStyle: {
2909
2946
  maxWidth: "100%",
2910
2947
  boxSizing: "border-box"
@@ -2951,15 +2988,13 @@ function ObjectListRow(props) {
2951
2988
  });
2952
2989
  }
2953
2990
  function ObjectDetailsEditor(props) {
2954
- var _item$name, _item$description2;
2955
2991
  const { item, labels, showName, showDescription, onCommitName, onCommitDescription } = props;
2956
- const [draftName, setDraftName] = useState((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : "");
2957
- const [draftDescription, setDraftDescription] = useState((_item$description2 = item === null || item === void 0 ? void 0 : item.description) !== null && _item$description2 !== void 0 ? _item$description2 : "");
2992
+ const [draftName, setDraftName] = useState((item === null || item === void 0 ? void 0 : item.name) ?? "");
2993
+ const [draftDescription, setDraftDescription] = useState((item === null || item === void 0 ? void 0 : item.description) ?? "");
2958
2994
  const disabled = (item === null || item === void 0 ? void 0 : item.disabled) === true;
2959
2995
  useEffect(() => {
2960
- var _item$name2, _item$description3;
2961
- setDraftName((_item$name2 = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name2 !== void 0 ? _item$name2 : "");
2962
- setDraftDescription((_item$description3 = item === null || item === void 0 ? void 0 : item.description) !== null && _item$description3 !== void 0 ? _item$description3 : "");
2996
+ setDraftName((item === null || item === void 0 ? void 0 : item.name) ?? "");
2997
+ setDraftDescription((item === null || item === void 0 ? void 0 : item.description) ?? "");
2963
2998
  }, [
2964
2999
  item === null || item === void 0 ? void 0 : item.description,
2965
3000
  item === null || item === void 0 ? void 0 : item.id,
@@ -3000,15 +3035,14 @@ function ObjectDetailsEditor(props) {
3000
3035
  className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
3001
3036
  children: labels.description
3002
3037
  }), /* @__PURE__ */ jsx("textarea", {
3003
- className: "univer-box-border univer-min-h-16 univer-w-full univer-resize-none univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-2 univer-text-sm univer-text-gray-900 univer-outline-none focus:univer-border-primary-500 focus:univer-ring-1 focus:univer-ring-primary-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-70 dark:!univer-border-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-gray-100 dark:focus:!univer-ring-primary-900",
3038
+ className: "univer-box-border univer-min-h-16 univer-w-full univer-resize-none univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-2 univer-text-sm univer-text-gray-900 univer-outline-none focus:univer-border-primary-500 focus:univer-ring-1 focus:univer-ring-primary-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-70 dark:!univer-border-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-gray-100 dark:focus:!univer-ring-primary-900",
3004
3039
  value: draftDescription,
3005
3040
  disabled,
3006
3041
  placeholder: labels.descriptionPlaceholder,
3007
3042
  "aria-label": labels.description,
3008
3043
  onChange: (event) => setDraftDescription(event.currentTarget.value),
3009
3044
  onBlur: () => {
3010
- var _item$description4;
3011
- if (!disabled && normalizeText(draftDescription) !== ((_item$description4 = item.description) !== null && _item$description4 !== void 0 ? _item$description4 : "")) onCommitDescription(draftDescription);
3045
+ if (!disabled && normalizeText(draftDescription) !== (item.description ?? "")) onCommitDescription(draftDescription);
3012
3046
  }
3013
3047
  })]
3014
3048
  })
@@ -3079,7 +3113,7 @@ const DrawingAlign = (props) => {
3079
3113
  }), /* @__PURE__ */ jsx("div", {
3080
3114
  className: "univer-relative univer-mt-2.5 univer-flex univer-h-full",
3081
3115
  children: /* @__PURE__ */ jsx("div", {
3082
- className: "univer-w-full univer-text-gray-900 dark:!univer-text-white",
3116
+ className: "univer-w-full univer-text-gray-900 dark:!univer-text-gray-0",
3083
3117
  children: /* @__PURE__ */ jsx(Select, {
3084
3118
  value: alignValue,
3085
3119
  options: alignOptions,
@@ -88,29 +88,11 @@ const locale = { "drawing-ui": {
88
88
  null: "لا يوجد تحديد للكائن"
89
89
  },
90
90
  "image-text-wrap": {
91
- title: "التفاف النص",
92
- wrappingStyle: "نمط التفاف",
93
91
  square: "مربع",
94
92
  topAndBottom: "أعلى وأسفل",
95
93
  inline: "في نفس السطر مع النص",
96
94
  behindText: "خلف النص",
97
- inFrontText: "أمام النص",
98
- wrapText: "تفاف النص",
99
- bothSide: "كلا الجانبين",
100
- leftOnly: "يسار فقط",
101
- rightOnly: "يمين فقط",
102
- distanceFromText: "المسافة من النص",
103
- top: "أعلى(بكسل)",
104
- left: "يسار(بكسل)",
105
- bottom: "أسفل(بكسل)",
106
- right: "يمين(بكسل)"
107
- },
108
- "image-popup": {
109
- replace: "استبدال",
110
- delete: "حذف",
111
- edit: "تحرير",
112
- crop: "قص",
113
- reset: "إعادة تعيين الحجم"
95
+ inFrontText: "أمام النص"
114
96
  }
115
97
  } };
116
98