@univerjs/drawing-ui 1.0.0-beta.0 → 1.0.0-beta.2

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 +115 -58
  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 +118 -61
  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 +32 -10
  42. package/lib/index.js +118 -61
  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 +11 -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 +8 -8
package/lib/es/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, useDependency, useObservable } from "@univerjs/ui";
4
+ import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IGalleryService, ILayoutService, 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
  };
@@ -624,7 +624,7 @@ const menuSchema = { [ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]:
624
624
  //#endregion
625
625
  //#region package.json
626
626
  var name = "@univerjs/drawing-ui";
627
- var version = "1.0.0-beta.0";
627
+ var version = "1.0.0-beta.2";
628
628
 
629
629
  //#endregion
630
630
  //#region src/config/config.ts
@@ -697,11 +697,11 @@ function ImagePopupMenu(props) {
697
697
  open: visible,
698
698
  onOpenChange: onVisibleChange,
699
699
  children: /* @__PURE__ */ jsxs("div", {
700
- 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, {
701
701
  "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
702
- "univer-bg-white dark:!univer-bg-gray-900": !visible
702
+ "univer-bg-gray-0 dark:!univer-bg-gray-900": !visible
703
703
  }),
704
- 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" })]
705
705
  })
706
706
  })
707
707
  });
@@ -724,6 +724,7 @@ function ToolbarGroup(props) {
724
724
  }
