@univerjs/sheets-drawing-ui 1.0.0-alpha.8 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +6 -10
- package/lib/cjs/index.js +202 -169
- package/lib/cjs/locale/ar-SA.js +1 -3
- package/lib/cjs/locale/ca-ES.js +1 -3
- package/lib/cjs/locale/de-DE.js +1 -3
- package/lib/cjs/locale/en-US.js +1 -3
- package/lib/cjs/locale/es-ES.js +1 -3
- package/lib/cjs/locale/fa-IR.js +1 -3
- package/lib/cjs/locale/fr-FR.js +1 -3
- package/lib/cjs/locale/id-ID.js +1 -3
- package/lib/cjs/locale/it-IT.js +1 -3
- package/lib/cjs/locale/ja-JP.js +1 -3
- package/lib/cjs/locale/ko-KR.js +1 -3
- package/lib/cjs/locale/pl-PL.js +1 -3
- package/lib/cjs/locale/pt-BR.js +1 -3
- package/lib/cjs/locale/ru-RU.js +1 -3
- package/lib/cjs/locale/sk-SK.js +1 -3
- package/lib/cjs/locale/vi-VN.js +1 -3
- package/lib/cjs/locale/zh-CN.js +1 -3
- package/lib/cjs/locale/zh-HK.js +1 -3
- package/lib/cjs/locale/zh-TW.js +1 -3
- package/lib/es/facade.js +6 -10
- package/lib/es/index.js +205 -172
- package/lib/es/locale/ar-SA.js +1 -3
- package/lib/es/locale/ca-ES.js +1 -3
- package/lib/es/locale/de-DE.js +1 -3
- package/lib/es/locale/en-US.js +1 -3
- package/lib/es/locale/es-ES.js +1 -3
- package/lib/es/locale/fa-IR.js +1 -3
- package/lib/es/locale/fr-FR.js +1 -3
- package/lib/es/locale/id-ID.js +1 -3
- package/lib/es/locale/it-IT.js +1 -3
- package/lib/es/locale/ja-JP.js +1 -3
- package/lib/es/locale/ko-KR.js +1 -3
- package/lib/es/locale/pl-PL.js +1 -3
- package/lib/es/locale/pt-BR.js +1 -3
- package/lib/es/locale/ru-RU.js +1 -3
- package/lib/es/locale/sk-SK.js +1 -3
- package/lib/es/locale/vi-VN.js +1 -3
- package/lib/es/locale/zh-CN.js +1 -3
- package/lib/es/locale/zh-HK.js +1 -3
- package/lib/es/locale/zh-TW.js +1 -3
- package/lib/facade.js +6 -10
- package/lib/index.js +205 -172
- package/lib/locale/ar-SA.js +1 -3
- package/lib/locale/ca-ES.js +1 -3
- package/lib/locale/de-DE.js +1 -3
- package/lib/locale/en-US.js +1 -3
- package/lib/locale/es-ES.js +1 -3
- package/lib/locale/fa-IR.js +1 -3
- package/lib/locale/fr-FR.js +1 -3
- package/lib/locale/id-ID.js +1 -3
- package/lib/locale/it-IT.js +1 -3
- package/lib/locale/ja-JP.js +1 -3
- package/lib/locale/ko-KR.js +1 -3
- package/lib/locale/pl-PL.js +1 -3
- package/lib/locale/pt-BR.js +1 -3
- package/lib/locale/ru-RU.js +1 -3
- package/lib/locale/sk-SK.js +1 -3
- package/lib/locale/vi-VN.js +1 -3
- package/lib/locale/zh-CN.js +1 -3
- package/lib/locale/zh-HK.js +1 -3
- package/lib/locale/zh-TW.js +1 -3
- package/lib/types/controllers/render-controllers/sheet-celll-image-hover.render-controller.d.ts +3 -1
- package/lib/types/controllers/ui.controller.d.ts +6 -2
- package/lib/types/locale/en-US.d.ts +0 -2
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +1 -0
- 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 +15 -15
package/lib/es/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
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, ImageUploadStatusType, Inject, Injector, InterceptorEffectEnum, LifecycleService, LifecycleStages, LocaleService, ObjectMatrix, Optional, Plugin, PositionedObjectLayoutType, RxDisposable, Tools, UniverInstanceType, UserManagerService, WrapTextType, createDocumentModelWithStyle, createIdentifier, fromEventSubject, generateRandomId, merge, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, drawingPositionToTransform, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
|
|
2
|
+
import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, drawingPositionToTransform, getSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
|
|
3
3
|
import { CURSOR_TYPE, DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Image, ObjectType, Rect, SHEET_VIEWPORT_KEY, UniverRenderEnginePlugin, Vector2, 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
5
|
import { buildDocTransform, docDrawingPositionToTransform } from "@univerjs/docs";
|
|
6
6
|
import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, IDrawingManagerService, SetDrawingSelectedOperation, UniverDrawingPlugin, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize } from "@univerjs/drawing";
|
|
7
|
-
import { COMMAND_LISTENER_SKELETON_CHANGE, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetFrozenMutation, SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetPermissionCheckController, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorkbookViewPermission, WorksheetEditPermission, WorksheetViewPermission, attachRangeWithCoord, discreteRangeToRange, getSheetCommandTarget } from "@univerjs/sheets";
|
|
7
|
+
import { COMMAND_LISTENER_SKELETON_CHANGE, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetFrozenMutation, SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetPermissionCheckController, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorkbookViewPermission, WorksheetEditPermission, WorksheetViewPermission, attachRangeWithCoord, discreteRangeToRange, getSheetCommandTarget, isCellImage } from "@univerjs/sheets";
|
|
8
8
|
import { COPY_TYPE, EditingRenderController, HoverManagerService, IEditorBridgeService, ISheetClipboardService, ISheetSelectionRenderService, PREDEFINED_HOOK_NAME_PASTE, SetCellEditVisibleOperation, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetPrintInterceptorService, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCurrentRangeDisable$, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
|
|
9
|
-
import { CanvasFloatDomPreviewService, CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, IClipboardInterfaceService, IContextMenuService, IDialogService, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonInsertGroup,
|
|
9
|
+
import { CanvasFloatDomPreviewService, CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, IClipboardInterfaceService, IContextMenuService, IDialogService, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonInsertGroup, UndoRedoGroupService, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
10
10
|
import { COMPONENT_IMAGE_POPUP_MENU, DrawingCommonPanel, DrawingRenderService, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation, UniverDrawingUIPlugin, disposeDrawingRenderObject, insertGroupObject } from "@univerjs/drawing-ui";
|
|
11
11
|
import { BehaviorSubject, EMPTY, Subject, combineLatest, distinctUntilChanged, filter, map, of, switchMap, take, tap, throttleTime } from "rxjs";
|
|
12
12
|
import { DocDrawingController, UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
|
|
@@ -124,28 +124,23 @@ function cloneGroupParams(groupParams) {
|
|
|
124
124
|
groupParams.groups.forEach((p) => idMap.set(p.drawingId, generateRandomId(10)));
|
|
125
125
|
const clonedNestedIdRecord = {};
|
|
126
126
|
for (const [oldGroupId, entry] of Object.entries(groupParams.nestedIdRecord)) {
|
|
127
|
-
var
|
|
128
|
-
const newGroupId =
|
|
127
|
+
var _entry$children;
|
|
128
|
+
const newGroupId = idMap.get(oldGroupId) ?? oldGroupId;
|
|
129
129
|
clonedNestedIdRecord[newGroupId] = {
|
|
130
130
|
drawingId: newGroupId,
|
|
131
|
-
children: (_entry$children = entry.children) === null || _entry$children === void 0 ? void 0 : _entry$children.map((id) =>
|
|
132
|
-
var _idMap$get2;
|
|
133
|
-
return (_idMap$get2 = idMap.get(id)) !== null && _idMap$get2 !== void 0 ? _idMap$get2 : id;
|
|
134
|
-
})
|
|
131
|
+
children: (_entry$children = entry.children) === null || _entry$children === void 0 ? void 0 : _entry$children.map((id) => idMap.get(id) ?? id)
|
|
135
132
|
};
|
|
136
133
|
}
|
|
137
134
|
const flatChildren = [];
|
|
138
135
|
const groups = [];
|
|
139
136
|
for (const group of groupParams.groups) {
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
const parentGroupId = group.groupId ? (_idMap$get4 = idMap.get(group.groupId)) !== null && _idMap$get4 !== void 0 ? _idMap$get4 : group.groupId : void 0;
|
|
137
|
+
const groupDrawingId = idMap.get(group.drawingId) ?? group.drawingId;
|
|
138
|
+
const parentGroupId = group.groupId ? idMap.get(group.groupId) ?? group.groupId : void 0;
|
|
143
139
|
groups.push(cloneDrawingParam(group, groupDrawingId, parentGroupId));
|
|
144
140
|
}
|
|
145
141
|
for (const child of groupParams.flatChildren || []) {
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
const parentGroupId = child.groupId ? (_idMap$get6 = idMap.get(child.groupId)) !== null && _idMap$get6 !== void 0 ? _idMap$get6 : child.groupId : void 0;
|
|
142
|
+
const childDrawingId = idMap.get(child.drawingId) ?? child.drawingId;
|
|
143
|
+
const parentGroupId = child.groupId ? idMap.get(child.groupId) ?? child.groupId : void 0;
|
|
149
144
|
flatChildren.push(cloneDrawingParam(child, childDrawingId, parentGroupId));
|
|
150
145
|
}
|
|
151
146
|
return {
|
|
@@ -448,7 +443,6 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
|
|
|
448
443
|
return this._insertCellImage(file, location);
|
|
449
444
|
}
|
|
450
445
|
async insertFloatImageByFile(file) {
|
|
451
|
-
var _transformToAxisAlign;
|
|
452
446
|
let imageParam;
|
|
453
447
|
try {
|
|
454
448
|
imageParam = await this._imageIoService.saveImage(file);
|
|
@@ -495,7 +489,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
|
|
|
495
489
|
source,
|
|
496
490
|
transform: newTransform,
|
|
497
491
|
sheetTransform,
|
|
498
|
-
axisAlignSheetTransform:
|
|
492
|
+
axisAlignSheetTransform: transformToAxisAlignPosition(newTransform, skeleton) ?? sheetTransform
|
|
499
493
|
};
|
|
500
494
|
return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
|
|
501
495
|
unitId,
|
|
@@ -571,10 +565,9 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
|
|
|
571
565
|
}
|
|
572
566
|
});
|
|
573
567
|
if (jsonXActions) {
|
|
574
|
-
var _location$row, _location$col;
|
|
575
568
|
docDataModel.apply(jsonXActions);
|
|
576
569
|
return this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, {
|
|
577
|
-
value: { [(
|
|
570
|
+
value: { [(location === null || location === void 0 ? void 0 : location.row) ?? row]: { [(location === null || location === void 0 ? void 0 : location.col) ?? col]: {
|
|
578
571
|
p: docDataModel.getSnapshot(),
|
|
579
572
|
t: 1
|
|
580
573
|
} } },
|
|
@@ -633,10 +626,9 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
|
|
|
633
626
|
}
|
|
634
627
|
});
|
|
635
628
|
if (jsonXActions) {
|
|
636
|
-
var _location$row2, _location$col2;
|
|
637
629
|
docDataModel.apply(jsonXActions);
|
|
638
630
|
return this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, {
|
|
639
|
-
value: { [(
|
|
631
|
+
value: { [(location === null || location === void 0 ? void 0 : location.row) ?? selection.primary.actualRow]: { [(location === null || location === void 0 ? void 0 : location.col) ?? selection.primary.actualColumn]: {
|
|
640
632
|
p: docDataModel.getSnapshot(),
|
|
641
633
|
t: 1
|
|
642
634
|
} } },
|
|
@@ -888,20 +880,17 @@ const InsertFloatImageCommand = {
|
|
|
888
880
|
if (files) {
|
|
889
881
|
const awaitFiles = files.map((file) => sheetDrawingUpdateController.insertFloatImageByFile(file));
|
|
890
882
|
return (await Promise.all(awaitFiles)).every((result) => result);
|
|
891
|
-
} else
|
|
892
|
-
var _sheetDrawingUpdateCo;
|
|
893
|
-
return (_sheetDrawingUpdateCo = sheetDrawingUpdateController.insertFloatImage()) !== null && _sheetDrawingUpdateCo !== void 0 ? _sheetDrawingUpdateCo : false;
|
|
894
|
-
}
|
|
883
|
+
} else return sheetDrawingUpdateController.insertFloatImage() ?? false;
|
|
895
884
|
}
|
|
896
885
|
};
|
|
897
886
|
const InsertCellImageCommand = {
|
|
898
887
|
id: "sheet.command.insert-cell-image",
|
|
899
888
|
type: CommandType.COMMAND,
|
|
900
889
|
handler: (accessor) => {
|
|
901
|
-
var _getCurrentTypeOfRend2
|
|
890
|
+
var _getCurrentTypeOfRend2;
|
|
902
891
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
903
892
|
const renderManagerService = accessor.get(IRenderManagerService);
|
|
904
|
-
return (_getCurrentTypeOfRend2 =
|
|
893
|
+
return ((_getCurrentTypeOfRend2 = getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET, univerInstanceService, renderManagerService)) === null || _getCurrentTypeOfRend2 === void 0 ? void 0 : _getCurrentTypeOfRend2.with(SheetDrawingUpdateController).insertCellImage()) ?? false;
|
|
905
894
|
}
|
|
906
895
|
};
|
|
907
896
|
|
|
@@ -914,6 +903,7 @@ const MoveDrawingsCommand = {
|
|
|
914
903
|
const commandService = accessor.get(ICommandService);
|
|
915
904
|
const drawingManagerService = accessor.get(ISheetDrawingService);
|
|
916
905
|
const sheetSkeletonService = accessor.get(SheetSkeletonService);
|
|
906
|
+
const undoRedoGroupService = accessor.get(UndoRedoGroupService);
|
|
917
907
|
const { direction } = params;
|
|
918
908
|
const drawings = drawingManagerService.getFocusDrawings();
|
|
919
909
|
if (drawings.length === 0) return false;
|
|
@@ -935,10 +925,10 @@ const MoveDrawingsCommand = {
|
|
|
935
925
|
axisAlignSheetTransform: transformToAxisAlignPosition(newTransform, skeleton)
|
|
936
926
|
};
|
|
937
927
|
}).filter((drawing) => drawing != null);
|
|
938
|
-
if (commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
|
|
928
|
+
if (undoRedoGroupService.runTimed(unitId, `sheet-drawing:nudge:${drawings[0].subUnitId}:${drawings.map((drawing) => drawing.drawingId).sort().join(",")}`, () => commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
|
|
939
929
|
unitId,
|
|
940
930
|
drawings: newDrawings
|
|
941
|
-
})) {
|
|
931
|
+
}))) {
|
|
942
932
|
commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]);
|
|
943
933
|
return true;
|
|
944
934
|
}
|
|
@@ -990,20 +980,14 @@ function rangeToA1Notation(range) {
|
|
|
990
980
|
return start === end ? start : `${start}:${end}`;
|
|
991
981
|
}
|
|
992
982
|
/**
|
|
993
|
-
* Check if a cell has image
|
|
994
|
-
*/
|
|
995
|
-
function cellHasImage$1(cell) {
|
|
996
|
-
var _cell$p, _cell$p2;
|
|
997
|
-
return !!((cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.drawingsOrder) === null || _cell$p === void 0 ? void 0 : _cell$p.length) && (cell === null || cell === void 0 || (_cell$p2 = cell.p) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.drawingsOrder) === null || _cell$p2 === void 0 ? void 0 : _cell$p2.length) > 0);
|
|
998
|
-
}
|
|
999
|
-
/**
|
|
1000
983
|
* Get image data from cell
|
|
1001
984
|
*/
|
|
1002
985
|
function getCellImageData(cell) {
|
|
1003
|
-
var
|
|
1004
|
-
|
|
1005
|
-
const drawingId =
|
|
1006
|
-
|
|
986
|
+
var _documentData$drawing;
|
|
987
|
+
const documentData = cell.p;
|
|
988
|
+
const drawingId = documentData === null || documentData === void 0 || (_documentData$drawing = documentData.drawingsOrder) === null || _documentData$drawing === void 0 ? void 0 : _documentData$drawing[0];
|
|
989
|
+
if (!isCellImage(documentData) || !drawingId || !(documentData === null || documentData === void 0 ? void 0 : documentData.drawings)) return null;
|
|
990
|
+
const drawing = documentData.drawings[drawingId];
|
|
1007
991
|
if (!drawing || !("source" in drawing) || !("imageSourceType" in drawing)) return null;
|
|
1008
992
|
return drawing;
|
|
1009
993
|
}
|
|
@@ -1050,7 +1034,7 @@ let BatchSaveImagesService = class BatchSaveImagesService extends Disposable {
|
|
|
1050
1034
|
const { startRow, endRow, startColumn, endColumn } = selection.range;
|
|
1051
1035
|
for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
|
|
1052
1036
|
const cell = cellMatrix.getValue(row, col);
|
|
1053
|
-
if (
|
|
1037
|
+
if (isCellImage(cell === null || cell === void 0 ? void 0 : cell.p)) {
|
|
1054
1038
|
const imageData = getCellImageData(cell);
|
|
1055
1039
|
if (imageData) images.push({
|
|
1056
1040
|
row,
|
|
@@ -1076,7 +1060,7 @@ let BatchSaveImagesService = class BatchSaveImagesService extends Disposable {
|
|
|
1076
1060
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
1077
1061
|
for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
|
|
1078
1062
|
const cell = cellMatrix.getValue(row, col);
|
|
1079
|
-
if (
|
|
1063
|
+
if (isCellImage(cell === null || cell === void 0 ? void 0 : cell.p)) {
|
|
1080
1064
|
const imageData = getCellImageData(cell);
|
|
1081
1065
|
if (imageData) images.push({
|
|
1082
1066
|
row,
|
|
@@ -1114,8 +1098,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends Disposable {
|
|
|
1114
1098
|
for (let row = minRow; row <= maxRow; row++) {
|
|
1115
1099
|
const cell = cellMatrix.getValue(row, col);
|
|
1116
1100
|
if (cell) {
|
|
1117
|
-
var _cell$v, _cell$
|
|
1118
|
-
if (((_cell$v = cell.v) === null || _cell$v === void 0 ? void 0 : _cell$v.toString()) || ((_cell$
|
|
1101
|
+
var _cell$v, _cell$p;
|
|
1102
|
+
if (((_cell$v = cell.v) === null || _cell$v === void 0 ? void 0 : _cell$v.toString()) || ((_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.body) === null || _cell$p === void 0 || (_cell$p = _cell$p.dataStream) === null || _cell$p === void 0 ? void 0 : _cell$p.trim()) || "") {
|
|
1119
1103
|
columnsWithData.add(col);
|
|
1120
1104
|
break;
|
|
1121
1105
|
}
|
|
@@ -1151,8 +1135,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends Disposable {
|
|
|
1151
1135
|
for (let row = minRow; row <= maxRow; row++) {
|
|
1152
1136
|
const cell = cellMatrix.getValue(row, col);
|
|
1153
1137
|
if (cell) {
|
|
1154
|
-
var _cell$v2, _cell$
|
|
1155
|
-
if (((_cell$v2 = cell.v) === null || _cell$v2 === void 0 ? void 0 : _cell$v2.toString()) || ((_cell$
|
|
1138
|
+
var _cell$v2, _cell$p2;
|
|
1139
|
+
if (((_cell$v2 = cell.v) === null || _cell$v2 === void 0 ? void 0 : _cell$v2.toString()) || ((_cell$p2 = cell.p) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.body) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.dataStream) === null || _cell$p2 === void 0 ? void 0 : _cell$p2.trim()) || "") {
|
|
1156
1140
|
columnsWithData.add(col);
|
|
1157
1141
|
break;
|
|
1158
1142
|
}
|
|
@@ -1203,8 +1187,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends Disposable {
|
|
|
1203
1187
|
if (worksheet) {
|
|
1204
1188
|
const cell = worksheet.getCellMatrix().getValue(imageInfo.row, config.columnIndex);
|
|
1205
1189
|
if (cell) {
|
|
1206
|
-
var _cell$v3, _cell$
|
|
1207
|
-
const value = ((_cell$v3 = cell.v) === null || _cell$v3 === void 0 ? void 0 : _cell$v3.toString()) || ((_cell$
|
|
1190
|
+
var _cell$v3, _cell$p3;
|
|
1191
|
+
const value = ((_cell$v3 = cell.v) === null || _cell$v3 === void 0 ? void 0 : _cell$v3.toString()) || ((_cell$p3 = cell.p) === null || _cell$p3 === void 0 || (_cell$p3 = _cell$p3.body) === null || _cell$p3 === void 0 || (_cell$p3 = _cell$p3.dataStream) === null || _cell$p3 === void 0 ? void 0 : _cell$p3.trim()) || "";
|
|
1208
1192
|
if (value) {
|
|
1209
1193
|
const sanitized = value.replace(/[<>:"/\\|?*]/g, "_").trim();
|
|
1210
1194
|
if (sanitized) parts.push(sanitized);
|
|
@@ -1225,8 +1209,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends Disposable {
|
|
|
1225
1209
|
if (worksheet) {
|
|
1226
1210
|
const cell = worksheet.getCellMatrix().getValue(imageInfo.row, config.columnIndex);
|
|
1227
1211
|
if (cell) {
|
|
1228
|
-
var _cell$v4, _cell$
|
|
1229
|
-
const value = ((_cell$v4 = cell.v) === null || _cell$v4 === void 0 ? void 0 : _cell$v4.toString()) || ((_cell$
|
|
1212
|
+
var _cell$v4, _cell$p4;
|
|
1213
|
+
const value = ((_cell$v4 = cell.v) === null || _cell$v4 === void 0 ? void 0 : _cell$v4.toString()) || ((_cell$p4 = cell.p) === null || _cell$p4 === void 0 || (_cell$p4 = _cell$p4.body) === null || _cell$p4 === void 0 || (_cell$p4 = _cell$p4.dataStream) === null || _cell$p4 === void 0 ? void 0 : _cell$p4.trim()) || "";
|
|
1230
1214
|
if (value) {
|
|
1231
1215
|
const sanitized = value.replace(/[<>:"/\\|?*]/g, "_").trim();
|
|
1232
1216
|
if (sanitized) parts.push(sanitized);
|
|
@@ -1391,21 +1375,24 @@ const SidebarSheetDrawingOperation = {
|
|
|
1391
1375
|
const sidebarService = accessor.get(ISidebarService);
|
|
1392
1376
|
const localeService = accessor.get(LocaleService);
|
|
1393
1377
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
1378
|
+
const drawingManagerService = accessor.get(IDrawingManagerService);
|
|
1394
1379
|
const commandService = accessor.get(ICommandService);
|
|
1395
1380
|
if (!getSheetCommandTarget(univerInstanceService)) return false;
|
|
1396
1381
|
switch (params.value) {
|
|
1397
1382
|
case "open":
|
|
1398
1383
|
sidebarService.open({
|
|
1384
|
+
id: COMPONENT_SHEET_DRAWING_PANEL,
|
|
1399
1385
|
header: { title: localeService.t("sheets-drawing-ui.panel.title") },
|
|
1400
1386
|
children: { label: COMPONENT_SHEET_DRAWING_PANEL },
|
|
1401
1387
|
onClose: () => {
|
|
1402
|
-
|
|
1388
|
+
const focusedDrawings = drawingManagerService.getFocusDrawings();
|
|
1389
|
+
if (focusedDrawings.length === 1 && focusedDrawings[0].drawingType === DrawingTypeEnum.DRAWING_IMAGE) commandService.syncExecuteCommand(SetDrawingSelectedOperation.id, []);
|
|
1403
1390
|
},
|
|
1404
1391
|
width: 360
|
|
1405
1392
|
});
|
|
1406
1393
|
break;
|
|
1407
1394
|
default:
|
|
1408
|
-
sidebarService.close();
|
|
1395
|
+
sidebarService.close(COMPONENT_SHEET_DRAWING_PANEL);
|
|
1409
1396
|
break;
|
|
1410
1397
|
}
|
|
1411
1398
|
return true;
|
|
@@ -1508,7 +1495,6 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
|
|
|
1508
1495
|
};
|
|
1509
1496
|
}
|
|
1510
1497
|
_generateGroupPasteMutations(pasteTo) {
|
|
1511
|
-
var _cloned$flatChildren;
|
|
1512
1498
|
if (!this._copyInfo) return {
|
|
1513
1499
|
redos: [],
|
|
1514
1500
|
undos: []
|
|
@@ -1539,12 +1525,11 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
|
|
|
1539
1525
|
left: pasteRect.startX,
|
|
1540
1526
|
top: pasteRect.startY
|
|
1541
1527
|
};
|
|
1542
|
-
const allDrawings = [...(
|
|
1528
|
+
const allDrawings = [...(cloned.flatChildren ?? []).map((d) => ({
|
|
1543
1529
|
...d,
|
|
1544
1530
|
unitId,
|
|
1545
1531
|
subUnitId
|
|
1546
1532
|
})), ...cloned.groups.map((d) => {
|
|
1547
|
-
var _transformToDrawingPo, _transformToAxisAlign;
|
|
1548
1533
|
if (d.drawingId !== newRootGroupId) return {
|
|
1549
1534
|
...d,
|
|
1550
1535
|
unitId,
|
|
@@ -1555,8 +1540,8 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
|
|
|
1555
1540
|
unitId,
|
|
1556
1541
|
subUnitId,
|
|
1557
1542
|
transform: newTransform,
|
|
1558
|
-
sheetTransform:
|
|
1559
|
-
axisAlignSheetTransform:
|
|
1543
|
+
sheetTransform: transformToDrawingPosition(newTransform, pasteToSkeleton) ?? origRootGroup.sheetTransform,
|
|
1544
|
+
axisAlignSheetTransform: transformToAxisAlignPosition(newTransform, pasteToSkeleton) ?? origRootGroup.sheetTransform
|
|
1560
1545
|
};
|
|
1561
1546
|
})];
|
|
1562
1547
|
const { undo: removeOp, redo: insertOp, objects } = this._sheetDrawingService.getBatchAddOp(allDrawings);
|
|
@@ -1680,14 +1665,13 @@ function shouldStartFloatDomMoveFromHandle(info, detail) {
|
|
|
1680
1665
|
return detail.hostAnchorId === info.id && (detail.hostUnitId == null || detail.hostUnitId === info.unitId) && (detail.button == null || detail.button === 0) && typeof detail.clientX === "number" && typeof detail.clientY === "number";
|
|
1681
1666
|
}
|
|
1682
1667
|
function createFloatDomMoveDragState(info, detail) {
|
|
1683
|
-
var _info$rect$left, _info$rect$top;
|
|
1684
1668
|
if (typeof detail.clientX !== "number" || typeof detail.clientY !== "number") return;
|
|
1685
1669
|
return {
|
|
1686
1670
|
pointerId: detail.pointerId,
|
|
1687
1671
|
startClientX: detail.clientX,
|
|
1688
1672
|
startClientY: detail.clientY,
|
|
1689
|
-
startLeft: Number(
|
|
1690
|
-
startTop: Number(
|
|
1673
|
+
startLeft: Number(info.rect.left ?? 0),
|
|
1674
|
+
startTop: Number(info.rect.top ?? 0)
|
|
1691
1675
|
};
|
|
1692
1676
|
}
|
|
1693
1677
|
function resolveFloatDomMoveDragTransform(state, event, scene) {
|
|
@@ -1969,8 +1953,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
1969
1953
|
* default {@link Rect} fallback.
|
|
1970
1954
|
*/
|
|
1971
1955
|
registerRenderObjectFactory(drawingType, factory) {
|
|
1972
|
-
|
|
1973
|
-
const factories = (_this$_renderObjectFa = this._renderObjectFactories.get(drawingType)) !== null && _this$_renderObjectFa !== void 0 ? _this$_renderObjectFa : [];
|
|
1956
|
+
const factories = this._renderObjectFactories.get(drawingType) ?? [];
|
|
1974
1957
|
factories.push(factory);
|
|
1975
1958
|
this._renderObjectFactories.set(drawingType, factories);
|
|
1976
1959
|
return { dispose: () => {
|
|
@@ -1982,10 +1965,9 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
1982
1965
|
} };
|
|
1983
1966
|
}
|
|
1984
1967
|
_createRenderObject(context) {
|
|
1985
|
-
var _factory;
|
|
1986
1968
|
const factories = this._renderObjectFactories.get(context.drawingType);
|
|
1987
1969
|
const factory = factories === null || factories === void 0 ? void 0 : factories[factories.length - 1];
|
|
1988
|
-
return (
|
|
1970
|
+
return (factory === null || factory === void 0 ? void 0 : factory(context)) ?? new Rect(context.key, context.config);
|
|
1989
1971
|
}
|
|
1990
1972
|
_bindScrollEvent() {
|
|
1991
1973
|
this._lifecycleService.lifecycle$.pipe(filter((s) => s === LifecycleStages.Rendered), take(1)).subscribe(() => {
|
|
@@ -2313,7 +2295,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2313
2295
|
if (data && data.border) imageConfig.stroke = data.border;
|
|
2314
2296
|
Object.assign(imageConfig, SHEET_CHART_RENDER_OBJECT_CONFIG);
|
|
2315
2297
|
} else imageConfig.rotateEnabled = false;
|
|
2316
|
-
const rect = rectShape
|
|
2298
|
+
const rect = rectShape ?? this._createRenderObject({
|
|
2317
2299
|
key: rectShapeKey,
|
|
2318
2300
|
config: imageConfig,
|
|
2319
2301
|
unitId,
|
|
@@ -2463,6 +2445,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2463
2445
|
if (previewObjectKey) scene.removeObject(previewObjectKey);
|
|
2464
2446
|
});
|
|
2465
2447
|
listener && disposableCollection.add(listener);
|
|
2448
|
+
this._bindFloatDomScroll(disposableCollection, info, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
|
|
2466
2449
|
this._domLayerInfoMap.set(drawingId, info);
|
|
2467
2450
|
});
|
|
2468
2451
|
}));
|
|
@@ -2515,23 +2498,6 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2515
2498
|
this._syncFloatDomVisibilityForActiveSheet(unitId, subUnitId);
|
|
2516
2499
|
updateSheet(unitId, subUnitId);
|
|
2517
2500
|
}));
|
|
2518
|
-
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => workbook ? workbook.activeSheet$ : of(null)), map((worksheet) => {
|
|
2519
|
-
if (!worksheet) return null;
|
|
2520
|
-
const unitId = worksheet.getUnitId();
|
|
2521
|
-
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
2522
|
-
return render ? {
|
|
2523
|
-
render,
|
|
2524
|
-
unitId,
|
|
2525
|
-
subUnitId: worksheet.getSheetId()
|
|
2526
|
-
} : null;
|
|
2527
|
-
}), switchMap((render) => render ? fromEventSubject(render.render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(map(() => ({
|
|
2528
|
-
unitId: render.unitId,
|
|
2529
|
-
subUnitId: render.subUnitId
|
|
2530
|
-
}))) : of(null))).subscribe((value) => {
|
|
2531
|
-
if (!value) return;
|
|
2532
|
-
const { unitId, subUnitId } = value;
|
|
2533
|
-
updateSheet(unitId, subUnitId);
|
|
2534
|
-
}));
|
|
2535
2501
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
2536
2502
|
if (commandInfo.id === SetZoomRatioOperation.id) {
|
|
2537
2503
|
const { unitId } = commandInfo.params;
|
|
@@ -2547,6 +2513,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2547
2513
|
}
|
|
2548
2514
|
}));
|
|
2549
2515
|
}
|
|
2516
|
+
_bindFloatDomScroll(disposableCollection, info, scene, skeleton, worksheet) {
|
|
2517
|
+
const viewport = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
2518
|
+
if (!viewport) return;
|
|
2519
|
+
disposableCollection.add(fromEventSubject(viewport.onScrollAfter$).subscribe(() => {
|
|
2520
|
+
info.position$.next(calcSheetFloatDomPosition(info.rect, scene, skeleton, worksheet, info));
|
|
2521
|
+
}));
|
|
2522
|
+
}
|
|
2550
2523
|
updateFloatDomProps(unitId, subUnitId, id, props) {
|
|
2551
2524
|
const info = this._domLayerInfoMap.get(id);
|
|
2552
2525
|
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
@@ -2576,13 +2549,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2576
2549
|
}
|
|
2577
2550
|
}
|
|
2578
2551
|
_getObjectIncludingGroup(scene, key, groupKey) {
|
|
2579
|
-
var
|
|
2580
|
-
return
|
|
2552
|
+
var _scene$getObjectInclu;
|
|
2553
|
+
return this._getChildObjectFromGroup(scene, key, groupKey) ?? ((_scene$getObjectInclu = scene.getObjectIncludeInGroup) === null || _scene$getObjectInclu === void 0 ? void 0 : _scene$getObjectInclu.call(scene, key)) ?? scene.getObject(key) ?? null;
|
|
2581
2554
|
}
|
|
2582
2555
|
_getChildObjectFromGroup(scene, key, groupKey) {
|
|
2583
|
-
var _scene$getObjectInclu2
|
|
2556
|
+
var _scene$getObjectInclu2;
|
|
2584
2557
|
if (!groupKey) return null;
|
|
2585
|
-
const groupObject = (_scene$getObjectInclu2 =
|
|
2558
|
+
const groupObject = ((_scene$getObjectInclu2 = scene.getObjectIncludeInGroup) === null || _scene$getObjectInclu2 === void 0 ? void 0 : _scene$getObjectInclu2.call(scene, groupKey)) ?? scene.getObject(groupKey);
|
|
2586
2559
|
return this._findChildObject(groupObject, key);
|
|
2587
2560
|
}
|
|
2588
2561
|
_findChildObject(object, key) {
|
|
@@ -2606,10 +2579,9 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2606
2579
|
if (info) info.rect = object;
|
|
2607
2580
|
}
|
|
2608
2581
|
_getChartDataBackground(data) {
|
|
2609
|
-
var _record$backgroundCol;
|
|
2610
2582
|
if (!data || typeof data !== "object" || Array.isArray(data)) return;
|
|
2611
2583
|
const record = data;
|
|
2612
|
-
const background =
|
|
2584
|
+
const background = record.backgroundColor ?? record.background;
|
|
2613
2585
|
return typeof background === "string" ? background : void 0;
|
|
2614
2586
|
}
|
|
2615
2587
|
_getPosition(position, unitId) {
|
|
@@ -2682,7 +2654,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2682
2654
|
if (!target) throw new Error("cannot find current target!");
|
|
2683
2655
|
const { unitId, subUnitId } = target;
|
|
2684
2656
|
const { initPosition, componentKey, data, allowTransform = true } = layer;
|
|
2685
|
-
const id = propId
|
|
2657
|
+
const id = propId ?? generateRandomId();
|
|
2686
2658
|
const sheetTransform = this._getPosition(initPosition, unitId);
|
|
2687
2659
|
if (sheetTransform == null) return;
|
|
2688
2660
|
const sheetDrawingParam = {
|
|
@@ -2767,7 +2739,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2767
2739
|
const skeletonParam = (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2768
2740
|
if (!skeletonParam) return;
|
|
2769
2741
|
const { componentKey, data, allowTransform = true } = config;
|
|
2770
|
-
const id = propId
|
|
2742
|
+
const id = propId ?? generateRandomId();
|
|
2771
2743
|
const { position: rangePosition, position$: rangePos$ } = this._createRangePositionObserver(range, currentRender, skeletonParam.skeleton);
|
|
2772
2744
|
const sheetTransform = this._getPosition(rangePosition, unitId);
|
|
2773
2745
|
if (sheetTransform == null) return;
|
|
@@ -2925,15 +2897,14 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2925
2897
|
};
|
|
2926
2898
|
this._canvasFloatDomService.addFloatDom(floatDomCfg);
|
|
2927
2899
|
this.disposeWithMe(rangePos$.subscribe((newRangePos) => {
|
|
2928
|
-
var _domAnchor$width, _domAnchor$height, _domAnchor$width2, _domAnchor$height2;
|
|
2929
2900
|
const calcOffsetPos = calcDomPositionByAnchor({
|
|
2930
2901
|
rotate: 0,
|
|
2931
2902
|
startX: newRangePos.startX,
|
|
2932
2903
|
startY: newRangePos.startY,
|
|
2933
2904
|
endX: newRangePos.endX,
|
|
2934
2905
|
endY: newRangePos.endY,
|
|
2935
|
-
width:
|
|
2936
|
-
height:
|
|
2906
|
+
width: domAnchor.width ?? newRangePos.width,
|
|
2907
|
+
height: domAnchor.height ?? newRangePos.height,
|
|
2937
2908
|
absolute: {
|
|
2938
2909
|
left: rangePosition.absolute.left,
|
|
2939
2910
|
top: rangePosition.absolute.top
|
|
@@ -2946,8 +2917,8 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2946
2917
|
}), {
|
|
2947
2918
|
left: calcOffsetPos.startX,
|
|
2948
2919
|
top: calcOffsetPos.startY,
|
|
2949
|
-
width:
|
|
2950
|
-
height:
|
|
2920
|
+
width: domAnchor.width ?? newRangePos.width,
|
|
2921
|
+
height: domAnchor.height ?? newRangePos.height,
|
|
2951
2922
|
zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
|
|
2952
2923
|
});
|
|
2953
2924
|
const newPos = calcSheetFloatDomPosition(newRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
|
|
@@ -2967,6 +2938,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2967
2938
|
this._canvasFloatDomService.removeFloatDom(drawingId);
|
|
2968
2939
|
});
|
|
2969
2940
|
listener && disposableCollection.add(listener);
|
|
2941
|
+
this._bindFloatDomScroll(disposableCollection, floatDomInfo, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet);
|
|
2970
2942
|
this._domLayerInfoMap.set(drawingId, floatDomInfo);
|
|
2971
2943
|
}
|
|
2972
2944
|
return this._createFloatDomDisposable(id);
|
|
@@ -2985,7 +2957,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2985
2957
|
const skeletonParam = (_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS8 === void 0 ? void 0 : _this$_renderManagerS8.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2986
2958
|
if (!skeletonParam) return;
|
|
2987
2959
|
const { componentKey, data, allowTransform = true } = config;
|
|
2988
|
-
const id = propId
|
|
2960
|
+
const id = propId ?? generateRandomId();
|
|
2989
2961
|
const { position: rangePosition, position$: rangePos$ } = this._createRangePositionObserver({
|
|
2990
2962
|
startRow: 0,
|
|
2991
2963
|
endRow: 0,
|
|
@@ -3166,6 +3138,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3166
3138
|
this._canvasFloatDomService.removeFloatDom(drawingId);
|
|
3167
3139
|
});
|
|
3168
3140
|
listener && disposableCollection.add(listener);
|
|
3141
|
+
this._bindFloatDomScroll(disposableCollection, floatDomInfo, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
|
|
3169
3142
|
this._domLayerInfoMap.set(drawingId, floatDomInfo);
|
|
3170
3143
|
}
|
|
3171
3144
|
return this._createFloatDomDisposable(id);
|
|
@@ -3281,12 +3254,11 @@ function calcCellPositionByCell(row, col, skeleton) {
|
|
|
3281
3254
|
};
|
|
3282
3255
|
}
|
|
3283
3256
|
function calcDomPositionByAnchor(rangePosition, domAnchor, scale) {
|
|
3284
|
-
|
|
3285
|
-
scale = (_scale = scale) !== null && _scale !== void 0 ? _scale : 1;
|
|
3257
|
+
scale = scale ?? 1;
|
|
3286
3258
|
const rangeWidth = rangePosition.endX - rangePosition.startX;
|
|
3287
3259
|
const rangeHeight = rangePosition.endY - rangePosition.startY;
|
|
3288
|
-
const domWidth = (
|
|
3289
|
-
const domHeight = (
|
|
3260
|
+
const domWidth = (domAnchor === null || domAnchor === void 0 ? void 0 : domAnchor.width) ?? rangeWidth;
|
|
3261
|
+
const domHeight = (domAnchor === null || domAnchor === void 0 ? void 0 : domAnchor.height) ?? rangeHeight;
|
|
3290
3262
|
let domLeft = 0;
|
|
3291
3263
|
let domTop = 0;
|
|
3292
3264
|
if (domAnchor) {
|
|
@@ -3381,13 +3353,6 @@ function UploadCellImageMenuFactory(accessor) {
|
|
|
3381
3353
|
//#endregion
|
|
3382
3354
|
//#region src/menu/save-images.menu.ts
|
|
3383
3355
|
/**
|
|
3384
|
-
* Check if a cell has image
|
|
3385
|
-
*/
|
|
3386
|
-
function cellHasImage(cell) {
|
|
3387
|
-
var _cell$p, _cell$p2;
|
|
3388
|
-
return !!((cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.drawingsOrder) === null || _cell$p === void 0 ? void 0 : _cell$p.length) && (cell === null || cell === void 0 || (_cell$p2 = cell.p) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.drawingsOrder) === null || _cell$p2 === void 0 ? void 0 : _cell$p2.length) > 0);
|
|
3389
|
-
}
|
|
3390
|
-
/**
|
|
3391
3356
|
* Check if selection range has any images
|
|
3392
3357
|
*/
|
|
3393
3358
|
function selectionHasImages(workbook, selection) {
|
|
@@ -3395,7 +3360,10 @@ function selectionHasImages(workbook, selection) {
|
|
|
3395
3360
|
if (!worksheet) return false;
|
|
3396
3361
|
const cellMatrix = worksheet.getCellMatrix();
|
|
3397
3362
|
const { startRow, endRow, startColumn, endColumn } = selection;
|
|
3398
|
-
for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++)
|
|
3363
|
+
for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
|
|
3364
|
+
const cell = cellMatrix.getValue(row, col);
|
|
3365
|
+
if (isCellImage(cell === null || cell === void 0 ? void 0 : cell.p)) return true;
|
|
3366
|
+
}
|
|
3399
3367
|
return false;
|
|
3400
3368
|
}
|
|
3401
3369
|
/**
|
|
@@ -3464,7 +3432,7 @@ const menuSchema = {
|
|
|
3464
3432
|
//#endregion
|
|
3465
3433
|
//#region package.json
|
|
3466
3434
|
var name = "@univerjs/sheets-drawing-ui";
|
|
3467
|
-
var version = "1.0.0-
|
|
3435
|
+
var version = "1.0.0-beta.1";
|
|
3468
3436
|
|
|
3469
3437
|
//#endregion
|
|
3470
3438
|
//#region src/config/config.ts
|
|
@@ -3599,18 +3567,17 @@ function BatchSaveImagesDialog() {
|
|
|
3599
3567
|
//#endregion
|
|
3600
3568
|
//#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
|
|
3601
3569
|
const SheetDrawingAnchor = (props) => {
|
|
3602
|
-
var _drawingParam$anchorT;
|
|
3603
3570
|
const commandService = useDependency(ICommandService);
|
|
3604
3571
|
const localeService = useDependency(LocaleService);
|
|
3605
3572
|
const drawingManagerService = useDependency(IDrawingManagerService);
|
|
3606
3573
|
const renderManagerService = useDependency(IRenderManagerService);
|
|
3607
3574
|
const { drawings } = props;
|
|
3608
|
-
const drawingParam = drawings[0];
|
|
3575
|
+
const drawingParam = isSheetDrawing(drawings[0]) ? drawings[0] : void 0;
|
|
3609
3576
|
const renderObject = drawingParam ? renderManagerService.getRenderUnitById(drawingParam.unitId) : void 0;
|
|
3610
3577
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
3611
3578
|
const transformer = scene === null || scene === void 0 ? void 0 : scene.getTransformerByCreate();
|
|
3612
3579
|
const [anchorShow, setAnchorShow] = useState(true);
|
|
3613
|
-
const [value, setValue] = useState(
|
|
3580
|
+
const [value, setValue] = useState(drawingParam ? getSheetDrawingPlacement(drawingParam).kind : SheetDrawingAnchorType.Position);
|
|
3614
3581
|
function getUpdateParams(objects, drawingManagerService) {
|
|
3615
3582
|
const params = [];
|
|
3616
3583
|
objects.forEach((object) => {
|
|
@@ -3620,6 +3587,10 @@ const SheetDrawingAnchor = (props) => {
|
|
|
3620
3587
|
params.push(null);
|
|
3621
3588
|
return true;
|
|
3622
3589
|
}
|
|
3590
|
+
if (!isSheetDrawing(searchParam)) {
|
|
3591
|
+
params.push(null);
|
|
3592
|
+
return true;
|
|
3593
|
+
}
|
|
3623
3594
|
const { unitId, subUnitId, drawingId, drawingType, anchorType, sheetTransform, axisAlignSheetTransform } = searchParam;
|
|
3624
3595
|
params.push({
|
|
3625
3596
|
unitId,
|
|
@@ -3643,10 +3614,9 @@ const SheetDrawingAnchor = (props) => {
|
|
|
3643
3614
|
const params = getUpdateParams(objects, drawingManagerService);
|
|
3644
3615
|
if (params.length === 0) setAnchorShow(false);
|
|
3645
3616
|
else if (params.length >= 1) {
|
|
3646
|
-
var _params$;
|
|
3647
3617
|
setAnchorShow(true);
|
|
3648
|
-
const
|
|
3649
|
-
setValue(
|
|
3618
|
+
const drawing = params[0];
|
|
3619
|
+
setValue(drawing ? getSheetDrawingPlacement(drawing).kind : SheetDrawingAnchorType.Position);
|
|
3650
3620
|
}
|
|
3651
3621
|
});
|
|
3652
3622
|
return () => {
|
|
@@ -3656,21 +3626,34 @@ const SheetDrawingAnchor = (props) => {
|
|
|
3656
3626
|
}, [drawingManagerService, transformer]);
|
|
3657
3627
|
if (!drawingParam || !transformer) return null;
|
|
3658
3628
|
function handleChange(value) {
|
|
3659
|
-
|
|
3629
|
+
const kind = getAnchorKind(value);
|
|
3630
|
+
if (!kind) return;
|
|
3660
3631
|
const focusDrawings = drawingManagerService.getFocusDrawings();
|
|
3661
|
-
if (focusDrawings.length
|
|
3662
|
-
const
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3632
|
+
if (!focusDrawings.length || !focusDrawings.every(isSheetDrawing)) return;
|
|
3633
|
+
const { unitId, subUnitId } = focusDrawings[0];
|
|
3634
|
+
const placementUpdates = [];
|
|
3635
|
+
for (const drawing of focusDrawings) {
|
|
3636
|
+
const { transform } = drawing;
|
|
3637
|
+
const { left, top, width, height } = transform ?? {};
|
|
3638
|
+
if (typeof left !== "number" || typeof top !== "number" || typeof width !== "number" || typeof height !== "number" || !Number.isFinite(left) || !Number.isFinite(top) || !Number.isFinite(width) || !Number.isFinite(height)) return;
|
|
3639
|
+
placementUpdates.push({
|
|
3666
3640
|
drawingId: drawing.drawingId,
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3641
|
+
placement: {
|
|
3642
|
+
kind,
|
|
3643
|
+
bounds: {
|
|
3644
|
+
left,
|
|
3645
|
+
top,
|
|
3646
|
+
width,
|
|
3647
|
+
height
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
if (commandService.syncExecuteCommand(SetSheetDrawingPlacementCommand.id, {
|
|
3653
|
+
unitId,
|
|
3654
|
+
subUnitId,
|
|
3655
|
+
drawings: placementUpdates
|
|
3656
|
+
})) setValue(kind);
|
|
3674
3657
|
}
|
|
3675
3658
|
return /* @__PURE__ */ jsxs("div", {
|
|
3676
3659
|
className: clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": !anchorShow }),
|
|
@@ -3698,6 +3681,13 @@ const SheetDrawingAnchor = (props) => {
|
|
|
3698
3681
|
}) })]
|
|
3699
3682
|
});
|
|
3700
3683
|
};
|
|
3684
|
+
function isSheetDrawing(drawing) {
|
|
3685
|
+
return Boolean(drawing && "sheetTransform" in drawing && "axisAlignSheetTransform" in drawing);
|
|
3686
|
+
}
|
|
3687
|
+
function getAnchorKind(value) {
|
|
3688
|
+
if (value === SheetDrawingAnchorType.Position || value === SheetDrawingAnchorType.Both || value === SheetDrawingAnchorType.None) return value;
|
|
3689
|
+
return null;
|
|
3690
|
+
}
|
|
3701
3691
|
|
|
3702
3692
|
//#endregion
|
|
3703
3693
|
//#region src/views/sheet-image-panel/SheetDrawingPanel.tsx
|
|
@@ -3813,16 +3803,15 @@ let DrawingContextMenuController = class DrawingContextMenuController extends Rx
|
|
|
3813
3803
|
}));
|
|
3814
3804
|
}
|
|
3815
3805
|
_getContextMenuPosition(drawings) {
|
|
3816
|
-
var _this$_drawingContext;
|
|
3817
3806
|
if (drawings.length !== 1) return ContextMenuPosition.DRAWING;
|
|
3818
3807
|
const [drawing] = drawings;
|
|
3819
|
-
return
|
|
3808
|
+
return this._drawingContextMenuService.getContextMenuPosition({
|
|
3820
3809
|
unitId: drawing.unitId,
|
|
3821
3810
|
subUnitId: drawing.subUnitId,
|
|
3822
3811
|
drawingId: drawing.drawingId,
|
|
3823
3812
|
drawingType: drawing.drawingType,
|
|
3824
3813
|
drawing
|
|
3825
|
-
})
|
|
3814
|
+
}) ?? ContextMenuPosition.DRAWING;
|
|
3826
3815
|
}
|
|
3827
3816
|
};
|
|
3828
3817
|
DrawingContextMenuController = __decorate([
|
|
@@ -3835,6 +3824,7 @@ DrawingContextMenuController = __decorate([
|
|
|
3835
3824
|
|
|
3836
3825
|
//#endregion
|
|
3837
3826
|
//#region src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts
|
|
3827
|
+
const CELL_IMAGE_PREVIEW_KEY = "preview-cell-image";
|
|
3838
3828
|
let SheetCellImageHoverRenderController = class SheetCellImageHoverRenderController extends Disposable {
|
|
3839
3829
|
constructor(_context, _hoverManagerService, _selectionsService, _drawingRenderService, _sheetSkeletonManagerService) {
|
|
3840
3830
|
super();
|
|
@@ -3873,15 +3863,31 @@ let SheetCellImageHoverRenderController = class SheetCellImageHoverRenderControl
|
|
|
3873
3863
|
_initImageClick() {
|
|
3874
3864
|
this.disposeWithMe(this._hoverManagerService.currentClickedCell$.subscribe((click) => {
|
|
3875
3865
|
if ((click === null || click === void 0 ? void 0 : click.drawing) && this._isSetCursor) {
|
|
3876
|
-
var _this$_sheetSkeletonM;
|
|
3877
3866
|
const imageDrawing = click.drawing.drawing.drawingOrigin;
|
|
3878
|
-
|
|
3879
|
-
if (!imageEle) return;
|
|
3880
|
-
this._drawingRenderService.previewImage("preview-cell-image", imageEle.src, imageEle.width, imageEle.height);
|
|
3881
|
-
this._context.scene.resetCursor();
|
|
3882
|
-
this._isSetCursor = false;
|
|
3867
|
+
this._previewImage(imageDrawing);
|
|
3883
3868
|
}
|
|
3884
3869
|
}));
|
|
3870
|
+
const currentDbClickedCell$ = this._hoverManagerService.currentDbClickedCell$;
|
|
3871
|
+
if (!currentDbClickedCell$) return;
|
|
3872
|
+
this.disposeWithMe(currentDbClickedCell$.subscribe(({ location }) => {
|
|
3873
|
+
var _worksheet$getCellRaw, _documentData$drawing, _documentData$drawing2;
|
|
3874
|
+
if (location.unitId !== this._context.unitId) return;
|
|
3875
|
+
const worksheet = this._context.unit.getSheetBySheetId(location.subUnitId);
|
|
3876
|
+
const documentData = worksheet === null || worksheet === void 0 || (_worksheet$getCellRaw = worksheet.getCellRaw(location.row, location.col)) === null || _worksheet$getCellRaw === void 0 ? void 0 : _worksheet$getCellRaw.p;
|
|
3877
|
+
const drawingId = documentData === null || documentData === void 0 || (_documentData$drawing = documentData.drawingsOrder) === null || _documentData$drawing === void 0 ? void 0 : _documentData$drawing[0];
|
|
3878
|
+
const imageDrawing = isCellImage(documentData) && drawingId ? (_documentData$drawing2 = documentData.drawings) === null || _documentData$drawing2 === void 0 ? void 0 : _documentData$drawing2[drawingId] : void 0;
|
|
3879
|
+
if (imageDrawing) this._previewImage(imageDrawing);
|
|
3880
|
+
}));
|
|
3881
|
+
}
|
|
3882
|
+
_previewImage(imageDrawing) {
|
|
3883
|
+
var _this$_sheetSkeletonM;
|
|
3884
|
+
if (this._disposed) return;
|
|
3885
|
+
const imageCacheMap = (_this$_sheetSkeletonM = this._sheetSkeletonManagerService.getCurrentSkeleton()) === null || _this$_sheetSkeletonM === void 0 ? void 0 : _this$_sheetSkeletonM.imageCacheMap;
|
|
3886
|
+
const imageEle = imageCacheMap === null || imageCacheMap === void 0 ? void 0 : imageCacheMap.getImage(imageDrawing.imageSourceType, imageDrawing.source, () => this._previewImage(imageDrawing));
|
|
3887
|
+
if (!imageEle) return;
|
|
3888
|
+
this._drawingRenderService.previewImage(CELL_IMAGE_PREVIEW_KEY, imageEle.src, imageEle.width, imageEle.height);
|
|
3889
|
+
this._context.scene.resetCursor();
|
|
3890
|
+
this._isSetCursor = false;
|
|
3885
3891
|
}
|
|
3886
3892
|
};
|
|
3887
3893
|
SheetCellImageHoverRenderController = __decorate([
|
|
@@ -3914,7 +3920,14 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
|
|
|
3914
3920
|
const drawingData = subUnitData.data[drawingId];
|
|
3915
3921
|
const { unitId, subUnitId } = drawingData;
|
|
3916
3922
|
const skeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
3917
|
-
if (skeletonParam && drawingData.sheetTransform
|
|
3923
|
+
if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId) {
|
|
3924
|
+
const transform = drawingPositionToTransform(drawingData.sheetTransform, skeletonParam);
|
|
3925
|
+
drawingData.transform = transform && drawingData.drawingType === DrawingTypeEnum.DRAWING_GROUP ? {
|
|
3926
|
+
...transform,
|
|
3927
|
+
left: (transform.left ?? 0) - skeletonParam.skeleton.rowHeaderWidthAndMarginLeft,
|
|
3928
|
+
top: (transform.top ?? 0) - skeletonParam.skeleton.columnHeaderHeightAndMarginTop
|
|
3929
|
+
} : transform;
|
|
3930
|
+
}
|
|
3918
3931
|
}
|
|
3919
3932
|
}
|
|
3920
3933
|
this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));
|
|
@@ -3930,9 +3943,11 @@ SheetsDrawingRenderController = __decorate([
|
|
|
3930
3943
|
//#endregion
|
|
3931
3944
|
//#region src/controllers/sheet-cell-image.controller.ts
|
|
3932
3945
|
function resizeImageByCell(injector, location, cell) {
|
|
3933
|
-
var
|
|
3934
|
-
|
|
3935
|
-
|
|
3946
|
+
var _documentData$drawing, _documentData$drawing2;
|
|
3947
|
+
const documentData = cell === null || cell === void 0 ? void 0 : cell.p;
|
|
3948
|
+
const drawingId = isCellImage(documentData) && (documentData === null || documentData === void 0 || (_documentData$drawing = documentData.drawingsOrder) === null || _documentData$drawing === void 0 ? void 0 : _documentData$drawing.length) === 1 ? documentData.drawingsOrder[0] : void 0;
|
|
3949
|
+
const image = drawingId ? documentData === null || documentData === void 0 || (_documentData$drawing2 = documentData.drawings) === null || _documentData$drawing2 === void 0 ? void 0 : _documentData$drawing2[drawingId] : void 0;
|
|
3950
|
+
if (image && documentData) {
|
|
3936
3951
|
const imageSize = getDrawingSizeByCell(injector, {
|
|
3937
3952
|
unitId: location.unitId,
|
|
3938
3953
|
subUnitId: location.subUnitId,
|
|
@@ -3948,8 +3963,8 @@ function resizeImageByCell(injector, location, cell) {
|
|
|
3948
3963
|
image.transform.top = 0;
|
|
3949
3964
|
image.docTransform.positionH.posOffset = 0;
|
|
3950
3965
|
image.docTransform.positionV.posOffset = 0;
|
|
3951
|
-
|
|
3952
|
-
|
|
3966
|
+
documentData.documentStyle.pageSize.width = Infinity;
|
|
3967
|
+
documentData.documentStyle.pageSize.height = Infinity;
|
|
3953
3968
|
return true;
|
|
3954
3969
|
}
|
|
3955
3970
|
}
|
|
@@ -3981,8 +3996,7 @@ let SheetCellImageController = class SheetCellImageController extends Disposable
|
|
|
3981
3996
|
effect: InterceptorEffectEnum.Style,
|
|
3982
3997
|
priority: InterceptCellContentPriority.CELL_IMAGE,
|
|
3983
3998
|
handler: (cell, pos, next) => {
|
|
3984
|
-
|
|
3985
|
-
if ((cell === null || cell === void 0 ? void 0 : cell.p) && ((_cell$p$drawingsOrder = cell.p.drawingsOrder) === null || _cell$p$drawingsOrder === void 0 ? void 0 : _cell$p$drawingsOrder.length)) {
|
|
3999
|
+
if (cell && isCellImage(cell.p)) {
|
|
3986
4000
|
if (cell === pos.rawData) cell = { ...pos.rawData };
|
|
3987
4001
|
if (!cell.interceptorStyle) cell.interceptorStyle = {};
|
|
3988
4002
|
cell.interceptorStyle.tr = { a: 0 };
|
|
@@ -4082,10 +4096,9 @@ let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController
|
|
|
4082
4096
|
_initDocImageCopyPasteHooks() {
|
|
4083
4097
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((commandInfo) => {
|
|
4084
4098
|
if (commandInfo.id === InnerPasteCommand.id) {
|
|
4085
|
-
var _doc$drawings;
|
|
4086
4099
|
const { doc } = commandInfo.params;
|
|
4087
4100
|
const currentDoc = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
|
|
4088
|
-
if (currentDoc == null || !Object.keys(
|
|
4101
|
+
if (currentDoc == null || !Object.keys(doc.drawings ?? {}).length) return;
|
|
4089
4102
|
const docUnitId = currentDoc.getUnitId();
|
|
4090
4103
|
if (DISABLE_UNITS.includes(docUnitId)) {
|
|
4091
4104
|
var _currentDoc$getBody;
|
|
@@ -4152,12 +4165,11 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
|
|
|
4152
4165
|
setTimeout(() => {
|
|
4153
4166
|
const drawingMap = this._drawingManagerService.drawingManagerData;
|
|
4154
4167
|
const removeDrawings = [];
|
|
4155
|
-
Object.keys(drawingMap
|
|
4156
|
-
|
|
4157
|
-
const subUnitMap = (_drawingMap$unitId = drawingMap[unitId]) !== null && _drawingMap$unitId !== void 0 ? _drawingMap$unitId : {};
|
|
4168
|
+
Object.keys(drawingMap ?? {}).forEach((unitId) => {
|
|
4169
|
+
const subUnitMap = drawingMap[unitId] ?? {};
|
|
4158
4170
|
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
4159
|
-
var _subUnitMap$subUnitId
|
|
4160
|
-
const drawingData = (_subUnitMap$subUnitId =
|
|
4171
|
+
var _subUnitMap$subUnitId;
|
|
4172
|
+
const drawingData = ((_subUnitMap$subUnitId = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId === void 0 ? void 0 : _subUnitMap$subUnitId.data) ?? {};
|
|
4161
4173
|
Object.keys(drawingData).forEach((drawingId) => {
|
|
4162
4174
|
if (unitId === selfUnitId) removeDrawings.push(drawingData[drawingId]);
|
|
4163
4175
|
});
|
|
@@ -4173,13 +4185,12 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
|
|
|
4173
4185
|
const drawingMap = this._drawingManagerService.drawingManagerData;
|
|
4174
4186
|
const insertDrawings = [];
|
|
4175
4187
|
const removeDrawings = [];
|
|
4176
|
-
Object.keys(drawingMap
|
|
4177
|
-
var _drawingMap$unitId2;
|
|
4188
|
+
Object.keys(drawingMap ?? {}).forEach((unitId) => {
|
|
4178
4189
|
if (unitId !== showUnitId) return;
|
|
4179
|
-
const subUnitMap =
|
|
4190
|
+
const subUnitMap = drawingMap[unitId] ?? {};
|
|
4180
4191
|
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
4181
|
-
var _subUnitMap$
|
|
4182
|
-
const drawingData = (
|
|
4192
|
+
var _subUnitMap$subUnitId2;
|
|
4193
|
+
const drawingData = ((_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) ?? {};
|
|
4183
4194
|
Object.keys(drawingData).forEach((drawingId) => {
|
|
4184
4195
|
if (unitId === showUnitId && subUnitId === showSubunitId) {
|
|
4185
4196
|
const drawing = drawingData[drawingId];
|
|
@@ -4403,7 +4414,6 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
4403
4414
|
subUnitId,
|
|
4404
4415
|
isCut: copyType === COPY_TYPE.CUT,
|
|
4405
4416
|
getTransform: (transform, sheetTransform) => {
|
|
4406
|
-
var _transformToDrawingPo, _transformToAxisAlign;
|
|
4407
4417
|
const pasteRect = attachRangeWithCoord(pasteToSkeleton, {
|
|
4408
4418
|
startRow: pasteRange.startRow,
|
|
4409
4419
|
endRow: pasteRange.endRow,
|
|
@@ -4417,8 +4427,8 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
4417
4427
|
};
|
|
4418
4428
|
return {
|
|
4419
4429
|
transform: newTransform,
|
|
4420
|
-
sheetTransform:
|
|
4421
|
-
axisAlignSheetTransform:
|
|
4430
|
+
sheetTransform: transformToDrawingPosition(newTransform, pasteToSkeleton) ?? sheetTransform,
|
|
4431
|
+
axisAlignSheetTransform: transformToAxisAlignPosition(newTransform, pasteToSkeleton) ?? sheetTransform
|
|
4422
4432
|
};
|
|
4423
4433
|
}
|
|
4424
4434
|
});
|
|
@@ -4549,11 +4559,10 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
4549
4559
|
unitId: toUnitId,
|
|
4550
4560
|
subUnitId: toSubUnitId,
|
|
4551
4561
|
getTransform: (transform, sheetTransform) => {
|
|
4552
|
-
var _transform$left, _transform$top, _transformToAxisAlign2;
|
|
4553
4562
|
const newTransform = {
|
|
4554
4563
|
...transform,
|
|
4555
|
-
left: ((
|
|
4556
|
-
top: ((
|
|
4564
|
+
left: ((transform === null || transform === void 0 ? void 0 : transform.left) ?? 0) + leftOffset,
|
|
4565
|
+
top: ((transform === null || transform === void 0 ? void 0 : transform.top) ?? 0) + topOffset
|
|
4557
4566
|
};
|
|
4558
4567
|
return {
|
|
4559
4568
|
transform: newTransform,
|
|
@@ -4570,7 +4579,7 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
4570
4579
|
column: sheetTransform.from.column + columnOffset
|
|
4571
4580
|
}
|
|
4572
4581
|
},
|
|
4573
|
-
axisAlignSheetTransform:
|
|
4582
|
+
axisAlignSheetTransform: transformToAxisAlignPosition(newTransform, toSkeleton) ?? sheetTransform
|
|
4574
4583
|
};
|
|
4575
4584
|
},
|
|
4576
4585
|
isCut: copyType === COPY_TYPE.CUT
|
|
@@ -4794,6 +4803,10 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
4794
4803
|
const { drawings } = command.params;
|
|
4795
4804
|
unitId = drawings === null || drawings === void 0 || (_drawings$ = drawings[0]) === null || _drawings$ === void 0 ? void 0 : _drawings$.unitId;
|
|
4796
4805
|
subUnitId = drawings === null || drawings === void 0 || (_drawings$2 = drawings[0]) === null || _drawings$2 === void 0 ? void 0 : _drawings$2.subUnitId;
|
|
4806
|
+
} else if (command.id === SetSheetDrawingPlacementCommand.id) {
|
|
4807
|
+
const target = getPlacementCommandTarget(command.params);
|
|
4808
|
+
unitId = target.unitId;
|
|
4809
|
+
subUnitId = target.subUnitId;
|
|
4797
4810
|
} else if (command.id === SetDrawingArrangeCommand.id) {
|
|
4798
4811
|
const params = command.params;
|
|
4799
4812
|
unitId = params.unitId;
|
|
@@ -4817,16 +4830,23 @@ SheetDrawingPermissionController = __decorate([
|
|
|
4817
4830
|
__decorateParam(6, Inject(SheetPermissionCheckController)),
|
|
4818
4831
|
__decorateParam(7, Inject(ISheetDrawingService))
|
|
4819
4832
|
], SheetDrawingPermissionController);
|
|
4833
|
+
function getPlacementCommandTarget(params) {
|
|
4834
|
+
if (!params) return {};
|
|
4835
|
+
return {
|
|
4836
|
+
unitId: "unitId" in params && typeof params.unitId === "string" ? params.unitId : void 0,
|
|
4837
|
+
subUnitId: "subUnitId" in params && typeof params.subUnitId === "string" ? params.subUnitId : void 0
|
|
4838
|
+
};
|
|
4839
|
+
}
|
|
4820
4840
|
|
|
4821
4841
|
//#endregion
|
|
4822
4842
|
//#region src/views/PrintingFloatDom.tsx
|
|
4823
4843
|
function createPrintingFloatDom(info, scene, skeleton, worksheet) {
|
|
4824
4844
|
const { width, height, angle, left, top } = info.transform;
|
|
4825
4845
|
const offsetBound = transformBound2DOMBound({
|
|
4826
|
-
left: left
|
|
4827
|
-
right: (left
|
|
4828
|
-
top: top
|
|
4829
|
-
bottom: (top
|
|
4846
|
+
left: left ?? 0,
|
|
4847
|
+
right: (left ?? 0) + (width ?? 0),
|
|
4848
|
+
top: top ?? 0,
|
|
4849
|
+
bottom: (top ?? 0) + (height ?? 0)
|
|
4830
4850
|
}, scene, skeleton, worksheet, void 0, true);
|
|
4831
4851
|
const { scaleX, scaleY } = scene.getAncestorScale();
|
|
4832
4852
|
const domPos = {
|
|
@@ -5193,11 +5213,13 @@ const DeleteDrawingsShortcutItem = {
|
|
|
5193
5213
|
* limitations under the License.
|
|
5194
5214
|
*/
|
|
5195
5215
|
let SheetDrawingUIController = class SheetDrawingUIController extends Disposable {
|
|
5196
|
-
constructor(_menuManagerService, _commandService, _shortcutService) {
|
|
5216
|
+
constructor(_menuManagerService, _commandService, _shortcutService, _drawingManagerService, _sidebarService) {
|
|
5197
5217
|
super();
|
|
5198
5218
|
this._menuManagerService = _menuManagerService;
|
|
5199
5219
|
this._commandService = _commandService;
|
|
5200
5220
|
this._shortcutService = _shortcutService;
|
|
5221
|
+
this._drawingManagerService = _drawingManagerService;
|
|
5222
|
+
this._sidebarService = _sidebarService;
|
|
5201
5223
|
this._init();
|
|
5202
5224
|
}
|
|
5203
5225
|
_initCustomComponents() {}
|
|
@@ -5229,17 +5251,27 @@ let SheetDrawingUIController = class SheetDrawingUIController extends Disposable
|
|
|
5229
5251
|
this.disposeWithMe(this._shortcutService.registerShortcut(item));
|
|
5230
5252
|
});
|
|
5231
5253
|
}
|
|
5254
|
+
_initImagePanel() {
|
|
5255
|
+
this.disposeWithMe(this._drawingManagerService.focus$.subscribe((drawings) => {
|
|
5256
|
+
if (!this._sidebarService.visible || this._sidebarService.options.id !== "COMPONENT_SHEET_DRAWING_PANEL") return;
|
|
5257
|
+
if (drawings.length === 1 && drawings[0].drawingType === DrawingTypeEnum.DRAWING_IMAGE) return;
|
|
5258
|
+
this._sidebarService.close(COMPONENT_SHEET_DRAWING_PANEL);
|
|
5259
|
+
}));
|
|
5260
|
+
}
|
|
5232
5261
|
_init() {
|
|
5233
5262
|
this._initCommands();
|
|
5234
5263
|
this._initCustomComponents();
|
|
5235
5264
|
this._initMenus();
|
|
5236
5265
|
this._initShortcuts();
|
|
5266
|
+
this._initImagePanel();
|
|
5237
5267
|
}
|
|
5238
5268
|
};
|
|
5239
5269
|
SheetDrawingUIController = __decorate([
|
|
5240
5270
|
__decorateParam(0, IMenuManagerService),
|
|
5241
5271
|
__decorateParam(1, ICommandService),
|
|
5242
|
-
__decorateParam(2, IShortcutService)
|
|
5272
|
+
__decorateParam(2, IShortcutService),
|
|
5273
|
+
__decorateParam(3, IDrawingManagerService),
|
|
5274
|
+
__decorateParam(4, Inject(ISidebarService))
|
|
5243
5275
|
], SheetDrawingUIController);
|
|
5244
5276
|
|
|
5245
5277
|
//#endregion
|
|
@@ -5328,7 +5360,8 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends RxDisp
|
|
|
5328
5360
|
const menus = this._canvasPopManagerService.getFeatureMenu(unitId, subUnitId, drawingId, drawingType);
|
|
5329
5361
|
singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
|
|
5330
5362
|
componentKey: COMPONENT_IMAGE_POPUP_MENU,
|
|
5331
|
-
|
|
5363
|
+
constrainToCanvas: true,
|
|
5364
|
+
direction: this._localeService.getDirection() === "rtl" ? "left" : "horizontal",
|
|
5332
5365
|
offset: [2, 0],
|
|
5333
5366
|
extraProps: { menuItems: menus || this._getImageMenuItems(unitId, subUnitId, drawingId, drawingType) }
|
|
5334
5367
|
}));
|
|
@@ -5622,7 +5655,7 @@ _defineProperty(UniverSheetsDrawingUIPlugin, "pluginName", "SHEET_IMAGE_UI_PLUGI
|
|
|
5622
5655
|
_defineProperty(UniverSheetsDrawingUIPlugin, "packageName", name);
|
|
5623
5656
|
_defineProperty(UniverSheetsDrawingUIPlugin, "version", version);
|
|
5624
5657
|
UniverSheetsDrawingUIPlugin = __decorate([
|
|
5625
|
-
DependentOn(UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsDrawingPlugin, UniverSheetsPlugin,
|
|
5658
|
+
DependentOn(UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsDrawingPlugin, UniverSheetsPlugin, UniverSheetsDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsUIPlugin),
|
|
5626
5659
|
__decorateParam(1, Inject(Injector)),
|
|
5627
5660
|
__decorateParam(2, IRenderManagerService),
|
|
5628
5661
|
__decorateParam(3, IConfigService)
|