@univerjs/sheets-drawing-ui 0.25.0 → 1.0.0-alpha.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.
Files changed (98) hide show
  1. package/lib/cjs/facade.js +7 -1
  2. package/lib/cjs/index.js +365 -346
  3. package/lib/cjs/locale/ar-SA.js +1 -0
  4. package/lib/cjs/locale/ca-ES.js +1 -0
  5. package/lib/cjs/locale/de-DE.js +1 -0
  6. package/lib/cjs/locale/en-US.js +1 -0
  7. package/lib/cjs/locale/es-ES.js +1 -0
  8. package/lib/cjs/locale/fa-IR.js +1 -0
  9. package/lib/cjs/locale/fr-FR.js +1 -0
  10. package/lib/cjs/locale/id-ID.js +1 -0
  11. package/lib/cjs/locale/it-IT.js +1 -0
  12. package/lib/cjs/locale/ja-JP.js +1 -0
  13. package/lib/cjs/locale/ko-KR.js +1 -0
  14. package/lib/cjs/locale/pl-PL.js +1 -0
  15. package/lib/cjs/locale/pt-BR.js +1 -0
  16. package/lib/cjs/locale/ru-RU.js +1 -0
  17. package/lib/cjs/locale/sk-SK.js +1 -0
  18. package/lib/cjs/locale/vi-VN.js +1 -0
  19. package/lib/cjs/locale/zh-CN.js +1 -0
  20. package/lib/cjs/locale/zh-HK.js +1 -0
  21. package/lib/cjs/locale/zh-TW.js +1 -0
  22. package/lib/es/facade.js +7 -1
  23. package/lib/es/index.js +367 -348
  24. package/lib/es/locale/ar-SA.js +1 -0
  25. package/lib/es/locale/ca-ES.js +1 -0
  26. package/lib/es/locale/de-DE.js +1 -0
  27. package/lib/es/locale/en-US.js +1 -0
  28. package/lib/es/locale/es-ES.js +1 -0
  29. package/lib/es/locale/fa-IR.js +1 -0
  30. package/lib/es/locale/fr-FR.js +1 -0
  31. package/lib/es/locale/id-ID.js +1 -0
  32. package/lib/es/locale/it-IT.js +1 -0
  33. package/lib/es/locale/ja-JP.js +1 -0
  34. package/lib/es/locale/ko-KR.js +1 -0
  35. package/lib/es/locale/pl-PL.js +1 -0
  36. package/lib/es/locale/pt-BR.js +1 -0
  37. package/lib/es/locale/ru-RU.js +1 -0
  38. package/lib/es/locale/sk-SK.js +1 -0
  39. package/lib/es/locale/vi-VN.js +1 -0
  40. package/lib/es/locale/zh-CN.js +1 -0
  41. package/lib/es/locale/zh-HK.js +1 -0
  42. package/lib/es/locale/zh-TW.js +1 -0
  43. package/lib/facade.js +7 -1
  44. package/lib/index.js +367 -348
  45. package/lib/locale/ar-SA.js +1 -0
  46. package/lib/locale/ca-ES.js +1 -0
  47. package/lib/locale/de-DE.js +1 -0
  48. package/lib/locale/en-US.js +1 -0
  49. package/lib/locale/es-ES.js +1 -0
  50. package/lib/locale/fa-IR.js +1 -0
  51. package/lib/locale/fr-FR.js +1 -0
  52. package/lib/locale/id-ID.js +1 -0
  53. package/lib/locale/it-IT.js +1 -0
  54. package/lib/locale/ja-JP.js +1 -0
  55. package/lib/locale/ko-KR.js +1 -0
  56. package/lib/locale/pl-PL.js +1 -0
  57. package/lib/locale/pt-BR.js +1 -0
  58. package/lib/locale/ru-RU.js +1 -0
  59. package/lib/locale/sk-SK.js +1 -0
  60. package/lib/locale/vi-VN.js +1 -0
  61. package/lib/locale/zh-CN.js +1 -0
  62. package/lib/locale/zh-HK.js +1 -0
  63. package/lib/locale/zh-TW.js +1 -0
  64. package/lib/types/controllers/components.controller.d.ts +22 -0
  65. package/lib/types/controllers/sheet-cell-image.controller.d.ts +2 -3
  66. package/lib/types/controllers/sheet-drawing-printing.controller.d.ts +1 -3
  67. package/lib/types/controllers/{sheet-drawing.controller.d.ts → ui.controller.d.ts} +2 -3
  68. package/lib/types/index.d.ts +6 -3
  69. package/lib/types/locale/en-US.d.ts +3 -0
  70. package/lib/types/locale/types.d.ts +18 -0
  71. package/lib/types/menu/image.menu.d.ts +4 -3
  72. package/lib/types/menu/save-images.menu.d.ts +2 -1
  73. package/lib/types/views/{printing-float-dom/index.d.ts → PrintingFloatDom.d.ts} +3 -2
  74. package/lib/types/views/batch-save-images/BatchSaveImagesDialog.d.ts +1 -1
  75. package/lib/types/views/sheet-image-panel/SheetDrawingAnchor.d.ts +1 -1
  76. package/lib/types/views/sheet-image-panel/SheetDrawingPanel.d.ts +1 -1
  77. package/lib/umd/facade.js +1 -1
  78. package/lib/umd/index.js +2 -2
  79. package/lib/umd/locale/ar-SA.js +1 -1
  80. package/lib/umd/locale/ca-ES.js +1 -1
  81. package/lib/umd/locale/de-DE.js +1 -1
  82. package/lib/umd/locale/en-US.js +1 -1
  83. package/lib/umd/locale/es-ES.js +1 -1
  84. package/lib/umd/locale/fa-IR.js +1 -1
  85. package/lib/umd/locale/fr-FR.js +1 -1
  86. package/lib/umd/locale/id-ID.js +1 -1
  87. package/lib/umd/locale/it-IT.js +1 -1
  88. package/lib/umd/locale/ja-JP.js +1 -1
  89. package/lib/umd/locale/ko-KR.js +1 -1
  90. package/lib/umd/locale/pl-PL.js +1 -1
  91. package/lib/umd/locale/pt-BR.js +1 -1
  92. package/lib/umd/locale/ru-RU.js +1 -1
  93. package/lib/umd/locale/sk-SK.js +1 -1
  94. package/lib/umd/locale/vi-VN.js +1 -1
  95. package/lib/umd/locale/zh-CN.js +1 -1
  96. package/lib/umd/locale/zh-HK.js +1 -1
  97. package/lib/umd/locale/zh-TW.js +1 -1
  98. package/package.json +14 -14
