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