@univerjs/sheets-drawing-ui 1.0.0-alpha.6 → 1.0.0-alpha.8
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/index.js +131 -1513
- package/lib/cjs/locale/vi-VN.js +5 -5
- package/lib/es/index.js +136 -1518
- package/lib/es/locale/vi-VN.js +5 -5
- package/lib/index.js +136 -1518
- package/lib/locale/vi-VN.js +5 -5
- package/lib/types/controllers/sheet-drawing-active-render.controller.d.ts +32 -0
- package/lib/types/services/batch-save-images.service.d.ts +1 -11
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/vi-VN.js +1 -1
- package/package.json +15 -15
- package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +0 -55
package/lib/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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,
|
|
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
2
|
import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, drawingPositionToTransform, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
|
|
3
|
-
import { CURSOR_TYPE, DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Image, ObjectType, Rect, SHEET_VIEWPORT_KEY, Vector2, getCurrentTypeOfRenderer, getGroupState, transformObjectOutOfGroup } from "@univerjs/engine-render";
|
|
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,
|
|
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
|
-
import { CanvasFloatDomPreviewService, CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, IClipboardInterfaceService, IContextMenuService, IDialogService, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonInsertGroup, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
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";
|
|
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, UniverUIPlugin, 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";
|
|
@@ -292,7 +292,7 @@ const UngroupSheetDrawingCommand = {
|
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
//#endregion
|
|
295
|
-
//#region \0@oxc-project+runtime@0.
|
|
295
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
296
296
|
function _typeof(o) {
|
|
297
297
|
"@babel/helpers - typeof";
|
|
298
298
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -303,7 +303,7 @@ function _typeof(o) {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
//#endregion
|
|
306
|
-
//#region \0@oxc-project+runtime@0.
|
|
306
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
307
307
|
function toPrimitive(t, r) {
|
|
308
308
|
if ("object" != _typeof(t) || !t) return t;
|
|
309
309
|
var e = t[Symbol.toPrimitive];
|
|
@@ -316,14 +316,14 @@ function toPrimitive(t, r) {
|
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
//#endregion
|
|
319
|
-
//#region \0@oxc-project+runtime@0.
|
|
319
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
320
320
|
function toPropertyKey(t) {
|
|
321
321
|
var i = toPrimitive(t, "string");
|
|
322
322
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
//#endregion
|
|
326
|
-
//#region \0@oxc-project+runtime@0.
|
|
326
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
327
327
|
function _defineProperty(e, r, t) {
|
|
328
328
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
329
329
|
value: t,
|
|
@@ -334,7 +334,7 @@ function _defineProperty(e, r, t) {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
//#endregion
|
|
337
|
-
//#region \0@oxc-project+runtime@0.
|
|
337
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
338
338
|
function __decorateParam(paramIndex, decorator) {
|
|
339
339
|
return function(target, key) {
|
|
340
340
|
decorator(target, key, paramIndex);
|
|
@@ -342,7 +342,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
//#endregion
|
|
345
|
-
//#region \0@oxc-project+runtime@0.
|
|
345
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
346
346
|
function __decorate(decorators, target, key, desc) {
|
|
347
347
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
348
348
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -378,11 +378,11 @@ function rotatedBoundingBox(width, height, angleDegrees) {
|
|
|
378
378
|
function getDrawingSizeByCell(accessor, location, originImageWidth, originImageHeight, angle) {
|
|
379
379
|
var _skeletonManagerServi;
|
|
380
380
|
const { rotatedHeight, rotatedWidth } = rotatedBoundingBox(originImageWidth, originImageHeight, angle);
|
|
381
|
-
const currentRender = accessor.get(IRenderManagerService).
|
|
381
|
+
const currentRender = accessor.get(IRenderManagerService).getRenderUnitById(location.unitId);
|
|
382
382
|
if (!currentRender) return false;
|
|
383
383
|
const skeleton = (_skeletonManagerServi = currentRender.with(SheetSkeletonManagerService).getSkeletonParam(location.subUnitId)) === null || _skeletonManagerServi === void 0 ? void 0 : _skeletonManagerServi.skeleton;
|
|
384
384
|
if (skeleton == null) return false;
|
|
385
|
-
const cellInfo = skeleton.
|
|
385
|
+
const cellInfo = skeleton.getCellWithCoordByIndex(location.row, location.col);
|
|
386
386
|
const cellWidth = cellInfo.mergeInfo.endX - cellInfo.mergeInfo.startX - 2;
|
|
387
387
|
const cellHeight = cellInfo.mergeInfo.endY - cellInfo.mergeInfo.startY - 2;
|
|
388
388
|
const imageRatio = rotatedWidth / rotatedHeight;
|
|
@@ -1037,12 +1037,6 @@ let BatchSaveImagesService = class BatchSaveImagesService extends Disposable {
|
|
|
1037
1037
|
this._imageIoService = _imageIoService;
|
|
1038
1038
|
this._urlImageService = _urlImageService;
|
|
1039
1039
|
}
|
|
1040
|
-
/**
|
|
1041
|
-
* @deprecated Use IURLImageService directly
|
|
1042
|
-
*/
|
|
1043
|
-
registerURLImageDownloader(downloader) {
|
|
1044
|
-
return this._urlImageService.registerURLImageDownloader(downloader);
|
|
1045
|
-
}
|
|
1046
1040
|
getCellImagesInSelection() {
|
|
1047
1041
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1048
1042
|
if (!workbook) return [];
|
|
@@ -1362,7 +1356,6 @@ const SaveCellImagesCommand = {
|
|
|
1362
1356
|
width: 360,
|
|
1363
1357
|
title: { title: titleText },
|
|
1364
1358
|
children: { label: BATCH_SAVE_IMAGES_DIALOG_ID },
|
|
1365
|
-
destroyOnClose: true,
|
|
1366
1359
|
preservePositionOnDestroy: true,
|
|
1367
1360
|
onClose: () => dialogService.close(BATCH_SAVE_IMAGES_DIALOG_ID)
|
|
1368
1361
|
});
|
|
@@ -2069,7 +2062,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2069
2062
|
}
|
|
2070
2063
|
_commitFloatDomMove(info) {
|
|
2071
2064
|
var _this$_renderManagerS;
|
|
2072
|
-
const skeletonParam = (_this$_renderManagerS = this._renderManagerService.
|
|
2065
|
+
const skeletonParam = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(info.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(SheetSkeletonManagerService).getSkeletonParam(info.subUnitId);
|
|
2073
2066
|
const drawing = this._sheetDrawingService.getDrawingByParam({
|
|
2074
2067
|
unitId: info.unitId,
|
|
2075
2068
|
subUnitId: info.subUnitId,
|
|
@@ -2238,7 +2231,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2238
2231
|
}
|
|
2239
2232
|
_getSceneAndTransformerByDrawingSearch(unitId) {
|
|
2240
2233
|
if (unitId == null) return;
|
|
2241
|
-
const renderUnit = this._renderManagerService.
|
|
2234
|
+
const renderUnit = this._renderManagerService.getRenderUnitById(unitId);
|
|
2242
2235
|
const scene = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.scene;
|
|
2243
2236
|
if (renderUnit == null || scene == null) return null;
|
|
2244
2237
|
return {
|
|
@@ -2262,7 +2255,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2262
2255
|
if (!workbook) return;
|
|
2263
2256
|
const activeSheetId = workbook.getActiveSheet().getSheetId();
|
|
2264
2257
|
if (!floatDomParam || !target) return;
|
|
2265
|
-
const skeleton = (_this$_renderManagerS2 = this._renderManagerService.
|
|
2258
|
+
const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2266
2259
|
if (!skeleton) return;
|
|
2267
2260
|
const { transform, drawingType, data, hidden, groupId } = floatDomParam;
|
|
2268
2261
|
if (!isCanvasFloatDomDrawingType(drawingType)) return;
|
|
@@ -2505,7 +2498,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2505
2498
|
unitId,
|
|
2506
2499
|
subUnitId
|
|
2507
2500
|
});
|
|
2508
|
-
const skeleton = (_this$_renderManagerS3 = this._renderManagerService.
|
|
2501
|
+
const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2509
2502
|
if (!renderObject || !target || !skeleton) return;
|
|
2510
2503
|
ids.forEach((id) => {
|
|
2511
2504
|
const floatDomInfo = this._domLayerInfoMap.get(id);
|
|
@@ -2525,7 +2518,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2525
2518
|
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => workbook ? workbook.activeSheet$ : of(null)), map((worksheet) => {
|
|
2526
2519
|
if (!worksheet) return null;
|
|
2527
2520
|
const unitId = worksheet.getUnitId();
|
|
2528
|
-
const render = this._renderManagerService.
|
|
2521
|
+
const render = this._renderManagerService.getRenderUnitById(unitId);
|
|
2529
2522
|
return render ? {
|
|
2530
2523
|
render,
|
|
2531
2524
|
unitId,
|
|
@@ -2622,7 +2615,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2622
2615
|
_getPosition(position, unitId) {
|
|
2623
2616
|
var _this$_renderManagerS4;
|
|
2624
2617
|
const { startX, endX, startY, endY } = position;
|
|
2625
|
-
const selectionRenderService = (_this$_renderManagerS4 = this._renderManagerService.
|
|
2618
|
+
const selectionRenderService = (_this$_renderManagerS4 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS4 === void 0 ? void 0 : _this$_renderManagerS4.with(ISheetSelectionRenderService);
|
|
2626
2619
|
if (selectionRenderService == null) return;
|
|
2627
2620
|
const start = selectionRenderService.getCellWithCoordByOffset(startX, startY);
|
|
2628
2621
|
if (start == null) return;
|
|
@@ -2769,9 +2762,9 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2769
2762
|
const { unitId, subUnitId } = target;
|
|
2770
2763
|
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
2771
2764
|
if (!renderObject) return;
|
|
2772
|
-
const currentRender = this._renderManagerService.
|
|
2765
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
2773
2766
|
if (!currentRender) return;
|
|
2774
|
-
const skeletonParam = (_this$_renderManagerS5 = this._renderManagerService.
|
|
2767
|
+
const skeletonParam = (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2775
2768
|
if (!skeletonParam) return;
|
|
2776
2769
|
const { componentKey, data, allowTransform = true } = config;
|
|
2777
2770
|
const id = propId !== null && propId !== void 0 ? propId : generateRandomId();
|
|
@@ -2809,7 +2802,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2809
2802
|
if (!workbook) return;
|
|
2810
2803
|
const activeSheetId = workbook.getActiveSheet().getSheetId();
|
|
2811
2804
|
if (!floatDomParam || !target) return;
|
|
2812
|
-
const skMangerService = (_this$_renderManagerS6 = this._renderManagerService.
|
|
2805
|
+
const skMangerService = (_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS6 === void 0 ? void 0 : _this$_renderManagerS6.with(SheetSkeletonManagerService);
|
|
2813
2806
|
if (!skMangerService) return;
|
|
2814
2807
|
const skeletonParam = skMangerService.getSkeletonParam(subUnitId);
|
|
2815
2808
|
if (!skeletonParam) return;
|
|
@@ -2946,7 +2939,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2946
2939
|
top: rangePosition.absolute.top
|
|
2947
2940
|
}
|
|
2948
2941
|
}, domAnchor);
|
|
2949
|
-
const
|
|
2942
|
+
const newRect = new Rect(getDrawingShapeKeyByDrawingSearch({
|
|
2950
2943
|
unitId,
|
|
2951
2944
|
subUnitId,
|
|
2952
2945
|
drawingId
|
|
@@ -2956,10 +2949,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2956
2949
|
width: (_domAnchor$width2 = domAnchor.width) !== null && _domAnchor$width2 !== void 0 ? _domAnchor$width2 : newRangePos.width,
|
|
2957
2950
|
height: (_domAnchor$height2 = domAnchor.height) !== null && _domAnchor$height2 !== void 0 ? _domAnchor$height2 : newRangePos.height,
|
|
2958
2951
|
zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
|
|
2959
|
-
})
|
|
2952
|
+
});
|
|
2953
|
+
const newPos = calcSheetFloatDomPosition(newRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
|
|
2960
2954
|
position$.next(newPos);
|
|
2961
2955
|
}));
|
|
2962
|
-
const skm = (_this$_renderManagerS7 = this._renderManagerService.
|
|
2956
|
+
const skm = (_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS7 === void 0 ? void 0 : _this$_renderManagerS7.with(SheetSkeletonManagerService);
|
|
2963
2957
|
const skeletonSubscription = skm === null || skm === void 0 ? void 0 : skm.currentSkeleton$.subscribe((skeleton) => {
|
|
2964
2958
|
if (!skeleton) return;
|
|
2965
2959
|
if (skeletonParam.sheetId !== skeleton.sheetId) this._removeDom(id, true);
|
|
@@ -2986,9 +2980,9 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2986
2980
|
if (!target) throw new Error("cannot find current target!");
|
|
2987
2981
|
const { unitId, subUnitId } = target;
|
|
2988
2982
|
if (!this._getSceneAndTransformerByDrawingSearch(unitId)) return;
|
|
2989
|
-
const currentRender = this._renderManagerService.
|
|
2983
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
2990
2984
|
if (!currentRender) return;
|
|
2991
|
-
const skeletonParam = (_this$_renderManagerS8 = this._renderManagerService.
|
|
2985
|
+
const skeletonParam = (_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS8 === void 0 ? void 0 : _this$_renderManagerS8.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2992
2986
|
if (!skeletonParam) return;
|
|
2993
2987
|
const { componentKey, data, allowTransform = true } = config;
|
|
2994
2988
|
const id = propId !== null && propId !== void 0 ? propId : generateRandomId();
|
|
@@ -3031,7 +3025,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3031
3025
|
if (!workbook) return;
|
|
3032
3026
|
const activeSheetId = workbook.getActiveSheet().getSheetId();
|
|
3033
3027
|
if (!floatDomParam || !target) return;
|
|
3034
|
-
const skMangerService = (_this$_renderManagerS9 = this._renderManagerService.
|
|
3028
|
+
const skMangerService = (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(SheetSkeletonManagerService);
|
|
3035
3029
|
if (!skMangerService) return;
|
|
3036
3030
|
const skeleton = skMangerService.getSkeletonParam(subUnitId);
|
|
3037
3031
|
if (!skeleton) return;
|
|
@@ -3149,7 +3143,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3149
3143
|
top: rangePosition.absolute.top
|
|
3150
3144
|
}
|
|
3151
3145
|
}, domLayoutParam);
|
|
3152
|
-
const
|
|
3146
|
+
const newRect = new Rect(getDrawingShapeKeyByDrawingSearch({
|
|
3153
3147
|
unitId,
|
|
3154
3148
|
subUnitId,
|
|
3155
3149
|
drawingId
|
|
@@ -3159,10 +3153,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3159
3153
|
width: domLayoutParam.width,
|
|
3160
3154
|
height: domLayoutParam.height,
|
|
3161
3155
|
zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
|
|
3162
|
-
})
|
|
3156
|
+
});
|
|
3157
|
+
const newPos = calcSheetFloatDomPosition(newRect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
|
|
3163
3158
|
position$.next(newPos);
|
|
3164
3159
|
}));
|
|
3165
|
-
const skm = (_this$_renderManagerS10 = this._renderManagerService.
|
|
3160
|
+
const skm = (_this$_renderManagerS10 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS10 === void 0 ? void 0 : _this$_renderManagerS10.with(SheetSkeletonManagerService);
|
|
3166
3161
|
skm === null || skm === void 0 || skm.currentSkeleton$.subscribe((skeleton) => {
|
|
3167
3162
|
if (!skeleton) return;
|
|
3168
3163
|
if (skeletonParam.sheetId !== skeleton.sheetId) this._removeDom(id, true);
|
|
@@ -3436,6 +3431,12 @@ function SaveCellImagesMenuFactory(accessor) {
|
|
|
3436
3431
|
const menuSchema = {
|
|
3437
3432
|
[RibbonInsertGroup.MEDIA]: { [SHEETS_IMAGE_MENU_ID]: {
|
|
3438
3433
|
order: 0,
|
|
3434
|
+
gridLayout: {
|
|
3435
|
+
row: 1,
|
|
3436
|
+
column: 1,
|
|
3437
|
+
rowSpan: 2,
|
|
3438
|
+
showLabel: true
|
|
3439
|
+
},
|
|
3439
3440
|
menuItemFactory: ImageMenuFactory,
|
|
3440
3441
|
[InsertFloatImageCommand.id]: {
|
|
3441
3442
|
order: 0,
|
|
@@ -3463,7 +3464,7 @@ const menuSchema = {
|
|
|
3463
3464
|
//#endregion
|
|
3464
3465
|
//#region package.json
|
|
3465
3466
|
var name = "@univerjs/sheets-drawing-ui";
|
|
3466
|
-
var version = "1.0.0-alpha.
|
|
3467
|
+
var version = "1.0.0-alpha.8";
|
|
3467
3468
|
|
|
3468
3469
|
//#endregion
|
|
3469
3470
|
//#region src/config/config.ts
|
|
@@ -3605,7 +3606,7 @@ const SheetDrawingAnchor = (props) => {
|
|
|
3605
3606
|
const renderManagerService = useDependency(IRenderManagerService);
|
|
3606
3607
|
const { drawings } = props;
|
|
3607
3608
|
const drawingParam = drawings[0];
|
|
3608
|
-
const renderObject = drawingParam ? renderManagerService.
|
|
3609
|
+
const renderObject = drawingParam ? renderManagerService.getRenderUnitById(drawingParam.unitId) : void 0;
|
|
3609
3610
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
3610
3611
|
const transformer = scene === null || scene === void 0 ? void 0 : scene.getTransformerByCreate();
|
|
3611
3612
|
const [anchorShow, setAnchorShow] = useState(true);
|
|
@@ -3644,7 +3645,8 @@ const SheetDrawingAnchor = (props) => {
|
|
|
3644
3645
|
else if (params.length >= 1) {
|
|
3645
3646
|
var _params$;
|
|
3646
3647
|
setAnchorShow(true);
|
|
3647
|
-
|
|
3648
|
+
const anchorType = ((_params$ = params[0]) === null || _params$ === void 0 ? void 0 : _params$.anchorType) || SheetDrawingAnchorType.Position;
|
|
3649
|
+
setValue(anchorType);
|
|
3648
3650
|
}
|
|
3649
3651
|
});
|
|
3650
3652
|
return () => {
|
|
@@ -3791,7 +3793,7 @@ let DrawingContextMenuController = class DrawingContextMenuController extends Rx
|
|
|
3791
3793
|
_contextMenuListener(workbook) {
|
|
3792
3794
|
var _this$_renderManagerS;
|
|
3793
3795
|
if (!workbook) return;
|
|
3794
|
-
const scene = (_this$_renderManagerS = this._renderManagerService.
|
|
3796
|
+
const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(workbook.getUnitId())) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
|
|
3795
3797
|
if (!scene) return;
|
|
3796
3798
|
const transformer = scene.getTransformerByCreate();
|
|
3797
3799
|
if (!transformer) return;
|
|
@@ -4099,7 +4101,6 @@ let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController
|
|
|
4099
4101
|
title: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteTitle") },
|
|
4100
4102
|
children: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteContent") },
|
|
4101
4103
|
width: 320,
|
|
4102
|
-
destroyOnClose: true,
|
|
4103
4104
|
onClose: handleCloseDialog,
|
|
4104
4105
|
showOk: true,
|
|
4105
4106
|
showCancel: true,
|
|
@@ -4122,6 +4123,86 @@ SheetCellImageCopyPasteController = __decorate([
|
|
|
4122
4123
|
__decorateParam(4, Inject(LocaleService))
|
|
4123
4124
|
], SheetCellImageCopyPasteController);
|
|
4124
4125
|
|
|
4126
|
+
//#endregion
|
|
4127
|
+
//#region src/controllers/sheet-drawing-active-render.controller.ts
|
|
4128
|
+
let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderController extends Disposable {
|
|
4129
|
+
constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService) {
|
|
4130
|
+
super();
|
|
4131
|
+
this._context = _context;
|
|
4132
|
+
this._commandService = _commandService;
|
|
4133
|
+
this._sheetSkeletonService = _sheetSkeletonService;
|
|
4134
|
+
this._sheetDrawingService = _sheetDrawingService;
|
|
4135
|
+
this._drawingManagerService = _drawingManagerService;
|
|
4136
|
+
this._commandListener();
|
|
4137
|
+
}
|
|
4138
|
+
_commandListener() {
|
|
4139
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
4140
|
+
if (command.id === SetWorksheetActiveOperation.id) {
|
|
4141
|
+
const { unitId, subUnitId } = command.params;
|
|
4142
|
+
this._updateDrawings(unitId, subUnitId);
|
|
4143
|
+
}
|
|
4144
|
+
}));
|
|
4145
|
+
this.disposeWithMe(this._context.activated$.subscribe((activated) => {
|
|
4146
|
+
const { unit, unitId } = this._context;
|
|
4147
|
+
if (activated) this._updateDrawings(unitId, unit.getActiveSheet().getSheetId());
|
|
4148
|
+
else this._clearDrawings(unitId);
|
|
4149
|
+
}));
|
|
4150
|
+
}
|
|
4151
|
+
_clearDrawings(selfUnitId) {
|
|
4152
|
+
setTimeout(() => {
|
|
4153
|
+
const drawingMap = this._drawingManagerService.drawingManagerData;
|
|
4154
|
+
const removeDrawings = [];
|
|
4155
|
+
Object.keys(drawingMap !== null && drawingMap !== void 0 ? drawingMap : {}).forEach((unitId) => {
|
|
4156
|
+
var _drawingMap$unitId;
|
|
4157
|
+
const subUnitMap = (_drawingMap$unitId = drawingMap[unitId]) !== null && _drawingMap$unitId !== void 0 ? _drawingMap$unitId : {};
|
|
4158
|
+
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
4159
|
+
var _subUnitMap$subUnitId, _subUnitMap$subUnitId2;
|
|
4160
|
+
const drawingData = (_subUnitMap$subUnitId = (_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) !== null && _subUnitMap$subUnitId !== void 0 ? _subUnitMap$subUnitId : {};
|
|
4161
|
+
Object.keys(drawingData).forEach((drawingId) => {
|
|
4162
|
+
if (unitId === selfUnitId) removeDrawings.push(drawingData[drawingId]);
|
|
4163
|
+
});
|
|
4164
|
+
});
|
|
4165
|
+
});
|
|
4166
|
+
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
4167
|
+
this._drawingManagerService.removeNotification(removeDrawings);
|
|
4168
|
+
});
|
|
4169
|
+
}
|
|
4170
|
+
_updateDrawings(showUnitId, showSubunitId) {
|
|
4171
|
+
setTimeout(() => {
|
|
4172
|
+
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
|
|
4173
|
+
const drawingMap = this._drawingManagerService.drawingManagerData;
|
|
4174
|
+
const insertDrawings = [];
|
|
4175
|
+
const removeDrawings = [];
|
|
4176
|
+
Object.keys(drawingMap !== null && drawingMap !== void 0 ? drawingMap : {}).forEach((unitId) => {
|
|
4177
|
+
var _drawingMap$unitId2;
|
|
4178
|
+
if (unitId !== showUnitId) return;
|
|
4179
|
+
const subUnitMap = (_drawingMap$unitId2 = drawingMap[unitId]) !== null && _drawingMap$unitId2 !== void 0 ? _drawingMap$unitId2 : {};
|
|
4180
|
+
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
4181
|
+
var _subUnitMap$subUnitId3, _subUnitMap$subUnitId4;
|
|
4182
|
+
const drawingData = (_subUnitMap$subUnitId3 = (_subUnitMap$subUnitId4 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId4 === void 0 ? void 0 : _subUnitMap$subUnitId4.data) !== null && _subUnitMap$subUnitId3 !== void 0 ? _subUnitMap$subUnitId3 : {};
|
|
4183
|
+
Object.keys(drawingData).forEach((drawingId) => {
|
|
4184
|
+
if (unitId === showUnitId && subUnitId === showSubunitId) {
|
|
4185
|
+
const drawing = drawingData[drawingId];
|
|
4186
|
+
if (drawing.sheetTransform) drawing.transform = drawingPositionToTransform(drawing.sheetTransform, sheetSkeletonParam);
|
|
4187
|
+
insertDrawings.push(drawingData[drawingId]);
|
|
4188
|
+
} else removeDrawings.push(drawingData[drawingId]);
|
|
4189
|
+
});
|
|
4190
|
+
});
|
|
4191
|
+
});
|
|
4192
|
+
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
4193
|
+
this._sheetDrawingService.addNotification(insertDrawings);
|
|
4194
|
+
this._drawingManagerService.removeNotification(removeDrawings);
|
|
4195
|
+
this._drawingManagerService.addNotification(insertDrawings);
|
|
4196
|
+
}, 0);
|
|
4197
|
+
}
|
|
4198
|
+
};
|
|
4199
|
+
SheetDrawingActiveRenderController = __decorate([
|
|
4200
|
+
__decorateParam(1, ICommandService),
|
|
4201
|
+
__decorateParam(2, Inject(SheetSkeletonService)),
|
|
4202
|
+
__decorateParam(3, ISheetDrawingService),
|
|
4203
|
+
__decorateParam(4, IDrawingManagerService)
|
|
4204
|
+
], SheetDrawingActiveRenderController);
|
|
4205
|
+
|
|
4125
4206
|
//#endregion
|
|
4126
4207
|
//#region src/controllers/sheet-drawing-copy-paste.controller.ts
|
|
4127
4208
|
const IMAGE_PNG_MIME_TYPE = "image/png";
|
|
@@ -4557,7 +4638,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
4557
4638
|
const subUnitId = sheet.getSheetId();
|
|
4558
4639
|
const drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
4559
4640
|
const drawingDataValues = Object.values(drawingData);
|
|
4560
|
-
const renderObject = this._renderManagerService.
|
|
4641
|
+
const renderObject = this._renderManagerService.getRenderUnitById(unitId);
|
|
4561
4642
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
4562
4643
|
if (!scene) return;
|
|
4563
4644
|
scene.getAllObjectsByOrder().forEach((object) => {
|
|
@@ -4591,7 +4672,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
4591
4672
|
const subUnitId = sheet.getSheetId();
|
|
4592
4673
|
const drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
4593
4674
|
const drawingDataValues = Object.values(drawingData);
|
|
4594
|
-
const renderObject = this._renderManagerService.
|
|
4675
|
+
const renderObject = this._renderManagerService.getRenderUnitById(unitId);
|
|
4595
4676
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
4596
4677
|
if (!scene) return;
|
|
4597
4678
|
scene.getAllObjectsByOrder().forEach((object) => {
|
|
@@ -4607,7 +4688,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
4607
4688
|
if (!sheet) return EMPTY;
|
|
4608
4689
|
const unitId = workbook.getUnitId();
|
|
4609
4690
|
const subUnitId = sheet.getSheetId();
|
|
4610
|
-
const renderObject = this._renderManagerService.
|
|
4691
|
+
const renderObject = this._renderManagerService.getRenderUnitById(unitId);
|
|
4611
4692
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
4612
4693
|
if (!scene) return EMPTY;
|
|
4613
4694
|
const transformer = scene.getTransformerByCreate();
|
|
@@ -4655,7 +4736,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
4655
4736
|
if (!sheet) return EMPTY;
|
|
4656
4737
|
const unitId = workbook.getUnitId();
|
|
4657
4738
|
const subUnitId = sheet.getSheetId();
|
|
4658
|
-
const renderObject = this._renderManagerService.
|
|
4739
|
+
const renderObject = this._renderManagerService.getRenderUnitById(unitId);
|
|
4659
4740
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
4660
4741
|
if (!scene) return EMPTY;
|
|
4661
4742
|
const transformer = scene.getTransformerByCreate();
|
|
@@ -4692,7 +4773,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
4692
4773
|
const sheet = workbook.getActiveSheet();
|
|
4693
4774
|
if (!sheet) return;
|
|
4694
4775
|
const subUnitId = sheet.getSheetId();
|
|
4695
|
-
const renderObject = this._renderManagerService.
|
|
4776
|
+
const renderObject = this._renderManagerService.getRenderUnitById(unitId);
|
|
4696
4777
|
const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
|
|
4697
4778
|
if (!scene) return;
|
|
4698
4779
|
const drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
@@ -4829,7 +4910,7 @@ let SheetDrawingPrintingController = class SheetDrawingPrintingController extend
|
|
|
4829
4910
|
} }));
|
|
4830
4911
|
this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE, { handler: (range, pos, next) => {
|
|
4831
4912
|
const { unitId, subUnitId } = pos;
|
|
4832
|
-
const renderer = this._renderManagerService.
|
|
4913
|
+
const renderer = this._renderManagerService.getRenderUnitById(unitId);
|
|
4833
4914
|
if (!renderer) return next(range);
|
|
4834
4915
|
const skeleton = renderer.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
4835
4916
|
if (!skeleton) return next(range);
|
|
@@ -4913,1469 +4994,6 @@ SheetDrawingPrintingController = __decorate([
|
|
|
4913
4994
|
__decorateParam(5, Inject(Injector))
|
|
4914
4995
|
], SheetDrawingPrintingController);
|
|
4915
4996
|
|
|
4916
|
-
//#endregion
|
|
4917
|
-
//#region src/controllers/sheet-drawing-transform-affected.controller.ts
|
|
4918
|
-
const UPDATE_COMMANDS = [
|
|
4919
|
-
InsertRowCommand.id,
|
|
4920
|
-
InsertColCommand.id,
|
|
4921
|
-
RemoveRowCommand.id,
|
|
4922
|
-
RemoveColCommand.id,
|
|
4923
|
-
DeleteRangeMoveLeftCommand.id,
|
|
4924
|
-
DeleteRangeMoveUpCommand.id,
|
|
4925
|
-
InsertRangeMoveDownCommand.id,
|
|
4926
|
-
InsertRangeMoveRightCommand.id,
|
|
4927
|
-
DeltaRowHeightCommand.id,
|
|
4928
|
-
SetRowHeightCommand.id,
|
|
4929
|
-
DeltaColumnWidthCommand.id,
|
|
4930
|
-
SetColWidthCommand.id,
|
|
4931
|
-
SetRowHiddenCommand.id,
|
|
4932
|
-
SetSpecificRowsVisibleCommand.id,
|
|
4933
|
-
SetSpecificColsVisibleCommand.id,
|
|
4934
|
-
SetColHiddenCommand.id,
|
|
4935
|
-
MoveColsCommand.id,
|
|
4936
|
-
MoveRowsCommand.id,
|
|
4937
|
-
MoveRangeCommand.id
|
|
4938
|
-
];
|
|
4939
|
-
const REFRESH_MUTATIONS = [
|
|
4940
|
-
SetRowVisibleMutation.id,
|
|
4941
|
-
SetRowHiddenMutation.id,
|
|
4942
|
-
SetColVisibleMutation.id,
|
|
4943
|
-
SetColHiddenMutation.id,
|
|
4944
|
-
SetWorksheetRowHeightMutation.id,
|
|
4945
|
-
SetWorksheetRowAutoHeightMutation.id,
|
|
4946
|
-
SetWorksheetRowIsAutoHeightMutation.id,
|
|
4947
|
-
SetWorksheetColWidthMutation.id
|
|
4948
|
-
];
|
|
4949
|
-
let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffectedController extends Disposable {
|
|
4950
|
-
constructor(_context, _commandService, _sheetSkeletonService, _selectionRenderService, _sheetInterceptorService, _selectionManagerService, _sheetDrawingService, _drawingManagerService, _univerInstanceService) {
|
|
4951
|
-
super();
|
|
4952
|
-
this._context = _context;
|
|
4953
|
-
this._commandService = _commandService;
|
|
4954
|
-
this._sheetSkeletonService = _sheetSkeletonService;
|
|
4955
|
-
this._selectionRenderService = _selectionRenderService;
|
|
4956
|
-
this._sheetInterceptorService = _sheetInterceptorService;
|
|
4957
|
-
this._selectionManagerService = _selectionManagerService;
|
|
4958
|
-
this._sheetDrawingService = _sheetDrawingService;
|
|
4959
|
-
this._drawingManagerService = _drawingManagerService;
|
|
4960
|
-
this._univerInstanceService = _univerInstanceService;
|
|
4961
|
-
this._sheetInterceptorListener();
|
|
4962
|
-
this._commandListener();
|
|
4963
|
-
this._sheetRefreshListener();
|
|
4964
|
-
}
|
|
4965
|
-
_sheetInterceptorListener() {
|
|
4966
|
-
this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({ getMutations: (commandInfo) => {
|
|
4967
|
-
const { id, params } = commandInfo;
|
|
4968
|
-
if (!UPDATE_COMMANDS.includes(id) || !params) return {
|
|
4969
|
-
redos: [],
|
|
4970
|
-
undos: []
|
|
4971
|
-
};
|
|
4972
|
-
if (id === InsertRowCommand.id) return this._moveRowInterceptor(params, "insert");
|
|
4973
|
-
else if ([
|
|
4974
|
-
MoveColsCommand.id,
|
|
4975
|
-
MoveRowsCommand.id,
|
|
4976
|
-
MoveRangeCommand.id
|
|
4977
|
-
].includes(id)) {
|
|
4978
|
-
let target;
|
|
4979
|
-
if (id === MoveRangeCommand.id) {
|
|
4980
|
-
const _params = params;
|
|
4981
|
-
if (_params.toUnitId && _params.fromUnitId && _params.toUnitId !== _params.fromUnitId || _params.toSubUnitId && _params.fromSubUnitId && _params.toSubUnitId !== _params.fromSubUnitId) return {
|
|
4982
|
-
redos: [],
|
|
4983
|
-
undos: []
|
|
4984
|
-
};
|
|
4985
|
-
target = getSheetCommandTarget(this._univerInstanceService, {
|
|
4986
|
-
unitId: _params.toUnitId,
|
|
4987
|
-
subUnitId: _params.toSubUnitId
|
|
4988
|
-
});
|
|
4989
|
-
} else target = getSheetCommandTarget(this._univerInstanceService, params);
|
|
4990
|
-
if (!target) return {
|
|
4991
|
-
redos: [],
|
|
4992
|
-
undos: []
|
|
4993
|
-
};
|
|
4994
|
-
const { unitId, subUnitId } = target;
|
|
4995
|
-
const { fromRange, toRange } = params;
|
|
4996
|
-
return this._moveRangeInterceptor(unitId, subUnitId, fromRange, toRange);
|
|
4997
|
-
} else if (id === InsertColCommand.id) return this._moveColInterceptor(params, "insert");
|
|
4998
|
-
else if (id === RemoveRowCommand.id) return this._moveRowInterceptor(params, "remove");
|
|
4999
|
-
else if (id === RemoveColCommand.id) return this._moveColInterceptor(params, "remove");
|
|
5000
|
-
else if (id === DeleteRangeMoveLeftCommand.id) {
|
|
5001
|
-
const { range } = params;
|
|
5002
|
-
return this._getRangeMoveUndo(range, 0);
|
|
5003
|
-
} else if (id === DeleteRangeMoveUpCommand.id) {
|
|
5004
|
-
const { range } = params;
|
|
5005
|
-
return this._getRangeMoveUndo(range, 1);
|
|
5006
|
-
} else if (id === InsertRangeMoveDownCommand.id) {
|
|
5007
|
-
const { range } = params;
|
|
5008
|
-
return this._getRangeMoveUndo(range, 2);
|
|
5009
|
-
} else if (id === InsertRangeMoveRightCommand.id) {
|
|
5010
|
-
const { range } = params;
|
|
5011
|
-
return this._getRangeMoveUndo(range, 3);
|
|
5012
|
-
} else if (id === SetRowHiddenCommand.id || id === SetSpecificRowsVisibleCommand.id) {
|
|
5013
|
-
var _this$_selectionManag;
|
|
5014
|
-
const _params = params;
|
|
5015
|
-
const target = getSheetCommandTarget(this._univerInstanceService, _params);
|
|
5016
|
-
if (!target) return {
|
|
5017
|
-
redos: [],
|
|
5018
|
-
undos: []
|
|
5019
|
-
};
|
|
5020
|
-
const { unitId, subUnitId } = target;
|
|
5021
|
-
const ranges = _params.ranges || ((_this$_selectionManag = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag === void 0 ? void 0 : _this$_selectionManag.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW));
|
|
5022
|
-
if (!ranges || ranges.length === 0) return {
|
|
5023
|
-
redos: [],
|
|
5024
|
-
undos: []
|
|
5025
|
-
};
|
|
5026
|
-
return this._getDrawingUndoForRowVisible(unitId, subUnitId, ranges);
|
|
5027
|
-
} else if (id === SetColHiddenCommand.id || id === SetSpecificColsVisibleCommand.id) {
|
|
5028
|
-
var _this$_selectionManag2;
|
|
5029
|
-
const _params = params;
|
|
5030
|
-
const target = getSheetCommandTarget(this._univerInstanceService, _params);
|
|
5031
|
-
if (!target) return {
|
|
5032
|
-
redos: [],
|
|
5033
|
-
undos: []
|
|
5034
|
-
};
|
|
5035
|
-
const { unitId, subUnitId } = target;
|
|
5036
|
-
const ranges = _params.ranges || ((_this$_selectionManag2 = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag2 === void 0 ? void 0 : _this$_selectionManag2.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN));
|
|
5037
|
-
if (!ranges || ranges.length === 0) return {
|
|
5038
|
-
redos: [],
|
|
5039
|
-
undos: []
|
|
5040
|
-
};
|
|
5041
|
-
return this._getDrawingUndoForColVisible(unitId, subUnitId, ranges);
|
|
5042
|
-
} else if (id === DeltaRowHeightCommand.id || id === DeltaColumnWidthCommand.id) {
|
|
5043
|
-
const target = getSheetCommandTarget(this._univerInstanceService);
|
|
5044
|
-
if (!target) return {
|
|
5045
|
-
redos: [],
|
|
5046
|
-
undos: []
|
|
5047
|
-
};
|
|
5048
|
-
const { unitId, subUnitId, worksheet } = target;
|
|
5049
|
-
const ranges = [];
|
|
5050
|
-
if (id === DeltaRowHeightCommand.id) ranges.push({
|
|
5051
|
-
startRow: params.anchorRow,
|
|
5052
|
-
endRow: params.anchorRow,
|
|
5053
|
-
startColumn: 0,
|
|
5054
|
-
endColumn: worksheet.getColumnCount() - 1
|
|
5055
|
-
});
|
|
5056
|
-
else ranges.push({
|
|
5057
|
-
startRow: 0,
|
|
5058
|
-
endRow: worksheet.getRowCount() - 1,
|
|
5059
|
-
startColumn: params.anchorCol,
|
|
5060
|
-
endColumn: params.anchorCol
|
|
5061
|
-
});
|
|
5062
|
-
return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges);
|
|
5063
|
-
} else if (id === SetRowHeightCommand.id || id === SetColWidthCommand.id) {
|
|
5064
|
-
var _this$_selectionManag3;
|
|
5065
|
-
const _params = params;
|
|
5066
|
-
const target = getSheetCommandTarget(this._univerInstanceService, _params);
|
|
5067
|
-
if (!target) return {
|
|
5068
|
-
redos: [],
|
|
5069
|
-
undos: []
|
|
5070
|
-
};
|
|
5071
|
-
const { unitId, subUnitId } = target;
|
|
5072
|
-
const ranges = _params.ranges || ((_this$_selectionManag3 = this._selectionManagerService.getCurrentSelections()) === null || _this$_selectionManag3 === void 0 ? void 0 : _this$_selectionManag3.map((s) => s.range));
|
|
5073
|
-
if (!ranges || ranges.length === 0) return {
|
|
5074
|
-
redos: [],
|
|
5075
|
-
undos: []
|
|
5076
|
-
};
|
|
5077
|
-
return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges);
|
|
5078
|
-
}
|
|
5079
|
-
return {
|
|
5080
|
-
redos: [],
|
|
5081
|
-
undos: []
|
|
5082
|
-
};
|
|
5083
|
-
} }));
|
|
5084
|
-
}
|
|
5085
|
-
_getRangeMoveUndo(range, type) {
|
|
5086
|
-
const target = getSheetCommandTarget(this._univerInstanceService);
|
|
5087
|
-
if (!target) return {
|
|
5088
|
-
redos: [],
|
|
5089
|
-
undos: []
|
|
5090
|
-
};
|
|
5091
|
-
const { unitId, subUnitId } = target;
|
|
5092
|
-
const drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
5093
|
-
const redos = [];
|
|
5094
|
-
const undos = [];
|
|
5095
|
-
const updateDrawings = [];
|
|
5096
|
-
const deleteDrawings = [];
|
|
5097
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
5098
|
-
const drawing = drawingData[drawingId];
|
|
5099
|
-
const { updateDrawings: updateDrawingsPart, deleteDrawings: deleteDrawingsPart } = this._getUpdateOrDeleteDrawings(range, type, drawing);
|
|
5100
|
-
updateDrawings.push(...updateDrawingsPart);
|
|
5101
|
-
deleteDrawings.push(...deleteDrawingsPart);
|
|
5102
|
-
});
|
|
5103
|
-
if (updateDrawings.length === 0 && deleteDrawings.length === 0) return {
|
|
5104
|
-
redos: [],
|
|
5105
|
-
undos: []
|
|
5106
|
-
};
|
|
5107
|
-
if (updateDrawings.length > 0) {
|
|
5108
|
-
const { undo, redo, objects } = this._sheetDrawingService.getBatchUpdateOp(updateDrawings);
|
|
5109
|
-
redos.push({
|
|
5110
|
-
id: SetDrawingApplyMutation.id,
|
|
5111
|
-
params: {
|
|
5112
|
-
unitId,
|
|
5113
|
-
subUnitId,
|
|
5114
|
-
op: redo,
|
|
5115
|
-
objects,
|
|
5116
|
-
type: DrawingApplyType.UPDATE
|
|
5117
|
-
}
|
|
5118
|
-
});
|
|
5119
|
-
undos.push({
|
|
5120
|
-
id: SetDrawingApplyMutation.id,
|
|
5121
|
-
params: {
|
|
5122
|
-
unitId,
|
|
5123
|
-
subUnitId,
|
|
5124
|
-
op: undo,
|
|
5125
|
-
objects,
|
|
5126
|
-
type: DrawingApplyType.UPDATE
|
|
5127
|
-
}
|
|
5128
|
-
});
|
|
5129
|
-
}
|
|
5130
|
-
if (deleteDrawings.length > 0) {
|
|
5131
|
-
const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings);
|
|
5132
|
-
const deleteUndo = deleteJsonOp.undo;
|
|
5133
|
-
const deleteRedo = deleteJsonOp.redo;
|
|
5134
|
-
const deleteObjects = deleteJsonOp.objects;
|
|
5135
|
-
redos.push({
|
|
5136
|
-
id: SetDrawingApplyMutation.id,
|
|
5137
|
-
params: {
|
|
5138
|
-
unitId,
|
|
5139
|
-
subUnitId,
|
|
5140
|
-
op: deleteRedo,
|
|
5141
|
-
objects: deleteObjects,
|
|
5142
|
-
type: DrawingApplyType.REMOVE
|
|
5143
|
-
}
|
|
5144
|
-
});
|
|
5145
|
-
undos.push({
|
|
5146
|
-
id: SetDrawingApplyMutation.id,
|
|
5147
|
-
params: {
|
|
5148
|
-
unitId,
|
|
5149
|
-
subUnitId,
|
|
5150
|
-
op: deleteUndo,
|
|
5151
|
-
objects: deleteObjects,
|
|
5152
|
-
type: DrawingApplyType.INSERT
|
|
5153
|
-
}
|
|
5154
|
-
});
|
|
5155
|
-
}
|
|
5156
|
-
redos.push({
|
|
5157
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5158
|
-
params: [unitId]
|
|
5159
|
-
});
|
|
5160
|
-
undos.push({
|
|
5161
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5162
|
-
params: [unitId]
|
|
5163
|
-
});
|
|
5164
|
-
return {
|
|
5165
|
-
redos,
|
|
5166
|
-
undos
|
|
5167
|
-
};
|
|
5168
|
-
}
|
|
5169
|
-
_getUpdateOrDeleteDrawings(range, type, drawing) {
|
|
5170
|
-
const updateDrawings = [];
|
|
5171
|
-
const deleteDrawings = [];
|
|
5172
|
-
const { sheetTransform, anchorType = SheetDrawingAnchorType.Position, transform, unitId, subUnitId, drawingId } = drawing;
|
|
5173
|
-
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
5174
|
-
if (!sheetTransform || !transform || !sheetSkeletonParam) return {
|
|
5175
|
-
updateDrawings,
|
|
5176
|
-
deleteDrawings
|
|
5177
|
-
};
|
|
5178
|
-
const { from, to } = sheetTransform;
|
|
5179
|
-
const { row: fromRow, column: fromColumn } = from;
|
|
5180
|
-
const { row: toRow, column: toColumn } = to;
|
|
5181
|
-
const { startRow, endRow, startColumn, endColumn } = range;
|
|
5182
|
-
let newSheetTransform = null;
|
|
5183
|
-
let newTransform = null;
|
|
5184
|
-
let axisAlignSheetTransform;
|
|
5185
|
-
if (type === 0 && fromRow >= startRow && toRow <= endRow) if (fromColumn >= startColumn && toColumn <= endColumn) deleteDrawings.push({
|
|
5186
|
-
unitId,
|
|
5187
|
-
subUnitId,
|
|
5188
|
-
drawingId
|
|
5189
|
-
});
|
|
5190
|
-
else {
|
|
5191
|
-
var _param$axisAlignSheet;
|
|
5192
|
-
const param = this._shrinkCol(startColumn, endColumn, {
|
|
5193
|
-
sheetSkeletonParam,
|
|
5194
|
-
sheetTransform,
|
|
5195
|
-
transform,
|
|
5196
|
-
anchorType
|
|
5197
|
-
});
|
|
5198
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5199
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5200
|
-
axisAlignSheetTransform = (_param$axisAlignSheet = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet !== void 0 ? _param$axisAlignSheet : void 0;
|
|
5201
|
-
}
|
|
5202
|
-
else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn) if (fromRow >= startRow && toRow <= endRow) deleteDrawings.push({
|
|
5203
|
-
unitId,
|
|
5204
|
-
subUnitId,
|
|
5205
|
-
drawingId
|
|
5206
|
-
});
|
|
5207
|
-
else {
|
|
5208
|
-
var _param$axisAlignSheet2;
|
|
5209
|
-
const param = this._shrinkRow(startRow, endRow, {
|
|
5210
|
-
sheetSkeletonParam,
|
|
5211
|
-
sheetTransform,
|
|
5212
|
-
transform,
|
|
5213
|
-
anchorType
|
|
5214
|
-
});
|
|
5215
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5216
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5217
|
-
axisAlignSheetTransform = (_param$axisAlignSheet2 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet2 !== void 0 ? _param$axisAlignSheet2 : void 0;
|
|
5218
|
-
}
|
|
5219
|
-
else if (type === 2) {
|
|
5220
|
-
var _param$axisAlignSheet3;
|
|
5221
|
-
const param = this._expandRow(startRow, endRow, {
|
|
5222
|
-
sheetSkeletonParam,
|
|
5223
|
-
sheetTransform,
|
|
5224
|
-
transform,
|
|
5225
|
-
anchorType
|
|
5226
|
-
});
|
|
5227
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5228
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5229
|
-
axisAlignSheetTransform = (_param$axisAlignSheet3 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet3 !== void 0 ? _param$axisAlignSheet3 : void 0;
|
|
5230
|
-
} else if (type === 3) {
|
|
5231
|
-
var _param$axisAlignSheet4;
|
|
5232
|
-
const param = this._expandCol(startColumn, endColumn, {
|
|
5233
|
-
sheetSkeletonParam,
|
|
5234
|
-
sheetTransform,
|
|
5235
|
-
transform,
|
|
5236
|
-
anchorType
|
|
5237
|
-
});
|
|
5238
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5239
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5240
|
-
axisAlignSheetTransform = (_param$axisAlignSheet4 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet4 !== void 0 ? _param$axisAlignSheet4 : void 0;
|
|
5241
|
-
}
|
|
5242
|
-
if (newSheetTransform && newTransform) {
|
|
5243
|
-
const newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
5244
|
-
updateDrawings.push({
|
|
5245
|
-
...drawing,
|
|
5246
|
-
sheetTransform: newSheetTransform,
|
|
5247
|
-
transform: newTransform,
|
|
5248
|
-
axisAlignSheetTransform
|
|
5249
|
-
});
|
|
5250
|
-
}
|
|
5251
|
-
return {
|
|
5252
|
-
updateDrawings,
|
|
5253
|
-
deleteDrawings
|
|
5254
|
-
};
|
|
5255
|
-
}
|
|
5256
|
-
_remainDrawingSize(transform, updateDrawings, drawing, skeleton) {
|
|
5257
|
-
const newSheetTransform = transformToDrawingPosition({ ...transform }, skeleton);
|
|
5258
|
-
if (newSheetTransform) {
|
|
5259
|
-
const axisAlignSheetTransform = transformToAxisAlignPosition({ ...transform }, skeleton);
|
|
5260
|
-
updateDrawings.push({
|
|
5261
|
-
...drawing,
|
|
5262
|
-
sheetTransform: newSheetTransform,
|
|
5263
|
-
axisAlignSheetTransform
|
|
5264
|
-
});
|
|
5265
|
-
}
|
|
5266
|
-
}
|
|
5267
|
-
_getDrawingUndoForColVisible(unitId, subUnitId, ranges) {
|
|
5268
|
-
const skeleton = this._sheetSkeletonService.getSkeleton(unitId, subUnitId);
|
|
5269
|
-
if (!skeleton) return {
|
|
5270
|
-
redos: [],
|
|
5271
|
-
undos: []
|
|
5272
|
-
};
|
|
5273
|
-
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId);
|
|
5274
|
-
const updateDrawings = [];
|
|
5275
|
-
const preUpdateDrawings = [];
|
|
5276
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
5277
|
-
const drawing = drawingData[drawingId];
|
|
5278
|
-
const { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
5279
|
-
if (anchorType === SheetDrawingAnchorType.None) this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
5280
|
-
else {
|
|
5281
|
-
const { from, to } = sheetTransform;
|
|
5282
|
-
const { row: fromRow, column: fromColumn } = from;
|
|
5283
|
-
const { row: toRow, column: toColumn } = to;
|
|
5284
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
5285
|
-
const { startColumn, endColumn } = ranges[i];
|
|
5286
|
-
if (toColumn < startColumn) continue;
|
|
5287
|
-
if (anchorType === SheetDrawingAnchorType.Position) {
|
|
5288
|
-
let newSheetTransform = null;
|
|
5289
|
-
let newTransform = null;
|
|
5290
|
-
if (fromColumn >= startColumn && fromColumn <= endColumn) {
|
|
5291
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5292
|
-
startColumn: fromColumn,
|
|
5293
|
-
endColumn,
|
|
5294
|
-
startRow: fromRow,
|
|
5295
|
-
endRow: toRow
|
|
5296
|
-
});
|
|
5297
|
-
newTransform = {
|
|
5298
|
-
...transform,
|
|
5299
|
-
left: selectionCell.startX
|
|
5300
|
-
};
|
|
5301
|
-
}
|
|
5302
|
-
if (newTransform) {
|
|
5303
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
5304
|
-
const axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
5305
|
-
if (newSheetTransform && newTransform) {
|
|
5306
|
-
updateDrawings.push({
|
|
5307
|
-
...drawing,
|
|
5308
|
-
sheetTransform: newSheetTransform,
|
|
5309
|
-
transform: newTransform,
|
|
5310
|
-
axisAlignSheetTransform
|
|
5311
|
-
});
|
|
5312
|
-
break;
|
|
5313
|
-
}
|
|
5314
|
-
}
|
|
5315
|
-
continue;
|
|
5316
|
-
}
|
|
5317
|
-
if (fromColumn >= startColumn && toColumn <= endColumn) continue;
|
|
5318
|
-
let newSheetTransform = null;
|
|
5319
|
-
let newTransform = null;
|
|
5320
|
-
if (fromColumn >= startColumn && fromColumn <= endColumn) {
|
|
5321
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5322
|
-
startColumn: fromColumn,
|
|
5323
|
-
endColumn,
|
|
5324
|
-
startRow: fromRow,
|
|
5325
|
-
endRow: toRow
|
|
5326
|
-
});
|
|
5327
|
-
newTransform = {
|
|
5328
|
-
...transform,
|
|
5329
|
-
left: (selectionCell === null || selectionCell === void 0 ? void 0 : selectionCell.startX) || 0,
|
|
5330
|
-
width: ((transform === null || transform === void 0 ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
|
|
5331
|
-
};
|
|
5332
|
-
} else if (toColumn >= startColumn && toColumn <= endColumn) {
|
|
5333
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5334
|
-
startColumn,
|
|
5335
|
-
endColumn: toColumn,
|
|
5336
|
-
startRow: fromRow,
|
|
5337
|
-
endRow: toRow
|
|
5338
|
-
});
|
|
5339
|
-
newTransform = {
|
|
5340
|
-
...transform,
|
|
5341
|
-
left: selectionCell.startX - ((transform === null || transform === void 0 ? void 0 : transform.width) || 0)
|
|
5342
|
-
};
|
|
5343
|
-
} else {
|
|
5344
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5345
|
-
startColumn,
|
|
5346
|
-
endColumn,
|
|
5347
|
-
startRow: fromRow,
|
|
5348
|
-
endRow: toRow
|
|
5349
|
-
});
|
|
5350
|
-
newTransform = {
|
|
5351
|
-
...transform,
|
|
5352
|
-
width: ((transform === null || transform === void 0 ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
|
|
5353
|
-
};
|
|
5354
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
5355
|
-
if (newSheetTransform && newTransform) {
|
|
5356
|
-
const axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
5357
|
-
preUpdateDrawings.push({
|
|
5358
|
-
...drawing,
|
|
5359
|
-
sheetTransform: newSheetTransform,
|
|
5360
|
-
transform: newTransform,
|
|
5361
|
-
axisAlignSheetTransform
|
|
5362
|
-
});
|
|
5363
|
-
break;
|
|
5364
|
-
}
|
|
5365
|
-
}
|
|
5366
|
-
if (newTransform) newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
5367
|
-
if (newTransform && newSheetTransform) {
|
|
5368
|
-
const axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
5369
|
-
updateDrawings.push({
|
|
5370
|
-
...drawing,
|
|
5371
|
-
sheetTransform: newSheetTransform,
|
|
5372
|
-
transform: newTransform,
|
|
5373
|
-
axisAlignSheetTransform
|
|
5374
|
-
});
|
|
5375
|
-
break;
|
|
5376
|
-
} else this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
5377
|
-
}
|
|
5378
|
-
}
|
|
5379
|
-
});
|
|
5380
|
-
if (updateDrawings.length === 0 && preUpdateDrawings.length === 0) return {
|
|
5381
|
-
redos: [],
|
|
5382
|
-
undos: []
|
|
5383
|
-
};
|
|
5384
|
-
const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
|
|
5385
|
-
const preRedos = [];
|
|
5386
|
-
const preUndos = [];
|
|
5387
|
-
if (preUpdateDrawings.length > 0) {
|
|
5388
|
-
const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
|
|
5389
|
-
preRedos.push(...redos);
|
|
5390
|
-
preUndos.push(...undos);
|
|
5391
|
-
}
|
|
5392
|
-
return {
|
|
5393
|
-
redos,
|
|
5394
|
-
undos,
|
|
5395
|
-
preRedos,
|
|
5396
|
-
preUndos
|
|
5397
|
-
};
|
|
5398
|
-
}
|
|
5399
|
-
_createUndoAndRedoMutation(unitId, subUnitId, updateDrawings) {
|
|
5400
|
-
const { undo, redo, objects } = this._sheetDrawingService.getBatchUpdateOp(updateDrawings);
|
|
5401
|
-
return {
|
|
5402
|
-
redos: [{
|
|
5403
|
-
id: SetDrawingApplyMutation.id,
|
|
5404
|
-
params: {
|
|
5405
|
-
unitId,
|
|
5406
|
-
subUnitId,
|
|
5407
|
-
op: redo,
|
|
5408
|
-
objects,
|
|
5409
|
-
type: DrawingApplyType.UPDATE
|
|
5410
|
-
}
|
|
5411
|
-
}, {
|
|
5412
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5413
|
-
params: [unitId]
|
|
5414
|
-
}],
|
|
5415
|
-
undos: [{
|
|
5416
|
-
id: SetDrawingApplyMutation.id,
|
|
5417
|
-
params: {
|
|
5418
|
-
unitId,
|
|
5419
|
-
subUnitId,
|
|
5420
|
-
op: undo,
|
|
5421
|
-
objects,
|
|
5422
|
-
type: DrawingApplyType.UPDATE
|
|
5423
|
-
}
|
|
5424
|
-
}, {
|
|
5425
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5426
|
-
params: [unitId]
|
|
5427
|
-
}]
|
|
5428
|
-
};
|
|
5429
|
-
}
|
|
5430
|
-
_getDrawingUndoForRowVisible(unitId, subUnitId, ranges) {
|
|
5431
|
-
const skeleton = this._sheetSkeletonService.getSkeleton(unitId, subUnitId);
|
|
5432
|
-
if (!skeleton) return {
|
|
5433
|
-
redos: [],
|
|
5434
|
-
undos: []
|
|
5435
|
-
};
|
|
5436
|
-
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId);
|
|
5437
|
-
const updateDrawings = [];
|
|
5438
|
-
const preUpdateDrawings = [];
|
|
5439
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
5440
|
-
const drawing = drawingData[drawingId];
|
|
5441
|
-
const { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
5442
|
-
if (anchorType === SheetDrawingAnchorType.None) this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
5443
|
-
else {
|
|
5444
|
-
const { from, to } = sheetTransform;
|
|
5445
|
-
const { row: fromRow, column: fromColumn } = from;
|
|
5446
|
-
const { row: toRow, column: toColumn } = to;
|
|
5447
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
5448
|
-
const { startRow, endRow } = ranges[i];
|
|
5449
|
-
if (toRow < startRow) continue;
|
|
5450
|
-
if (anchorType === SheetDrawingAnchorType.Position) {
|
|
5451
|
-
let newSheetTransform = null;
|
|
5452
|
-
let newTransform = null;
|
|
5453
|
-
if (fromRow >= startRow && fromRow <= endRow) {
|
|
5454
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5455
|
-
startColumn: fromColumn,
|
|
5456
|
-
endColumn: toColumn,
|
|
5457
|
-
startRow: fromRow,
|
|
5458
|
-
endRow
|
|
5459
|
-
});
|
|
5460
|
-
newTransform = {
|
|
5461
|
-
...transform,
|
|
5462
|
-
top: selectionCell.startY
|
|
5463
|
-
};
|
|
5464
|
-
}
|
|
5465
|
-
if (newTransform) {
|
|
5466
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
5467
|
-
const axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
5468
|
-
if (newSheetTransform && newTransform) {
|
|
5469
|
-
updateDrawings.push({
|
|
5470
|
-
...drawing,
|
|
5471
|
-
sheetTransform: newSheetTransform,
|
|
5472
|
-
transform: newTransform,
|
|
5473
|
-
axisAlignSheetTransform
|
|
5474
|
-
});
|
|
5475
|
-
break;
|
|
5476
|
-
}
|
|
5477
|
-
}
|
|
5478
|
-
continue;
|
|
5479
|
-
}
|
|
5480
|
-
if (fromRow >= startRow && toRow <= endRow) continue;
|
|
5481
|
-
let newSheetTransform = null;
|
|
5482
|
-
let newTransform = null;
|
|
5483
|
-
if (fromRow >= startRow && fromRow <= endRow) {
|
|
5484
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5485
|
-
startColumn: fromColumn,
|
|
5486
|
-
endColumn: toColumn,
|
|
5487
|
-
startRow: fromRow,
|
|
5488
|
-
endRow
|
|
5489
|
-
});
|
|
5490
|
-
newTransform = {
|
|
5491
|
-
...transform,
|
|
5492
|
-
top: (selectionCell === null || selectionCell === void 0 ? void 0 : selectionCell.startY) || 0,
|
|
5493
|
-
height: ((transform === null || transform === void 0 ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
|
|
5494
|
-
};
|
|
5495
|
-
} else if (toRow >= startRow && toRow <= endRow) {
|
|
5496
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5497
|
-
startColumn: fromColumn,
|
|
5498
|
-
endColumn: toColumn,
|
|
5499
|
-
startRow,
|
|
5500
|
-
endRow: toRow
|
|
5501
|
-
});
|
|
5502
|
-
newTransform = {
|
|
5503
|
-
...transform,
|
|
5504
|
-
top: selectionCell.startY - ((transform === null || transform === void 0 ? void 0 : transform.height) || 0)
|
|
5505
|
-
};
|
|
5506
|
-
} else {
|
|
5507
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5508
|
-
startColumn: fromColumn,
|
|
5509
|
-
endColumn: toColumn,
|
|
5510
|
-
startRow,
|
|
5511
|
-
endRow
|
|
5512
|
-
});
|
|
5513
|
-
newTransform = {
|
|
5514
|
-
...transform,
|
|
5515
|
-
height: ((transform === null || transform === void 0 ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
|
|
5516
|
-
};
|
|
5517
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
5518
|
-
if (newSheetTransform && newTransform) {
|
|
5519
|
-
const axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
5520
|
-
preUpdateDrawings.push({
|
|
5521
|
-
...drawing,
|
|
5522
|
-
sheetTransform: newSheetTransform,
|
|
5523
|
-
transform: newTransform,
|
|
5524
|
-
axisAlignSheetTransform
|
|
5525
|
-
});
|
|
5526
|
-
break;
|
|
5527
|
-
}
|
|
5528
|
-
}
|
|
5529
|
-
if (newTransform) newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
5530
|
-
if (newTransform && newSheetTransform) {
|
|
5531
|
-
const axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
5532
|
-
updateDrawings.push({
|
|
5533
|
-
...drawing,
|
|
5534
|
-
sheetTransform: newSheetTransform,
|
|
5535
|
-
transform: newTransform,
|
|
5536
|
-
axisAlignSheetTransform
|
|
5537
|
-
});
|
|
5538
|
-
break;
|
|
5539
|
-
} else this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
5540
|
-
}
|
|
5541
|
-
}
|
|
5542
|
-
});
|
|
5543
|
-
if (updateDrawings.length === 0 && preUpdateDrawings.length === 0) return {
|
|
5544
|
-
redos: [],
|
|
5545
|
-
undos: []
|
|
5546
|
-
};
|
|
5547
|
-
const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
|
|
5548
|
-
const preRedos = [];
|
|
5549
|
-
const preUndos = [];
|
|
5550
|
-
if (preUpdateDrawings.length > 0) {
|
|
5551
|
-
const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
|
|
5552
|
-
preRedos.push(...redos);
|
|
5553
|
-
preUndos.push(...undos);
|
|
5554
|
-
}
|
|
5555
|
-
return {
|
|
5556
|
-
redos,
|
|
5557
|
-
undos,
|
|
5558
|
-
preRedos,
|
|
5559
|
-
preUndos
|
|
5560
|
-
};
|
|
5561
|
-
}
|
|
5562
|
-
_getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges) {
|
|
5563
|
-
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
5564
|
-
if (!sheetSkeletonParam) return {
|
|
5565
|
-
redos: [],
|
|
5566
|
-
undos: []
|
|
5567
|
-
};
|
|
5568
|
-
const { skeleton } = sheetSkeletonParam;
|
|
5569
|
-
const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId);
|
|
5570
|
-
const updateDrawings = [];
|
|
5571
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
5572
|
-
const drawing = drawingData[drawingId];
|
|
5573
|
-
const { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
5574
|
-
if (anchorType === SheetDrawingAnchorType.None) this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
5575
|
-
else {
|
|
5576
|
-
const { from, to } = sheetTransform;
|
|
5577
|
-
const { row: fromRow, column: fromColumn } = from;
|
|
5578
|
-
const { row: toRow, column: toColumn } = to;
|
|
5579
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
5580
|
-
const { startRow, endRow, startColumn, endColumn } = ranges[i];
|
|
5581
|
-
if (toRow < startRow || toColumn < startColumn) continue;
|
|
5582
|
-
if (anchorType === SheetDrawingAnchorType.Position) {
|
|
5583
|
-
if (fromRow <= startRow && toRow >= endRow || fromColumn <= startColumn && toColumn >= endColumn) {
|
|
5584
|
-
this._remainDrawingSize(transform, updateDrawings, drawing, skeleton);
|
|
5585
|
-
continue;
|
|
5586
|
-
}
|
|
5587
|
-
}
|
|
5588
|
-
const newTransform = drawingPositionToTransform({ ...sheetTransform }, sheetSkeletonParam);
|
|
5589
|
-
if (newTransform) {
|
|
5590
|
-
updateDrawings.push({
|
|
5591
|
-
...drawing,
|
|
5592
|
-
transform: newTransform
|
|
5593
|
-
});
|
|
5594
|
-
break;
|
|
5595
|
-
}
|
|
5596
|
-
}
|
|
5597
|
-
}
|
|
5598
|
-
});
|
|
5599
|
-
if (updateDrawings.length === 0) return {
|
|
5600
|
-
redos: [],
|
|
5601
|
-
undos: []
|
|
5602
|
-
};
|
|
5603
|
-
return this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
|
|
5604
|
-
}
|
|
5605
|
-
_getUnitIdAndSubUnitId(params, type) {
|
|
5606
|
-
let target;
|
|
5607
|
-
if (type === "insert") target = getSheetCommandTarget(this._univerInstanceService, params);
|
|
5608
|
-
else target = getSheetCommandTarget(this._univerInstanceService);
|
|
5609
|
-
if (!target) return;
|
|
5610
|
-
const { unitId, subUnitId } = target;
|
|
5611
|
-
return {
|
|
5612
|
-
unitId,
|
|
5613
|
-
subUnitId
|
|
5614
|
-
};
|
|
5615
|
-
}
|
|
5616
|
-
_moveRangeInterceptor(unitId, subUnitId, fromRange, toRange) {
|
|
5617
|
-
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
5618
|
-
if (!sheetSkeletonParam) return {
|
|
5619
|
-
redos: [],
|
|
5620
|
-
undos: []
|
|
5621
|
-
};
|
|
5622
|
-
const { skeleton } = sheetSkeletonParam;
|
|
5623
|
-
const selectionRect = attachRangeWithCoord(skeleton, fromRange);
|
|
5624
|
-
if (!selectionRect) return {
|
|
5625
|
-
redos: [],
|
|
5626
|
-
undos: []
|
|
5627
|
-
};
|
|
5628
|
-
const { startX, endX, startY, endY } = selectionRect;
|
|
5629
|
-
const drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
5630
|
-
const containedDrawings = [];
|
|
5631
|
-
Object.keys(drawings).forEach((drawingId) => {
|
|
5632
|
-
const drawing = drawings[drawingId];
|
|
5633
|
-
if (drawing.anchorType !== SheetDrawingAnchorType.Both) return;
|
|
5634
|
-
const { transform } = drawing;
|
|
5635
|
-
if (!transform) return;
|
|
5636
|
-
const { left = 0, top = 0, width = 0, height = 0 } = transform;
|
|
5637
|
-
const { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
|
|
5638
|
-
drawingStartX: left,
|
|
5639
|
-
drawingEndX: left + width,
|
|
5640
|
-
drawingStartY: top,
|
|
5641
|
-
drawingEndY: top + height
|
|
5642
|
-
};
|
|
5643
|
-
if (startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY) containedDrawings.push(drawing);
|
|
5644
|
-
});
|
|
5645
|
-
const redos = [];
|
|
5646
|
-
const undos = [];
|
|
5647
|
-
const rowOffset = toRange.startRow - fromRange.startRow;
|
|
5648
|
-
const colOffset = toRange.startColumn - fromRange.startColumn;
|
|
5649
|
-
const updateDrawings = containedDrawings.map((drawing) => {
|
|
5650
|
-
const oldSheetTransform = drawing.sheetTransform;
|
|
5651
|
-
const sheetTransform = {
|
|
5652
|
-
to: {
|
|
5653
|
-
...oldSheetTransform.to,
|
|
5654
|
-
row: oldSheetTransform.to.row + rowOffset,
|
|
5655
|
-
column: oldSheetTransform.to.column + colOffset
|
|
5656
|
-
},
|
|
5657
|
-
from: {
|
|
5658
|
-
...oldSheetTransform.from,
|
|
5659
|
-
row: oldSheetTransform.from.row + rowOffset,
|
|
5660
|
-
column: oldSheetTransform.from.column + colOffset
|
|
5661
|
-
}
|
|
5662
|
-
};
|
|
5663
|
-
const transform = drawingPositionToTransform(sheetTransform, sheetSkeletonParam);
|
|
5664
|
-
return {
|
|
5665
|
-
unitId,
|
|
5666
|
-
subUnitId,
|
|
5667
|
-
drawingId: drawing.drawingId,
|
|
5668
|
-
transform,
|
|
5669
|
-
sheetTransform
|
|
5670
|
-
};
|
|
5671
|
-
});
|
|
5672
|
-
if (updateDrawings.length) {
|
|
5673
|
-
const { undo, redo, objects } = this._sheetDrawingService.getBatchUpdateOp(updateDrawings);
|
|
5674
|
-
redos.push({
|
|
5675
|
-
id: SetDrawingApplyMutation.id,
|
|
5676
|
-
params: {
|
|
5677
|
-
unitId,
|
|
5678
|
-
subUnitId,
|
|
5679
|
-
op: redo,
|
|
5680
|
-
objects,
|
|
5681
|
-
type: DrawingApplyType.UPDATE
|
|
5682
|
-
}
|
|
5683
|
-
});
|
|
5684
|
-
undos.push({
|
|
5685
|
-
id: SetDrawingApplyMutation.id,
|
|
5686
|
-
params: {
|
|
5687
|
-
unitId,
|
|
5688
|
-
subUnitId,
|
|
5689
|
-
op: undo,
|
|
5690
|
-
objects,
|
|
5691
|
-
type: DrawingApplyType.UPDATE
|
|
5692
|
-
}
|
|
5693
|
-
});
|
|
5694
|
-
}
|
|
5695
|
-
return {
|
|
5696
|
-
redos,
|
|
5697
|
-
undos
|
|
5698
|
-
};
|
|
5699
|
-
}
|
|
5700
|
-
_moveRowInterceptor(params, type) {
|
|
5701
|
-
const target = this._getUnitIdAndSubUnitId(params, type);
|
|
5702
|
-
if (!target) return {
|
|
5703
|
-
redos: [],
|
|
5704
|
-
undos: []
|
|
5705
|
-
};
|
|
5706
|
-
const { unitId, subUnitId } = target;
|
|
5707
|
-
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
5708
|
-
if (!sheetSkeletonParam) return {
|
|
5709
|
-
redos: [],
|
|
5710
|
-
undos: []
|
|
5711
|
-
};
|
|
5712
|
-
const { range } = params;
|
|
5713
|
-
const rowStartIndex = range.startRow;
|
|
5714
|
-
const rowEndIndex = range.endRow;
|
|
5715
|
-
const redos = [];
|
|
5716
|
-
const undos = [];
|
|
5717
|
-
const data = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
5718
|
-
const updateDrawings = [];
|
|
5719
|
-
const deleteDrawings = [];
|
|
5720
|
-
Object.keys(data).forEach((drawingId) => {
|
|
5721
|
-
const { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = data[drawingId];
|
|
5722
|
-
if (!sheetTransform || !transform) return;
|
|
5723
|
-
let newSheetTransform;
|
|
5724
|
-
let newTransform;
|
|
5725
|
-
let axisAlignSheetTransform;
|
|
5726
|
-
if (type === "insert") {
|
|
5727
|
-
var _param$axisAlignSheet5;
|
|
5728
|
-
const param = this._expandRow(rowStartIndex, rowEndIndex, {
|
|
5729
|
-
sheetSkeletonParam,
|
|
5730
|
-
sheetTransform,
|
|
5731
|
-
transform,
|
|
5732
|
-
anchorType
|
|
5733
|
-
});
|
|
5734
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5735
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5736
|
-
axisAlignSheetTransform = (_param$axisAlignSheet5 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet5 !== void 0 ? _param$axisAlignSheet5 : void 0;
|
|
5737
|
-
} else {
|
|
5738
|
-
const { from, to } = sheetTransform;
|
|
5739
|
-
const { row: fromRow } = from;
|
|
5740
|
-
const { row: toRow } = to;
|
|
5741
|
-
if (anchorType === SheetDrawingAnchorType.Both && fromRow >= rowStartIndex && toRow <= rowEndIndex) deleteDrawings.push({
|
|
5742
|
-
unitId,
|
|
5743
|
-
subUnitId,
|
|
5744
|
-
drawingId
|
|
5745
|
-
});
|
|
5746
|
-
else {
|
|
5747
|
-
var _param$axisAlignSheet6;
|
|
5748
|
-
const param = this._shrinkRow(rowStartIndex, rowEndIndex, {
|
|
5749
|
-
sheetSkeletonParam,
|
|
5750
|
-
sheetTransform,
|
|
5751
|
-
transform,
|
|
5752
|
-
anchorType
|
|
5753
|
-
});
|
|
5754
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5755
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5756
|
-
axisAlignSheetTransform = (_param$axisAlignSheet6 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet6 !== void 0 ? _param$axisAlignSheet6 : void 0;
|
|
5757
|
-
}
|
|
5758
|
-
}
|
|
5759
|
-
if (!newSheetTransform || !newTransform) return;
|
|
5760
|
-
const params = {
|
|
5761
|
-
unitId,
|
|
5762
|
-
subUnitId,
|
|
5763
|
-
drawingId,
|
|
5764
|
-
transform: newTransform,
|
|
5765
|
-
sheetTransform: newSheetTransform,
|
|
5766
|
-
axisAlignSheetTransform
|
|
5767
|
-
};
|
|
5768
|
-
updateDrawings.push(params);
|
|
5769
|
-
});
|
|
5770
|
-
if (updateDrawings.length === 0 && deleteDrawings.length === 0) return {
|
|
5771
|
-
redos: [],
|
|
5772
|
-
undos: []
|
|
5773
|
-
};
|
|
5774
|
-
if (updateDrawings.length > 0) {
|
|
5775
|
-
const { undo, redo, objects } = this._sheetDrawingService.getBatchUpdateOp(updateDrawings);
|
|
5776
|
-
redos.push({
|
|
5777
|
-
id: SetDrawingApplyMutation.id,
|
|
5778
|
-
params: {
|
|
5779
|
-
unitId,
|
|
5780
|
-
subUnitId,
|
|
5781
|
-
op: redo,
|
|
5782
|
-
objects,
|
|
5783
|
-
type: DrawingApplyType.UPDATE
|
|
5784
|
-
}
|
|
5785
|
-
});
|
|
5786
|
-
undos.push({
|
|
5787
|
-
id: SetDrawingApplyMutation.id,
|
|
5788
|
-
params: {
|
|
5789
|
-
unitId,
|
|
5790
|
-
subUnitId,
|
|
5791
|
-
op: undo,
|
|
5792
|
-
objects,
|
|
5793
|
-
type: DrawingApplyType.UPDATE
|
|
5794
|
-
}
|
|
5795
|
-
});
|
|
5796
|
-
}
|
|
5797
|
-
if (deleteDrawings.length > 0) {
|
|
5798
|
-
const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings);
|
|
5799
|
-
const deleteUndo = deleteJsonOp.undo;
|
|
5800
|
-
const deleteRedo = deleteJsonOp.redo;
|
|
5801
|
-
const deleteObjects = deleteJsonOp.objects;
|
|
5802
|
-
redos.push({
|
|
5803
|
-
id: SetDrawingApplyMutation.id,
|
|
5804
|
-
params: {
|
|
5805
|
-
unitId,
|
|
5806
|
-
subUnitId,
|
|
5807
|
-
op: deleteRedo,
|
|
5808
|
-
objects: deleteObjects,
|
|
5809
|
-
type: DrawingApplyType.REMOVE
|
|
5810
|
-
}
|
|
5811
|
-
});
|
|
5812
|
-
undos.push({
|
|
5813
|
-
id: SetDrawingApplyMutation.id,
|
|
5814
|
-
params: {
|
|
5815
|
-
unitId,
|
|
5816
|
-
subUnitId,
|
|
5817
|
-
op: deleteUndo,
|
|
5818
|
-
objects: deleteObjects,
|
|
5819
|
-
type: DrawingApplyType.INSERT
|
|
5820
|
-
}
|
|
5821
|
-
});
|
|
5822
|
-
}
|
|
5823
|
-
redos.push({
|
|
5824
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5825
|
-
params: [unitId]
|
|
5826
|
-
});
|
|
5827
|
-
undos.push({
|
|
5828
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5829
|
-
params: [unitId]
|
|
5830
|
-
});
|
|
5831
|
-
return {
|
|
5832
|
-
redos,
|
|
5833
|
-
undos
|
|
5834
|
-
};
|
|
5835
|
-
}
|
|
5836
|
-
_moveColInterceptor(params, type) {
|
|
5837
|
-
const target = this._getUnitIdAndSubUnitId(params, type);
|
|
5838
|
-
if (!target) return {
|
|
5839
|
-
redos: [],
|
|
5840
|
-
undos: []
|
|
5841
|
-
};
|
|
5842
|
-
const { unitId, subUnitId } = target;
|
|
5843
|
-
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
5844
|
-
if (!sheetSkeletonParam) return {
|
|
5845
|
-
redos: [],
|
|
5846
|
-
undos: []
|
|
5847
|
-
};
|
|
5848
|
-
const { range } = params;
|
|
5849
|
-
const colStartIndex = range.startColumn;
|
|
5850
|
-
const colEndIndex = range.endColumn;
|
|
5851
|
-
const redos = [];
|
|
5852
|
-
const undos = [];
|
|
5853
|
-
const data = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
5854
|
-
const updateDrawings = [];
|
|
5855
|
-
const deleteDrawings = [];
|
|
5856
|
-
Object.keys(data).forEach((drawingId) => {
|
|
5857
|
-
const { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = data[drawingId];
|
|
5858
|
-
if (!sheetTransform || !transform) return;
|
|
5859
|
-
let newSheetTransform;
|
|
5860
|
-
let newTransform;
|
|
5861
|
-
let axisAlignSheetTransform;
|
|
5862
|
-
if (type === "insert") {
|
|
5863
|
-
var _param$axisAlignSheet7;
|
|
5864
|
-
const param = this._expandCol(colStartIndex, colEndIndex, {
|
|
5865
|
-
sheetSkeletonParam,
|
|
5866
|
-
sheetTransform,
|
|
5867
|
-
transform,
|
|
5868
|
-
anchorType
|
|
5869
|
-
});
|
|
5870
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5871
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5872
|
-
axisAlignSheetTransform = (_param$axisAlignSheet7 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet7 !== void 0 ? _param$axisAlignSheet7 : void 0;
|
|
5873
|
-
} else {
|
|
5874
|
-
const { from, to } = sheetTransform;
|
|
5875
|
-
const { column: fromColumn } = from;
|
|
5876
|
-
const { column: toColumn } = to;
|
|
5877
|
-
if (anchorType === SheetDrawingAnchorType.Both && fromColumn >= colStartIndex && toColumn <= colEndIndex) deleteDrawings.push({
|
|
5878
|
-
unitId,
|
|
5879
|
-
subUnitId,
|
|
5880
|
-
drawingId
|
|
5881
|
-
});
|
|
5882
|
-
else {
|
|
5883
|
-
var _param$axisAlignSheet8;
|
|
5884
|
-
const param = this._shrinkCol(colStartIndex, colEndIndex, {
|
|
5885
|
-
sheetSkeletonParam,
|
|
5886
|
-
sheetTransform,
|
|
5887
|
-
transform,
|
|
5888
|
-
anchorType
|
|
5889
|
-
});
|
|
5890
|
-
newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
|
|
5891
|
-
newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
|
|
5892
|
-
axisAlignSheetTransform = (_param$axisAlignSheet8 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet8 !== void 0 ? _param$axisAlignSheet8 : void 0;
|
|
5893
|
-
}
|
|
5894
|
-
}
|
|
5895
|
-
if (!newSheetTransform || !newTransform) return;
|
|
5896
|
-
const params = {
|
|
5897
|
-
unitId,
|
|
5898
|
-
subUnitId,
|
|
5899
|
-
drawingId,
|
|
5900
|
-
transform: newTransform,
|
|
5901
|
-
sheetTransform: newSheetTransform,
|
|
5902
|
-
axisAlignSheetTransform
|
|
5903
|
-
};
|
|
5904
|
-
updateDrawings.push(params);
|
|
5905
|
-
});
|
|
5906
|
-
if (updateDrawings.length === 0 && deleteDrawings.length === 0) return {
|
|
5907
|
-
redos: [],
|
|
5908
|
-
undos: []
|
|
5909
|
-
};
|
|
5910
|
-
if (updateDrawings.length > 0) {
|
|
5911
|
-
const { undo, redo, objects } = this._sheetDrawingService.getBatchUpdateOp(updateDrawings);
|
|
5912
|
-
redos.push({
|
|
5913
|
-
id: SetDrawingApplyMutation.id,
|
|
5914
|
-
params: {
|
|
5915
|
-
unitId,
|
|
5916
|
-
subUnitId,
|
|
5917
|
-
op: redo,
|
|
5918
|
-
objects,
|
|
5919
|
-
type: DrawingApplyType.UPDATE
|
|
5920
|
-
}
|
|
5921
|
-
});
|
|
5922
|
-
undos.push({
|
|
5923
|
-
id: SetDrawingApplyMutation.id,
|
|
5924
|
-
params: {
|
|
5925
|
-
unitId,
|
|
5926
|
-
subUnitId,
|
|
5927
|
-
op: undo,
|
|
5928
|
-
objects,
|
|
5929
|
-
type: DrawingApplyType.UPDATE
|
|
5930
|
-
}
|
|
5931
|
-
});
|
|
5932
|
-
}
|
|
5933
|
-
if (deleteDrawings.length > 0) {
|
|
5934
|
-
const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings);
|
|
5935
|
-
const deleteUndo = deleteJsonOp.undo;
|
|
5936
|
-
const deleteRedo = deleteJsonOp.redo;
|
|
5937
|
-
const deleteObjects = deleteJsonOp.objects;
|
|
5938
|
-
redos.push({
|
|
5939
|
-
id: SetDrawingApplyMutation.id,
|
|
5940
|
-
params: {
|
|
5941
|
-
unitId,
|
|
5942
|
-
subUnitId,
|
|
5943
|
-
op: deleteRedo,
|
|
5944
|
-
objects: deleteObjects,
|
|
5945
|
-
type: DrawingApplyType.REMOVE
|
|
5946
|
-
}
|
|
5947
|
-
});
|
|
5948
|
-
undos.push({
|
|
5949
|
-
id: SetDrawingApplyMutation.id,
|
|
5950
|
-
params: {
|
|
5951
|
-
unitId,
|
|
5952
|
-
subUnitId,
|
|
5953
|
-
op: deleteUndo,
|
|
5954
|
-
objects: deleteObjects,
|
|
5955
|
-
type: DrawingApplyType.INSERT
|
|
5956
|
-
}
|
|
5957
|
-
});
|
|
5958
|
-
}
|
|
5959
|
-
redos.push({
|
|
5960
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5961
|
-
params: [unitId]
|
|
5962
|
-
});
|
|
5963
|
-
undos.push({
|
|
5964
|
-
id: ClearSheetDrawingTransformerOperation.id,
|
|
5965
|
-
params: [unitId]
|
|
5966
|
-
});
|
|
5967
|
-
return {
|
|
5968
|
-
redos,
|
|
5969
|
-
undos
|
|
5970
|
-
};
|
|
5971
|
-
}
|
|
5972
|
-
_expandCol(colStartIndex, colEndIndex, options) {
|
|
5973
|
-
const { sheetSkeletonParam, sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = options;
|
|
5974
|
-
const { skeleton } = sheetSkeletonParam;
|
|
5975
|
-
const colCount = colEndIndex - colStartIndex + 1;
|
|
5976
|
-
const { from, to } = sheetTransform;
|
|
5977
|
-
const { column: fromColumn } = from;
|
|
5978
|
-
const { column: toColumn } = to;
|
|
5979
|
-
if (anchorType === SheetDrawingAnchorType.None) return {
|
|
5980
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
5981
|
-
newTransform: transform,
|
|
5982
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
5983
|
-
};
|
|
5984
|
-
let newSheetTransform = null;
|
|
5985
|
-
let newTransform = null;
|
|
5986
|
-
let axisAlignSheetTransform = null;
|
|
5987
|
-
if (fromColumn >= colStartIndex) {
|
|
5988
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
5989
|
-
startColumn: colStartIndex,
|
|
5990
|
-
endColumn: colEndIndex,
|
|
5991
|
-
startRow: from.row,
|
|
5992
|
-
endRow: to.row
|
|
5993
|
-
});
|
|
5994
|
-
newTransform = {
|
|
5995
|
-
...transform,
|
|
5996
|
-
left: (transform.left || 0) + selectionCell.endX - selectionCell.startX
|
|
5997
|
-
};
|
|
5998
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
5999
|
-
axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
6000
|
-
} else if (toColumn >= colEndIndex) if (anchorType === SheetDrawingAnchorType.Both) {
|
|
6001
|
-
newSheetTransform = {
|
|
6002
|
-
from: { ...from },
|
|
6003
|
-
to: {
|
|
6004
|
-
...to,
|
|
6005
|
-
column: toColumn + colCount
|
|
6006
|
-
}
|
|
6007
|
-
};
|
|
6008
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6009
|
-
} else return {
|
|
6010
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
6011
|
-
newTransform: transform,
|
|
6012
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
6013
|
-
};
|
|
6014
|
-
if (newSheetTransform && newTransform) return {
|
|
6015
|
-
newSheetTransform,
|
|
6016
|
-
newTransform,
|
|
6017
|
-
axisAlignSheetTransform
|
|
6018
|
-
};
|
|
6019
|
-
return null;
|
|
6020
|
-
}
|
|
6021
|
-
_shrinkCol(colStartIndex, colEndIndex, options) {
|
|
6022
|
-
const { sheetSkeletonParam, sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = options;
|
|
6023
|
-
const { skeleton } = sheetSkeletonParam;
|
|
6024
|
-
const colCount = colEndIndex - colStartIndex + 1;
|
|
6025
|
-
const { from, to } = sheetTransform;
|
|
6026
|
-
const { column: fromColumn } = from;
|
|
6027
|
-
const { column: toColumn } = to;
|
|
6028
|
-
if (anchorType === SheetDrawingAnchorType.None) return {
|
|
6029
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
6030
|
-
newTransform: transform,
|
|
6031
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
6032
|
-
};
|
|
6033
|
-
let newSheetTransform = null;
|
|
6034
|
-
let newTransform = null;
|
|
6035
|
-
let axisAlignSheetTransform = null;
|
|
6036
|
-
if (fromColumn > colEndIndex) {
|
|
6037
|
-
newSheetTransform = {
|
|
6038
|
-
from: {
|
|
6039
|
-
...from,
|
|
6040
|
-
column: fromColumn - colCount
|
|
6041
|
-
},
|
|
6042
|
-
to: {
|
|
6043
|
-
...to,
|
|
6044
|
-
column: toColumn - colCount
|
|
6045
|
-
}
|
|
6046
|
-
};
|
|
6047
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6048
|
-
} else if (fromColumn >= colStartIndex && toColumn <= colEndIndex) return null;
|
|
6049
|
-
else if (fromColumn < colStartIndex && toColumn > colEndIndex) if (anchorType === SheetDrawingAnchorType.Both) {
|
|
6050
|
-
newSheetTransform = {
|
|
6051
|
-
from: { ...from },
|
|
6052
|
-
to: {
|
|
6053
|
-
...to,
|
|
6054
|
-
column: toColumn - colCount
|
|
6055
|
-
}
|
|
6056
|
-
};
|
|
6057
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6058
|
-
} else return {
|
|
6059
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
6060
|
-
newTransform: transform,
|
|
6061
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
6062
|
-
};
|
|
6063
|
-
else if (fromColumn >= colStartIndex && fromColumn <= colEndIndex) {
|
|
6064
|
-
if (fromColumn === colStartIndex) newTransform = {
|
|
6065
|
-
...transform,
|
|
6066
|
-
left: (transform.left || 0) - sheetTransform.from.columnOffset
|
|
6067
|
-
};
|
|
6068
|
-
else {
|
|
6069
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
6070
|
-
startColumn: colStartIndex,
|
|
6071
|
-
endColumn: fromColumn - 1,
|
|
6072
|
-
startRow: from.row,
|
|
6073
|
-
endRow: to.row
|
|
6074
|
-
});
|
|
6075
|
-
newTransform = {
|
|
6076
|
-
...transform,
|
|
6077
|
-
left: (transform.left || 0) - selectionCell.endX + selectionCell.startX - sheetTransform.from.columnOffset
|
|
6078
|
-
};
|
|
6079
|
-
}
|
|
6080
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
6081
|
-
axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
6082
|
-
} else if (toColumn >= colStartIndex && toColumn <= colEndIndex && anchorType === SheetDrawingAnchorType.Both) {
|
|
6083
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
6084
|
-
startColumn: colStartIndex - 1,
|
|
6085
|
-
endColumn: colStartIndex - 1,
|
|
6086
|
-
startRow: from.row,
|
|
6087
|
-
endRow: to.row
|
|
6088
|
-
});
|
|
6089
|
-
newSheetTransform = {
|
|
6090
|
-
from: { ...from },
|
|
6091
|
-
to: {
|
|
6092
|
-
...to,
|
|
6093
|
-
column: colStartIndex - 1,
|
|
6094
|
-
columnOffset: selectionCell.endX - selectionCell.startX
|
|
6095
|
-
}
|
|
6096
|
-
};
|
|
6097
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6098
|
-
}
|
|
6099
|
-
if (newSheetTransform && newTransform) return {
|
|
6100
|
-
newSheetTransform,
|
|
6101
|
-
newTransform,
|
|
6102
|
-
axisAlignSheetTransform
|
|
6103
|
-
};
|
|
6104
|
-
return null;
|
|
6105
|
-
}
|
|
6106
|
-
_expandRow(rowStartIndex, rowEndIndex, options) {
|
|
6107
|
-
const { sheetSkeletonParam, sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = options;
|
|
6108
|
-
const { skeleton } = sheetSkeletonParam;
|
|
6109
|
-
const rowCount = rowEndIndex - rowStartIndex + 1;
|
|
6110
|
-
const { from, to } = sheetTransform;
|
|
6111
|
-
const { row: fromRow } = from;
|
|
6112
|
-
const { row: toRow } = to;
|
|
6113
|
-
if (anchorType === SheetDrawingAnchorType.None) return {
|
|
6114
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
6115
|
-
newTransform: transform,
|
|
6116
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
6117
|
-
};
|
|
6118
|
-
let newSheetTransform = null;
|
|
6119
|
-
let newTransform = null;
|
|
6120
|
-
let axisAlignSheetTransform = null;
|
|
6121
|
-
if (fromRow >= rowStartIndex) {
|
|
6122
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
6123
|
-
startRow: rowStartIndex,
|
|
6124
|
-
endRow: rowEndIndex,
|
|
6125
|
-
startColumn: from.column,
|
|
6126
|
-
endColumn: to.column
|
|
6127
|
-
});
|
|
6128
|
-
newTransform = {
|
|
6129
|
-
...transform,
|
|
6130
|
-
top: (transform.top || 0) + selectionCell.endY - selectionCell.startY
|
|
6131
|
-
};
|
|
6132
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
6133
|
-
axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
6134
|
-
} else if (toRow >= rowEndIndex) if (anchorType === SheetDrawingAnchorType.Both) {
|
|
6135
|
-
newSheetTransform = {
|
|
6136
|
-
from: { ...from },
|
|
6137
|
-
to: {
|
|
6138
|
-
...to,
|
|
6139
|
-
row: toRow + rowCount
|
|
6140
|
-
}
|
|
6141
|
-
};
|
|
6142
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6143
|
-
} else return {
|
|
6144
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
6145
|
-
newTransform: transform,
|
|
6146
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
6147
|
-
};
|
|
6148
|
-
if (newSheetTransform && newTransform) return {
|
|
6149
|
-
newSheetTransform,
|
|
6150
|
-
newTransform,
|
|
6151
|
-
axisAlignSheetTransform
|
|
6152
|
-
};
|
|
6153
|
-
return null;
|
|
6154
|
-
}
|
|
6155
|
-
_shrinkRow(rowStartIndex, rowEndIndex, options) {
|
|
6156
|
-
const { sheetSkeletonParam, sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = options;
|
|
6157
|
-
const { skeleton } = sheetSkeletonParam;
|
|
6158
|
-
const rowCount = rowEndIndex - rowStartIndex + 1;
|
|
6159
|
-
const { from, to } = sheetTransform;
|
|
6160
|
-
const { row: fromRow } = from;
|
|
6161
|
-
const { row: toRow } = to;
|
|
6162
|
-
if (anchorType === SheetDrawingAnchorType.None) return {
|
|
6163
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
6164
|
-
newTransform: transform,
|
|
6165
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
6166
|
-
};
|
|
6167
|
-
let newSheetTransform = null;
|
|
6168
|
-
let newTransform = null;
|
|
6169
|
-
let axisAlignSheetTransform = null;
|
|
6170
|
-
if (fromRow > rowEndIndex) {
|
|
6171
|
-
newSheetTransform = {
|
|
6172
|
-
from: {
|
|
6173
|
-
...from,
|
|
6174
|
-
row: fromRow - rowCount
|
|
6175
|
-
},
|
|
6176
|
-
to: {
|
|
6177
|
-
...to,
|
|
6178
|
-
row: toRow - rowCount
|
|
6179
|
-
}
|
|
6180
|
-
};
|
|
6181
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6182
|
-
} else if (fromRow >= rowStartIndex && toRow <= rowEndIndex) return null;
|
|
6183
|
-
else if (fromRow < rowStartIndex && toRow > rowEndIndex) if (anchorType === SheetDrawingAnchorType.Both) {
|
|
6184
|
-
newSheetTransform = {
|
|
6185
|
-
from: { ...from },
|
|
6186
|
-
to: {
|
|
6187
|
-
...to,
|
|
6188
|
-
row: toRow - rowCount
|
|
6189
|
-
}
|
|
6190
|
-
};
|
|
6191
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6192
|
-
} else return {
|
|
6193
|
-
newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
|
|
6194
|
-
newTransform: transform,
|
|
6195
|
-
axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
|
|
6196
|
-
};
|
|
6197
|
-
else if (fromRow >= rowStartIndex && fromRow <= rowEndIndex) {
|
|
6198
|
-
if (fromRow === rowStartIndex) newTransform = {
|
|
6199
|
-
...transform,
|
|
6200
|
-
top: (transform.top || 0) - sheetTransform.from.rowOffset
|
|
6201
|
-
};
|
|
6202
|
-
else {
|
|
6203
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
6204
|
-
startRow: rowStartIndex,
|
|
6205
|
-
endRow: fromRow - 1,
|
|
6206
|
-
startColumn: from.column,
|
|
6207
|
-
endColumn: to.column
|
|
6208
|
-
});
|
|
6209
|
-
newTransform = {
|
|
6210
|
-
...transform,
|
|
6211
|
-
top: (transform.top || 0) - selectionCell.endY + selectionCell.startY - sheetTransform.from.rowOffset
|
|
6212
|
-
};
|
|
6213
|
-
}
|
|
6214
|
-
newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
|
|
6215
|
-
axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
|
|
6216
|
-
} else if (toRow >= rowStartIndex && toRow <= rowEndIndex && anchorType === SheetDrawingAnchorType.Both) {
|
|
6217
|
-
const selectionCell = attachRangeWithCoord(skeleton, {
|
|
6218
|
-
startColumn: from.column,
|
|
6219
|
-
endColumn: from.column,
|
|
6220
|
-
startRow: rowStartIndex - 1,
|
|
6221
|
-
endRow: rowStartIndex - 1
|
|
6222
|
-
});
|
|
6223
|
-
newSheetTransform = {
|
|
6224
|
-
from: { ...from },
|
|
6225
|
-
to: {
|
|
6226
|
-
...to,
|
|
6227
|
-
row: rowStartIndex - 1,
|
|
6228
|
-
rowOffset: selectionCell.endY - selectionCell.startY
|
|
6229
|
-
}
|
|
6230
|
-
};
|
|
6231
|
-
newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
|
|
6232
|
-
}
|
|
6233
|
-
if (newSheetTransform && newTransform) return {
|
|
6234
|
-
newSheetTransform,
|
|
6235
|
-
newTransform,
|
|
6236
|
-
axisAlignSheetTransform
|
|
6237
|
-
};
|
|
6238
|
-
return null;
|
|
6239
|
-
}
|
|
6240
|
-
_commandListener() {
|
|
6241
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
6242
|
-
if (command.id === SetWorksheetActiveOperation.id) {
|
|
6243
|
-
const { unitId, subUnitId } = command.params;
|
|
6244
|
-
this._updateDrawings(unitId, subUnitId);
|
|
6245
|
-
}
|
|
6246
|
-
}));
|
|
6247
|
-
this.disposeWithMe(this._context.activated$.subscribe((activated) => {
|
|
6248
|
-
const { unit, unitId } = this._context;
|
|
6249
|
-
if (activated) {
|
|
6250
|
-
const subUnitId = unit.getActiveSheet().getSheetId();
|
|
6251
|
-
this._updateDrawings(unitId, subUnitId);
|
|
6252
|
-
} else this._clearDrawings(unitId);
|
|
6253
|
-
}));
|
|
6254
|
-
}
|
|
6255
|
-
_clearDrawings(selfUnitId) {
|
|
6256
|
-
setTimeout(() => {
|
|
6257
|
-
const drawingMap = this._drawingManagerService.drawingManagerData;
|
|
6258
|
-
const removeDrawings = [];
|
|
6259
|
-
Object.keys(drawingMap !== null && drawingMap !== void 0 ? drawingMap : {}).forEach((unitId) => {
|
|
6260
|
-
var _drawingMap$unitId;
|
|
6261
|
-
const subUnitMap = (_drawingMap$unitId = drawingMap[unitId]) !== null && _drawingMap$unitId !== void 0 ? _drawingMap$unitId : {};
|
|
6262
|
-
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
6263
|
-
var _subUnitMap$subUnitId, _subUnitMap$subUnitId2;
|
|
6264
|
-
const drawingData = (_subUnitMap$subUnitId = (_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) !== null && _subUnitMap$subUnitId !== void 0 ? _subUnitMap$subUnitId : {};
|
|
6265
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
6266
|
-
if (unitId === selfUnitId) removeDrawings.push(drawingData[drawingId]);
|
|
6267
|
-
});
|
|
6268
|
-
});
|
|
6269
|
-
});
|
|
6270
|
-
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
6271
|
-
this._drawingManagerService.removeNotification(removeDrawings);
|
|
6272
|
-
});
|
|
6273
|
-
}
|
|
6274
|
-
_updateDrawings(showUnitId, showSubunitId) {
|
|
6275
|
-
setTimeout(() => {
|
|
6276
|
-
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
|
|
6277
|
-
const drawingMap = this._drawingManagerService.drawingManagerData;
|
|
6278
|
-
const insertDrawings = [];
|
|
6279
|
-
const removeDrawings = [];
|
|
6280
|
-
Object.keys(drawingMap !== null && drawingMap !== void 0 ? drawingMap : {}).forEach((unitId) => {
|
|
6281
|
-
var _drawingMap$unitId2;
|
|
6282
|
-
if (unitId !== showUnitId) return;
|
|
6283
|
-
const subUnitMap = (_drawingMap$unitId2 = drawingMap[unitId]) !== null && _drawingMap$unitId2 !== void 0 ? _drawingMap$unitId2 : {};
|
|
6284
|
-
Object.keys(subUnitMap).forEach((subUnitId) => {
|
|
6285
|
-
var _subUnitMap$subUnitId3, _subUnitMap$subUnitId4;
|
|
6286
|
-
const drawingData = (_subUnitMap$subUnitId3 = (_subUnitMap$subUnitId4 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId4 === void 0 ? void 0 : _subUnitMap$subUnitId4.data) !== null && _subUnitMap$subUnitId3 !== void 0 ? _subUnitMap$subUnitId3 : {};
|
|
6287
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
6288
|
-
if (unitId === showUnitId && subUnitId === showSubunitId) {
|
|
6289
|
-
const drawing = drawingData[drawingId];
|
|
6290
|
-
if (drawing.sheetTransform) drawing.transform = drawingPositionToTransform(drawing.sheetTransform, sheetSkeletonParam);
|
|
6291
|
-
insertDrawings.push(drawingData[drawingId]);
|
|
6292
|
-
} else removeDrawings.push(drawingData[drawingId]);
|
|
6293
|
-
});
|
|
6294
|
-
});
|
|
6295
|
-
});
|
|
6296
|
-
this._sheetDrawingService.removeNotification(removeDrawings);
|
|
6297
|
-
this._sheetDrawingService.addNotification(insertDrawings);
|
|
6298
|
-
this._drawingManagerService.removeNotification(removeDrawings);
|
|
6299
|
-
this._drawingManagerService.addNotification(insertDrawings);
|
|
6300
|
-
}, 0);
|
|
6301
|
-
}
|
|
6302
|
-
_sheetRefreshListener() {
|
|
6303
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
6304
|
-
if (!REFRESH_MUTATIONS.includes(command.id)) return;
|
|
6305
|
-
requestIdleCallback(() => {
|
|
6306
|
-
const params = command.params;
|
|
6307
|
-
const target = getSheetCommandTarget(this._univerInstanceService, params);
|
|
6308
|
-
if (!target) return;
|
|
6309
|
-
const { unitId, subUnitId, worksheet } = target;
|
|
6310
|
-
let ranges = [];
|
|
6311
|
-
if ("ranges" in params) ranges = params.ranges;
|
|
6312
|
-
else if ("rowsAutoHeightInfo" in params) ranges = params.rowsAutoHeightInfo.map((info) => ({
|
|
6313
|
-
startRow: info.row,
|
|
6314
|
-
endRow: info.row,
|
|
6315
|
-
startColumn: 0,
|
|
6316
|
-
endColumn: worksheet.getColumnCount() - 1
|
|
6317
|
-
}));
|
|
6318
|
-
this._refreshDrawingTransform(unitId, subUnitId, ranges);
|
|
6319
|
-
});
|
|
6320
|
-
}));
|
|
6321
|
-
}
|
|
6322
|
-
_refreshDrawingTransform(unitId, subUnitId, ranges) {
|
|
6323
|
-
var _this$_drawingManager;
|
|
6324
|
-
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
6325
|
-
const drawingData = (_this$_drawingManager = this._drawingManagerService.getDrawingData(unitId, subUnitId)) !== null && _this$_drawingManager !== void 0 ? _this$_drawingManager : {};
|
|
6326
|
-
const updateDrawings = [];
|
|
6327
|
-
Object.keys(drawingData).forEach((drawingId) => {
|
|
6328
|
-
const drawing = drawingData[drawingId];
|
|
6329
|
-
const { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
|
|
6330
|
-
if (anchorType === SheetDrawingAnchorType.None) return true;
|
|
6331
|
-
if (!sheetTransform) return true;
|
|
6332
|
-
const { from, to } = sheetTransform;
|
|
6333
|
-
const { row: fromRow, column: fromColumn } = from;
|
|
6334
|
-
const { row: toRow, column: toColumn } = to;
|
|
6335
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
6336
|
-
const { startRow, endRow, startColumn, endColumn } = ranges[i];
|
|
6337
|
-
if (Rectangle.intersects({
|
|
6338
|
-
startRow,
|
|
6339
|
-
endRow,
|
|
6340
|
-
startColumn,
|
|
6341
|
-
endColumn
|
|
6342
|
-
}, {
|
|
6343
|
-
startRow: fromRow,
|
|
6344
|
-
endRow: toRow,
|
|
6345
|
-
startColumn: fromColumn,
|
|
6346
|
-
endColumn: toColumn
|
|
6347
|
-
}) || fromRow > endRow || fromColumn > endColumn) {
|
|
6348
|
-
const isPositionAnchor = anchorType === SheetDrawingAnchorType.Position;
|
|
6349
|
-
const newTransform = drawingPositionToTransform(sheetTransform, sheetSkeletonParam);
|
|
6350
|
-
updateDrawings.push({
|
|
6351
|
-
...drawing,
|
|
6352
|
-
transform: {
|
|
6353
|
-
...newTransform,
|
|
6354
|
-
width: isPositionAnchor ? transform === null || transform === void 0 ? void 0 : transform.width : newTransform === null || newTransform === void 0 ? void 0 : newTransform.width,
|
|
6355
|
-
height: isPositionAnchor ? transform === null || transform === void 0 ? void 0 : transform.height : newTransform === null || newTransform === void 0 ? void 0 : newTransform.height
|
|
6356
|
-
}
|
|
6357
|
-
});
|
|
6358
|
-
break;
|
|
6359
|
-
}
|
|
6360
|
-
}
|
|
6361
|
-
});
|
|
6362
|
-
if (updateDrawings.length === 0) return;
|
|
6363
|
-
this._sheetDrawingService.refreshTransform(updateDrawings);
|
|
6364
|
-
this._drawingManagerService.refreshTransform(updateDrawings);
|
|
6365
|
-
this._commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]);
|
|
6366
|
-
}
|
|
6367
|
-
};
|
|
6368
|
-
SheetDrawingTransformAffectedController = __decorate([
|
|
6369
|
-
__decorateParam(1, ICommandService),
|
|
6370
|
-
__decorateParam(2, Inject(SheetSkeletonService)),
|
|
6371
|
-
__decorateParam(3, ISheetSelectionRenderService),
|
|
6372
|
-
__decorateParam(4, Inject(SheetInterceptorService)),
|
|
6373
|
-
__decorateParam(5, Inject(SheetsSelectionsService)),
|
|
6374
|
-
__decorateParam(6, ISheetDrawingService),
|
|
6375
|
-
__decorateParam(7, IDrawingManagerService),
|
|
6376
|
-
__decorateParam(8, IUniverInstanceService)
|
|
6377
|
-
], SheetDrawingTransformAffectedController);
|
|
6378
|
-
|
|
6379
4997
|
//#endregion
|
|
6380
4998
|
//#region src/commands/commands/flip-drawings.command.ts
|
|
6381
4999
|
/**
|
|
@@ -6496,7 +5114,7 @@ const FlipSheetDrawingCommand = {
|
|
|
6496
5114
|
}
|
|
6497
5115
|
};
|
|
6498
5116
|
function getSceneByDrawingSearch(accessor, unitId) {
|
|
6499
|
-
const render = accessor.get(IRenderManagerService).
|
|
5117
|
+
const render = accessor.get(IRenderManagerService).getRenderUnitById(unitId);
|
|
6500
5118
|
if (!render) return null;
|
|
6501
5119
|
return render.scene;
|
|
6502
5120
|
}
|
|
@@ -6685,7 +5303,7 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends RxDisp
|
|
|
6685
5303
|
}
|
|
6686
5304
|
_popupMenuListener(unitId) {
|
|
6687
5305
|
var _this$_renderManagerS;
|
|
6688
|
-
const scene = (_this$_renderManagerS = this._renderManagerService.
|
|
5306
|
+
const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
|
|
6689
5307
|
if (!scene) return;
|
|
6690
5308
|
const transformer = scene.getTransformerByCreate();
|
|
6691
5309
|
if (!transformer) return;
|
|
@@ -6849,7 +5467,7 @@ let SheetDrawingHitTestService = class SheetDrawingHitTestService extends Dispos
|
|
|
6849
5467
|
}
|
|
6850
5468
|
hitTest(unitId, subUnitId, offsetX, offsetY) {
|
|
6851
5469
|
var _this$_renderManagerS;
|
|
6852
|
-
const scene = (_this$_renderManagerS = this._renderManagerService.
|
|
5470
|
+
const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
|
|
6853
5471
|
if (!scene) return null;
|
|
6854
5472
|
return this._hitTestScene(scene, unitId, subUnitId, offsetX, offsetY);
|
|
6855
5473
|
}
|
|
@@ -6873,7 +5491,7 @@ let SheetDrawingHitTestService = class SheetDrawingHitTestService extends Dispos
|
|
|
6873
5491
|
this._disposeDoubleClickListener();
|
|
6874
5492
|
return;
|
|
6875
5493
|
}
|
|
6876
|
-
const render = this._renderManagerService.
|
|
5494
|
+
const render = this._renderManagerService.getRenderUnitById(context.unitId);
|
|
6877
5495
|
const scene = render === null || render === void 0 ? void 0 : render.scene;
|
|
6878
5496
|
if (!render || !scene) {
|
|
6879
5497
|
this._disposeDoubleClickListener();
|
|
@@ -6991,7 +5609,7 @@ let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends Plug
|
|
|
6991
5609
|
_registerRenderModules() {
|
|
6992
5610
|
[
|
|
6993
5611
|
[SheetDrawingUpdateController],
|
|
6994
|
-
[
|
|
5612
|
+
[SheetDrawingActiveRenderController],
|
|
6995
5613
|
[SheetsDrawingRenderController],
|
|
6996
5614
|
[SheetCellImageHoverRenderController]
|
|
6997
5615
|
].forEach((m) => {
|
|
@@ -7004,7 +5622,7 @@ _defineProperty(UniverSheetsDrawingUIPlugin, "pluginName", "SHEET_IMAGE_UI_PLUGI
|
|
|
7004
5622
|
_defineProperty(UniverSheetsDrawingUIPlugin, "packageName", name);
|
|
7005
5623
|
_defineProperty(UniverSheetsDrawingUIPlugin, "version", version);
|
|
7006
5624
|
UniverSheetsDrawingUIPlugin = __decorate([
|
|
7007
|
-
DependentOn(UniverDrawingPlugin, UniverDocsDrawingPlugin, UniverDrawingUIPlugin,
|
|
5625
|
+
DependentOn(UniverDrawingPlugin, UniverRenderEnginePlugin, UniverDocsDrawingPlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsUIPlugin),
|
|
7008
5626
|
__decorateParam(1, Inject(Injector)),
|
|
7009
5627
|
__decorateParam(2, IRenderManagerService),
|
|
7010
5628
|
__decorateParam(3, IConfigService)
|