package/lib/cjs/index.js CHANGED
@@ -10,9 +10,9 @@ let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
10
10
  let _univerjs_ui = require("@univerjs/ui");
11
11
  let _univerjs_docs_drawing = require("@univerjs/docs-drawing");
12
12
  let _univerjs_drawing_ui = require("@univerjs/drawing-ui");
13
- let rxjs = require("rxjs");
14
13
  let react = require("react");
15
14
  let react_jsx_runtime = require("react/jsx-runtime");
15
+ let rxjs = require("rxjs");
16
16
 
17
17
  //#region src/commands/commands/delete-drawings.command.ts
18
18
  const DeleteDrawingsCommand = {
@@ -292,7 +292,7 @@ const UngroupSheetDrawingCommand = {
292
292
  };
293
293
 
294
294
  //#endregion
295
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
295
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
296
296
  function _typeof(o) {
297
297
  "@babel/helpers - typeof";
298
298
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -303,7 +303,7 @@ function _typeof(o) {
303
303
  }
304
304
 
305
305
  //#endregion
306
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
306
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
307
307
  function toPrimitive(t, r) {
308
308
  if ("object" != _typeof(t) || !t) return t;
309
309
  var e = t[Symbol.toPrimitive];
@@ -316,14 +316,14 @@ function toPrimitive(t, r) {
316
316
  }
317
317
 
318
318
  //#endregion
319
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
319
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
320
320
  function toPropertyKey(t) {
321
321
  var i = toPrimitive(t, "string");
322
322
  return "symbol" == _typeof(i) ? i : i + "";
323
323
  }
324
324
 
325
325
  //#endregion
326
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
326
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
327
327
  function _defineProperty(e, r, t) {
328
328
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
329
329
  value: t,
@@ -334,7 +334,7 @@ function _defineProperty(e, r, t) {
334
334
  }
335
335
 
336
336
  //#endregion
337
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
337
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
338
338
  function __decorateParam(paramIndex, decorator) {
339
339
  return function(target, key) {
340
340
  decorator(target, key, paramIndex);
@@ -342,7 +342,7 @@ function __decorateParam(paramIndex, decorator) {
342
342
  }
343
343
 
344
344
  //#endregion
345
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
345
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
346
346
  function __decorate(decorators, target, key, desc) {
347
347
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
348
348
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1660,27 +1660,27 @@ function ImageMenuFactory(accessor) {
1660
1660
  })
1661
1661
  };
1662
1662
  }
1663
- function UploadFloatImageMenuFactory(_accessor) {
1663
+ function UploadFloatImageMenuFactory(accessor) {
1664
1664
  return {
1665
1665
  id: InsertFloatImageCommand.id,
1666
1666
  title: "sheets-drawing-ui.upload.float",
1667
1667
  type: _univerjs_ui.MenuItemType.BUTTON,
1668
- hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(_accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
1668
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
1669
1669
  };
1670
1670
  }
1671
- function UploadCellImageMenuFactory(_accessor) {
1671
+ function UploadCellImageMenuFactory(accessor) {
1672
1672
  return {
1673
1673
  id: InsertCellImageCommand.id,
1674
1674
  title: "sheets-drawing-ui.upload.cell",
1675
1675
  type: _univerjs_ui.MenuItemType.BUTTON,
1676
- hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(_accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
1676
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
1677
1677
  };
1678
1678
  }
1679
1679
 
1680
1680
  //#endregion
1681
1681
  //#region package.json
1682
1682
  var name = "@univerjs/sheets-drawing-ui";
1683
- var version = "0.25.0";
1683
+ var version = "1.0.0-alpha.0";
1684
1684
 
1685
1685
  //#endregion
1686
1686
  //#region src/config/config.ts
@@ -1688,6 +1688,282 @@ const SHEETS_DRAWING_UI_PLUGIN_CONFIG_KEY = "sheets-drawing-ui.config";
1688
1688
  const configSymbol = Symbol(SHEETS_DRAWING_UI_PLUGIN_CONFIG_KEY);
1689
1689
  const defaultPluginConfig = {};
1690
1690
 
1691
+ //#endregion
1692
+ //#region src/views/batch-save-images/BatchSaveImagesDialog.tsx
1693
+ function BatchSaveImagesDialog() {
1694
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
1695
+ const dialogService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IDialogService);
1696
+ const batchSaveService = (0, _univerjs_ui.useDependency)(IBatchSaveImagesService);
1697
+ const [fileNameParts, setFileNameParts] = (0, react.useState)(["cellAddress"]);
1698
+ const [saving, setSaving] = (0, react.useState)(false);
1699
+ const [error, setError] = (0, react.useState)(null);
1700
+ const images = (0, react.useMemo)(() => batchSaveService.getCellImagesInSelection(), [batchSaveService]);
1701
+ const dataColumns = (0, react.useMemo)(() => batchSaveService.getDataColumns(), [batchSaveService]);
1702
+ const rowRange = (0, react.useMemo)(() => batchSaveService.getSelectionRowRange(), [batchSaveService]);
1703
+ const hasAvailableColumns = dataColumns.length > 0;
1704
+ const columnOptions = (0, react.useMemo)(() => {
1705
+ return dataColumns.map((col) => ({
1706
+ label: col.label,
1707
+ value: String(col.index)
1708
+ }));
1709
+ }, [dataColumns]);
1710
+ const [selectedColumn, setSelectedColumn] = (0, react.useState)(() => columnOptions.length > 0 ? columnOptions[0].value : "0");
1711
+ (0, _univerjs_sheets_ui.useHighlightRange)((0, react.useMemo)(() => {
1712
+ if (!fileNameParts.includes("columnValue") || !rowRange) return [];
1713
+ const colIndex = Number(selectedColumn);
1714
+ return [{
1715
+ startRow: rowRange.startRow,
1716
+ endRow: rowRange.endRow,
1717
+ startColumn: colIndex,
1718
+ endColumn: colIndex
1719
+ }];
1720
+ }, [
1721
+ fileNameParts,
1722
+ selectedColumn,
1723
+ rowRange
1724
+ ]));
1725
+ const handleFileNamePartsChange = (0, react.useCallback)((value) => {
1726
+ if (value.length === 0) return;
1727
+ setFileNameParts(value);
1728
+ }, []);
1729
+ const handleColumnChange = (0, react.useCallback)((value) => {
1730
+ setSelectedColumn(String(value));
1731
+ }, []);
1732
+ const handleCancel = (0, react.useCallback)(() => {
1733
+ dialogService.close(BATCH_SAVE_IMAGES_DIALOG_ID);
1734
+ }, [dialogService]);
1735
+ const handleConfirm = (0, react.useCallback)(async () => {
1736
+ if (images.length === 0) return;
1737
+ setSaving(true);
1738
+ setError(null);
1739
+ try {
1740
+ await batchSaveService.saveImages(images, {
1741
+ fileNameParts,
1742
+ columnIndex: fileNameParts.includes("columnValue") ? Number(selectedColumn) : void 0
1743
+ });
1744
+ dialogService.close(BATCH_SAVE_IMAGES_DIALOG_ID);
1745
+ } catch (err) {
1746
+ console.error("Failed to save images:", err);
1747
+ setError(localeService.t("sheets-drawing-ui.save.error"));
1748
+ } finally {
1749
+ setSaving(false);
1750
+ }
1751
+ }, [
1752
+ batchSaveService,
1753
+ images,
1754
+ fileNameParts,
1755
+ selectedColumn,
1756
+ dialogService,
1757
+ localeService
1758
+ ]);
1759
+ const showColumnSelect = fileNameParts.includes("columnValue");
1760
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1761
+ className: "univer-flex univer-flex-col",
1762
+ children: [
1763
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1764
+ label: localeService.t("sheets-drawing-ui.save.imageCount"),
1765
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1766
+ className: "univer-text-sm univer-text-gray-600",
1767
+ children: images.length
1768
+ })
1769
+ }),
1770
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1771
+ label: localeService.t("sheets-drawing-ui.save.fileNameConfig"),
1772
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CheckboxGroup, {
1773
+ value: fileNameParts,
1774
+ onChange: handleFileNamePartsChange,
1775
+ direction: "vertical",
1776
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
1777
+ value: "cellAddress",
1778
+ disabled: !hasAvailableColumns,
1779
+ children: localeService.t("sheets-drawing-ui.save.useRowCol")
1780
+ }), hasAvailableColumns && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
1781
+ value: "columnValue",
1782
+ children: localeService.t("sheets-drawing-ui.save.useColumnValue")
1783
+ })]
1784
+ })
1785
+ }),
1786
+ showColumnSelect && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
1787
+ label: localeService.t("sheets-drawing-ui.save.selectColumn"),
1788
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
1789
+ value: selectedColumn,
1790
+ options: columnOptions,
1791
+ onChange: handleColumnChange
1792
+ })
1793
+ }),
1794
+ error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1795
+ className: "univer-text-xs univer-text-red-500",
1796
+ children: error
1797
+ }),
1798
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1799
+ className: "univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",
1800
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
1801
+ onClick: handleCancel,
1802
+ disabled: saving,
1803
+ children: localeService.t("sheets-drawing-ui.save.cancel")
1804
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
1805
+ variant: "primary",
1806
+ onClick: handleConfirm,
1807
+ disabled: saving || images.length === 0,
1808
+ children: saving ? localeService.t("sheets-drawing-ui.save.saving") : localeService.t("sheets-drawing-ui.save.confirm")
1809
+ })]
1810
+ })
1811
+ ]
1812
+ });
1813
+ }
1814
+
1815
+ //#endregion
1816
+ //#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
1817
+ const SheetDrawingAnchor = (props) => {
1818
+ var _drawingParam$anchorT;
1819
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
1820
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
1821
+ const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
1822
+ const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
1823
+ const { drawings } = props;
1824
+ const drawingParam = drawings[0];
1825
+ if (drawingParam == null) return;
1826
+ const { unitId } = drawingParam;
1827
+ const renderObject = renderManagerService.getRenderById(unitId);
1828
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1829
+ if (scene == null) return;
1830
+ const transformer = scene.getTransformerByCreate();
1831
+ const [anchorShow, setAnchorShow] = (0, react.useState)(true);
1832
+ const [value, setValue] = (0, react.useState)((_drawingParam$anchorT = drawingParam.anchorType) !== null && _drawingParam$anchorT !== void 0 ? _drawingParam$anchorT : _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
1833
+ function getUpdateParams(objects, drawingManagerService) {
1834
+ const params = [];
1835
+ objects.forEach((object) => {
1836
+ const { oKey } = object;
1837
+ const searchParam = drawingManagerService.getDrawingOKey(oKey);
1838
+ if (searchParam == null) {
1839
+ params.push(null);
1840
+ return true;
1841
+ }
1842
+ const { unitId, subUnitId, drawingId, drawingType, anchorType, sheetTransform, axisAlignSheetTransform } = searchParam;
1843
+ params.push({
1844
+ unitId,
1845
+ subUnitId,
1846
+ drawingId,
1847
+ anchorType,
1848
+ sheetTransform,
1849
+ drawingType,
1850
+ axisAlignSheetTransform
1851
+ });
1852
+ });
1853
+ return params;
1854
+ }
1855
+ (0, react.useEffect)(() => {
1856
+ const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
1857
+ if (changeSelf === true) setAnchorShow(false);
1858
+ });
1859
+ const onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
1860
+ const { objects } = state;
1861
+ const params = getUpdateParams(objects, drawingManagerService);
1862
+ if (params.length === 0) setAnchorShow(false);
1863
+ else if (params.length >= 1) {
1864
+ var _params$;
1865
+ setAnchorShow(true);
1866
+ setValue(((_params$ = params[0]) === null || _params$ === void 0 ? void 0 : _params$.anchorType) || _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
1867
+ }
1868
+ });
1869
+ return () => {
1870
+ onChangeStartObserver.unsubscribe();
1871
+ onClearControlObserver.unsubscribe();
1872
+ };
1873
+ }, []);
1874
+ function handleChange(value) {
1875
+ setValue(value);
1876
+ const focusDrawings = drawingManagerService.getFocusDrawings();
1877
+ if (focusDrawings.length === 0) return;
1878
+ const updateParams = focusDrawings.map((drawing) => {
1879
+ return {
1880
+ unitId: drawing.unitId,
1881
+ subUnitId: drawing.subUnitId,
1882
+ drawingId: drawing.drawingId,
1883
+ anchorType: value
1884
+ };
1885
+ });
1886
+ commandService.executeCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
1887
+ unitId: focusDrawings[0].unitId,
1888
+ drawings: updateParams
1889
+ });
1890
+ }
1891
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1892
+ className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": !anchorShow }),
1893
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
1894
+ className: "univer-text-gray-600 dark:!univer-text-gray-200",
1895
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: localeService.t("sheets-drawing-ui.drawing-anchor.title") })
1896
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.RadioGroup, {
1897
+ value,
1898
+ onChange: handleChange,
1899
+ direction: "vertical",
1900
+ children: [
1901
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
1902
+ value: _univerjs_sheets_drawing.SheetDrawingAnchorType.Both,
1903
+ children: localeService.t("sheets-drawing-ui.drawing-anchor.both")
1904
+ }),
1905
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
1906
+ value: _univerjs_sheets_drawing.SheetDrawingAnchorType.Position,
1907
+ children: localeService.t("sheets-drawing-ui.drawing-anchor.position")
1908
+ }),
1909
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
1910
+ value: _univerjs_sheets_drawing.SheetDrawingAnchorType.None,
1911
+ children: localeService.t("sheets-drawing-ui.drawing-anchor.none")
1912
+ })
1913
+ ]
1914
+ }) })]
1915
+ });
1916
+ };
1917
+
1918
+ //#endregion
1919
+ //#region src/views/sheet-image-panel/SheetDrawingPanel.tsx
1920
+ const SheetDrawingPanel = () => {
1921
+ const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
1922
+ const [drawings, setDrawings] = (0, react.useState)(drawingManagerService.getFocusDrawings());
1923
+ (0, react.useEffect)(() => {
1924
+ const focusDispose = drawingManagerService.focus$.subscribe((drawings) => {
1925
+ setDrawings(drawings);
1926
+ });
1927
+ return () => {
1928
+ focusDispose.unsubscribe();
1929
+ };
1930
+ }, []);
1931
+ return !!(drawings === null || drawings === void 0 ? void 0 : drawings.length) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1932
+ className: "univer-text-sm",
1933
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_drawing_ui.DrawingCommonPanel, { drawings }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetDrawingAnchor, { drawings })]
1934
+ });
1935
+ };
1936
+
1937
+ //#endregion
1938
+ //#region src/controllers/components.controller.ts
1939
+ /**
1940
+ * Copyright 2023-present DreamNum Co., Ltd.
1941
+ *
1942
+ * Licensed under the Apache License, Version 2.0 (the "License");
1943
+ * you may not use this file except in compliance with the License.
1944
+ * You may obtain a copy of the License at
1945
+ *
1946
+ * http://www.apache.org/licenses/LICENSE-2.0
1947
+ *
1948
+ * Unless required by applicable law or agreed to in writing, software
1949
+ * distributed under the License is distributed on an "AS IS" BASIS,
1950
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1951
+ * See the License for the specific language governing permissions and
1952
+ * limitations under the License.
1953
+ */
1954
+ let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
1955
+ constructor(_componentManager) {
1956
+ super();
1957
+ this._componentManager = _componentManager;
1958
+ this._registerComponents();
1959
+ }
1960
+ _registerComponents() {
1961
+ this.disposeWithMe(this._componentManager.register(COMPONENT_SHEET_DRAWING_PANEL, SheetDrawingPanel));
1962
+ this.disposeWithMe(this._componentManager.register(BATCH_SAVE_IMAGES_DIALOG_ID, BatchSaveImagesDialog));
1963
+ }
1964
+ };
1965
+ ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))], ComponentsController);
1966
+
1691
1967
  //#endregion