725
725
  function ToolbarButton(props) {
726
726
  return /* @__PURE__ */ jsx(Tooltip, {
727
+ className: "univer-fill-mode-backwards univer-delay-100",
727
728
  title: props.title,
728
729
  placement: "bottom",
729
730
  children: /* @__PURE__ */ jsx("button", {
@@ -742,7 +743,7 @@ function ToolbarDropdownButton(props) {
742
743
  open,
743
744
  onOpenChange: setOpen,
744
745
  overlay: /* @__PURE__ */ jsx("div", {
745
- 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",
746
+ 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",
746
747
  children: props.options.map((option) => /* @__PURE__ */ jsxs("button", {
747
748
  type: "button",
748
749
  onClick: () => {
@@ -760,6 +761,7 @@ function ToolbarDropdownButton(props) {
760
761
  }, option.value))
761
762
  }),
762
763
  children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Tooltip, {
764
+ className: "univer-fill-mode-backwards univer-delay-100",
763
765
  title: props.title,
764
766
  placement: "bottom",
765
767
  children: /* @__PURE__ */ jsxs("button", {
@@ -831,7 +833,7 @@ function DocImageFloatingToolbar(props) {
831
833
  event.stopPropagation();
832
834
  event.preventDefault();
833
835
  },
834
- 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),
836
+ 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),
835
837
  children: [/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ToolbarDropdownButton, {
836
838
  title: ((_wrappingStyleOptions = wrappingStyleOptions.find((option) => option.value === wrappingStyle)) === null || _wrappingStyleOptions === void 0 ? void 0 : _wrappingStyleOptions.label) ?? localeService.t("drawing-ui.image-text-wrap.inline"),
837
839
  value: wrappingStyle,
@@ -856,11 +858,14 @@ function DocChartFloatingToolbar(props) {
856
858
  const [hidden, setHidden] = useState(false);
857
859
  const chartTypeItem = props.menuItems.find((item) => item.type === "select");
858
860
  const actionItems = props.menuItems.filter((item) => item.type !== "select" && item.icon).sort((a, b) => a.index - b.index);
859
- const chartTypeOptions = ((chartTypeItem === null || chartTypeItem === void 0 ? void 0 : chartTypeItem.options) ?? []).map((option) => ({
860
- label: String(option.label),
861
- value: option.value,
862
- icon: /* @__PURE__ */ jsx(ChartIcon, {})
863
- }));
861
+ const chartTypeOptions = ((chartTypeItem === null || chartTypeItem === void 0 ? void 0 : chartTypeItem.options) ?? []).map((option) => {
862
+ const Icon = option.icon ? iconManager.get(option.icon) : ChartIcon;
863
+ return {
864
+ label: String(option.label),
865
+ value: option.value,
866
+ icon: /* @__PURE__ */ jsx(Icon, {})
867
+ };
868
+ });
864
869
  const executeMenuItem = (item) => {
865
870
  if (!item || item.disable) return;
866
871
  if (item.hideOnClick) setHidden(true);
@@ -873,7 +878,7 @@ function DocChartFloatingToolbar(props) {
873
878
  event.stopPropagation();
874
879
  event.preventDefault();
875
880
  },
876
- 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),
881
+ 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),
877
882
  children: [chartTypeItem && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ToolbarDropdownButton, {
878
883
  title: localeService.t(chartTypeItem.label),
879
884
  value: chartTypeItem.value ?? ((_chartTypeOptions$ = chartTypeOptions[0]) === null || _chartTypeOptions$ === void 0 ? void 0 : _chartTypeOptions$.value) ?? "",
@@ -1953,7 +1958,7 @@ var ImageCropperObject = class extends Shape {
1953
1958
  //#endregion
1954
1959
  //#region src/controllers/image-cropper.controller.ts
1955
1960
  let ImageCropperController = class ImageCropperController extends Disposable {
1956
- constructor(_commandService, _drawingManagerService, _renderManagerService, _univerInstanceService, _messageService, _localeService) {
1961
+ constructor(_commandService, _drawingManagerService, _renderManagerService, _univerInstanceService, _messageService, _localeService, _shortcutService, _layoutService) {
1957
1962
  super();
1958
1963
  this._commandService = _commandService;
1959
1964
  this._drawingManagerService = _drawingManagerService;
@@ -1961,7 +1966,14 @@ let ImageCropperController = class ImageCropperController extends Disposable {
1961
1966
  this._univerInstanceService = _univerInstanceService;
1962
1967
  this._messageService = _messageService;
1963
1968
  this._localeService = _localeService;
1969
+ this._shortcutService = _shortcutService;
1970
+ this._layoutService = _layoutService;
1964
1971
  _defineProperty(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1972
+ _defineProperty(this, "_cropShortcutDisposables", new DisposableCollection());
1973
+ _defineProperty(this, "_cropSnapshots", /* @__PURE__ */ new WeakMap());
1974
+ _defineProperty(this, "_pendingCropSnapshot", null);
1975
+ _defineProperty(this, "_activeCropSession", null);
1976
+ this.disposeWithMe(this._cropShortcutDisposables);
1965
1977
  this._init();
1966
1978
  }
1967
1979
  _init() {
@@ -1996,12 +2008,17 @@ let ImageCropperController = class ImageCropperController extends Disposable {
1996
2008
  return;
1997
2009
  }
1998
2010
  if (imageShape == null) return;
1999
- this._updateCropperObject(cropType, imageShape);
2000
- this._commandService.executeCommand(OpenImageCropOperation.id, {
2001
- unitId,
2002
- subUnitId,
2003
- drawingId
2004
- });
2011
+ this._pendingCropSnapshot = this._captureCropSnapshot(imageShape);
2012
+ try {
2013
+ this._updateCropperObject(cropType, imageShape);
2014
+ this._commandService.syncExecuteCommand(OpenImageCropOperation.id, {
2015
+ unitId,
2016
+ subUnitId,
2017
+ drawingId
2018
+ });
2019
+ } finally {
2020
+ this._pendingCropSnapshot = null;
2021
+ }
2005
2022
  }));
2006
2023
  }
2007
2024
  _calculateSrcRectByRatio(left, top, width, height, numerator, denominator) {
@@ -2069,6 +2086,7 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2069
2086
  if (command.id !== OpenImageCropOperation.id) return;
2070
2087
  const params = command.params;
2071
2088
  if (params == null) return;
2089
+ if (this._activeCropSession != null) this._commandService.syncExecuteCommand(CloseImageCropOperation.id, { isAuto: true });
2072
2090
  const { unitId, subUnitId, drawingId } = params;
2073
2091
  const renderObject = this._renderManagerService.getRenderUnitById(unitId);
2074
2092
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
@@ -2103,17 +2121,26 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2103
2121
  prstGeom: imageShape.prstGeom,
2104
2122
  applyTransform: imageShape.calculateTransformWithSrcRect()
2105
2123
  });
2124
+ this._cropSnapshots.set(imageCropperObject, this._pendingCropSnapshot ?? this._captureCropSnapshot(imageShape));
2125
+ this._pendingCropSnapshot = null;
2106
2126
  scene.addObject(imageCropperObject, imageShape.getLayerIndex() + 1).attachTransformerTo(imageCropperObject);
2127
+ this._activeCropSession = {
2128
+ scene,
2129
+ imageShape,
2130
+ imageCropperObject
2131
+ };
2107
2132
  transformer === null || transformer === void 0 || transformer.createControlForCopper(imageCropperObject);
2108
2133
  this._addHoverForImageCopper(imageCropperObject);
2109
2134
  imageShape.openRenderByCropper();
2110
2135
  transformer === null || transformer === void 0 || transformer.refreshControls();
2111
2136
  imageCropperObject.makeDirty(true);
2137
+ this._registerCropShortcuts();
2112
2138
  this._commandService.syncExecuteCommand(SetDrawingSelectedOperation.id, [{
2113
2139
  unitId,
2114
2140
  subUnitId,
2115
2141
  drawingId
2116
2142
  }]);
2143
+ this._layoutService.focus();
2117
2144
  }));
2118
2145
  }
2119
2146
  _searchCropObject(scene) {
@@ -2123,39 +2150,40 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2123
2150
  _initCloseCrop() {
2124
2151
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
2125
2152
  if (command.id !== CloseImageCropOperation.id) return;
2126
- const currentUnit = this._univerInstanceService.getFocusedUnit();
2127
- if (currentUnit == null) return;
2128
- const unitId = currentUnit.getUnitId();
2129
- const renderObject = this._renderManagerService.getRenderUnitById(unitId);
2130
- const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2131
- if (scene == null) return true;
2132
- const imageCropperObject = this._searchCropObject(scene);
2133
- if (imageCropperObject == null) return;
2134
- const imageShape = this._getApplyObjectByCropObject(imageCropperObject);
2135
- if (imageShape == null) return;
2153
+ const cropSession = this._activeCropSession;
2154
+ if (cropSession == null) return;
2155
+ const { scene, imageShape, imageCropperObject } = cropSession;
2136
2156
  const transformer = scene.getTransformerByCreate();
2137
2157
  transformer.detachFrom(imageCropperObject);
2138
2158
  transformer.clearCopperControl();
2139
- const srcRect = this._getSrcRectByTransformState(imageShape, imageCropperObject);
2140
- const drawingParam = this._drawingManagerService.getDrawingOKey(imageShape.oKey);
2141
- if (drawingParam != null) {
2142
- const { left, top, height, width } = imageCropperObject;
2143
- this._drawingManagerService.featurePluginUpdateNotification([{
2144
- ...drawingParam,
2145
- transform: {
2146
- ...drawingParam.transform,
2147
- left,
2148
- top,
2149
- height,
2150
- width
2151
- },
2152
- srcRect: srcRect.srcRectAngle
2153
- }]);
2159
+ const params = command.params;
2160
+ if (params === null || params === void 0 ? void 0 : params.isCancel) this._restoreCropSnapshot(imageShape, imageCropperObject);
2161
+ else {
2162
+ const srcRect = this._getSrcRectByTransformState(imageShape, imageCropperObject);
2163
+ const drawingParam = this._drawingManagerService.getDrawingOKey(imageShape.oKey);
2164
+ if (drawingParam != null) {
2165
+ const { left, top, height, width } = imageCropperObject;
2166
+ this._drawingManagerService.featurePluginUpdateNotification([{
2167
+ ...drawingParam,
2168
+ transform: {
2169
+ ...drawingParam.transform,
2170
+ left,
2171
+ top,
2172
+ height,
2173
+ width
2174
+ },
2175
+ srcRect: srcRect.srcRectAngle
2176
+ }]);
2177
+ }
2178
+ imageShape.setSrcRect({ ...srcRect.srcRectAngle });
2154
2179
  }
2155
- imageShape.setSrcRect({ ...srcRect.srcRectAngle });
2156
2180
  imageShape.closeRenderByCropper();
2157
2181
  imageShape.makeDirty(true);
2158
- imageCropperObject === null || imageCropperObject === void 0 || imageCropperObject.dispose();
2182
+ transformer.refreshControls();
2183
+ this._cropSnapshots.delete(imageCropperObject);
2184
+ imageCropperObject.dispose();
2185
+ this._activeCropSession = null;
2186
+ this._cropShortcutDisposables.dispose();
2159
2187
  }));
2160
2188
  const sheetUnit$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => workbook ? workbook.activeSheet$ : of(null)));
2161
2189
  this.disposeWithMe(sheetUnit$.subscribe(() => {
@@ -2171,6 +2199,33 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2171
2199
  if (applyObject == null) return null;
2172
2200
  return applyObject;
2173
2201
  }
2202
+ _captureCropSnapshot(imageShape) {
2203
+ return {
2204
+ transform: imageShape.getState(),
2205
+ srcRect: imageShape.srcRect == null ? imageShape.srcRect : { ...imageShape.srcRect }
2206
+ };
2207
+ }
2208
+ _restoreCropSnapshot(imageShape, imageCropperObject) {
2209
+ const snapshot = this._cropSnapshots.get(imageCropperObject);
2210
+ if (snapshot) {
2211
+ imageShape.transformByStateCloseCropper(snapshot.transform);
2212
+ imageShape.setSrcRect(snapshot.srcRect);
2213
+ }
2214
+ }
2215
+ _registerCropShortcuts() {
2216
+ this._cropShortcutDisposables.dispose();
2217
+ this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({
2218
+ id: CloseImageCropOperation.id,
2219
+ binding: KeyCode.ENTER,
2220
+ priority: 1e3
2221
+ }));
2222
+ this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({
2223
+ id: CloseImageCropOperation.id,
2224
+ binding: KeyCode.ESC,
2225
+ priority: 1e3,
2226
+ staticParameters: { isCancel: true }
2227
+ }));
2228
+ }
2174
2229
  _addListenerOnImage(scene) {
2175
2230
  const transformer = scene.getTransformerByCreate();
2176
2231
  let startTransform = null;
@@ -2223,8 +2278,8 @@ let ImageCropperController = class ImageCropperController extends Disposable {
2223
2278
  }));
2224
2279
  }
2225
2280
  _getSrcRectByTransformState(applyObject, imageCropperObject) {
2226
- const { left, top, height, width, strokeWidth, angle: copperAngle } = imageCropperObject;
2227
- const { left: applyLeft, top: applyTop, width: applyWidth, height: applyHeight, angle: applyAngle, strokeWidth: applyStrokeWidth } = applyObject;
2281
+ const { left, top, height, width } = imageCropperObject;
2282
+ const { left: applyLeft, top: applyTop, width: applyWidth, height: applyHeight, angle: applyAngle } = applyObject;
2228
2283
  const newLeft = left - applyLeft;
2229
2284
  const newTop = top - applyTop;
2230
2285
  const srcRect = {
@@ -2260,7 +2315,9 @@ ImageCropperController = __decorate([
2260
2315
  __decorateParam(2, IRenderManagerService),
2261
2316
  __decorateParam(3, IUniverInstanceService),
2262
2317
  __decorateParam(4, IMessageService),
2263
- __decorateParam(5, Inject(LocaleService))
2318
+ __decorateParam(5, Inject(LocaleService)),
2319
+ __decorateParam(6, IShortcutService),
2320
+ __decorateParam(7, ILayoutService)
2264
2321
  ], ImageCropperController);
2265
2322
 
2266
2323
  //#endregion
@@ -2746,7 +2803,7 @@ function ObjectListPanelBase(props) {
2746
2803
  ["locked", labels.filterLocked]
2747
2804
  ].map(([mode, label]) => /* @__PURE__ */ jsx("button", {
2748
2805
  type: "button",
2749
- 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"),
2806
+ 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"),
2750
2807
  "aria-pressed": filterMode === mode,
2751
2808
  onClick: () => setFilterMode(mode),
2752
2809
  children: /* @__PURE__ */ jsx("span", {
@@ -2776,7 +2833,7 @@ function ObjectListPanelBase(props) {
2776
2833
  children: [
2777
2834
  section.id ? /* @__PURE__ */ jsx("span", {
2778
2835
  className: "univer-flex univer-size-4 univer-shrink-0 univer-items-center univer-justify-center",
2779
- children: sectionCollapsed ? /* @__PURE__ */ jsx(MoreRightIcon, {}) : /* @__PURE__ */ jsx(MoreDownIcon, {})
2836
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { className: clsx({ "-univer-rotate-90 rtl:univer-rotate-90": sectionCollapsed }) })
2780
2837
  }) : /* @__PURE__ */ jsx("span", { className: "univer-size-4 univer-shrink-0" }),
2781
2838
  /* @__PURE__ */ jsx("span", {
2782
2839
  className: "univer-min-w-0 univer-flex-1 univer-truncate univer-text-left",
@@ -2885,11 +2942,11 @@ function ObjectListRow(props) {
2885
2942
  event.stopPropagation();
2886
2943
  onToggleExpanded();
2887
2944
  },
2888
- children: item.expanded ? /* @__PURE__ */ jsx(MoreDownIcon, {}) : /* @__PURE__ */ jsx(MoreRightIcon, {})
2945
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { className: clsx({ "-univer-rotate-90 rtl:univer-rotate-90": !item.expanded }) })
2889
2946
  }) : /* @__PURE__ */ jsx("span", { className: "univer-size-5 univer-shrink-0" }),
2890
2947
  showName ? /* @__PURE__ */ jsx(Input, {
2891
2948
  className: clsx("univer-h-7 univer-w-0 univer-min-w-0 univer-flex-1", disabled && "univer-cursor-not-allowed"),
2892
- 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"),
2949
+ 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"),
2893
2950
  inputStyle: {
2894
2951
  maxWidth: "100%",
2895
2952
  boxSizing: "border-box"
@@ -2983,7 +3040,7 @@ function ObjectDetailsEditor(props) {
2983
3040
  className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
2984
3041
  children: labels.description
2985
3042
  }), /* @__PURE__ */ jsx("textarea", {
2986
- 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",
3043
+ 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",
2987
3044
  value: draftDescription,
2988
3045
  disabled,
2989
3046
  placeholder: labels.descriptionPlaceholder,
@@ -3061,7 +3118,7 @@ const DrawingAlign = (props) => {
3061
3118
  }), /* @__PURE__ */ jsx("div", {
3062
3119
  className: "univer-relative univer-mt-2.5 univer-flex univer-h-full",
3063
3120
  children: /* @__PURE__ */ jsx("div", {
3064
- className: "univer-w-full univer-text-gray-900 dark:!univer-text-white",
3121
+ className: "univer-w-full univer-text-gray-900 dark:!univer-text-gray-0",
3065
3122
  children: /* @__PURE__ */ jsx(Select, {
3066
3123
  value: alignValue,
3067
3124
  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
 
@@ -88,29 +88,11 @@ const locale = { "drawing-ui": {
88
88
  null: "Cap objecte seleccionat"
89
89
  },
90
90
  "image-text-wrap": {
91
- title: "Ajust del text",
92
- wrappingStyle: "Estil d'ajust",
93
91
  square: "Quadrat",
94
92
  topAndBottom: "A dalt i a baix",
95
93
  inline: "En línia amb el text",
96
94
  behindText: "Darrere del text",
97
- inFrontText: "Davant del text",
98
- wrapText: "Ajusta el text",
99
- bothSide: "Ambdós costats",
100
- leftOnly: "Només esquerra",
101
- rightOnly: "Només dreta",
102
- distanceFromText: "Distància del text",
103
- top: "A dalt(px)",
104
- left: "Esquerra(px)",
105
- bottom: "A baix(px)",
106
- right: "Dreta(px)"
107
- },
108
- "image-popup": {
109
- replace: "Reemplaça",
110
- delete: "Elimina",
111
- edit: "Edita",
112
- crop: "Retalla",
113
- reset: "Restableix la mida"
95
+ inFrontText: "Davant del text"
114
96
  }
115
97
  } };
116
98
 
@@ -88,29 +88,11 @@ const locale = { "drawing-ui": {
88
88
  null: "Keine Objektauswahl"
89
89
  },
90
90
  "image-text-wrap": {
91
- title: "Textumbruch",
92
- wrappingStyle: "Umbruchstil",
93
91
  square: "Quadratisch",
94
92
  topAndBottom: "Oben und unten",
95
93
  inline: "Im Textfluss",
96
94
  behindText: "Hinter dem Text",
97
- inFrontText: "Vor dem Text",
98
- wrapText: "Text umbrechen",
99
- bothSide: "Beide Seiten",
100
- leftOnly: "Nur links",
101
- rightOnly: "Nur rechts",
102
- distanceFromText: "Abstand vom Text",
103
- top: "Oben(px)",
104
- left: "Links(px)",
105
- bottom: "Unten(px)",
106
- right: "Rechts(px)"
107
- },
108
- "image-popup": {
109
- replace: "Ersetzen",
110
- delete: "Löschen",
111
- edit: "Bearbeiten",
112
- crop: "Zuschneiden",
113
- reset: "Größe zurücksetzen"
95
+ inFrontText: "Vor dem Text"
114
96
  }
115
97
  } };
116
98
 
@@ -102,30 +102,12 @@ const locale = { "drawing-ui": {
102
102
  },
103
103
  null: "No Object Selection"
104
104
  },
105
- "image-popup": {
106
- replace: "Replace",
107
- delete: "Delete",
108
- edit: "Edit",
109
- crop: "Crop",
110
- reset: "Reset Size"
111
- },
112
105
  "image-text-wrap": {
113
- title: "Text Wrapping",
114
- wrappingStyle: "Wrapping Style",
115
106
  square: "Square",
116
107
  topAndBottom: "Top and Bottom",
117
108
  inline: "In line with text",
118
109
  behindText: "Behind text",
119
- inFrontText: "In front of text",
120
- wrapText: "Wrap text",
121
- bothSide: "Both sides",
122
- leftOnly: "Left only",
123
- rightOnly: "Right only",
124
- distanceFromText: "Distance from text",
125
- top: "Top(px)",
126
- left: "Left(px)",
127
- bottom: "Bottom(px)",
128
- right: "Right(px)"
110
+ inFrontText: "In front of text"
129
111
  }
130
112
  } };
131
113
 
@@ -88,29 +88,11 @@ const locale = { "drawing-ui": {
88
88
  null: "Ningún objeto seleccionado"
89
89
  },
90
90
  "image-text-wrap": {
91
- title: "Ajuste de texto",
92
- wrappingStyle: "Estilo de ajuste",
93
91
  square: "Cuadrado",
94
92
  topAndBottom: "Arriba y abajo",
95
93
  inline: "En línea con el texto",
96
94
  behindText: "Detrás del texto",
97
- inFrontText: "Delante del texto",
98
- wrapText: "Ajustar texto",
99
- bothSide: "Ambos lados",
100
- leftOnly: "Solo izquierda",
101
- rightOnly: "Solo derecha",
102
- distanceFromText: "Distancia del texto",
103
- top: "Arriba(px)",
104
- left: "Izquierda(px)",
105
- bottom: "Abajo(px)",
106
- right: "Derecha(px)"
107
- },
108
- "image-popup": {
109
- replace: "Reemplazar",
110
- delete: "Eliminar",
111
- edit: "Editar",
112
- crop: "Recortar",
113
- reset: "Restablecer tamaño"
95
+ inFrontText: "Delante del texto"
114
96
  }
115
97
  } };
116
98
 
@@ -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: "بالا(px)",
104
- left: "چپ(px)",
105
- bottom: "پایین(px)",
106
- right: "راست(px)"
107
- },
108
- "image-popup": {
109
- replace: "تعویض",
110
- delete: "حذف",
111
- edit: "ویرایش",
112
- crop: "کراپ",
113
- reset: "بازنشانی اندازه"
95
+ inFrontText: "جلوی متن"
114
96
  }
115
97
  } };
116
98
 
@@ -88,29 +88,11 @@ const locale = { "drawing-ui": {
88
88
  null: "Aucune sélection d'objet"
89
89
  },
90
90
  "image-text-wrap": {
91
- title: "Habillage du texte",
92
- wrappingStyle: "Style d'habillage",
93
91
  square: "Carré",
94
92
  topAndBottom: "Haut et bas",
95
93
  inline: "Aligné avec le texte",
96
94
  behindText: "Derrière le texte",
97
- inFrontText: "Devant le texte",
98
- wrapText: "Habiller le texte",
99
- bothSide: "Des deux côtés",
100
- leftOnly: "Seulement à gauche",
101
- rightOnly: "Seulement à droite",
102
- distanceFromText: "Distance du texte",
103
- top: "Haut(px)",
104
- left: "Gauche(px)",
105
- bottom: "Bas(px)",
106
- right: "Droite(px)"
107
- },
108
- "image-popup": {
109
- replace: "Remplacer",
110
- delete: "Supprimer",
111
- edit: "Modifier",
112
- crop: "Rogner",
113
- reset: "Réinitialiser la taille"
95
+ inFrontText: "Devant le texte"
114
96
  }
115
97
  } };
116
98
 
@@ -88,29 +88,11 @@ const locale = { "drawing-ui": {
88
88
  null: "Tidak Ada Objek yang Dipilih"
89
89
  },
90
90
  "image-text-wrap": {
91
- title: "Pembungkus Teks",
92
- wrappingStyle: "Gaya Pembungkus",
93
91
  square: "Kotak",
94
92
  topAndBottom: "Atas dan Bawah",
95
93
  inline: "Sejajar dengan teks",
96
94
  behindText: "Di belakang teks",
97
- inFrontText: "Di depan teks",
98
- wrapText: "Bungkus teks",
99
- bothSide: "Kedua sisi",
100
- leftOnly: "Kiri saja",
101
- rightOnly: "Kanan saja",
102
- distanceFromText: "Jarak dari teks",
103
- top: "Atas(px)",
104
- left: "Kiri(px)",
105
- bottom: "Bawah(px)",
106
- right: "Kanan(px)"
107
- },
108
- "image-popup": {
109
- replace: "Ganti",
110
- delete: "Hapus",
111
- edit: "Edit",
112
- crop: "Pangkas",
113
- reset: "Atur Ulang Ukuran"
95
+ inFrontText: "Di depan teks"
114
96
  }
115
97
  } };
116
98