1692
1968
  //#region src/controllers/drawing-context-menu.controller.ts
1693
1969
  let DrawingContextMenuController = class DrawingContextMenuController extends _univerjs_core.RxDisposable {
@@ -1745,12 +2021,21 @@ let SheetCellImageHoverRenderController = class SheetCellImageHoverRenderControl
1745
2021
  }
1746
2022
  _initHover() {
1747
2023
  this.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe((0, rxjs.throttleTime)(33)).subscribe((richText) => {
1748
- var _currentSelections$0$, _currentSelections$0$2;
1749
2024
  let currentSelections = [];
1750
2025
  if (richText !== null) currentSelections = this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections();
1751
- if (currentSelections.length > 0 && (richText === null || richText === void 0 ? void 0 : richText.unitId) === this._context.unitId && (richText === null || richText === void 0 ? void 0 : richText.drawing) && currentSelections.length === 1 && ((_currentSelections$0$ = currentSelections[0].primary) === null || _currentSelections$0$ === void 0 ? void 0 : _currentSelections$0$.actualRow) === richText.row && ((_currentSelections$0$2 = currentSelections[0].primary) === null || _currentSelections$0$2 === void 0 ? void 0 : _currentSelections$0$2.actualColumn) === richText.col) {
1752
- this._isSetCursor = true;
1753
- this._context.scene.setCursor(_univerjs_engine_render.CURSOR_TYPE.ZOOM_IN);
2026
+ if ((richText === null || richText === void 0 ? void 0 : richText.unitId) === this._context.unitId && (richText === null || richText === void 0 ? void 0 : richText.drawing) && currentSelections.length === 1 && currentSelections[0].primary) {
2027
+ const { row, col } = richText;
2028
+ const { actualRow, actualColumn, startRow, startColumn, endRow, endColumn, isMerged, isMergedMainCell } = currentSelections[0].primary;
2029
+ if ((isMerged || isMergedMainCell) && row >= startRow && row <= endRow && col >= startColumn && col <= endColumn) {
2030
+ this._isSetCursor = true;
2031
+ this._context.scene.setCursor(_univerjs_engine_render.CURSOR_TYPE.ZOOM_IN);
2032
+ } else if (row === actualRow && col === actualColumn) {
2033
+ this._isSetCursor = true;
2034
+ this._context.scene.setCursor(_univerjs_engine_render.CURSOR_TYPE.ZOOM_IN);
2035
+ } else if (this._isSetCursor) {
2036
+ this._isSetCursor = false;
2037
+ this._context.scene.resetCursor();
2038
+ }
1754
2039
  } else if (this._isSetCursor) {
1755
2040
  this._isSetCursor = false;
1756
2041
  this._context.scene.resetCursor();
@@ -1843,9 +2128,8 @@ function resizeImageByCell(injector, location, cell) {
1843
2128
  return false;
1844
2129
  }
1845
2130
  let SheetCellImageController = class SheetCellImageController extends _univerjs_core.Disposable {
1846
- constructor(_commandService, _sheetInterceptorService, _injector, _drawingManagerService, _docDrawingController, _editorBridgeService) {
2131
+ constructor(_sheetInterceptorService, _injector, _drawingManagerService, _docDrawingController, _editorBridgeService) {
1847
2132
  super();
1848
- this._commandService = _commandService;
1849
2133
  this._sheetInterceptorService = _sheetInterceptorService;
1850
2134
  this._injector = _injector;
1851
2135
  this._drawingManagerService = _drawingManagerService;
@@ -1863,15 +2147,6 @@ let SheetCellImageController = class SheetCellImageController extends _univerjs_
1863
2147
  this._drawingManagerService.initializeNotification(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
1864
2148
  }
1865
2149
  }));
1866
- this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
1867
- if (commandInfo.id === _univerjs_docs_ui.ReplaceSnapshotCommand.id) {
1868
- if (commandInfo.params.unitId === _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY) {
1869
- this._drawingManagerService.removeDrawingDataForUnit(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);
1870
- this._docDrawingController.loadDrawingDataForUnit(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);
1871
- this._drawingManagerService.initializeNotification(_univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);
1872
- }
1873
- }
1874
- }));
1875
2150
  }
1876
2151
  _initCellContentInterceptor() {
1877
2152
  this.disposeWithMe(this._sheetInterceptorService.intercept(_univerjs_sheets.INTERCEPTOR_POINT.CELL_CONTENT, {
@@ -1896,12 +2171,11 @@ let SheetCellImageController = class SheetCellImageController extends _univerjs_
1896
2171
  }
1897
2172
  };
1898
2173
  SheetCellImageController = __decorate([
1899
- __decorateParam(0, _univerjs_core.ICommandService),
1900
- __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
1901
- __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
1902
- __decorateParam(3, _univerjs_drawing.IDrawingManagerService),
1903
- __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs_drawing.DocDrawingController)),
1904
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.IEditorBridgeService))
2174
+ __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
2175
+ __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
2176
+ __decorateParam(2, _univerjs_drawing.IDrawingManagerService),
2177
+ __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_docs_drawing.DocDrawingController)),
2178
+ __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.IEditorBridgeService))
1905
2179
  ], SheetCellImageController);
1906
2180
 
1907
2181
  //#endregion
@@ -1948,11 +2222,7 @@ SheetCellImageAutofillController = __decorate([__decorateParam(0, (0, _univerjs_
1948
2222
 
1949
2223
  //#endregion
1950
2224
  //#region src/controllers/sheet-cell-image-copy-paste.controller.ts
1951
- const DISABLE_UNITS = [
1952
- _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
1953
- _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
1954
- _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY
1955
- ];
2225
+ const DISABLE_UNITS = [_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY, _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];
1956
2226
  let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController extends _univerjs_core.Disposable {
1957
2227
  constructor(_commandService, _univerInstanceService, _dialogService, _renderManagerService, _localeService) {
1958
2228
  super();
@@ -1990,31 +2260,29 @@ let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController
1990
2260
  if (currentDoc == null || !Object.keys((_doc$drawings = doc.drawings) !== null && _doc$drawings !== void 0 ? _doc$drawings : {}).length) return;
1991
2261
  const docUnitId = currentDoc.getUnitId();
1992
2262
  if (DISABLE_UNITS.includes(docUnitId)) {
1993
- if (docUnitId !== _univerjs_core.DOCS_ZEN_EDITOR_UNIT_ID_KEY) {
1994
- var _currentDoc$getBody;
1995
- const handleCloseDialog = () => {
1996
- this._dialogService.close("sheet-cell-image-copy-paste");
1997
- this._commandService.syncExecuteCommand(_univerjs_sheets_ui.SetCellEditVisibleOperation.id, { visible: false });
1998
- };
1999
- if (((_currentDoc$getBody = currentDoc.getBody()) === null || _currentDoc$getBody === void 0 ? void 0 : _currentDoc$getBody.dataStream) === "\r\n") {
2000
- this._commandService.syncExecuteCommand(_univerjs_sheets_ui.SetCellEditVisibleOperation.id, { visible: false });
2263
+ var _currentDoc$getBody;
2264
+ const handleCloseDialog = () => {
2265
+ this._dialogService.close("sheet-cell-image-copy-paste");
2266
+ this._commandService.syncExecuteCommand(_univerjs_sheets_ui.SetCellEditVisibleOperation.id, { visible: false });
2267
+ };
2268
+ if (((_currentDoc$getBody = currentDoc.getBody()) === null || _currentDoc$getBody === void 0 ? void 0 : _currentDoc$getBody.dataStream) === "\r\n") {
2269
+ this._commandService.syncExecuteCommand(_univerjs_sheets_ui.SetCellEditVisibleOperation.id, { visible: false });
2270
+ this._setCellImage(Object.values(doc.drawings)[0]);
2271
+ } else this._dialogService.open({
2272
+ id: "sheet-cell-image-copy-paste",
2273
+ title: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteTitle") },
2274
+ children: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteContent") },
2275
+ width: 320,
2276
+ destroyOnClose: true,
2277
+ onClose: handleCloseDialog,
2278
+ showOk: true,
2279
+ showCancel: true,
2280
+ onOk: () => {
2281
+ handleCloseDialog();
2001
2282
  this._setCellImage(Object.values(doc.drawings)[0]);
2002
- } else this._dialogService.open({
2003
- id: "sheet-cell-image-copy-paste",
2004
- title: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteTitle") },
2005
- children: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteContent") },
2006
- width: 320,
2007
- destroyOnClose: true,
2008
- onClose: handleCloseDialog,
2009
- showOk: true,
2010
- showCancel: true,
2011
- onOk: () => {
2012
- handleCloseDialog();
2013
- this._setCellImage(Object.values(doc.drawings)[0]);
2014
- },
2015
- onCancel: handleCloseDialog
2016
- });
2017
- }
2283
+ },
2284
+ onCancel: handleCloseDialog
2285
+ });
2018
2286
  }
2019
2287
  }
2020
2288
  }));
@@ -3687,7 +3955,7 @@ function calculateOffset(value, rangeWidth) {
3687
3955
  }
3688
3956
 
3689
3957
  //#endregion
3690
- //#region src/views/printing-float-dom/index.tsx
3958
+ //#region src/views/PrintingFloatDom.tsx
3691
3959
  const PrintingFloatDom = (props) => {
3692
3960
  const { floatDomInfos, scene, skeleton, worksheet } = props;
3693
3961
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -3740,17 +4008,20 @@ const PrintingFloatDom = (props) => {
3740
4008
  }, id))
3741
4009
  });
3742
4010
  };
4011
+ function mountPrintingFloatDom(props, root, injector) {
4012
+ (0, _univerjs_design.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)((0, _univerjs_ui.connectInjector)(PrintingFloatDom, injector), { ...props }), root);
4013
+ return () => (0, _univerjs_design.unmount)(root);
4014
+ }
3743
4015
 
3744
4016
  //#endregion
3745
- //#region src/controllers/sheet-drawing-printing.controller.tsx
4017
+ //#region src/controllers/sheet-drawing-printing.controller.ts
3746
4018
  let SheetDrawingPrintingController = class SheetDrawingPrintingController extends _univerjs_core.Disposable {
3747
- constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService, _canvasFloatDomManagerService, _componetManager, _injector) {
4019
+ constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService, _componetManager, _injector) {
3748
4020
  super();
3749
4021
  this._sheetPrintInterceptorService = _sheetPrintInterceptorService;
3750
4022
  this._drawingRenderService = _drawingRenderService;
3751
4023
  this._drawingManagerService = _drawingManagerService;
3752
4024
  this._renderManagerService = _renderManagerService;
3753
- this._canvasFloatDomManagerService = _canvasFloatDomManagerService;
3754
4025
  this._componetManager = _componetManager;
3755
4026
  this._injector = _injector;
3756
4027
  this._initPrinting();
@@ -3812,29 +4083,28 @@ let SheetDrawingPrintingController = class SheetDrawingPrintingController extend
3812
4083
  const unitData = this._drawingManagerService.getDrawingDataForUnit(unitId);
3813
4084
  const subUnitData = unitData === null || unitData === void 0 ? void 0 : unitData[subUnitId];
3814
4085
  if (subUnitData) {
3815
- const floatDomInfos = subUnitData.order.map((id) => {
3816
- const drawing = subUnitData.data[id];
3817
- if (drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_CHART) return {
3818
- ...drawing,
3819
- componentKey: this._componetManager.get(_univerjs_core.PRINT_CHART_COMPONENT_KEY)
3820
- };
3821
- if (drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_DOM) {
3822
- const printingComponentKey = this._sheetPrintInterceptorService.getPrintComponent(drawing.componentKey);
3823
- return {
4086
+ const unmountPrintingFloatDom = mountPrintingFloatDom({
4087
+ floatDomInfos: subUnitData.order.map((id) => {
4088
+ const drawing = subUnitData.data[id];
4089
+ if (drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_CHART) return {
3824
4090
  ...drawing,
3825
- componentKey: this._componetManager.get(printingComponentKey || drawing.componentKey)
4091
+ componentKey: this._componetManager.get(_univerjs_core.PRINT_CHART_COMPONENT_KEY)
3826
4092
  };
3827
- }
3828
- return null;
3829
- }).filter(Boolean);
3830
- (0, _univerjs_design.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)((0, _univerjs_ui.connectInjector)(PrintingFloatDom, this._injector), {
3831
- floatDomInfos,
4093
+ if (drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_DOM) {
4094
+ const printingComponentKey = this._sheetPrintInterceptorService.getPrintComponent(drawing.componentKey);
4095
+ return {
4096
+ ...drawing,
4097
+ componentKey: this._componetManager.get(printingComponentKey || drawing.componentKey)
4098
+ };
4099
+ }
4100
+ return null;
4101
+ }).filter(Boolean),
3832
4102
  scene: pos.scene,
3833
4103
  skeleton: pos.skeleton,
3834
4104
  worksheet: pos.worksheet
3835
- }), pos.root);
4105
+ }, pos.root, this._injector);
3836
4106
  disposableCollection === null || disposableCollection === void 0 || disposableCollection.add(() => {
3837
- (0, _univerjs_design.unmount)(pos.root);
4107
+ unmountPrintingFloatDom();
3838
4108
  });
3839
4109
  return next(disposableCollection);
3840
4110
  }
@@ -3846,9 +4116,8 @@ SheetDrawingPrintingController = __decorate([
3846
4116
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_drawing_ui.DrawingRenderService)),
3847
4117
  __decorateParam(2, _univerjs_drawing.IDrawingManagerService),
3848
4118
  __decorateParam(3, _univerjs_engine_render.IRenderManagerService),
3849
- __decorateParam(4, (0, _univerjs_core.Inject)(SheetCanvasFloatDomManagerService)),
3850
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
3851
- __decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
4119
+ __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
4120
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
3852
4121
  ], SheetDrawingPrintingController);
3853
4122
 
3854
4123
  //#endregion
@@ -5509,252 +5778,6 @@ const menuSchema = {
5509
5778
  } } }
5510
5779
  };
5511
5780
 
5512
- //#endregion
5513
- //#region src/views/batch-save-images/BatchSaveImagesDialog.tsx
5514
- function BatchSaveImagesDialog() {
5515
- const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
5516
- const dialogService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IDialogService);
5517
- const batchSaveService = (0, _univerjs_ui.useDependency)(IBatchSaveImagesService);
5518
- const [fileNameParts, setFileNameParts] = (0, react.useState)(["cellAddress"]);
5519
- const [saving, setSaving] = (0, react.useState)(false);
5520
- const [error, setError] = (0, react.useState)(null);
5521
- const images = (0, react.useMemo)(() => batchSaveService.getCellImagesInSelection(), [batchSaveService]);
5522
- const dataColumns = (0, react.useMemo)(() => batchSaveService.getDataColumns(), [batchSaveService]);
5523
- const rowRange = (0, react.useMemo)(() => batchSaveService.getSelectionRowRange(), [batchSaveService]);
5524
- const hasAvailableColumns = dataColumns.length > 0;
5525
- const columnOptions = (0, react.useMemo)(() => {
5526
- return dataColumns.map((col) => ({
5527
- label: col.label,
5528
- value: String(col.index)
5529
- }));
5530
- }, [dataColumns]);
5531
- const [selectedColumn, setSelectedColumn] = (0, react.useState)(() => columnOptions.length > 0 ? columnOptions[0].value : "0");
5532
- (0, _univerjs_sheets_ui.useHighlightRange)((0, react.useMemo)(() => {
5533
- if (!fileNameParts.includes("columnValue") || !rowRange) return [];
5534
- const colIndex = Number(selectedColumn);
5535
- return [{
5536
- startRow: rowRange.startRow,
5537
- endRow: rowRange.endRow,
5538
- startColumn: colIndex,
5539
- endColumn: colIndex
5540
- }];
5541
- }, [
5542
- fileNameParts,
5543
- selectedColumn,
5544
- rowRange
5545
- ]));
5546
- const handleFileNamePartsChange = (0, react.useCallback)((value) => {
5547
- if (value.length === 0) return;
5548
- setFileNameParts(value);
5549
- }, []);
5550
- const handleColumnChange = (0, react.useCallback)((value) => {
5551
- setSelectedColumn(String(value));
5552
- }, []);
5553
- const handleCancel = (0, react.useCallback)(() => {
5554
- dialogService.close(BATCH_SAVE_IMAGES_DIALOG_ID);
5555
- }, [dialogService]);
5556
- const handleConfirm = (0, react.useCallback)(async () => {
5557
- if (images.length === 0) return;
5558
- setSaving(true);
5559
- setError(null);
5560
- try {
5561
- await batchSaveService.saveImages(images, {
5562
- fileNameParts,
5563
- columnIndex: fileNameParts.includes("columnValue") ? Number(selectedColumn) : void 0
5564
- });
5565
- dialogService.close(BATCH_SAVE_IMAGES_DIALOG_ID);
5566
- } catch (err) {
5567
- console.error("Failed to save images:", err);
5568
- setError(localeService.t("sheets-drawing-ui.save.error"));
5569
- } finally {
5570
- setSaving(false);
5571
- }
5572
- }, [
5573
- batchSaveService,
5574
- images,
5575
- fileNameParts,
5576
- selectedColumn,
5577
- dialogService,
5578
- localeService
5579
- ]);
5580
- const showColumnSelect = fileNameParts.includes("columnValue");
5581
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5582
- className: "univer-flex univer-flex-col",
5583
- children: [
5584
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
5585
- label: localeService.t("sheets-drawing-ui.save.imageCount"),
5586
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5587
- className: "univer-text-sm univer-text-gray-600",
5588
- children: images.length
5589
- })
5590
- }),
5591
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
5592
- label: localeService.t("sheets-drawing-ui.save.fileNameConfig"),
5593
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.CheckboxGroup, {
5594
- value: fileNameParts,
5595
- onChange: handleFileNamePartsChange,
5596
- direction: "vertical",
5597
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
5598
- value: "cellAddress",
5599
- disabled: !hasAvailableColumns,
5600
- children: localeService.t("sheets-drawing-ui.save.useRowCol")
5601
- }), hasAvailableColumns && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
5602
- value: "columnValue",
5603
- children: localeService.t("sheets-drawing-ui.save.useColumnValue")
5604
- })]
5605
- })
5606
- }),
5607
- showColumnSelect && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, {
5608
- label: localeService.t("sheets-drawing-ui.save.selectColumn"),
5609
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
5610
- value: selectedColumn,
5611
- options: columnOptions,
5612
- onChange: handleColumnChange
5613
- })
5614
- }),
5615
- error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5616
- className: "univer-text-xs univer-text-red-500",
5617
- children: error
5618
- }),
5619
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5620
- className: "univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",
5621
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
5622
- onClick: handleCancel,
5623
- disabled: saving,
5624
- children: localeService.t("sheets-drawing-ui.save.cancel")
5625
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
5626
- variant: "primary",
5627
- onClick: handleConfirm,
5628
- disabled: saving || images.length === 0,
5629
- children: saving ? localeService.t("sheets-drawing-ui.save.saving") : localeService.t("sheets-drawing-ui.save.confirm")
5630
- })]
5631
- })
5632
- ]
5633
- });
5634
- }
5635
-
5636
- //#endregion
5637
- //#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
5638
- const SheetDrawingAnchor = (props) => {
5639
- var _drawingParam$anchorT;
5640
- const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
5641
- const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
5642
- const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
5643
- const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
5644
- const { drawings } = props;
5645
- const drawingParam = drawings[0];
5646
- if (drawingParam == null) return;
5647
- const { unitId } = drawingParam;
5648
- const renderObject = renderManagerService.getRenderById(unitId);
5649
- const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
5650
- if (scene == null) return;
5651
- const transformer = scene.getTransformerByCreate();
5652
- const [anchorShow, setAnchorShow] = (0, react.useState)(true);
5653
- const [value, setValue] = (0, react.useState)((_drawingParam$anchorT = drawingParam.anchorType) !== null && _drawingParam$anchorT !== void 0 ? _drawingParam$anchorT : _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
5654
- function getUpdateParams(objects, drawingManagerService) {
5655
- const params = [];
5656
- objects.forEach((object) => {
5657
- const { oKey } = object;
5658
- const searchParam = drawingManagerService.getDrawingOKey(oKey);
5659
- if (searchParam == null) {
5660
- params.push(null);
5661
- return true;
5662
- }
5663
- const { unitId, subUnitId, drawingId, drawingType, anchorType, sheetTransform, axisAlignSheetTransform } = searchParam;
5664
- params.push({
5665
- unitId,
5666
- subUnitId,
5667
- drawingId,
5668
- anchorType,
5669
- sheetTransform,
5670
- drawingType,
5671
- axisAlignSheetTransform
5672
- });
5673
- });
5674
- return params;
5675
- }
5676
- (0, react.useEffect)(() => {
5677
- const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
5678
- if (changeSelf === true) setAnchorShow(false);
5679
- });
5680
- const onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
5681
- const { objects } = state;
5682
- const params = getUpdateParams(objects, drawingManagerService);
5683
- if (params.length === 0) setAnchorShow(false);
5684
- else if (params.length >= 1) {
5685
- var _params$;
5686
- setAnchorShow(true);
5687
- setValue(((_params$ = params[0]) === null || _params$ === void 0 ? void 0 : _params$.anchorType) || _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
5688
- }
5689
- });
5690
- return () => {
5691
- onChangeStartObserver.unsubscribe();
5692
- onClearControlObserver.unsubscribe();
5693
- };
5694
- }, []);
5695
- function handleChange(value) {
5696
- setValue(value);
5697
- const focusDrawings = drawingManagerService.getFocusDrawings();
5698
- if (focusDrawings.length === 0) return;
5699
- const updateParams = focusDrawings.map((drawing) => {
5700
- return {
5701
- unitId: drawing.unitId,
5702
- subUnitId: drawing.subUnitId,
5703
- drawingId: drawing.drawingId,
5704
- anchorType: value
5705
- };
5706
- });
5707
- commandService.executeCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
5708
- unitId: focusDrawings[0].unitId,
5709
- drawings: updateParams
5710
- });
5711
- }
5712
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5713
- className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": !anchorShow }),
5714
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
5715
- className: "univer-text-gray-600 dark:!univer-text-gray-200",
5716
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: localeService.t("sheets-drawing-ui.drawing-anchor.title") })
5717
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.RadioGroup, {
5718
- value,
5719
- onChange: handleChange,
5720
- direction: "vertical",
5721
- children: [
5722
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
5723
- value: _univerjs_sheets_drawing.SheetDrawingAnchorType.Both,
5724
- children: localeService.t("sheets-drawing-ui.drawing-anchor.both")
5725
- }),
5726
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
5727
- value: _univerjs_sheets_drawing.SheetDrawingAnchorType.Position,
5728
- children: localeService.t("sheets-drawing-ui.drawing-anchor.position")
5729
- }),
5730
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
5731
- value: _univerjs_sheets_drawing.SheetDrawingAnchorType.None,
5732
- children: localeService.t("sheets-drawing-ui.drawing-anchor.none")
5733
- })
5734
- ]
5735
- }) })]
5736
- });
5737
- };
5738
-
5739
- //#endregion
5740
- //#region src/views/sheet-image-panel/SheetDrawingPanel.tsx
5741
- const SheetDrawingPanel = () => {
5742
- const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
5743
- const [drawings, setDrawings] = (0, react.useState)(drawingManagerService.getFocusDrawings());
5744
- (0, react.useEffect)(() => {
5745
- const focusDispose = drawingManagerService.focus$.subscribe((drawings) => {
5746
- setDrawings(drawings);
5747
- });
5748
- return () => {
5749
- focusDispose.unsubscribe();
5750
- };
5751
- }, []);
5752
- return !!(drawings === null || drawings === void 0 ? void 0 : drawings.length) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5753
- className: "univer-text-sm",
5754
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_drawing_ui.DrawingCommonPanel, { drawings }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetDrawingAnchor, { drawings })]
5755
- });
5756
- };
5757
-
5758
5781
  //#endregion
5759
5782
  //#region src/controllers/shortcuts/drawing.shortcut.ts
5760
5783
  function whenSheetDrawingFocused(contextService) {
@@ -5812,7 +5835,7 @@ const DeleteDrawingsShortcutItem = {
5812
5835
  };
5813
5836
 
5814
5837
  //#endregion
5815
- //#region src/controllers/sheet-drawing.controller.ts
5838
+ //#region src/controllers/ui.controller.ts
5816
5839
  /**
5817
5840
  * Copyright 2023-present DreamNum Co., Ltd.
5818
5841
  *
@@ -5829,19 +5852,14 @@ const DeleteDrawingsShortcutItem = {
5829
5852
  * limitations under the License.
5830
5853
  */
5831
5854
  let SheetDrawingUIController = class SheetDrawingUIController extends _univerjs_core.Disposable {
5832
- constructor(_componentManager, _menuManagerService, _commandService, _shortcutService) {
5855
+ constructor(_menuManagerService, _commandService, _shortcutService) {
5833
5856
  super();
5834
- this._componentManager = _componentManager;
5835
5857
  this._menuManagerService = _menuManagerService;
5836
5858
  this._commandService = _commandService;
5837
5859
  this._shortcutService = _shortcutService;
5838
5860
  this._init();
5839
5861
  }
5840
- _initCustomComponents() {
5841
- const componentManager = this._componentManager;
5842
- this.disposeWithMe(componentManager.register(COMPONENT_SHEET_DRAWING_PANEL, SheetDrawingPanel));
5843
- this.disposeWithMe(componentManager.register(BATCH_SAVE_IMAGES_DIALOG_ID, BatchSaveImagesDialog));
5844
- }
5862
+ _initCustomComponents() {}
5845
5863
  _initMenus() {
5846
5864
  this._menuManagerService.mergeMenu(menuSchema);
5847
5865
  }
@@ -5878,10 +5896,9 @@ let SheetDrawingUIController = class SheetDrawingUIController extends _univerjs_
5878
5896
  }
5879
5897
  };
5880
5898
  SheetDrawingUIController = __decorate([
5881
- __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
5882
- __decorateParam(1, _univerjs_ui.IMenuManagerService),
5883
- __decorateParam(2, _univerjs_core.ICommandService),
5884
- __decorateParam(3, _univerjs_ui.IShortcutService)
5899
+ __decorateParam(0, _univerjs_ui.IMenuManagerService),
5900
+ __decorateParam(1, _univerjs_core.ICommandService),
5901
+ __decorateParam(2, _univerjs_ui.IShortcutService)
5885
5902
  ], SheetDrawingUIController);
5886
5903
 
5887
5904
  //#endregion
@@ -5915,7 +5932,7 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
5915
5932
  if (status > 0 && !messageDisposable) messageDisposable = this._messageService.show({
5916
5933
  id: MESSAGE_ID,
5917
5934
  type: _univerjs_design.MessageType.Loading,
5918
- content: `${this._localeService.t("sheets-ui.uploadLoading.loading")}: ${status}`,
5935
+ content: `${this._localeService.t("sheets-drawing-ui.uploadLoading.loading")}: ${status}`,
5919
5936
  duration: 0
5920
5937
  });
5921
5938
  else if (status === 0) {
@@ -5962,7 +5979,7 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
5962
5979
  if (!object) return;
5963
5980
  const oKey = object.oKey;
5964
5981
  const drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
5965
- if (!drawingParam) return;
5982
+ if (!drawingParam || drawingParam.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_SHAPE) return;
5966
5983
  const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
5967
5984
  const data = drawingParam.data;
5968
5985
  if (data && data.disablePopup) return;
@@ -6097,6 +6114,7 @@ let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends _uni
6097
6114
  }
6098
6115
  onStarting() {
6099
6116
  (0, _univerjs_core.registerDependencies)(this._injector, [
6117
+ [ComponentsController],
6100
6118
  [SheetCanvasFloatDomManagerService],
6101
6119
  [SheetDrawingUIController],
6102
6120
  [DrawingPopupMenuController],
@@ -6111,6 +6129,7 @@ let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends _uni
6111
6129
  [DrawingContextMenuController]
6112
6130
  ]);
6113
6131
  (0, _univerjs_core.touchDependencies)(this._injector, [[SheetCanvasFloatDomManagerService]]);
6132
+ this._injector.get(ComponentsController);
6114
6133
  }
6115
6134
  onReady() {
6116
6135
  (0, _univerjs_core.touchDependencies)(this._injector, [