@univerjs/sheets-drawing-ui 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/lib/cjs/facade.js +4 -9
- package/lib/cjs/index.js +780 -410
- package/lib/cjs/locale/ar-SA.js +1 -2
- package/lib/cjs/locale/ca-ES.js +1 -2
- package/lib/cjs/locale/de-DE.js +1 -2
- package/lib/cjs/locale/en-US.js +1 -2
- package/lib/cjs/locale/es-ES.js +1 -2
- package/lib/cjs/locale/fa-IR.js +1 -2
- package/lib/cjs/locale/fr-FR.js +1 -2
- package/lib/cjs/locale/id-ID.js +1 -2
- package/lib/cjs/locale/it-IT.js +1 -2
- package/lib/cjs/locale/ja-JP.js +1 -2
- package/lib/cjs/locale/ko-KR.js +1 -2
- package/lib/cjs/locale/pl-PL.js +1 -2
- package/lib/cjs/locale/pt-BR.js +1 -2
- package/lib/cjs/locale/ru-RU.js +1 -2
- package/lib/cjs/locale/sk-SK.js +1 -2
- package/lib/cjs/locale/vi-VN.js +1 -2
- package/lib/cjs/locale/zh-CN.js +1 -2
- package/lib/cjs/locale/zh-HK.js +1 -2
- package/lib/cjs/locale/zh-TW.js +1 -2
- package/lib/es/facade.js +4 -8
- package/lib/es/index.js +786 -416
- package/lib/es/locale/ar-SA.js +1 -2
- package/lib/es/locale/ca-ES.js +1 -2
- package/lib/es/locale/de-DE.js +1 -2
- package/lib/es/locale/en-US.js +1 -2
- package/lib/es/locale/es-ES.js +1 -2
- package/lib/es/locale/fa-IR.js +1 -2
- package/lib/es/locale/fr-FR.js +1 -2
- package/lib/es/locale/id-ID.js +1 -2
- package/lib/es/locale/it-IT.js +1 -2
- package/lib/es/locale/ja-JP.js +1 -2
- package/lib/es/locale/ko-KR.js +1 -2
- package/lib/es/locale/pl-PL.js +1 -2
- package/lib/es/locale/pt-BR.js +1 -2
- package/lib/es/locale/ru-RU.js +1 -2
- package/lib/es/locale/sk-SK.js +1 -2
- package/lib/es/locale/vi-VN.js +1 -2
- package/lib/es/locale/zh-CN.js +1 -2
- package/lib/es/locale/zh-HK.js +1 -2
- package/lib/es/locale/zh-TW.js +1 -2
- package/lib/facade.js +4 -8
- package/lib/index.js +786 -416
- package/lib/locale/ar-SA.js +1 -2
- package/lib/locale/ca-ES.js +1 -2
- package/lib/locale/de-DE.js +1 -2
- package/lib/locale/en-US.js +1 -2
- package/lib/locale/es-ES.js +1 -2
- package/lib/locale/fa-IR.js +1 -2
- package/lib/locale/fr-FR.js +1 -2
- package/lib/locale/id-ID.js +1 -2
- package/lib/locale/it-IT.js +1 -2
- package/lib/locale/ja-JP.js +1 -2
- package/lib/locale/ko-KR.js +1 -2
- package/lib/locale/pl-PL.js +1 -2
- package/lib/locale/pt-BR.js +1 -2
- package/lib/locale/ru-RU.js +1 -2
- package/lib/locale/sk-SK.js +1 -2
- package/lib/locale/vi-VN.js +1 -2
- package/lib/locale/zh-CN.js +1 -2
- package/lib/locale/zh-HK.js +1 -2
- package/lib/locale/zh-TW.js +1 -2
- package/lib/types/controllers/sheet-drawing-copy-paste.controller.d.ts +7 -3
- package/lib/types/controllers/sheet-drawing-permission.controller.d.ts +2 -0
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +7 -4
- package/lib/types/facade/f-worksheet.d.ts +5 -1
- package/lib/types/menu/drawing-popup-menu.controller.d.ts +5 -2
- package/lib/types/services/batch-save-images.service.d.ts +1 -1
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +11 -4
- package/lib/types/services/drawing-context-menu.service.d.ts +1 -1
- package/lib/types/views/background/worksheet-background-image.extension.d.ts +1 -0
- package/lib/umd/index.js +2 -2
- package/package.json +19 -19
package/lib/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ let react = require("react");
|
|
|
15
15
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
16
16
|
let _univerjs_docs_ui = require("@univerjs/docs-ui");
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// src/commands/commands/delete-drawings.command.ts
|
|
19
19
|
const DeleteDrawingsCommand = {
|
|
20
20
|
id: "sheet.command.delete-drawing",
|
|
21
21
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -40,8 +40,7 @@ const DeleteDrawingsCommand = {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
//#region src/commands/commands/utils.ts
|
|
43
|
+
// src/commands/commands/utils.ts
|
|
45
44
|
function ungroupToGroup(ungroupParams) {
|
|
46
45
|
const newGroupParams = [];
|
|
47
46
|
ungroupParams.forEach((ungroupParam) => {
|
|
@@ -161,8 +160,7 @@ function cloneDrawingParam(param, newDrawingId, parentGroupId) {
|
|
|
161
160
|
return JSON.parse(JSON.stringify(newParam));
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
|
|
165
|
-
//#region src/commands/commands/group-sheet-drawing.command.ts
|
|
163
|
+
// src/commands/commands/group-sheet-drawing.command.ts
|
|
166
164
|
/**
|
|
167
165
|
* The command to insert new defined name
|
|
168
166
|
*/
|
|
@@ -224,8 +222,7 @@ const GroupSheetDrawingCommand = {
|
|
|
224
222
|
}
|
|
225
223
|
};
|
|
226
224
|
|
|
227
|
-
|
|
228
|
-
//#region src/commands/commands/ungroup-sheet-drawing.command.ts
|
|
225
|
+
// src/commands/commands/ungroup-sheet-drawing.command.ts
|
|
229
226
|
/**
|
|
230
227
|
* The command to insert new defined name
|
|
231
228
|
*/
|
|
@@ -287,8 +284,7 @@ const UngroupSheetDrawingCommand = {
|
|
|
287
284
|
}
|
|
288
285
|
};
|
|
289
286
|
|
|
290
|
-
|
|
291
|
-
//#region src/utils/worksheet-background-image.ts
|
|
287
|
+
// src/utils/worksheet-background-image.ts
|
|
292
288
|
/**
|
|
293
289
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
294
290
|
*
|
|
@@ -427,8 +423,7 @@ function readUint32Be(bytes, offset) {
|
|
|
427
423
|
return ((bytes[offset] ?? 0) << 24 >>> 0 | (bytes[offset + 1] ?? 0) << 16 | (bytes[offset + 2] ?? 0) << 8 | (bytes[offset + 3] ?? 0)) >>> 0;
|
|
428
424
|
}
|
|
429
425
|
|
|
430
|
-
|
|
431
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
426
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
432
427
|
function _typeof(o) {
|
|
433
428
|
"@babel/helpers - typeof";
|
|
434
429
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -438,28 +433,25 @@ function _typeof(o) {
|
|
|
438
433
|
}, _typeof(o);
|
|
439
434
|
}
|
|
440
435
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
function toPrimitive(t, r) {
|
|
436
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
437
|
+
function toPrimitive(t, e) {
|
|
444
438
|
if ("object" != _typeof(t) || !t) return t;
|
|
445
|
-
var
|
|
446
|
-
if (void 0 !==
|
|
447
|
-
var i =
|
|
439
|
+
var r;
|
|
440
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
441
|
+
var i = r.call(t, e || "default");
|
|
448
442
|
if ("object" != _typeof(i)) return i;
|
|
449
443
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
450
444
|
}
|
|
451
|
-
return ("string" ===
|
|
445
|
+
return ("string" === e ? String : Number)(t);
|
|
452
446
|
}
|
|
453
447
|
|
|
454
|
-
|
|
455
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
448
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
456
449
|
function toPropertyKey(t) {
|
|
457
450
|
var i = toPrimitive(t, "string");
|
|
458
451
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
459
452
|
}
|
|
460
453
|
|
|
461
|
-
|
|
462
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
454
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
463
455
|
function _defineProperty(e, r, t) {
|
|
464
456
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
465
457
|
value: t,
|
|
@@ -469,16 +461,14 @@ function _defineProperty(e, r, t) {
|
|
|
469
461
|
}) : e[r] = t, e;
|
|
470
462
|
}
|
|
471
463
|
|
|
472
|
-
|
|
473
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
464
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
474
465
|
function __decorateParam(paramIndex, decorator) {
|
|
475
466
|
return function(target, key) {
|
|
476
467
|
decorator(target, key, paramIndex);
|
|
477
468
|
};
|
|
478
469
|
}
|
|
479
470
|
|
|
480
|
-
|
|
481
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
471
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
482
472
|
function __decorate(decorators, target, key, desc) {
|
|
483
473
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
484
474
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -486,8 +476,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
486
476
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
487
477
|
}
|
|
488
478
|
|
|
489
|
-
|
|
490
|
-
//#region src/controllers/sheet-drawing-update.controller.ts
|
|
479
|
+
// src/controllers/sheet-drawing-update.controller.ts
|
|
491
480
|
/**
|
|
492
481
|
* Calculate the bounding box after rotation
|
|
493
482
|
* @param {number} width Width
|
|
@@ -530,12 +519,11 @@ function getDrawingSizeByCell(accessor, location, originImageWidth, originImageH
|
|
|
530
519
|
};
|
|
531
520
|
}
|
|
532
521
|
let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _univerjs_core.Disposable {
|
|
533
|
-
constructor(_context, _commandService, _sheetInterceptorService,
|
|
522
|
+
constructor(_context, _commandService, _sheetInterceptorService, _imageIoService, _fileOpenerService, _sheetDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, selectionManagerService, _sheetSkeletonService, _injector, _urlImageService) {
|
|
534
523
|
super();
|
|
535
524
|
this._context = _context;
|
|
536
525
|
this._commandService = _commandService;
|
|
537
526
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
538
|
-
this._selectionRenderService = _selectionRenderService;
|
|
539
527
|
this._imageIoService = _imageIoService;
|
|
540
528
|
this._fileOpenerService = _fileOpenerService;
|
|
541
529
|
this._sheetDrawingService = _sheetDrawingService;
|
|
@@ -554,6 +542,8 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
554
542
|
this._focusDrawingListener();
|
|
555
543
|
}
|
|
556
544
|
async insertFloatImage() {
|
|
545
|
+
const target = this._captureImageTarget();
|
|
546
|
+
if (!target) return false;
|
|
557
547
|
const files = await this._fileOpenerService.openFile({
|
|
558
548
|
multiple: true,
|
|
559
549
|
accept: _univerjs_drawing.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
|
|
@@ -566,18 +556,19 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
566
556
|
});
|
|
567
557
|
return false;
|
|
568
558
|
} else if (fileLength === 0) return false;
|
|
569
|
-
files.
|
|
570
|
-
|
|
559
|
+
return (await Promise.all(files.map((file) => this._insertFloatImage(file, target).catch((error) => {
|
|
560
|
+
this._injector.get(_univerjs_core.ILogService).error(error);
|
|
561
|
+
return false;
|
|
562
|
+
})))).every(Boolean);
|
|
571
563
|
}
|
|
572
564
|
async insertCellImage() {
|
|
565
|
+
const target = this._captureCellImageTarget();
|
|
566
|
+
if (!target) return false;
|
|
573
567
|
const file = (await this._fileOpenerService.openFile({
|
|
574
568
|
multiple: false,
|
|
575
569
|
accept: _univerjs_drawing.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
|
|
576
570
|
}))[0];
|
|
577
|
-
if (file)
|
|
578
|
-
await this._insertCellImage(file);
|
|
579
|
-
return true;
|
|
580
|
-
}
|
|
571
|
+
if (file) return this._insertCellImage(file, void 0, target);
|
|
581
572
|
return false;
|
|
582
573
|
}
|
|
583
574
|
async setWorksheetBackgroundImage(files) {
|
|
@@ -622,6 +613,15 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
622
613
|
return this._insertCellImage(file, location);
|
|
623
614
|
}
|
|
624
615
|
async insertFloatImageByFile(file) {
|
|
616
|
+
const target = this._captureImageTarget();
|
|
617
|
+
if (!target) return false;
|
|
618
|
+
return this._insertFloatImage(file, target).catch((error) => {
|
|
619
|
+
this._injector.get(_univerjs_core.ILogService).error(error);
|
|
620
|
+
return false;
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
async _insertFloatImage(file, target) {
|
|
624
|
+
if (!this._isImageTargetValid(target)) return false;
|
|
625
625
|
let imageParam;
|
|
626
626
|
try {
|
|
627
627
|
imageParam = await this._imageIoService.saveImage(file);
|
|
@@ -640,11 +640,14 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
640
640
|
content: this._localeService.t("sheets-drawing-ui.update-status.invalidImage")
|
|
641
641
|
});
|
|
642
642
|
}
|
|
643
|
-
if (imageParam == null) return;
|
|
644
|
-
const { unitId, subUnitId } =
|
|
643
|
+
if (imageParam == null || !this._isImageTargetValid(target)) return false;
|
|
644
|
+
const { unitId, subUnitId } = target;
|
|
645
645
|
const { imageId, imageSourceType, source, base64Cache } = imageParam;
|
|
646
|
-
const
|
|
647
|
-
|
|
646
|
+
const imageSize = await (0, _univerjs_drawing.getImageSize)(base64Cache || "").catch(() => null);
|
|
647
|
+
if (!imageSize) return false;
|
|
648
|
+
const { width, height, image } = imageSize;
|
|
649
|
+
if (!this._isImageTargetValid(target) || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return false;
|
|
650
|
+
const { sceneWidth, sceneHeight } = target;
|
|
648
651
|
this._imageIoService.addImageSourceCache(source, imageSourceType, image);
|
|
649
652
|
let scale = 1;
|
|
650
653
|
if (width > _univerjs_drawing.DRAWING_IMAGE_WIDTH_LIMIT || height > _univerjs_drawing.DRAWING_IMAGE_HEIGHT_LIMIT) {
|
|
@@ -652,13 +655,51 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
652
655
|
const scaleHeight = _univerjs_drawing.DRAWING_IMAGE_HEIGHT_LIMIT / height;
|
|
653
656
|
scale = Math.min(scaleWidth, scaleHeight);
|
|
654
657
|
}
|
|
658
|
+
if (target.worksheet.getConfig().type === _univerjs_core.SheetTypes.CHART) {
|
|
659
|
+
const bounds = this._getChartImageBounds(target.render);
|
|
660
|
+
if (!bounds) return false;
|
|
661
|
+
const marker = {
|
|
662
|
+
row: 0,
|
|
663
|
+
column: 0,
|
|
664
|
+
rowOffset: 0,
|
|
665
|
+
columnOffset: 0
|
|
666
|
+
};
|
|
667
|
+
const placed = (0, _univerjs_sheets_drawing.transformDrawingsToChartSheet)([{
|
|
668
|
+
unitId,
|
|
669
|
+
subUnitId,
|
|
670
|
+
drawingId: imageId,
|
|
671
|
+
drawingType: _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE,
|
|
672
|
+
imageSourceType,
|
|
673
|
+
source,
|
|
674
|
+
transform: {
|
|
675
|
+
left: 0,
|
|
676
|
+
top: 0,
|
|
677
|
+
width: width * scale,
|
|
678
|
+
height: height * scale
|
|
679
|
+
},
|
|
680
|
+
sheetTransform: {
|
|
681
|
+
from: marker,
|
|
682
|
+
to: marker
|
|
683
|
+
},
|
|
684
|
+
axisAlignSheetTransform: {
|
|
685
|
+
from: marker,
|
|
686
|
+
to: marker
|
|
687
|
+
}
|
|
688
|
+
}], bounds, target.worksheet.getConfig().rightToLeft === _univerjs_core.BooleanNumber.TRUE);
|
|
689
|
+
if (!(placed === null || placed === void 0 ? void 0 : placed.length)) return false;
|
|
690
|
+
const [drawing] = placed;
|
|
691
|
+
return this._commandService.executeCommand(_univerjs_sheets_drawing.InsertSheetDrawingCommand.id, {
|
|
692
|
+
unitId,
|
|
693
|
+
drawings: [drawing]
|
|
694
|
+
});
|
|
695
|
+
}
|
|
655
696
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
656
|
-
if (!sheetSkeletonParam) return;
|
|
697
|
+
if (!sheetSkeletonParam) return false;
|
|
657
698
|
const { skeleton } = sheetSkeletonParam;
|
|
658
|
-
const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight, skeleton);
|
|
659
|
-
if (!sheetTransform) return;
|
|
699
|
+
const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight, skeleton, target.range);
|
|
700
|
+
if (!sheetTransform) return false;
|
|
660
701
|
const newTransform = (0, _univerjs_sheets_drawing.drawingPositionToTransform)(sheetTransform, sheetSkeletonParam);
|
|
661
|
-
if (!newTransform) return;
|
|
702
|
+
if (!newTransform) return false;
|
|
662
703
|
const sheetDrawingParam = {
|
|
663
704
|
unitId,
|
|
664
705
|
subUnitId,
|
|
@@ -675,7 +716,9 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
675
716
|
drawings: [sheetDrawingParam]
|
|
676
717
|
});
|
|
677
718
|
}
|
|
678
|
-
async _insertCellImage(file, location) {
|
|
719
|
+
async _insertCellImage(file, location, capturedTarget) {
|
|
720
|
+
const target = capturedTarget ?? this._captureCellImageTarget(location);
|
|
721
|
+
if (!target || !this._isImageTargetValid(target)) return false;
|
|
679
722
|
let imageParam;
|
|
680
723
|
try {
|
|
681
724
|
imageParam = await this._imageIoService.saveImage(file);
|
|
@@ -698,21 +741,11 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
698
741
|
const { imageId, imageSourceType, source, base64Cache } = imageParam;
|
|
699
742
|
const { width, height, image } = await (0, _univerjs_drawing.getImageSize)(base64Cache || "");
|
|
700
743
|
this._imageIoService.addImageSourceCache(source, imageSourceType, image);
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
let col = selection.primary.actualColumn;
|
|
705
|
-
if (selection.primary.isMerged) {
|
|
706
|
-
row = selection.primary.startRow;
|
|
707
|
-
col = selection.primary.startColumn;
|
|
708
|
-
}
|
|
744
|
+
if (!this._isImageTargetValid(target)) return false;
|
|
745
|
+
const cellLocation = target.location;
|
|
746
|
+
const { row, col } = cellLocation;
|
|
709
747
|
const docDataModel = (0, _univerjs_core.createDocumentModelWithStyle)("", {});
|
|
710
|
-
const imageSize = getDrawingSizeByCell(this._injector,
|
|
711
|
-
unitId: this._context.unitId,
|
|
712
|
-
subUnitId: this._context.unit.getActiveSheet().getSheetId(),
|
|
713
|
-
row,
|
|
714
|
-
col
|
|
715
|
-
}, width, height, 0);
|
|
748
|
+
const imageSize = getDrawingSizeByCell(this._injector, cellLocation, width, height, 0);
|
|
716
749
|
if (!imageSize) return false;
|
|
717
750
|
const docTransform = (0, _univerjs_docs.buildDocTransform)(imageSize.width, imageSize.height);
|
|
718
751
|
const docDrawingParam = {
|
|
@@ -746,17 +779,25 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
746
779
|
if (jsonXActions) {
|
|
747
780
|
docDataModel.apply(jsonXActions);
|
|
748
781
|
return this._commandService.syncExecuteCommand(_univerjs_sheets.SetRangeValuesCommand.id, {
|
|
749
|
-
value: { [
|
|
782
|
+
value: { [row]: { [col]: {
|
|
750
783
|
p: docDataModel.getSnapshot(),
|
|
751
784
|
t: 1
|
|
752
785
|
} } },
|
|
753
|
-
unitId:
|
|
754
|
-
subUnitId:
|
|
786
|
+
unitId: target.unitId,
|
|
787
|
+
subUnitId: target.subUnitId,
|
|
788
|
+
range: {
|
|
789
|
+
startRow: row,
|
|
790
|
+
endRow: row,
|
|
791
|
+
startColumn: col,
|
|
792
|
+
endColumn: col
|
|
793
|
+
}
|
|
755
794
|
});
|
|
756
795
|
}
|
|
757
796
|
return false;
|
|
758
797
|
}
|
|
759
798
|
async insertCellImageByUrl(url, location) {
|
|
799
|
+
const target = this._captureCellImageTarget(location);
|
|
800
|
+
if (!target) return false;
|
|
760
801
|
let src = url;
|
|
761
802
|
try {
|
|
762
803
|
src = await this._urlImageService.getImage(url);
|
|
@@ -765,15 +806,10 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
765
806
|
}
|
|
766
807
|
const { width, height, image } = await (0, _univerjs_drawing.getImageSize)(src || "");
|
|
767
808
|
this._imageIoService.addImageSourceCache(url, _univerjs_core.ImageSourceType.URL, image);
|
|
768
|
-
|
|
769
|
-
|
|
809
|
+
if (!this._isImageTargetValid(target)) return false;
|
|
810
|
+
const cellLocation = target.location;
|
|
770
811
|
const docDataModel = (0, _univerjs_core.createDocumentModelWithStyle)("", {});
|
|
771
|
-
const imageSize = getDrawingSizeByCell(this._injector,
|
|
772
|
-
unitId: this._context.unitId,
|
|
773
|
-
subUnitId: this._context.unit.getActiveSheet().getSheetId(),
|
|
774
|
-
row: selection.primary.actualRow,
|
|
775
|
-
col: selection.primary.actualColumn
|
|
776
|
-
}, width, height, 0);
|
|
812
|
+
const imageSize = getDrawingSizeByCell(this._injector, cellLocation, width, height, 0);
|
|
777
813
|
if (!imageSize) return false;
|
|
778
814
|
const docTransform = (0, _univerjs_docs.buildDocTransform)(imageSize.width, imageSize.height);
|
|
779
815
|
const docDrawingParam = {
|
|
@@ -807,16 +843,87 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
807
843
|
if (jsonXActions) {
|
|
808
844
|
docDataModel.apply(jsonXActions);
|
|
809
845
|
return this._commandService.syncExecuteCommand(_univerjs_sheets.SetRangeValuesCommand.id, {
|
|
810
|
-
value: { [
|
|
846
|
+
value: { [cellLocation.row]: { [cellLocation.col]: {
|
|
811
847
|
p: docDataModel.getSnapshot(),
|
|
812
848
|
t: 1
|
|
813
849
|
} } },
|
|
814
|
-
unitId:
|
|
815
|
-
subUnitId:
|
|
850
|
+
unitId: target.unitId,
|
|
851
|
+
subUnitId: target.subUnitId,
|
|
852
|
+
range: {
|
|
853
|
+
startRow: cellLocation.row,
|
|
854
|
+
endRow: cellLocation.row,
|
|
855
|
+
startColumn: cellLocation.col,
|
|
856
|
+
endColumn: cellLocation.col
|
|
857
|
+
}
|
|
816
858
|
});
|
|
817
859
|
}
|
|
818
860
|
return false;
|
|
819
861
|
}
|
|
862
|
+
_captureImageTarget(location) {
|
|
863
|
+
if (this._disposed) return null;
|
|
864
|
+
const instances = this._injector.get(_univerjs_core.IUniverInstanceService);
|
|
865
|
+
const host = (0, _univerjs_sheets.getSheetCommandTarget)(instances, location ?? { unitId: this._context.unitId });
|
|
866
|
+
const render = host && this._injector.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(host.unitId);
|
|
867
|
+
const sheetType = (host === null || host === void 0 ? void 0 : host.worksheet.getConfig().type) ?? _univerjs_core.SheetTypes.GRID;
|
|
868
|
+
if (!host || !render || sheetType !== _univerjs_core.SheetTypes.GRID && sheetType !== _univerjs_core.SheetTypes.CHART) return null;
|
|
869
|
+
const frame = render.components.get(_univerjs_sheets_ui.SHEET_VIEW_KEY.CHART_PAGE);
|
|
870
|
+
const pageFrame = frame instanceof _univerjs_engine_render.Rect ? frame : void 0;
|
|
871
|
+
const selections = this._workbookSelections.getCurrentSelections();
|
|
872
|
+
const range = (selections === null || selections === void 0 ? void 0 : selections.length) ? { ...selections[selections.length - 1].range } : {
|
|
873
|
+
startRow: 0,
|
|
874
|
+
endRow: 0,
|
|
875
|
+
startColumn: 0,
|
|
876
|
+
endColumn: 0
|
|
877
|
+
};
|
|
878
|
+
const target = {
|
|
879
|
+
...host,
|
|
880
|
+
render,
|
|
881
|
+
location,
|
|
882
|
+
pageFrame,
|
|
883
|
+
range,
|
|
884
|
+
sceneWidth: render.scene.width,
|
|
885
|
+
sceneHeight: render.scene.height
|
|
886
|
+
};
|
|
887
|
+
return this._isImageTargetValid(target) ? target : null;
|
|
888
|
+
}
|
|
889
|
+
_captureCellImageTarget(location) {
|
|
890
|
+
const target = this._captureImageTarget(location);
|
|
891
|
+
if (!target || (target.worksheet.getConfig().type ?? _univerjs_core.SheetTypes.GRID) !== _univerjs_core.SheetTypes.GRID) return null;
|
|
892
|
+
if (!location) {
|
|
893
|
+
const selection = this._workbookSelections.getCurrentLastSelection();
|
|
894
|
+
if (!selection) return null;
|
|
895
|
+
const { primary } = selection;
|
|
896
|
+
target.location = {
|
|
897
|
+
unitId: target.unitId,
|
|
898
|
+
subUnitId: target.subUnitId,
|
|
899
|
+
row: primary.isMerged ? primary.startRow : primary.actualRow,
|
|
900
|
+
col: primary.isMerged ? primary.startColumn : primary.actualColumn
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
return target;
|
|
904
|
+
}
|
|
905
|
+
_isImageTargetValid(target) {
|
|
906
|
+
if (this._disposed) return false;
|
|
907
|
+
const instances = this._injector.get(_univerjs_core.IUniverInstanceService);
|
|
908
|
+
const { workbook, worksheet, unitId, subUnitId, render } = target;
|
|
909
|
+
if (instances.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET) !== workbook || workbook.getSheetBySheetId(subUnitId) !== worksheet || render.isDisposed() || this._injector.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(unitId) !== render) return false;
|
|
910
|
+
return worksheet.getConfig().type !== _univerjs_core.SheetTypes.CHART || target.pageFrame === render.components.get(_univerjs_sheets_ui.SHEET_VIEW_KEY.CHART_PAGE) && Boolean(this._getChartImageBounds(render));
|
|
911
|
+
}
|
|
912
|
+
_getChartImageBounds(render) {
|
|
913
|
+
const frame = render.components.get(_univerjs_sheets_ui.SHEET_VIEW_KEY.CHART_PAGE);
|
|
914
|
+
if (!frame || ![
|
|
915
|
+
frame.left,
|
|
916
|
+
frame.top,
|
|
917
|
+
frame.width,
|
|
918
|
+
frame.height
|
|
919
|
+
].every(Number.isFinite) || frame.width <= 0 || frame.height <= 0) return null;
|
|
920
|
+
return {
|
|
921
|
+
left: frame.left,
|
|
922
|
+
top: frame.top,
|
|
923
|
+
width: frame.width,
|
|
924
|
+
height: frame.height
|
|
925
|
+
};
|
|
926
|
+
}
|
|
820
927
|
_getUnitInfo() {
|
|
821
928
|
const workbook = this._context.unit;
|
|
822
929
|
const worksheet = workbook.getActiveSheet();
|
|
@@ -825,15 +932,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
825
932
|
subUnitId: worksheet.getSheetId()
|
|
826
933
|
};
|
|
827
934
|
}
|
|
828
|
-
_getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight, skeleton) {
|
|
829
|
-
const selections = this._workbookSelections.getCurrentSelections();
|
|
830
|
-
let range = {
|
|
831
|
-
startRow: 0,
|
|
832
|
-
endRow: 0,
|
|
833
|
-
startColumn: 0,
|
|
834
|
-
endColumn: 0
|
|
835
|
-
};
|
|
836
|
-
if (selections && selections.length > 0) range = selections[selections.length - 1].range;
|
|
935
|
+
_getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight, skeleton, range) {
|
|
837
936
|
const rangeWithCoord = (0, _univerjs_sheets.attachRangeWithCoord)(skeleton, range);
|
|
838
937
|
if (rangeWithCoord == null) return;
|
|
839
938
|
let { startColumn, startRow, startX, startY } = rangeWithCoord;
|
|
@@ -855,7 +954,10 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
855
954
|
isChangeStart = true;
|
|
856
955
|
}
|
|
857
956
|
if (isChangeStart) {
|
|
858
|
-
const newCoord =
|
|
957
|
+
const newCoord = skeleton.getCellWithCoordByOffset(startX, startY, 1, 1, {
|
|
958
|
+
x: 0,
|
|
959
|
+
y: 0
|
|
960
|
+
});
|
|
859
961
|
if (newCoord == null) return;
|
|
860
962
|
startX = newCoord.startX;
|
|
861
963
|
startY = newCoord.startY;
|
|
@@ -868,7 +970,10 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
868
970
|
row: startRow,
|
|
869
971
|
rowOffset: 0
|
|
870
972
|
};
|
|
871
|
-
const endSelectionCell =
|
|
973
|
+
const endSelectionCell = skeleton.getCellWithCoordByOffset(startX + imageWidth, startY + imageHeight, 1, 1, {
|
|
974
|
+
x: 0,
|
|
975
|
+
y: 0
|
|
976
|
+
});
|
|
872
977
|
if (endSelectionCell == null) return;
|
|
873
978
|
return {
|
|
874
979
|
from,
|
|
@@ -898,14 +1003,27 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
898
1003
|
params.forEach((param) => {
|
|
899
1004
|
const { unitId, subUnitId, drawingId, transform } = param;
|
|
900
1005
|
const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
|
|
901
|
-
if (!transform
|
|
902
|
-
const { skeleton } = sheetSkeletonParam;
|
|
1006
|
+
if (!transform) return;
|
|
903
1007
|
const sheetDrawing = this._sheetDrawingService.getDrawingByParam({
|
|
904
1008
|
unitId,
|
|
905
1009
|
subUnitId,
|
|
906
1010
|
drawingId
|
|
907
1011
|
});
|
|
908
1012
|
if (sheetDrawing == null || sheetDrawing.unitId !== this._context.unitId) return;
|
|
1013
|
+
if (sheetDrawing.anchorType === _univerjs_sheets_drawing.SheetDrawingAnchorType.None) {
|
|
1014
|
+
const next = {
|
|
1015
|
+
...sheetDrawing,
|
|
1016
|
+
...param,
|
|
1017
|
+
transform: {
|
|
1018
|
+
...sheetDrawing.transform,
|
|
1019
|
+
...transform
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
drawings.push((0, _univerjs_sheets_drawing.applySheetDrawingPlacement)(next, (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(next)));
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
if (!sheetSkeletonParam) return;
|
|
1026
|
+
const { skeleton } = sheetSkeletonParam;
|
|
909
1027
|
const sheetTransform = (0, _univerjs_sheets_drawing.transformToDrawingPosition)({
|
|
910
1028
|
...sheetDrawing.transform,
|
|
911
1029
|
...transform
|
|
@@ -1030,22 +1148,20 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
|
|
|
1030
1148
|
SheetDrawingUpdateController = __decorate([
|
|
1031
1149
|
__decorateParam(1, _univerjs_core.ICommandService),
|
|
1032
1150
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
1033
|
-
__decorateParam(3,
|
|
1034
|
-
__decorateParam(4,
|
|
1035
|
-
__decorateParam(5,
|
|
1036
|
-
__decorateParam(6,
|
|
1037
|
-
__decorateParam(7,
|
|
1038
|
-
__decorateParam(8,
|
|
1039
|
-
__decorateParam(9,
|
|
1040
|
-
__decorateParam(10, (0, _univerjs_core.Inject)(
|
|
1041
|
-
__decorateParam(11, (0, _univerjs_core.Inject)(_univerjs_sheets.
|
|
1042
|
-
__decorateParam(12, (0, _univerjs_core.Inject)(
|
|
1043
|
-
__decorateParam(13,
|
|
1044
|
-
__decorateParam(14, _univerjs_core.IURLImageService)
|
|
1151
|
+
__decorateParam(3, _univerjs_core.IImageIoService),
|
|
1152
|
+
__decorateParam(4, _univerjs_ui.ILocalFileService),
|
|
1153
|
+
__decorateParam(5, _univerjs_sheets_drawing.ISheetDrawingService),
|
|
1154
|
+
__decorateParam(6, _univerjs_drawing.IDrawingManagerService),
|
|
1155
|
+
__decorateParam(7, _univerjs_core.IContextService),
|
|
1156
|
+
__decorateParam(8, _univerjs_ui.IMessageService),
|
|
1157
|
+
__decorateParam(9, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
1158
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService)),
|
|
1159
|
+
__decorateParam(11, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService)),
|
|
1160
|
+
__decorateParam(12, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1161
|
+
__decorateParam(13, _univerjs_core.IURLImageService)
|
|
1045
1162
|
], SheetDrawingUpdateController);
|
|
1046
1163
|
|
|
1047
|
-
|
|
1048
|
-
//#region src/commands/commands/insert-image.command.ts
|
|
1164
|
+
// src/commands/commands/insert-image.command.ts
|
|
1049
1165
|
const InsertFloatImageCommand = {
|
|
1050
1166
|
id: "sheet.command.insert-float-image",
|
|
1051
1167
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -1073,8 +1189,7 @@ const InsertCellImageCommand = {
|
|
|
1073
1189
|
}
|
|
1074
1190
|
};
|
|
1075
1191
|
|
|
1076
|
-
|
|
1077
|
-
//#region src/commands/commands/move-drawings.command.ts
|
|
1192
|
+
// src/commands/commands/move-drawings.command.ts
|
|
1078
1193
|
const MoveDrawingsCommand = {
|
|
1079
1194
|
id: "sheet.command.move-drawing",
|
|
1080
1195
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -1087,27 +1202,60 @@ const MoveDrawingsCommand = {
|
|
|
1087
1202
|
const drawings = drawingManagerService.getFocusDrawings();
|
|
1088
1203
|
if (drawings.length === 0) return false;
|
|
1089
1204
|
const unitId = drawings[0].unitId;
|
|
1090
|
-
const
|
|
1091
|
-
const
|
|
1092
|
-
const
|
|
1093
|
-
if (!transform
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1205
|
+
const movableDrawings = drawings.flatMap((drawing) => {
|
|
1206
|
+
const sheetDrawing = drawing;
|
|
1207
|
+
const { transform, anchorType = _univerjs_sheets_drawing.SheetDrawingAnchorType.Position } = sheetDrawing;
|
|
1208
|
+
if (!transform) return [];
|
|
1209
|
+
const skeleton = sheetSkeletonService.getSkeleton(drawing.unitId, drawing.subUnitId);
|
|
1210
|
+
if (anchorType !== _univerjs_sheets_drawing.SheetDrawingAnchorType.None && !skeleton) return [];
|
|
1211
|
+
return [{
|
|
1212
|
+
drawing: sheetDrawing,
|
|
1213
|
+
skeleton,
|
|
1214
|
+
anchorType
|
|
1215
|
+
}];
|
|
1216
|
+
});
|
|
1217
|
+
if (movableDrawings.length === 0) return false;
|
|
1218
|
+
let moveX = direction === _univerjs_core.Direction.LEFT ? -1 : direction === _univerjs_core.Direction.RIGHT ? 1 : 0;
|
|
1219
|
+
let moveY = direction === _univerjs_core.Direction.UP ? -1 : direction === _univerjs_core.Direction.DOWN ? 1 : 0;
|
|
1220
|
+
let minX = -Infinity;
|
|
1221
|
+
let minY = -Infinity;
|
|
1222
|
+
let maxX = Infinity;
|
|
1223
|
+
let maxY = Infinity;
|
|
1224
|
+
for (const { drawing, skeleton } of movableDrawings) {
|
|
1225
|
+
if (!skeleton) continue;
|
|
1226
|
+
const { left = 0, top = 0, width = 0, height = 0 } = drawing.transform;
|
|
1227
|
+
const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop, columnTotalWidth, rowTotalHeight } = skeleton;
|
|
1228
|
+
minX = Math.max(minX, rowHeaderWidthAndMarginLeft - left);
|
|
1229
|
+
minY = Math.max(minY, columnHeaderHeightAndMarginTop - top);
|
|
1230
|
+
maxX = Math.min(maxX, rowHeaderWidthAndMarginLeft + columnTotalWidth - left - width);
|
|
1231
|
+
maxY = Math.min(maxY, columnHeaderHeightAndMarginTop + rowTotalHeight - top - height);
|
|
1232
|
+
}
|
|
1233
|
+
moveX = Math.max(minX, Math.min(moveX, maxX));
|
|
1234
|
+
moveY = Math.max(minY, Math.min(moveY, maxY));
|
|
1235
|
+
if (moveX === 0 && moveY === 0) return false;
|
|
1236
|
+
const newDrawings = movableDrawings.flatMap(({ drawing, skeleton, anchorType }) => {
|
|
1237
|
+
const { left = 0, top = 0, width = 0, height = 0 } = drawing.transform;
|
|
1238
|
+
const bounds = {
|
|
1239
|
+
left: left + moveX,
|
|
1240
|
+
top: top + moveY,
|
|
1241
|
+
width,
|
|
1242
|
+
height
|
|
1105
1243
|
};
|
|
1106
|
-
|
|
1244
|
+
if (anchorType === _univerjs_sheets_drawing.SheetDrawingAnchorType.None) return [(0, _univerjs_sheets_drawing.applySheetDrawingPlacement)(drawing, {
|
|
1245
|
+
kind: anchorType,
|
|
1246
|
+
bounds
|
|
1247
|
+
})];
|
|
1248
|
+
if (!skeleton) return [];
|
|
1249
|
+
return [(0, _univerjs_sheets_drawing.applySheetDrawingPlacement)(drawing, {
|
|
1250
|
+
kind: anchorType,
|
|
1251
|
+
bounds
|
|
1252
|
+
}, skeleton)];
|
|
1253
|
+
});
|
|
1254
|
+
if (newDrawings.length === 0) return false;
|
|
1107
1255
|
if (undoRedoGroupService.runTimed(unitId, `sheet-drawing:nudge:${drawings[0].subUnitId}:${drawings.map((drawing) => drawing.drawingId).sort().join(",")}`, () => commandService.syncExecuteCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
|
|
1108
1256
|
unitId,
|
|
1109
1257
|
drawings: newDrawings
|
|
1110
|
-
}))) {
|
|
1258
|
+
}), "append")) {
|
|
1111
1259
|
commandService.syncExecuteCommand(_univerjs_sheets_drawing.ClearSheetDrawingTransformerOperation.id, [unitId]);
|
|
1112
1260
|
return true;
|
|
1113
1261
|
}
|
|
@@ -1115,8 +1263,7 @@ const MoveDrawingsCommand = {
|
|
|
1115
1263
|
}
|
|
1116
1264
|
};
|
|
1117
1265
|
|
|
1118
|
-
|
|
1119
|
-
//#region src/services/batch-save-images.service.ts
|
|
1266
|
+
// src/services/batch-save-images.service.ts
|
|
1120
1267
|
/**
|
|
1121
1268
|
* File name part type for multi-select
|
|
1122
1269
|
*/
|
|
@@ -1475,8 +1622,7 @@ BatchSaveImagesService = __decorate([
|
|
|
1475
1622
|
__decorateParam(3, _univerjs_core.IURLImageService)
|
|
1476
1623
|
], BatchSaveImagesService);
|
|
1477
1624
|
|
|
1478
|
-
|
|
1479
|
-
//#region src/views/batch-save-images/component-name.ts
|
|
1625
|
+
// src/views/batch-save-images/component-name.ts
|
|
1480
1626
|
/**
|
|
1481
1627
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1482
1628
|
*
|
|
@@ -1494,8 +1640,7 @@ BatchSaveImagesService = __decorate([
|
|
|
1494
1640
|
*/
|
|
1495
1641
|
const BATCH_SAVE_IMAGES_DIALOG_ID = "sheet.dialog.batch-save-images";
|
|
1496
1642
|
|
|
1497
|
-
|
|
1498
|
-
//#region src/commands/commands/save-cell-images.command.ts
|
|
1643
|
+
// src/commands/commands/save-cell-images.command.ts
|
|
1499
1644
|
const SaveCellImagesCommand = {
|
|
1500
1645
|
id: "sheet.command.save-cell-images",
|
|
1501
1646
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -1526,8 +1671,7 @@ const SaveCellImagesCommand = {
|
|
|
1526
1671
|
}
|
|
1527
1672
|
};
|
|
1528
1673
|
|
|
1529
|
-
|
|
1530
|
-
//#region src/commands/commands/worksheet-background-image.command.ts
|
|
1674
|
+
// src/commands/commands/worksheet-background-image.command.ts
|
|
1531
1675
|
const AddWorksheetBackgroundImageCommand = {
|
|
1532
1676
|
id: "sheet.command.add-worksheet-background-image",
|
|
1533
1677
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -1544,8 +1688,7 @@ const DeleteWorksheetBackgroundImageCommand = {
|
|
|
1544
1688
|
handler: (accessor) => accessor.get(_univerjs_core.ICommandService).executeCommand(_univerjs_sheets_drawing.SetWorksheetBackgroundImageCommand.id, { backgroundImage: null })
|
|
1545
1689
|
};
|
|
1546
1690
|
|
|
1547
|
-
|
|
1548
|
-
//#region src/views/sheet-image-panel/component-name.ts
|
|
1691
|
+
// src/views/sheet-image-panel/component-name.ts
|
|
1549
1692
|
/**
|
|
1550
1693
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1551
1694
|
*
|
|
@@ -1563,8 +1706,7 @@ const DeleteWorksheetBackgroundImageCommand = {
|
|
|
1563
1706
|
*/
|
|
1564
1707
|
const COMPONENT_SHEET_DRAWING_PANEL = "COMPONENT_SHEET_DRAWING_PANEL";
|
|
1565
1708
|
|
|
1566
|
-
|
|
1567
|
-
//#region src/commands/operations/open-drawing-panel.operation.ts
|
|
1709
|
+
// src/commands/operations/open-drawing-panel.operation.ts
|
|
1568
1710
|
const SidebarSheetDrawingOperation = {
|
|
1569
1711
|
id: "sidebar.operation.sheet-image",
|
|
1570
1712
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -1594,8 +1736,7 @@ const SidebarSheetDrawingOperation = {
|
|
|
1594
1736
|
}
|
|
1595
1737
|
};
|
|
1596
1738
|
|
|
1597
|
-
|
|
1598
|
-
//#region src/commands/operations/edit-sheet-drawing.operation.ts
|
|
1739
|
+
// src/commands/operations/edit-sheet-drawing.operation.ts
|
|
1599
1740
|
const EditSheetDrawingOperation = {
|
|
1600
1741
|
id: "sheet.operation.edit-sheet-image",
|
|
1601
1742
|
type: _univerjs_core.CommandType.OPERATION,
|
|
@@ -1608,8 +1749,7 @@ const EditSheetDrawingOperation = {
|
|
|
1608
1749
|
}
|
|
1609
1750
|
};
|
|
1610
1751
|
|
|
1611
|
-
|
|
1612
|
-
//#region src/controllers/sheet-drawing-group-copy-paste.controller.ts
|
|
1752
|
+
// src/controllers/sheet-drawing-group-copy-paste.controller.ts
|
|
1613
1753
|
const specialPastes$1 = [
|
|
1614
1754
|
_univerjs_sheets_ui.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,
|
|
1615
1755
|
_univerjs_sheets_ui.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,
|
|
@@ -1811,8 +1951,7 @@ SheetsDrawingGroupCopyPasteController = __decorate([
|
|
|
1811
1951
|
__decorateParam(4, _univerjs_drawing.IDrawingManagerService)
|
|
1812
1952
|
], SheetsDrawingGroupCopyPasteController);
|
|
1813
1953
|
|
|
1814
|
-
|
|
1815
|
-
//#region src/services/sheet-chart-render-object.config.ts
|
|
1954
|
+
// src/services/sheet-chart-render-object.config.ts
|
|
1816
1955
|
/** Shared Chart frame config for editor and isolated print Scene objects. */
|
|
1817
1956
|
const SHEET_CHART_RENDER_OBJECT_CONFIG = Object.freeze({
|
|
1818
1957
|
borderEnabled: false,
|
|
@@ -1822,8 +1961,7 @@ const SHEET_CHART_RENDER_OBJECT_CONFIG = Object.freeze({
|
|
|
1822
1961
|
strokeWidth: 1
|
|
1823
1962
|
});
|
|
1824
1963
|
|
|
1825
|
-
|
|
1826
|
-
//#region src/services/canvas-float-dom-manager.service.ts
|
|
1964
|
+
// src/services/canvas-float-dom-manager.service.ts
|
|
1827
1965
|
var _SheetCanvasFloatDomManagerService;
|
|
1828
1966
|
const SHEET_FLOAT_DOM_PREFIX = "univer-sheet-float-dom-";
|
|
1829
1967
|
function createExternalRuntimeDisposable(owner, id, disposeById) {
|
|
@@ -1889,9 +2027,12 @@ function applyFloatDomTransformerConfig(rect, floatDomParam) {
|
|
|
1889
2027
|
};
|
|
1890
2028
|
}
|
|
1891
2029
|
function applySheetChartTransformerConfig(rect) {
|
|
2030
|
+
var _rect$transformerConf, _rect$transformerConf2;
|
|
1892
2031
|
rect.transformerConfig = {
|
|
1893
2032
|
...rect.transformerConfig,
|
|
1894
|
-
...SHEET_CHART_TRANSFORMER_CONFIG
|
|
2033
|
+
...SHEET_CHART_TRANSFORMER_CONFIG,
|
|
2034
|
+
moveEnabled: ((_rect$transformerConf = rect.transformerConfig) === null || _rect$transformerConf === void 0 ? void 0 : _rect$transformerConf.moveEnabled) ?? SHEET_CHART_TRANSFORMER_CONFIG.moveEnabled,
|
|
2035
|
+
resizeEnabled: ((_rect$transformerConf2 = rect.transformerConfig) === null || _rect$transformerConf2 === void 0 ? void 0 : _rect$transformerConf2.resizeEnabled) ?? SHEET_CHART_TRANSFORMER_CONFIG.resizeEnabled
|
|
1895
2036
|
};
|
|
1896
2037
|
}
|
|
1897
2038
|
function isStage2RuntimeEmbedFloatDom(floatDomParam) {
|
|
@@ -2020,8 +2161,8 @@ function transformBound2DOMBound(posOfFloatObject, scene, skeleton, worksheet, f
|
|
|
2020
2161
|
const { boundsOfViewArea: specBoundsOfViewArea, scrollDirectionResponse } = floatDomInfo || {};
|
|
2021
2162
|
const { rowHeaderWidth, columnHeaderHeight } = skeleton;
|
|
2022
2163
|
const boundsOfViewArea = {
|
|
2023
|
-
top: skipBoundsOfViewArea ? 0 : columnHeaderHeight,
|
|
2024
|
-
left: skipBoundsOfViewArea ? 0 : rowHeaderWidth
|
|
2164
|
+
top: skipBoundsOfViewArea ? 0 : columnHeaderHeight * scaleY,
|
|
2165
|
+
left: skipBoundsOfViewArea ? 0 : rowHeaderWidth * scaleX
|
|
2025
2166
|
};
|
|
2026
2167
|
if (specBoundsOfViewArea) {
|
|
2027
2168
|
if (_univerjs_core.Tools.isDefine(boundsOfViewArea.top)) boundsOfViewArea.top = specBoundsOfViewArea.top;
|
|
@@ -2119,6 +2260,10 @@ const calcSheetFloatDomPosition = (floatObject, scene, skeleton, worksheet, floa
|
|
|
2119
2260
|
};
|
|
2120
2261
|
};
|
|
2121
2262
|
let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = class SheetCanvasFloatDomManagerService extends _univerjs_core.Disposable {
|
|
2263
|
+
registerMoveTransformConstraint(constraint) {
|
|
2264
|
+
this._moveTransformConstraints.add(constraint);
|
|
2265
|
+
return (0, _univerjs_core.toDisposable)(() => this._moveTransformConstraints.delete(constraint));
|
|
2266
|
+
}
|
|
2122
2267
|
constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService, _lifecycleService, _canvasFloatDomPreviewService) {
|
|
2123
2268
|
super();
|
|
2124
2269
|
this._renderManagerService = _renderManagerService;
|
|
@@ -2136,12 +2281,29 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2136
2281
|
_defineProperty(this, "add$", this._add$.asObservable());
|
|
2137
2282
|
_defineProperty(this, "_remove$", new rxjs.Subject());
|
|
2138
2283
|
_defineProperty(this, "remove$", this._remove$.asObservable());
|
|
2284
|
+
_defineProperty(this, "_moveTransformConstraints", /* @__PURE__ */ new Set());
|
|
2285
|
+
_defineProperty(this, "_floatDomMoveDisposables", /* @__PURE__ */ new Map());
|
|
2139
2286
|
_defineProperty(this, "_renderObjectFactories", /* @__PURE__ */ new Map());
|
|
2140
2287
|
this._drawingAddListener();
|
|
2141
2288
|
this._featureUpdateListener();
|
|
2142
2289
|
this._deleteListener();
|
|
2143
2290
|
this._bindScrollEvent();
|
|
2144
2291
|
this._bindEmbedFloatDragHandleEvent();
|
|
2292
|
+
this.disposeWithMe(this._renderManagerService.disposed$.subscribe((unitId) => {
|
|
2293
|
+
for (const info of Array.from(this._domLayerInfoMap.values())) if (info.unitId === unitId) this._removeDom(info.id);
|
|
2294
|
+
}));
|
|
2295
|
+
this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe((unit) => {
|
|
2296
|
+
for (const info of Array.from(this._domLayerInfoMap.values())) if (info.unitId === unit.getUnitId()) this._removeDom(info.id);
|
|
2297
|
+
}));
|
|
2298
|
+
}
|
|
2299
|
+
dispose() {
|
|
2300
|
+
this._moveTransformConstraints.clear();
|
|
2301
|
+
for (const id of Array.from(this._domLayerInfoMap.keys())) this._removeDom(id);
|
|
2302
|
+
this._renderObjectFactories.clear();
|
|
2303
|
+
this._transformChange$.complete();
|
|
2304
|
+
this._add$.complete();
|
|
2305
|
+
this._remove$.complete();
|
|
2306
|
+
super.dispose();
|
|
2145
2307
|
}
|
|
2146
2308
|
/**
|
|
2147
2309
|
* Register a factory that creates the canvas-side render object for a sheet
|
|
@@ -2166,14 +2328,26 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2166
2328
|
const factory = factories === null || factories === void 0 ? void 0 : factories[factories.length - 1];
|
|
2167
2329
|
return (factory === null || factory === void 0 ? void 0 : factory(context)) ?? new _univerjs_engine_render.Rect(context.key, context.config);
|
|
2168
2330
|
}
|
|
2331
|
+
_forwardWheelToCanvas(canvas, event) {
|
|
2332
|
+
if (!canvas.dispatchEvent(new WheelEvent(event.type, event))) event.preventDefault();
|
|
2333
|
+
}
|
|
2169
2334
|
_bindScrollEvent() {
|
|
2170
|
-
this._lifecycleService.lifecycle$.pipe((0, rxjs.filter)((s) => s === _univerjs_core.LifecycleStages.Rendered), (0, rxjs.take)(1)).subscribe(() => {
|
|
2335
|
+
this.disposeWithMe(this._lifecycleService.lifecycle$.pipe((0, rxjs.filter)((s) => s === _univerjs_core.LifecycleStages.Rendered), (0, rxjs.take)(1)).subscribe(() => {
|
|
2171
2336
|
this._scrollUpdateListener();
|
|
2172
|
-
});
|
|
2337
|
+
}));
|
|
2173
2338
|
}
|
|
2174
2339
|
getFloatDomInfo(id) {
|
|
2175
2340
|
return this._domLayerInfoMap.get(id);
|
|
2176
2341
|
}
|
|
2342
|
+
updateFloatDomEventOptions(id, eventOptions) {
|
|
2343
|
+
const info = this._domLayerInfoMap.get(id);
|
|
2344
|
+
if (!(info === null || info === void 0 ? void 0 : info.floatDomConfig)) return;
|
|
2345
|
+
info.floatDomConfig = {
|
|
2346
|
+
...info.floatDomConfig,
|
|
2347
|
+
eventOptions
|
|
2348
|
+
};
|
|
2349
|
+
this._canvasFloatDomService.updateFloatDom(id, { eventOptions });
|
|
2350
|
+
}
|
|
2177
2351
|
getFloatDomsBySubUnitId(unitId, subUnitId) {
|
|
2178
2352
|
return Array.from(this._domLayerInfoMap.values()).filter((info) => info.subUnitId === subUnitId && info.unitId === unitId);
|
|
2179
2353
|
}
|
|
@@ -2190,6 +2364,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2190
2364
|
this.disposeWithMe(() => document.removeEventListener(EMBED_FLOAT_DRAG_HANDLE_POINTER_DOWN_EVENT, listener));
|
|
2191
2365
|
}
|
|
2192
2366
|
_handleEmbedFloatDragHandlePointerDown(event) {
|
|
2367
|
+
var _this$_floatDomMoveDi, _this$_univerInstance2;
|
|
2193
2368
|
const detail = event.detail;
|
|
2194
2369
|
if (!(detail === null || detail === void 0 ? void 0 : detail.hostAnchorId)) return;
|
|
2195
2370
|
const info = this._domLayerInfoMap.get(detail.hostAnchorId);
|
|
@@ -2197,7 +2372,21 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2197
2372
|
const dragState = createFloatDomMoveDragState(info, detail);
|
|
2198
2373
|
const renderObject = this._getSceneAndTransformerByDrawingSearch(info.unitId);
|
|
2199
2374
|
if (!dragState || !renderObject) return;
|
|
2200
|
-
|
|
2375
|
+
(_this$_floatDomMoveDi = this._floatDomMoveDisposables.get(info.id)) === null || _this$_floatDomMoveDi === void 0 || _this$_floatDomMoveDi.dispose();
|
|
2376
|
+
const { scene, transformer, canvas } = renderObject;
|
|
2377
|
+
const isCurrentHost = () => {
|
|
2378
|
+
var _this$_getSceneAndTra, _this$_univerInstance;
|
|
2379
|
+
return this._domLayerInfoMap.get(info.id) === info && ((_this$_getSceneAndTra = this._getSceneAndTransformerByDrawingSearch(info.unitId)) === null || _this$_getSceneAndTra === void 0 ? void 0 : _this$_getSceneAndTra.scene) === scene && ((_this$_univerInstance = this._univerInstanceService.getUnit(info.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getActiveSheet().getSheetId()) === info.subUnitId;
|
|
2380
|
+
};
|
|
2381
|
+
const isChartSheet = ((_this$_univerInstance2 = this._univerInstanceService.getUnit(info.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getSheetBySheetId(info.subUnitId)) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getConfig().type) === _univerjs_core.SheetTypes.CHART;
|
|
2382
|
+
const toScenePoint = (point) => {
|
|
2383
|
+
const bounds = canvas.getBoundingClientRect();
|
|
2384
|
+
return scene.getMainViewport().transformVector2SceneCoord(_univerjs_engine_render.Vector2.FromArray([point.clientX - bounds.left, point.clientY - bounds.top]));
|
|
2385
|
+
};
|
|
2386
|
+
const startPoint = isChartSheet ? toScenePoint({
|
|
2387
|
+
clientX: dragState.startClientX,
|
|
2388
|
+
clientY: dragState.startClientY
|
|
2389
|
+
}) : void 0;
|
|
2201
2390
|
if (info.rect.oKey) {
|
|
2202
2391
|
var _scene$getTransformer;
|
|
2203
2392
|
transformer.clearControlByIds([info.rect.oKey]);
|
|
@@ -2205,15 +2394,35 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2205
2394
|
}
|
|
2206
2395
|
const handlePointerMove = (pointerEvent) => {
|
|
2207
2396
|
if (dragState.pointerId != null && pointerEvent.pointerId !== dragState.pointerId) return;
|
|
2397
|
+
if (!isCurrentHost()) return;
|
|
2208
2398
|
pointerEvent.preventDefault();
|
|
2209
|
-
const
|
|
2210
|
-
|
|
2399
|
+
const point = startPoint && toScenePoint(pointerEvent);
|
|
2400
|
+
const nextTransform = point && startPoint ? {
|
|
2401
|
+
left: dragState.startLeft + point.x - startPoint.x,
|
|
2402
|
+
top: dragState.startTop + point.y - startPoint.y
|
|
2403
|
+
} : resolveFloatDomMoveDragTransform(dragState, pointerEvent, scene);
|
|
2404
|
+
const drawing = this._sheetDrawingService.getDrawingByParam({
|
|
2405
|
+
unitId: info.unitId,
|
|
2406
|
+
subUnitId: info.subUnitId,
|
|
2407
|
+
drawingId: info.id
|
|
2408
|
+
});
|
|
2409
|
+
if ((drawing === null || drawing === void 0 ? void 0 : drawing.anchorType) === _univerjs_sheets_drawing.SheetDrawingAnchorType.None) {
|
|
2410
|
+
const next = {
|
|
2411
|
+
...drawing,
|
|
2412
|
+
transform: {
|
|
2413
|
+
...drawing.transform,
|
|
2414
|
+
...nextTransform
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
let transform = (0, _univerjs_sheets_drawing.applySheetDrawingPlacement)(drawing, (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(next)).transform;
|
|
2418
|
+
for (const constraint of this._moveTransformConstraints) transform = constraint(drawing, transform);
|
|
2419
|
+
info.rect.transformByState(transform);
|
|
2420
|
+
} else info.rect.transformByState(nextTransform);
|
|
2211
2421
|
};
|
|
2212
2422
|
const handlePointerUp = (pointerEvent) => {
|
|
2213
2423
|
if (dragState.pointerId != null && pointerEvent.pointerId !== dragState.pointerId) return;
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
window.removeEventListener("pointercancel", handlePointerCancel, true);
|
|
2424
|
+
cleanupDrag();
|
|
2425
|
+
if (!isCurrentHost()) return;
|
|
2217
2426
|
pointerEvent.preventDefault();
|
|
2218
2427
|
if (info.rect.left !== dragState.startLeft || info.rect.top !== dragState.startTop) this._commitFloatDomMove(info);
|
|
2219
2428
|
if (info.runtimeStage === "stage1") {
|
|
@@ -2223,9 +2432,8 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2223
2432
|
};
|
|
2224
2433
|
const handlePointerCancel = (pointerEvent) => {
|
|
2225
2434
|
if (dragState.pointerId != null && pointerEvent.pointerId !== dragState.pointerId) return;
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
window.removeEventListener("pointercancel", handlePointerCancel, true);
|
|
2435
|
+
cleanupDrag();
|
|
2436
|
+
if (!isCurrentHost()) return;
|
|
2229
2437
|
info.rect.transformByState({
|
|
2230
2438
|
left: dragState.startLeft,
|
|
2231
2439
|
top: dragState.startTop
|
|
@@ -2235,6 +2443,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2235
2443
|
(_scene$attachTransfor2 = scene.attachTransformerTo) === null || _scene$attachTransfor2 === void 0 || _scene$attachTransfor2.call(scene, info.rect);
|
|
2236
2444
|
}
|
|
2237
2445
|
};
|
|
2446
|
+
const cleanupDrag = () => {
|
|
2447
|
+
this._floatDomMoveDisposables.delete(info.id);
|
|
2448
|
+
window.removeEventListener("pointermove", handlePointerMove, true);
|
|
2449
|
+
window.removeEventListener("pointerup", handlePointerUp, true);
|
|
2450
|
+
window.removeEventListener("pointercancel", handlePointerCancel, true);
|
|
2451
|
+
};
|
|
2452
|
+
this._floatDomMoveDisposables.set(info.id, { dispose: cleanupDrag });
|
|
2238
2453
|
window.addEventListener("pointermove", handlePointerMove, true);
|
|
2239
2454
|
window.addEventListener("pointerup", handlePointerUp, true);
|
|
2240
2455
|
window.addEventListener("pointercancel", handlePointerCancel, true);
|
|
@@ -2247,7 +2462,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2247
2462
|
subUnitId: info.subUnitId,
|
|
2248
2463
|
drawingId: info.id
|
|
2249
2464
|
});
|
|
2250
|
-
if (!
|
|
2465
|
+
if (!(drawing === null || drawing === void 0 ? void 0 : drawing.transform) || this._domLayerInfoMap.get(info.id) !== info) return;
|
|
2251
2466
|
const transform = {
|
|
2252
2467
|
...drawing.transform,
|
|
2253
2468
|
left: info.rect.left,
|
|
@@ -2260,6 +2475,18 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2260
2475
|
skewX: info.rect.skewX,
|
|
2261
2476
|
skewY: info.rect.skewY
|
|
2262
2477
|
};
|
|
2478
|
+
if (drawing.anchorType === _univerjs_sheets_drawing.SheetDrawingAnchorType.None) {
|
|
2479
|
+
const next = {
|
|
2480
|
+
...drawing,
|
|
2481
|
+
transform
|
|
2482
|
+
};
|
|
2483
|
+
this._commandService.syncExecuteCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
|
|
2484
|
+
unitId: info.unitId,
|
|
2485
|
+
drawings: [(0, _univerjs_sheets_drawing.applySheetDrawingPlacement)(drawing, (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(next))]
|
|
2486
|
+
});
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
if (!skeletonParam) return;
|
|
2263
2490
|
const sheetTransform = (0, _univerjs_sheets_drawing.transformToDrawingPosition)(transform, skeletonParam.skeleton);
|
|
2264
2491
|
const axisAlignSheetTransform = (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(transform, skeletonParam.skeleton);
|
|
2265
2492
|
if (!sheetTransform || !axisAlignSheetTransform) return;
|
|
@@ -2440,7 +2667,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2440
2667
|
const activeSheetId = workbook.getActiveSheet().getSheetId();
|
|
2441
2668
|
if (!floatDomParam || !target) return;
|
|
2442
2669
|
const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2443
|
-
if (!skeleton) return;
|
|
2670
|
+
if (!skeleton && (target.worksheet.getConfig().type !== _univerjs_core.SheetTypes.CHART || floatDomParam.anchorType !== _univerjs_sheets_drawing.SheetDrawingAnchorType.None)) return;
|
|
2444
2671
|
const { transform, drawingType, data, hidden, groupId } = floatDomParam;
|
|
2445
2672
|
if (!isCanvasFloatDomDrawingType(drawingType)) return;
|
|
2446
2673
|
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
@@ -2488,6 +2715,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2488
2715
|
top,
|
|
2489
2716
|
width,
|
|
2490
2717
|
height,
|
|
2718
|
+
angle,
|
|
2719
|
+
flipX,
|
|
2720
|
+
flipY,
|
|
2721
|
+
skewX,
|
|
2722
|
+
skewY,
|
|
2491
2723
|
zIndex: this._getDrawingZIndex(unitId, subUnitId, drawingId)
|
|
2492
2724
|
};
|
|
2493
2725
|
const isChart = drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_CHART;
|
|
@@ -2529,18 +2761,17 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2529
2761
|
});
|
|
2530
2762
|
previewSubscription && disposableCollection.add(previewSubscription);
|
|
2531
2763
|
}
|
|
2532
|
-
const initPosition =
|
|
2764
|
+
const initPosition = this._calculateFloatDomPosition(rect, renderObject.renderUnit.scene, target.worksheet, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton);
|
|
2533
2765
|
const position$ = new rxjs.BehaviorSubject(initPosition);
|
|
2534
2766
|
const domId = `${SHEET_FLOAT_DOM_PREFIX}${(0, _univerjs_core.generateRandomId)(6)}`;
|
|
2535
2767
|
const shouldAutoMountRuntime = shouldAutoMountFloatDomRuntime(floatDomParam);
|
|
2536
2768
|
const shouldSyncEmbedRuntimeStage = isEmbedFloatDomData(floatDomParam);
|
|
2537
2769
|
let info;
|
|
2538
2770
|
const handleRuntimeStageEnter = (stage) => {
|
|
2539
|
-
if (info)
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
}
|
|
2771
|
+
if (!info || this._domLayerInfoMap.get(drawingId) !== info) return;
|
|
2772
|
+
info.runtimeStage = stage;
|
|
2773
|
+
info.runtimeMounted = shouldAutoMountRuntime || stage === "stage2";
|
|
2774
|
+
if (shouldUpdateFloatDomLayerOnRuntimeStageChange(floatDomParam)) this._canvasFloatDomService.updateFloatDom(drawingId, { eventPassThrough: shouldPassThroughFloatDomRuntimeEvents(floatDomParam, stage) });
|
|
2544
2775
|
syncFloatDomHostSelectionOnStageEnter(stage, this._getSceneAndTransformerByDrawingSearch(unitId), rect);
|
|
2545
2776
|
};
|
|
2546
2777
|
const floatDomConfig = {
|
|
@@ -2549,6 +2780,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2549
2780
|
domId,
|
|
2550
2781
|
componentKey: floatDomParam.componentKey,
|
|
2551
2782
|
eventPassThrough: shouldPassThroughFloatDomRuntimeEvents(floatDomParam, "inactive"),
|
|
2783
|
+
preventBrowserZoom: true,
|
|
2552
2784
|
preserveOnFocusChange: shouldPreserveFloatDomOnFocusChange(floatDomParam),
|
|
2553
2785
|
onPointerDown: (evt) => {
|
|
2554
2786
|
if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt)) canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
@@ -2560,7 +2792,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2560
2792
|
if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt)) canvas.dispatchEvent(new PointerEvent(evt.type, evt));
|
|
2561
2793
|
},
|
|
2562
2794
|
onWheel: (evt) => {
|
|
2563
|
-
if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt))
|
|
2795
|
+
if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt)) this._forwardWheelToCanvas(canvas, evt);
|
|
2564
2796
|
},
|
|
2565
2797
|
data,
|
|
2566
2798
|
props: shouldSyncEmbedRuntimeStage ? { onRuntimeStageEnter: handleRuntimeStageEnter } : void 0,
|
|
@@ -2639,7 +2871,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2639
2871
|
disposableCollection.add(sceneUpListener);
|
|
2640
2872
|
}
|
|
2641
2873
|
const listener = rect.onTransformChange$.subscribeEvent(() => {
|
|
2642
|
-
const newPosition =
|
|
2874
|
+
const newPosition = this._calculateFloatDomPosition(rect, renderObject.renderUnit.scene, target.worksheet, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton);
|
|
2643
2875
|
position$.next(newPosition);
|
|
2644
2876
|
if (previewObjectKey) this._syncPreviewObjectTransform(scene.getObject(previewObjectKey), rect);
|
|
2645
2877
|
});
|
|
@@ -2648,7 +2880,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2648
2880
|
if (previewObjectKey) scene.removeObject(previewObjectKey);
|
|
2649
2881
|
});
|
|
2650
2882
|
listener && disposableCollection.add(listener);
|
|
2651
|
-
this._bindFloatDomScroll(disposableCollection, info, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
|
|
2883
|
+
this._bindFloatDomScroll(disposableCollection, info, renderObject.renderUnit.scene, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton, target.worksheet);
|
|
2652
2884
|
this._domLayerInfoMap.set(drawingId, info);
|
|
2653
2885
|
});
|
|
2654
2886
|
}));
|
|
@@ -2685,11 +2917,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2685
2917
|
subUnitId
|
|
2686
2918
|
});
|
|
2687
2919
|
const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
|
|
2688
|
-
if (!renderObject || !target || !skeleton) return;
|
|
2920
|
+
if (!renderObject || !target || !skeleton && target.worksheet.getConfig().type !== _univerjs_core.SheetTypes.CHART) return;
|
|
2689
2921
|
ids.forEach((id) => {
|
|
2690
2922
|
const floatDomInfo = this._domLayerInfoMap.get(id);
|
|
2691
2923
|
if (floatDomInfo) {
|
|
2692
|
-
const position =
|
|
2924
|
+
const position = this._calculateFloatDomPosition(floatDomInfo.rect, renderObject.renderUnit.scene, target.worksheet, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton, floatDomInfo);
|
|
2693
2925
|
floatDomInfo.position$.next(position);
|
|
2694
2926
|
}
|
|
2695
2927
|
});
|
|
@@ -2719,9 +2951,35 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2719
2951
|
_bindFloatDomScroll(disposableCollection, info, scene, skeleton, worksheet) {
|
|
2720
2952
|
const viewport = scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
2721
2953
|
if (!viewport) return;
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2954
|
+
const updatePosition = () => {
|
|
2955
|
+
if (this._domLayerInfoMap.get(info.id) !== info) return;
|
|
2956
|
+
info.position$.next(this._calculateFloatDomPosition(info.rect, scene, worksheet, skeleton, info));
|
|
2957
|
+
};
|
|
2958
|
+
disposableCollection.add((0, _univerjs_core.fromEventSubject)(viewport.onScrollAfter$).subscribe(updatePosition));
|
|
2959
|
+
if (worksheet.getConfig().type === _univerjs_core.SheetTypes.CHART) {
|
|
2960
|
+
disposableCollection.add(scene.onTransformChange$.subscribeEvent(updatePosition));
|
|
2961
|
+
disposableCollection.add(viewport.onResized$.subscribe(updatePosition));
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
_calculateFloatDomPosition(rect, scene, worksheet, skeleton, info) {
|
|
2965
|
+
if (skeleton) return calcSheetFloatDomPosition(rect, scene, skeleton, worksheet, info);
|
|
2966
|
+
const center = scene.getMainViewport().getAbsoluteVector(_univerjs_engine_render.Vector2.FromArray([rect.left + rect.width / 2, rect.top + rect.height / 2]));
|
|
2967
|
+
const { scaleX, scaleY, angle } = scene.transform.decompose();
|
|
2968
|
+
const width = rect.width * scaleX;
|
|
2969
|
+
const height = rect.height * scaleY;
|
|
2970
|
+
return {
|
|
2971
|
+
startX: center.x - width / 2,
|
|
2972
|
+
startY: center.y - height / 2,
|
|
2973
|
+
endX: center.x + width / 2,
|
|
2974
|
+
endY: center.y + height / 2,
|
|
2975
|
+
width,
|
|
2976
|
+
height,
|
|
2977
|
+
rotate: rect.angle + angle,
|
|
2978
|
+
absolute: {
|
|
2979
|
+
left: false,
|
|
2980
|
+
top: false
|
|
2981
|
+
}
|
|
2982
|
+
};
|
|
2725
2983
|
}
|
|
2726
2984
|
updateFloatDomProps(unitId, subUnitId, id, props) {
|
|
2727
2985
|
const info = this._domLayerInfoMap.get(id);
|
|
@@ -2891,9 +3149,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
2891
3149
|
return this._createFloatDomDisposable(id);
|
|
2892
3150
|
}
|
|
2893
3151
|
_removeDom(id, removeDrawing = false) {
|
|
3152
|
+
var _this$_floatDomMoveDi2;
|
|
2894
3153
|
const info = this._domLayerInfoMap.get(id);
|
|
2895
3154
|
if (!info) return;
|
|
2896
3155
|
const { unitId, subUnitId } = info;
|
|
3156
|
+
(_this$_floatDomMoveDi2 = this._floatDomMoveDisposables.get(id)) === null || _this$_floatDomMoveDi2 === void 0 || _this$_floatDomMoveDi2.dispose();
|
|
2897
3157
|
this._domLayerInfoMap.delete(id);
|
|
2898
3158
|
info.dispose.dispose();
|
|
2899
3159
|
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
|
|
@@ -3057,17 +3317,9 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3057
3317
|
subUnitId
|
|
3058
3318
|
}, domRect, scene, this._drawingManagerService);
|
|
3059
3319
|
const disposableCollection = new _univerjs_core.DisposableCollection();
|
|
3060
|
-
const viewMain = scene.getMainViewport();
|
|
3061
|
-
const { rowHeaderWidth, columnHeaderHeight } = skeletonParam.skeleton;
|
|
3062
3320
|
const floatDomInfo = {
|
|
3063
3321
|
dispose: disposableCollection,
|
|
3064
3322
|
rect: domRect,
|
|
3065
|
-
boundsOfViewArea: {
|
|
3066
|
-
top: columnHeaderHeight,
|
|
3067
|
-
left: rowHeaderWidth,
|
|
3068
|
-
bottom: viewMain.bottom,
|
|
3069
|
-
right: viewMain.right
|
|
3070
|
-
},
|
|
3071
3323
|
domAnchor,
|
|
3072
3324
|
unitId,
|
|
3073
3325
|
subUnitId,
|
|
@@ -3084,12 +3336,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3084
3336
|
let floatDomCfg = {
|
|
3085
3337
|
position$,
|
|
3086
3338
|
id: drawingId,
|
|
3339
|
+
preventBrowserZoom: true,
|
|
3087
3340
|
componentKey: floatDomParam.componentKey,
|
|
3088
3341
|
onPointerDown: () => {},
|
|
3089
3342
|
onPointerMove: () => {},
|
|
3090
3343
|
onPointerUp: () => {},
|
|
3091
3344
|
onWheel: (evt) => {
|
|
3092
|
-
|
|
3345
|
+
this._forwardWheelToCanvas(canvas, evt);
|
|
3093
3346
|
},
|
|
3094
3347
|
data,
|
|
3095
3348
|
unitId
|
|
@@ -3293,12 +3546,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
|
|
|
3293
3546
|
let floatDomCfg = {
|
|
3294
3547
|
position$,
|
|
3295
3548
|
id: drawingId,
|
|
3549
|
+
preventBrowserZoom: true,
|
|
3296
3550
|
componentKey: floatDomParam.componentKey,
|
|
3297
3551
|
onPointerDown: () => {},
|
|
3298
3552
|
onPointerMove: () => {},
|
|
3299
3553
|
onPointerUp: () => {},
|
|
3300
3554
|
onWheel: (evt) => {
|
|
3301
|
-
|
|
3555
|
+
this._forwardWheelToCanvas(canvas, evt);
|
|
3302
3556
|
},
|
|
3303
3557
|
data,
|
|
3304
3558
|
unitId
|
|
@@ -3511,8 +3765,7 @@ function calculateOffset(value, rangeWidth) {
|
|
|
3511
3765
|
return rangeWidth * Number.parseFloat(value) / 100;
|
|
3512
3766
|
}
|
|
3513
3767
|
|
|
3514
|
-
|
|
3515
|
-
//#region src/embed/floating-host/register-sheets-drawing-floating-host.ts
|
|
3768
|
+
// src/embed/floating-host/register-sheets-drawing-floating-host.ts
|
|
3516
3769
|
const SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES = [[SheetCanvasFloatDomManagerService]];
|
|
3517
3770
|
function registerSheetsDrawingFloatingHostCapability(injector) {
|
|
3518
3771
|
if (!injector.has(SheetCanvasFloatDomManagerService)) (0, _univerjs_core.registerDependencies)(injector, SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES);
|
|
@@ -3536,9 +3789,27 @@ function touchSheetsDrawingFloatingHostCapabilityWhenReady(injector) {
|
|
|
3536
3789
|
});
|
|
3537
3790
|
}
|
|
3538
3791
|
|
|
3539
|
-
|
|
3540
|
-
//#region src/menu/image.menu.ts
|
|
3792
|
+
// src/menu/image.menu.ts
|
|
3541
3793
|
const SHEETS_IMAGE_MENU_ID = "sheet.menu.image";
|
|
3794
|
+
/** Chart Sheets have no cells; other sheet types retain the existing range-menu permission rules. */
|
|
3795
|
+
function getImageMenuDisabled$(accessor, floating) {
|
|
3796
|
+
return (0, _univerjs_sheets_ui.deriveStateFromActiveSheet$)(accessor.get(_univerjs_core.IUniverInstanceService), true, ({ workbook, worksheet }) => {
|
|
3797
|
+
if (worksheet.getConfig().type === _univerjs_core.SheetTypes.CHART) {
|
|
3798
|
+
if (!floating) return (0, rxjs.of)(true);
|
|
3799
|
+
const permissions = accessor.get(_univerjs_core.IPermissionService);
|
|
3800
|
+
const ids = [new _univerjs_sheets.WorkbookEditablePermission(workbook.getUnitId()).id, new _univerjs_sheets.WorksheetEditPermission(workbook.getUnitId(), worksheet.getSheetId()).id];
|
|
3801
|
+
return permissions.permissionPointUpdate$.pipe((0, rxjs.startWith)(null), (0, rxjs.map)(() => ids.some((id) => {
|
|
3802
|
+
var _permissions$getPermi;
|
|
3803
|
+
return ((_permissions$getPermi = permissions.getPermissionPoint(id)) === null || _permissions$getPermi === void 0 ? void 0 : _permissions$getPermi.value) !== true;
|
|
3804
|
+
})), (0, rxjs.distinctUntilChanged)());
|
|
3805
|
+
}
|
|
3806
|
+
return (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
|
|
3807
|
+
workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
|
|
3808
|
+
worksheetTypes: [_univerjs_sheets.WorksheetEditPermission],
|
|
3809
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
|
|
3810
|
+
});
|
|
3811
|
+
});
|
|
3812
|
+
}
|
|
3542
3813
|
function ImageMenuFactory(accessor) {
|
|
3543
3814
|
return {
|
|
3544
3815
|
id: SHEETS_IMAGE_MENU_ID,
|
|
@@ -3546,17 +3817,14 @@ function ImageMenuFactory(accessor) {
|
|
|
3546
3817
|
icon: "AddImageIcon",
|
|
3547
3818
|
tooltip: "sheets-drawing-ui.title",
|
|
3548
3819
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
3549
|
-
disabled$:
|
|
3550
|
-
workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
|
|
3551
|
-
worksheetTypes: [_univerjs_sheets.WorksheetEditPermission],
|
|
3552
|
-
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
|
|
3553
|
-
})
|
|
3820
|
+
disabled$: getImageMenuDisabled$(accessor, true)
|
|
3554
3821
|
};
|
|
3555
3822
|
}
|
|
3556
3823
|
function UploadFloatImageMenuFactory(accessor) {
|
|
3557
3824
|
return {
|
|
3558
3825
|
id: InsertFloatImageCommand.id,
|
|
3559
3826
|
title: "sheets-drawing-ui.upload.float",
|
|
3827
|
+
disabled$: getImageMenuDisabled$(accessor, true),
|
|
3560
3828
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
3561
3829
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
|
|
3562
3830
|
};
|
|
@@ -3565,13 +3833,13 @@ function UploadCellImageMenuFactory(accessor) {
|
|
|
3565
3833
|
return {
|
|
3566
3834
|
id: InsertCellImageCommand.id,
|
|
3567
3835
|
title: "sheets-drawing-ui.upload.cell",
|
|
3836
|
+
disabled$: getImageMenuDisabled$(accessor, false),
|
|
3568
3837
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
3569
3838
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)
|
|
3570
3839
|
};
|
|
3571
3840
|
}
|
|
3572
3841
|
|
|
3573
|
-
|
|
3574
|
-
//#region src/menu/save-images.menu.ts
|
|
3842
|
+
// src/menu/save-images.menu.ts
|
|
3575
3843
|
/**
|
|
3576
3844
|
* Check if selection range has any images
|
|
3577
3845
|
*/
|
|
@@ -3614,8 +3882,7 @@ function SaveCellImagesMenuFactory(accessor) {
|
|
|
3614
3882
|
};
|
|
3615
3883
|
}
|
|
3616
3884
|
|
|
3617
|
-
|
|
3618
|
-
//#region src/menu/worksheet-background-image.menu.ts
|
|
3885
|
+
// src/menu/worksheet-background-image.menu.ts
|
|
3619
3886
|
const WORKSHEET_BACKGROUND_IMAGE_MENU_ID = "sheet.menu.worksheet-background-image";
|
|
3620
3887
|
function worksheetBackgroundImagePresent$(accessor) {
|
|
3621
3888
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
@@ -3672,8 +3939,7 @@ function DeleteWorksheetBackgroundImageMenuFactory(accessor) {
|
|
|
3672
3939
|
};
|
|
3673
3940
|
}
|
|
3674
3941
|
|
|
3675
|
-
|
|
3676
|
-
//#region src/menu/schema.ts
|
|
3942
|
+
// src/menu/schema.ts
|
|
3677
3943
|
const menuSchema = {
|
|
3678
3944
|
[_univerjs_ui.RibbonInsertGroup.MEDIA]: { [SHEETS_IMAGE_MENU_ID]: {
|
|
3679
3945
|
order: 0,
|
|
@@ -3725,19 +3991,16 @@ const menuSchema = {
|
|
|
3725
3991
|
} } }
|
|
3726
3992
|
};
|
|
3727
3993
|
|
|
3728
|
-
|
|
3729
|
-
//#region package.json
|
|
3994
|
+
// package.json
|
|
3730
3995
|
var name = "@univerjs/sheets-drawing-ui";
|
|
3731
|
-
var version = "1.
|
|
3996
|
+
var version = "1.5.0";
|
|
3732
3997
|
|
|
3733
|
-
|
|
3734
|
-
//#region src/config/config.ts
|
|
3998
|
+
// src/config/config.ts
|
|
3735
3999
|
const SHEETS_DRAWING_UI_PLUGIN_CONFIG_KEY = "sheets-drawing-ui.config";
|
|
3736
4000
|
const configSymbol = Symbol(SHEETS_DRAWING_UI_PLUGIN_CONFIG_KEY);
|
|
3737
4001
|
const defaultPluginConfig = {};
|
|
3738
4002
|
|
|
3739
|
-
|
|
3740
|
-
//#region src/services/drawing-context-menu.service.ts
|
|
4003
|
+
// src/services/drawing-context-menu.service.ts
|
|
3741
4004
|
const IDrawingContextMenuService = (0, _univerjs_core.createIdentifier)("sheets-drawing-ui.drawing-context-menu.service");
|
|
3742
4005
|
var DrawingContextMenuService = class extends _univerjs_core.Disposable {
|
|
3743
4006
|
constructor(..._args) {
|
|
@@ -3756,8 +4019,7 @@ var DrawingContextMenuService = class extends _univerjs_core.Disposable {
|
|
|
3756
4019
|
}
|
|
3757
4020
|
};
|
|
3758
4021
|
|
|
3759
|
-
|
|
3760
|
-
//#region src/controllers/drawing-context-menu.controller.ts
|
|
4022
|
+
// src/controllers/drawing-context-menu.controller.ts
|
|
3761
4023
|
let DrawingContextMenuController = class DrawingContextMenuController extends _univerjs_core.RxDisposable {
|
|
3762
4024
|
constructor(_drawingManagerService, _contextMenuService, _renderManagerService, _univerInstanceService, _drawingContextMenuService) {
|
|
3763
4025
|
super();
|
|
@@ -3813,8 +4075,7 @@ DrawingContextMenuController = __decorate([
|
|
|
3813
4075
|
__decorateParam(4, IDrawingContextMenuService)
|
|
3814
4076
|
], DrawingContextMenuController);
|
|
3815
4077
|
|
|
3816
|
-
|
|
3817
|
-
//#region src/views/batch-save-images/BatchSaveImagesDialog.tsx
|
|
4078
|
+
// src/views/batch-save-images/BatchSaveImagesDialog.tsx
|
|
3818
4079
|
function BatchSaveImagesDialog({ SelectComponent = _univerjs_design.Select } = {}) {
|
|
3819
4080
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
3820
4081
|
const dialogService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IDialogService);
|
|
@@ -3938,8 +4199,7 @@ function BatchSaveImagesDialog({ SelectComponent = _univerjs_design.Select } = {
|
|
|
3938
4199
|
});
|
|
3939
4200
|
}
|
|
3940
4201
|
|
|
3941
|
-
|
|
3942
|
-
//#region src/views/batch-save-images/MobileBatchSaveImagesDialog.tsx
|
|
4202
|
+
// src/views/batch-save-images/MobileBatchSaveImagesDialog.tsx
|
|
3943
4203
|
/**
|
|
3944
4204
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3945
4205
|
*
|
|
@@ -3959,14 +4219,12 @@ function MobileBatchSaveImagesDialog() {
|
|
|
3959
4219
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BatchSaveImagesDialog, { SelectComponent: _univerjs_design.MobileSelect });
|
|
3960
4220
|
}
|
|
3961
4221
|
|
|
3962
|
-
|
|
3963
|
-
//#region src/views/sheet-image-panel/sheet-drawing-panel.util.ts
|
|
4222
|
+
// src/views/sheet-image-panel/sheet-drawing-panel.util.ts
|
|
3964
4223
|
function isSheetDrawing(drawing) {
|
|
3965
4224
|
return Boolean(drawing && "sheetTransform" in drawing && drawing.sheetTransform);
|
|
3966
4225
|
}
|
|
3967
4226
|
|
|
3968
|
-
|
|
3969
|
-
//#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
|
|
4227
|
+
// src/views/sheet-image-panel/SheetDrawingAnchor.tsx
|
|
3970
4228
|
const SheetDrawingAnchor = (props) => {
|
|
3971
4229
|
function getAnchorKind(value) {
|
|
3972
4230
|
if (value === _univerjs_sheets_drawing.SheetDrawingAnchorType.Position || value === _univerjs_sheets_drawing.SheetDrawingAnchorType.Both || value === _univerjs_sheets_drawing.SheetDrawingAnchorType.None) return value;
|
|
@@ -4088,8 +4346,7 @@ const SheetDrawingAnchor = (props) => {
|
|
|
4088
4346
|
});
|
|
4089
4347
|
};
|
|
4090
4348
|
|
|
4091
|
-
|
|
4092
|
-
//#region src/commands/operations/preview-sheet-image-opacity.operation.ts
|
|
4349
|
+
// src/commands/operations/preview-sheet-image-opacity.operation.ts
|
|
4093
4350
|
const PreviewSheetImageOpacityOperation = {
|
|
4094
4351
|
id: "sheet.operation.preview-image-opacity",
|
|
4095
4352
|
type: _univerjs_core.CommandType.OPERATION,
|
|
@@ -4104,8 +4361,7 @@ const PreviewSheetImageOpacityOperation = {
|
|
|
4104
4361
|
}
|
|
4105
4362
|
};
|
|
4106
4363
|
|
|
4107
|
-
|
|
4108
|
-
//#region src/views/sheet-image-panel/SheetImageTransparencySlider.tsx
|
|
4364
|
+
// src/views/sheet-image-panel/SheetImageTransparencySlider.tsx
|
|
4109
4365
|
const MIN_TRANSPARENCY = 0;
|
|
4110
4366
|
const MAX_TRANSPARENCY = 100;
|
|
4111
4367
|
const TRANSPARENCY_STEP = 1;
|
|
@@ -4363,8 +4619,7 @@ function normalizeTransparency$1(value) {
|
|
|
4363
4619
|
return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
|
|
4364
4620
|
}
|
|
4365
4621
|
|
|
4366
|
-
|
|
4367
|
-
//#region src/views/sheet-image-panel/SheetImageTransparency.tsx
|
|
4622
|
+
// src/views/sheet-image-panel/SheetImageTransparency.tsx
|
|
4368
4623
|
const IMAGE_TRANSPARENCY_PRESETS = [
|
|
4369
4624
|
0,
|
|
4370
4625
|
15,
|
|
@@ -4472,8 +4727,7 @@ function transparencyToOpacity(transparency) {
|
|
|
4472
4727
|
return (100 - transparency) / 100;
|
|
4473
4728
|
}
|
|
4474
4729
|
|
|
4475
|
-
|
|
4476
|
-
//#region src/views/sheet-image-panel/SheetDrawingPanel.tsx
|
|
4730
|
+
// src/views/sheet-image-panel/SheetDrawingPanel.tsx
|
|
4477
4731
|
/**
|
|
4478
4732
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4479
4733
|
*
|
|
@@ -4502,8 +4756,7 @@ const SheetDrawingPanel = () => {
|
|
|
4502
4756
|
});
|
|
4503
4757
|
};
|
|
4504
4758
|
|
|
4505
|
-
|
|
4506
|
-
//#region src/controllers/mobile/components.controller.ts
|
|
4759
|
+
// src/controllers/mobile/components.controller.ts
|
|
4507
4760
|
/**
|
|
4508
4761
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4509
4762
|
*
|
|
@@ -4528,8 +4781,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
|
|
|
4528
4781
|
};
|
|
4529
4782
|
MobileComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))], MobileComponentsController);
|
|
4530
4783
|
|
|
4531
|
-
|
|
4532
|
-
//#region src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts
|
|
4784
|
+
// src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts
|
|
4533
4785
|
const CELL_IMAGE_PREVIEW_KEY = "preview-cell-image";
|
|
4534
4786
|
let SheetCellImageHoverRenderController = class SheetCellImageHoverRenderController extends _univerjs_core.Disposable {
|
|
4535
4787
|
constructor(_context, _hoverManagerService, _selectionsService, _drawingRenderService, _sheetSkeletonManagerService) {
|
|
@@ -4603,8 +4855,7 @@ SheetCellImageHoverRenderController = __decorate([
|
|
|
4603
4855
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService))
|
|
4604
4856
|
], SheetCellImageHoverRenderController);
|
|
4605
4857
|
|
|
4606
|
-
|
|
4607
|
-
//#region src/controllers/render-controllers/sheet-drawing.render-controller.ts
|
|
4858
|
+
// src/controllers/render-controllers/sheet-drawing.render-controller.ts
|
|
4608
4859
|
let SheetsDrawingRenderController = class SheetsDrawingRenderController extends _univerjs_core.Disposable {
|
|
4609
4860
|
constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService, _logService) {
|
|
4610
4861
|
super();
|
|
@@ -4664,13 +4915,13 @@ SheetsDrawingRenderController = __decorate([
|
|
|
4664
4915
|
__decorateParam(4, _univerjs_core.ILogService)
|
|
4665
4916
|
], SheetsDrawingRenderController);
|
|
4666
4917
|
|
|
4667
|
-
|
|
4668
|
-
//#region src/views/background/worksheet-background-image.extension.ts
|
|
4918
|
+
// src/views/background/worksheet-background-image.extension.ts
|
|
4669
4919
|
const WORKSHEET_BACKGROUND_IMAGE_EXTENSION_KEY = "WorksheetBackgroundImageExtension";
|
|
4670
|
-
var WorksheetBackgroundImageExtension = class extends _univerjs_engine_render.SheetExtension {
|
|
4920
|
+
var WorksheetBackgroundImageExtension = class WorksheetBackgroundImageExtension extends _univerjs_engine_render.SheetExtension {
|
|
4671
4921
|
constructor(injector, _requestRender) {
|
|
4672
4922
|
super();
|
|
4673
4923
|
this._requestRender = _requestRender;
|
|
4924
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === WorksheetBackgroundImageExtension);
|
|
4674
4925
|
_defineProperty(this, "uKey", WORKSHEET_BACKGROUND_IMAGE_EXTENSION_KEY);
|
|
4675
4926
|
_defineProperty(this, "type", _univerjs_engine_render.SHEET_EXTENSION_TYPE.BACKGROUND);
|
|
4676
4927
|
_defineProperty(this, "_imageCache", void 0);
|
|
@@ -4705,8 +4956,7 @@ var WorksheetBackgroundImageExtension = class extends _univerjs_engine_render.Sh
|
|
|
4705
4956
|
}
|
|
4706
4957
|
};
|
|
4707
4958
|
|
|
4708
|
-
|
|
4709
|
-
//#region src/controllers/render-controllers/worksheet-background.render-controller.ts
|
|
4959
|
+
// src/controllers/render-controllers/worksheet-background.render-controller.ts
|
|
4710
4960
|
let WorksheetBackgroundRenderController = class WorksheetBackgroundRenderController extends _univerjs_core.Disposable {
|
|
4711
4961
|
constructor(_context, commandService, injector) {
|
|
4712
4962
|
super();
|
|
@@ -4728,8 +4978,7 @@ let WorksheetBackgroundRenderController = class WorksheetBackgroundRenderControl
|
|
|
4728
4978
|
};
|
|
4729
4979
|
WorksheetBackgroundRenderController = __decorate([__decorateParam(1, _univerjs_core.ICommandService), __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], WorksheetBackgroundRenderController);
|
|
4730
4980
|
|
|
4731
|
-
|
|
4732
|
-
//#region src/controllers/sheet-cell-image.controller.ts
|
|
4981
|
+
// src/controllers/sheet-cell-image.controller.ts
|
|
4733
4982
|
function resizeImageByCell(injector, location, cell) {
|
|
4734
4983
|
var _documentData$drawing, _documentData$drawing2;
|
|
4735
4984
|
const documentData = cell === null || cell === void 0 ? void 0 : cell.p;
|
|
@@ -4808,8 +5057,7 @@ SheetCellImageController = __decorate([
|
|
|
4808
5057
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.IEditorBridgeService))
|
|
4809
5058
|
], SheetCellImageController);
|
|
4810
5059
|
|
|
4811
|
-
|
|
4812
|
-
//#region src/controllers/sheet-cell-image-autofill.controller.ts
|
|
5060
|
+
// src/controllers/sheet-cell-image-autofill.controller.ts
|
|
4813
5061
|
/**
|
|
4814
5062
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4815
5063
|
*
|
|
@@ -4850,8 +5098,7 @@ let SheetCellImageAutofillController = class SheetCellImageAutofillController ex
|
|
|
4850
5098
|
};
|
|
4851
5099
|
SheetCellImageAutofillController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets.IAutoFillService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], SheetCellImageAutofillController);
|
|
4852
5100
|
|
|
4853
|
-
|
|
4854
|
-
//#region src/controllers/sheet-cell-image-copy-paste.controller.ts
|
|
5101
|
+
// src/controllers/sheet-cell-image-copy-paste.controller.ts
|
|
4855
5102
|
const DISABLE_UNITS = [_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY, _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];
|
|
4856
5103
|
let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController extends _univerjs_core.Disposable {
|
|
4857
5104
|
constructor(_commandService, _univerInstanceService, _dialogService, _renderManagerService, _localeService) {
|
|
@@ -4924,8 +5171,7 @@ SheetCellImageCopyPasteController = __decorate([
|
|
|
4924
5171
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
|
|
4925
5172
|
], SheetCellImageCopyPasteController);
|
|
4926
5173
|
|
|
4927
|
-
|
|
4928
|
-
//#region src/controllers/sheet-drawing-active-render.controller.ts
|
|
5174
|
+
// src/controllers/sheet-drawing-active-render.controller.ts
|
|
4929
5175
|
let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderController extends _univerjs_core.Disposable {
|
|
4930
5176
|
constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService, _logService) {
|
|
4931
5177
|
super();
|
|
@@ -5051,8 +5297,7 @@ function prepareSheetDrawings(drawings, skeleton) {
|
|
|
5051
5297
|
};
|
|
5052
5298
|
}
|
|
5053
5299
|
|
|
5054
|
-
|
|
5055
|
-
//#region src/controllers/sheet-drawing-copy-paste.controller.ts
|
|
5300
|
+
// src/controllers/sheet-drawing-copy-paste.controller.ts
|
|
5056
5301
|
const IMAGE_PNG_MIME_TYPE = "image/png";
|
|
5057
5302
|
function base64ToBlob(base64) {
|
|
5058
5303
|
const arr = base64.split(",");
|
|
@@ -5094,7 +5339,11 @@ const specialPastes = [
|
|
|
5094
5339
|
_univerjs_sheets_ui.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA
|
|
5095
5340
|
];
|
|
5096
5341
|
let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController extends _univerjs_core.RxDisposable {
|
|
5097
|
-
|
|
5342
|
+
dispose() {
|
|
5343
|
+
this._copyInfo = null;
|
|
5344
|
+
super.dispose();
|
|
5345
|
+
}
|
|
5346
|
+
constructor(_sheetClipboardService, _renderManagerService, _sheetSkeletonService, _drawingService, _clipboardInterfaceService, _commandService, _instanceService, _permissions) {
|
|
5098
5347
|
super();
|
|
5099
5348
|
this._sheetClipboardService = _sheetClipboardService;
|
|
5100
5349
|
this._renderManagerService = _renderManagerService;
|
|
@@ -5102,6 +5351,8 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
5102
5351
|
this._drawingService = _drawingService;
|
|
5103
5352
|
this._clipboardInterfaceService = _clipboardInterfaceService;
|
|
5104
5353
|
this._commandService = _commandService;
|
|
5354
|
+
this._instanceService = _instanceService;
|
|
5355
|
+
this._permissions = _permissions;
|
|
5105
5356
|
_defineProperty(this, "_copyInfo", void 0);
|
|
5106
5357
|
this._initCopyPaste();
|
|
5107
5358
|
}
|
|
@@ -5111,12 +5362,15 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
5111
5362
|
_initCopyPaste() {
|
|
5112
5363
|
this.disposeWithMe(this._sheetClipboardService.addClipboardHook({
|
|
5113
5364
|
id: "SHEET_IMAGE_UI_PLUGIN",
|
|
5114
|
-
onBeforeCopyFocusedObject: (unitId,
|
|
5365
|
+
onBeforeCopyFocusedObject: (unitId, subUnitId, copyType) => {
|
|
5115
5366
|
this._copyInfo = null;
|
|
5116
5367
|
const drawings = this._focusedDrawings.filter((drawing) => drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE);
|
|
5117
5368
|
if (drawings.length === 0) return false;
|
|
5118
5369
|
const [drawing] = drawings;
|
|
5119
5370
|
if (copyType === _univerjs_sheets_ui.COPY_TYPE.CUT) {
|
|
5371
|
+
var _this$_instanceServic;
|
|
5372
|
+
const worksheet = (_this$_instanceServic = this._instanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_instanceServic === void 0 ? void 0 : _this$_instanceServic.getSheetBySheetId(subUnitId);
|
|
5373
|
+
if ((worksheet === null || worksheet === void 0 ? void 0 : worksheet.getConfig().type) === _univerjs_core.SheetTypes.CHART) return false;
|
|
5120
5374
|
const params = {
|
|
5121
5375
|
unitId,
|
|
5122
5376
|
drawings
|
|
@@ -5246,12 +5500,15 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
5246
5500
|
};
|
|
5247
5501
|
}
|
|
5248
5502
|
_generateSingleDrawingPasteMutations(pasteContext, copyType) {
|
|
5503
|
+
var _this$_instanceServic2;
|
|
5249
5504
|
const { pasteType, pasteTo } = pasteContext;
|
|
5250
5505
|
if (specialPastes.includes(pasteType)) return {
|
|
5251
5506
|
redos: [],
|
|
5252
5507
|
undos: []
|
|
5253
5508
|
};
|
|
5254
5509
|
const { unitId, subUnitId, range } = pasteTo;
|
|
5510
|
+
const worksheet = (_this$_instanceServic2 = this._instanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.getSheetBySheetId(subUnitId);
|
|
5511
|
+
if ((worksheet === null || worksheet === void 0 ? void 0 : worksheet.getConfig().type) === _univerjs_core.SheetTypes.CHART) return this._generateChartSheetImagePasteMutations(pasteTo);
|
|
5255
5512
|
const pasteToSkeleton = this._sheetSkeletonService.getSkeleton(unitId, subUnitId);
|
|
5256
5513
|
if (!pasteToSkeleton) return {
|
|
5257
5514
|
redos: [],
|
|
@@ -5297,6 +5554,47 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
5297
5554
|
}
|
|
5298
5555
|
});
|
|
5299
5556
|
}
|
|
5557
|
+
_generateChartSheetImagePasteMutations(pasteTo) {
|
|
5558
|
+
var _this$_renderManagerS;
|
|
5559
|
+
const { unitId, subUnitId } = pasteTo;
|
|
5560
|
+
const worksheet = this._instanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET).getSheetBySheetId(subUnitId);
|
|
5561
|
+
if (!this._permissions.permissionCheckWithoutRange({
|
|
5562
|
+
workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
|
|
5563
|
+
worksheetTypes: [_univerjs_sheets.WorksheetEditPermission]
|
|
5564
|
+
}, unitId, subUnitId)) throw new _univerjs_core.CustomCommandExecutionError(_univerjs_sheets_ui.SheetPasteCommand.id);
|
|
5565
|
+
const source = this._copyInfo;
|
|
5566
|
+
if (!this._permissions.permissionCheckWithoutRange({
|
|
5567
|
+
workbookTypes: [_univerjs_sheets.WorkbookCopyPermission],
|
|
5568
|
+
worksheetTypes: [_univerjs_sheets.WorksheetCopyPermission]
|
|
5569
|
+
}, source.unitId, source.subUnitId) || source.drawings.some((drawing) => !_univerjs_core.Tools.diffValue(drawing, this._drawingService.getDrawingByParam(drawing)))) throw new _univerjs_core.CustomCommandExecutionError(_univerjs_sheets_ui.SheetPasteCommand.id);
|
|
5570
|
+
const frame = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.components.get(_univerjs_sheets_ui.SHEET_VIEW_KEY.CHART_PAGE);
|
|
5571
|
+
const originals = this._copyInfo.drawings;
|
|
5572
|
+
const placed = frame && (0, _univerjs_sheets_drawing.transformDrawingsToChartSheet)(originals, {
|
|
5573
|
+
left: frame.left,
|
|
5574
|
+
top: frame.top,
|
|
5575
|
+
width: frame.width,
|
|
5576
|
+
height: frame.height
|
|
5577
|
+
}, worksheet.getConfig().rightToLeft === _univerjs_core.BooleanNumber.TRUE);
|
|
5578
|
+
if (!placed) return {
|
|
5579
|
+
redos: [],
|
|
5580
|
+
undos: []
|
|
5581
|
+
};
|
|
5582
|
+
const copies = new Map(placed.map((drawing) => [drawing.drawingId, drawing]));
|
|
5583
|
+
return this._generateMutations(originals, {
|
|
5584
|
+
unitId,
|
|
5585
|
+
subUnitId,
|
|
5586
|
+
isCut: false,
|
|
5587
|
+
getTransform: (_transform, _sheetTransform, drawing) => {
|
|
5588
|
+
const copy = copies.get(drawing.drawingId);
|
|
5589
|
+
return {
|
|
5590
|
+
anchorType: copy.anchorType,
|
|
5591
|
+
transform: copy.transform,
|
|
5592
|
+
sheetTransform: copy.sheetTransform,
|
|
5593
|
+
axisAlignSheetTransform: copy.axisAlignSheetTransform
|
|
5594
|
+
};
|
|
5595
|
+
}
|
|
5596
|
+
});
|
|
5597
|
+
}
|
|
5300
5598
|
_generateMutations(drawings, payload) {
|
|
5301
5599
|
const { unitId, subUnitId, getTransform, isCut } = payload;
|
|
5302
5600
|
const redos = [];
|
|
@@ -5305,15 +5603,13 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
|
|
|
5305
5603
|
drawings.forEach((drawing) => {
|
|
5306
5604
|
const { transform, sheetTransform } = drawing;
|
|
5307
5605
|
if (!transform) return;
|
|
5308
|
-
const transformContext = getTransform(transform, sheetTransform);
|
|
5606
|
+
const transformContext = getTransform(transform, sheetTransform, drawing);
|
|
5309
5607
|
const drawingObject = {
|
|
5310
5608
|
...drawing,
|
|
5311
|
-
|
|
5312
|
-
subUnitId,
|
|
5609
|
+
...transformContext,
|
|
5313
5610
|
drawingId: isCut ? drawing.drawingId : (0, _univerjs_core.generateRandomId)(),
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
axisAlignSheetTransform: transformContext.axisAlignSheetTransform
|
|
5611
|
+
unitId,
|
|
5612
|
+
subUnitId
|
|
5317
5613
|
};
|
|
5318
5614
|
if (isCut) {
|
|
5319
5615
|
const { undo, redo, objects } = _drawingService.getBatchUpdateOp([drawingObject]);
|
|
@@ -5456,11 +5752,136 @@ SheetsDrawingCopyPasteController = __decorate([
|
|
|
5456
5752
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService)),
|
|
5457
5753
|
__decorateParam(3, _univerjs_drawing.IDrawingManagerService),
|
|
5458
5754
|
__decorateParam(4, _univerjs_ui.IClipboardInterfaceService),
|
|
5459
|
-
__decorateParam(5, _univerjs_core.ICommandService)
|
|
5755
|
+
__decorateParam(5, _univerjs_core.ICommandService),
|
|
5756
|
+
__decorateParam(6, _univerjs_core.IUniverInstanceService),
|
|
5757
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetPermissionCheckController))
|
|
5460
5758
|
], SheetsDrawingCopyPasteController);
|
|
5461
5759
|
|
|
5462
|
-
|
|
5463
|
-
|
|
5760
|
+
// src/commands/commands/flip-drawings.command.ts
|
|
5761
|
+
/**
|
|
5762
|
+
* The command to flip sheet drawing elements
|
|
5763
|
+
*/
|
|
5764
|
+
const FlipSheetDrawingCommand = {
|
|
5765
|
+
id: "sheet.command.toggle-flip-drawings",
|
|
5766
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
5767
|
+
handler: (accessor, params) => {
|
|
5768
|
+
if (!params) return false;
|
|
5769
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5770
|
+
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5771
|
+
const sheetDrawingService = accessor.get(_univerjs_sheets_drawing.ISheetDrawingService);
|
|
5772
|
+
const sheetSkeletonService = accessor.get(_univerjs_sheets.SheetSkeletonService);
|
|
5773
|
+
const { drawings } = params;
|
|
5774
|
+
const flipH = params.flipH;
|
|
5775
|
+
const flipV = params.flipV;
|
|
5776
|
+
const unitIds = [];
|
|
5777
|
+
const updateParams = [];
|
|
5778
|
+
for (const param of drawings) {
|
|
5779
|
+
const { unitId, subUnitId, drawingId } = param;
|
|
5780
|
+
unitIds.push(unitId);
|
|
5781
|
+
const drawingData = sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
5782
|
+
const existing = drawingData === null || drawingData === void 0 ? void 0 : drawingData[drawingId];
|
|
5783
|
+
if (!existing) continue;
|
|
5784
|
+
const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
|
|
5785
|
+
if (!skeleton) continue;
|
|
5786
|
+
const transform = { ...existing.transform };
|
|
5787
|
+
if (flipH) transform.flipX = !transform.flipX;
|
|
5788
|
+
if (flipV) transform.flipY = !transform.flipY;
|
|
5789
|
+
const sheetTransform = (0, _univerjs_sheets_drawing.transformToDrawingPosition)(transform, skeleton);
|
|
5790
|
+
const axisAlignSheetTransform = (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(transform, skeleton);
|
|
5791
|
+
const updateParamItem = {
|
|
5792
|
+
unitId,
|
|
5793
|
+
subUnitId,
|
|
5794
|
+
drawingType: existing.drawingType,
|
|
5795
|
+
drawingId,
|
|
5796
|
+
transform,
|
|
5797
|
+
sheetTransform,
|
|
5798
|
+
axisAlignSheetTransform
|
|
5799
|
+
};
|
|
5800
|
+
if (existing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) {
|
|
5801
|
+
const scene = getSceneByDrawingSearch(accessor, unitId);
|
|
5802
|
+
if (scene) {
|
|
5803
|
+
const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
|
|
5804
|
+
unitId,
|
|
5805
|
+
subUnitId,
|
|
5806
|
+
drawingId
|
|
5807
|
+
});
|
|
5808
|
+
const imageShape = scene.getObject(drawingShapeKey);
|
|
5809
|
+
if (imageShape) {
|
|
5810
|
+
const srcRect = imageShape.srcRect;
|
|
5811
|
+
if (srcRect) {
|
|
5812
|
+
let newSrcRect;
|
|
5813
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = srcRect;
|
|
5814
|
+
if (flipH) {
|
|
5815
|
+
const centerX = left + (right - left) / 2;
|
|
5816
|
+
newSrcRect = {
|
|
5817
|
+
left: centerX - (right - left) / 2,
|
|
5818
|
+
top,
|
|
5819
|
+
right: centerX + (right - left) / 2,
|
|
5820
|
+
bottom
|
|
5821
|
+
};
|
|
5822
|
+
}
|
|
5823
|
+
if (flipV) {
|
|
5824
|
+
const centerY = top + (bottom - top) / 2;
|
|
5825
|
+
newSrcRect = {
|
|
5826
|
+
left,
|
|
5827
|
+
top: centerY - (bottom - top) / 2,
|
|
5828
|
+
right,
|
|
5829
|
+
bottom: centerY + (bottom - top) / 2
|
|
5830
|
+
};
|
|
5831
|
+
}
|
|
5832
|
+
if (newSrcRect) updateParamItem.srcRect = newSrcRect;
|
|
5833
|
+
}
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5836
|
+
}
|
|
5837
|
+
updateParams.push(updateParamItem);
|
|
5838
|
+
}
|
|
5839
|
+
if (updateParams.length === 0) return false;
|
|
5840
|
+
const { unitId: opUnitId, subUnitId: opSubUnitId, undo, redo, objects } = sheetDrawingService.getBatchUpdateOp(updateParams);
|
|
5841
|
+
const updateMutation = {
|
|
5842
|
+
id: _univerjs_sheets_drawing.SetDrawingApplyMutation.id,
|
|
5843
|
+
params: {
|
|
5844
|
+
unitId: opUnitId,
|
|
5845
|
+
subUnitId: opSubUnitId,
|
|
5846
|
+
op: redo,
|
|
5847
|
+
objects,
|
|
5848
|
+
type: _univerjs_sheets_drawing.DrawingApplyType.UPDATE
|
|
5849
|
+
}
|
|
5850
|
+
};
|
|
5851
|
+
const undoUpdateMutation = {
|
|
5852
|
+
id: _univerjs_sheets_drawing.SetDrawingApplyMutation.id,
|
|
5853
|
+
params: {
|
|
5854
|
+
unitId: opUnitId,
|
|
5855
|
+
subUnitId: opSubUnitId,
|
|
5856
|
+
op: undo,
|
|
5857
|
+
objects,
|
|
5858
|
+
type: _univerjs_sheets_drawing.DrawingApplyType.UPDATE
|
|
5859
|
+
}
|
|
5860
|
+
};
|
|
5861
|
+
if ((0, _univerjs_core.sequenceExecute)([updateMutation], commandService).result) {
|
|
5862
|
+
undoRedoService.pushUndoRedo({
|
|
5863
|
+
unitID: opUnitId,
|
|
5864
|
+
undoMutations: [undoUpdateMutation, {
|
|
5865
|
+
id: _univerjs_sheets_drawing.ClearSheetDrawingTransformerOperation.id,
|
|
5866
|
+
params: unitIds
|
|
5867
|
+
}],
|
|
5868
|
+
redoMutations: [updateMutation, {
|
|
5869
|
+
id: _univerjs_sheets_drawing.ClearSheetDrawingTransformerOperation.id,
|
|
5870
|
+
params: unitIds
|
|
5871
|
+
}]
|
|
5872
|
+
});
|
|
5873
|
+
return true;
|
|
5874
|
+
}
|
|
5875
|
+
return false;
|
|
5876
|
+
}
|
|
5877
|
+
};
|
|
5878
|
+
function getSceneByDrawingSearch(accessor, unitId) {
|
|
5879
|
+
const render = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(unitId);
|
|
5880
|
+
if (!render) return null;
|
|
5881
|
+
return render.scene;
|
|
5882
|
+
}
|
|
5883
|
+
|
|
5884
|
+
// src/controllers/sheet-drawing-permission.controller.ts
|
|
5464
5885
|
const drawingObjectTypes = [
|
|
5465
5886
|
_univerjs_engine_render.ObjectType.IMAGE,
|
|
5466
5887
|
_univerjs_engine_render.ObjectType.SHAPE,
|
|
@@ -5483,6 +5904,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
5483
5904
|
this._initViewPermissionChange();
|
|
5484
5905
|
this._initEditPermissionChange();
|
|
5485
5906
|
this._initCommandPermissionCheck();
|
|
5907
|
+
this._initChartSheetCommandPermissionCheck();
|
|
5486
5908
|
}
|
|
5487
5909
|
_initDrawingVisible() {
|
|
5488
5910
|
const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
@@ -5658,6 +6080,30 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
|
|
|
5658
6080
|
}
|
|
5659
6081
|
}));
|
|
5660
6082
|
}
|
|
6083
|
+
_initChartSheetCommandPermissionCheck() {
|
|
6084
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
6085
|
+
if (command.id === GroupSheetDrawingCommand.id || command.id === UngroupSheetDrawingCommand.id) {
|
|
6086
|
+
for (const group of command.params ?? []) {
|
|
6087
|
+
this._checkChartSheetEditPermission(group.parent.unitId, group.parent.subUnitId);
|
|
6088
|
+
for (const child of group.children) this._checkChartSheetEditPermission(child.unitId, child.subUnitId);
|
|
6089
|
+
}
|
|
6090
|
+
return;
|
|
6091
|
+
}
|
|
6092
|
+
if (command.id === FlipSheetDrawingCommand.id) {
|
|
6093
|
+
const params = command.params;
|
|
6094
|
+
for (const drawing of (params === null || params === void 0 ? void 0 : params.drawings) ?? []) this._checkChartSheetEditPermission(drawing.unitId, drawing.subUnitId);
|
|
6095
|
+
}
|
|
6096
|
+
}));
|
|
6097
|
+
}
|
|
6098
|
+
_checkChartSheetEditPermission(unitId, subUnitId) {
|
|
6099
|
+
var _this$_univerInstance;
|
|
6100
|
+
const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
|
|
6101
|
+
if ((worksheet === null || worksheet === void 0 ? void 0 : worksheet.getConfig().type) !== _univerjs_core.SheetTypes.CHART) return;
|
|
6102
|
+
if (!this._sheetPermissionCheckController.permissionCheckWithoutRange({
|
|
6103
|
+
workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
|
|
6104
|
+
worksheetTypes: [_univerjs_sheets.WorksheetEditPermission]
|
|
6105
|
+
}, unitId, subUnitId)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-drawing-ui.permission.dialog.editErr"));
|
|
6106
|
+
}
|
|
5661
6107
|
_initCommandPermissionCheck() {
|
|
5662
6108
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
5663
6109
|
let unitId;
|
|
@@ -5702,8 +6148,7 @@ function getPlacementCommandTarget(params) {
|
|
|
5702
6148
|
};
|
|
5703
6149
|
}
|
|
5704
6150
|
|
|
5705
|
-
|
|
5706
|
-
//#region src/views/PrintingFloatDom.tsx
|
|
6151
|
+
// src/views/PrintingFloatDom.tsx
|
|
5707
6152
|
function createPrintingFloatDom(info, scene, skeleton, worksheet) {
|
|
5708
6153
|
const { width, height, angle, left, top } = info.transform;
|
|
5709
6154
|
const offsetBound = transformBound2DOMBound({
|
|
@@ -5765,8 +6210,7 @@ function mountPrintingFloatDom(props, root, injector) {
|
|
|
5765
6210
|
return () => (0, _univerjs_design.unmount)(root);
|
|
5766
6211
|
}
|
|
5767
6212
|
|
|
5768
|
-
|
|
5769
|
-
//#region src/controllers/sheet-drawing-printing.controller.ts
|
|
6213
|
+
// src/controllers/sheet-drawing-printing.controller.ts
|
|
5770
6214
|
let SheetDrawingPrintingController = class SheetDrawingPrintingController extends _univerjs_core.Disposable {
|
|
5771
6215
|
constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService, _componetManager, _injector) {
|
|
5772
6216
|
super();
|
|
@@ -5788,7 +6232,10 @@ let SheetDrawingPrintingController = class SheetDrawingPrintingController extend
|
|
|
5788
6232
|
const drawing = subUnitData.data[id];
|
|
5789
6233
|
if (drawing.hidden) return;
|
|
5790
6234
|
if (drawing.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_CHART && drawing.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_DOM && drawing.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_BLOCK) {
|
|
5791
|
-
const resource = this._drawingRenderService.renderDrawing(drawing, scene, {
|
|
6235
|
+
const resource = this._drawingRenderService.renderDrawing(drawing, scene, {
|
|
6236
|
+
allowInactiveSheet: true,
|
|
6237
|
+
interactive: false
|
|
6238
|
+
});
|
|
5792
6239
|
if (resource) resourceCollector.add(Promise.resolve(resource));
|
|
5793
6240
|
}
|
|
5794
6241
|
});
|
|
@@ -5880,133 +6327,7 @@ SheetDrawingPrintingController = __decorate([
|
|
|
5880
6327
|
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.Injector))
|
|
5881
6328
|
], SheetDrawingPrintingController);
|
|
5882
6329
|
|
|
5883
|
-
|
|
5884
|
-
//#region src/commands/commands/flip-drawings.command.ts
|
|
5885
|
-
/**
|
|
5886
|
-
* The command to flip sheet drawing elements
|
|
5887
|
-
*/
|
|
5888
|
-
const FlipSheetDrawingCommand = {
|
|
5889
|
-
id: "sheet.command.toggle-flip-drawings",
|
|
5890
|
-
type: _univerjs_core.CommandType.COMMAND,
|
|
5891
|
-
handler: (accessor, params) => {
|
|
5892
|
-
if (!params) return false;
|
|
5893
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
5894
|
-
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
5895
|
-
const sheetDrawingService = accessor.get(_univerjs_sheets_drawing.ISheetDrawingService);
|
|
5896
|
-
const sheetSkeletonService = accessor.get(_univerjs_sheets.SheetSkeletonService);
|
|
5897
|
-
const { drawings } = params;
|
|
5898
|
-
const flipH = params.flipH;
|
|
5899
|
-
const flipV = params.flipV;
|
|
5900
|
-
const unitIds = [];
|
|
5901
|
-
const updateParams = [];
|
|
5902
|
-
for (const param of drawings) {
|
|
5903
|
-
const { unitId, subUnitId, drawingId } = param;
|
|
5904
|
-
unitIds.push(unitId);
|
|
5905
|
-
const drawingData = sheetDrawingService.getDrawingData(unitId, subUnitId);
|
|
5906
|
-
const existing = drawingData === null || drawingData === void 0 ? void 0 : drawingData[drawingId];
|
|
5907
|
-
if (!existing) continue;
|
|
5908
|
-
const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
|
|
5909
|
-
if (!skeleton) continue;
|
|
5910
|
-
const transform = { ...existing.transform };
|
|
5911
|
-
if (flipH) transform.flipX = !transform.flipX;
|
|
5912
|
-
if (flipV) transform.flipY = !transform.flipY;
|
|
5913
|
-
const sheetTransform = (0, _univerjs_sheets_drawing.transformToDrawingPosition)(transform, skeleton);
|
|
5914
|
-
const axisAlignSheetTransform = (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(transform, skeleton);
|
|
5915
|
-
const updateParamItem = {
|
|
5916
|
-
unitId,
|
|
5917
|
-
subUnitId,
|
|
5918
|
-
drawingType: existing.drawingType,
|
|
5919
|
-
drawingId,
|
|
5920
|
-
transform,
|
|
5921
|
-
sheetTransform,
|
|
5922
|
-
axisAlignSheetTransform
|
|
5923
|
-
};
|
|
5924
|
-
if (existing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) {
|
|
5925
|
-
const scene = getSceneByDrawingSearch(accessor, unitId);
|
|
5926
|
-
if (scene) {
|
|
5927
|
-
const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
|
|
5928
|
-
unitId,
|
|
5929
|
-
subUnitId,
|
|
5930
|
-
drawingId
|
|
5931
|
-
});
|
|
5932
|
-
const imageShape = scene.getObject(drawingShapeKey);
|
|
5933
|
-
if (imageShape) {
|
|
5934
|
-
const srcRect = imageShape.srcRect;
|
|
5935
|
-
if (srcRect) {
|
|
5936
|
-
let newSrcRect;
|
|
5937
|
-
const { left = 0, top = 0, right = 0, bottom = 0 } = srcRect;
|
|
5938
|
-
if (flipH) {
|
|
5939
|
-
const centerX = left + (right - left) / 2;
|
|
5940
|
-
newSrcRect = {
|
|
5941
|
-
left: centerX - (right - left) / 2,
|
|
5942
|
-
top,
|
|
5943
|
-
right: centerX + (right - left) / 2,
|
|
5944
|
-
bottom
|
|
5945
|
-
};
|
|
5946
|
-
}
|
|
5947
|
-
if (flipV) {
|
|
5948
|
-
const centerY = top + (bottom - top) / 2;
|
|
5949
|
-
newSrcRect = {
|
|
5950
|
-
left,
|
|
5951
|
-
top: centerY - (bottom - top) / 2,
|
|
5952
|
-
right,
|
|
5953
|
-
bottom: centerY + (bottom - top) / 2
|
|
5954
|
-
};
|
|
5955
|
-
}
|
|
5956
|
-
if (newSrcRect) updateParamItem.srcRect = newSrcRect;
|
|
5957
|
-
}
|
|
5958
|
-
}
|
|
5959
|
-
}
|
|
5960
|
-
}
|
|
5961
|
-
updateParams.push(updateParamItem);
|
|
5962
|
-
}
|
|
5963
|
-
if (updateParams.length === 0) return false;
|
|
5964
|
-
const { unitId: opUnitId, subUnitId: opSubUnitId, undo, redo, objects } = sheetDrawingService.getBatchUpdateOp(updateParams);
|
|
5965
|
-
const updateMutation = {
|
|
5966
|
-
id: _univerjs_sheets_drawing.SetDrawingApplyMutation.id,
|
|
5967
|
-
params: {
|
|
5968
|
-
unitId: opUnitId,
|
|
5969
|
-
subUnitId: opSubUnitId,
|
|
5970
|
-
op: redo,
|
|
5971
|
-
objects,
|
|
5972
|
-
type: _univerjs_sheets_drawing.DrawingApplyType.UPDATE
|
|
5973
|
-
}
|
|
5974
|
-
};
|
|
5975
|
-
const undoUpdateMutation = {
|
|
5976
|
-
id: _univerjs_sheets_drawing.SetDrawingApplyMutation.id,
|
|
5977
|
-
params: {
|
|
5978
|
-
unitId: opUnitId,
|
|
5979
|
-
subUnitId: opSubUnitId,
|
|
5980
|
-
op: undo,
|
|
5981
|
-
objects,
|
|
5982
|
-
type: _univerjs_sheets_drawing.DrawingApplyType.UPDATE
|
|
5983
|
-
}
|
|
5984
|
-
};
|
|
5985
|
-
if ((0, _univerjs_core.sequenceExecute)([updateMutation], commandService).result) {
|
|
5986
|
-
undoRedoService.pushUndoRedo({
|
|
5987
|
-
unitID: opUnitId,
|
|
5988
|
-
undoMutations: [undoUpdateMutation, {
|
|
5989
|
-
id: _univerjs_sheets_drawing.ClearSheetDrawingTransformerOperation.id,
|
|
5990
|
-
params: unitIds
|
|
5991
|
-
}],
|
|
5992
|
-
redoMutations: [updateMutation, {
|
|
5993
|
-
id: _univerjs_sheets_drawing.ClearSheetDrawingTransformerOperation.id,
|
|
5994
|
-
params: unitIds
|
|
5995
|
-
}]
|
|
5996
|
-
});
|
|
5997
|
-
return true;
|
|
5998
|
-
}
|
|
5999
|
-
return false;
|
|
6000
|
-
}
|
|
6001
|
-
};
|
|
6002
|
-
function getSceneByDrawingSearch(accessor, unitId) {
|
|
6003
|
-
const render = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(unitId);
|
|
6004
|
-
if (!render) return null;
|
|
6005
|
-
return render.scene;
|
|
6006
|
-
}
|
|
6007
|
-
|
|
6008
|
-
//#endregion
|
|
6009
|
-
//#region src/controllers/shortcuts/drawing.shortcut.ts
|
|
6330
|
+
// src/controllers/shortcuts/drawing.shortcut.ts
|
|
6010
6331
|
function whenSheetDrawingFocused(contextService) {
|
|
6011
6332
|
return contextService.getContextValue(_univerjs_core.FOCUSING_SHEET) && !contextService.getContextValue(_univerjs_core.FOCUSING_FX_BAR_EDITOR) && !contextService.getContextValue(_univerjs_core.FOCUSING_PANEL_EDITOR) && contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS) && !contextService.getContextValue(_univerjs_core.FOCUSING_SHAPE_TEXT_EDITOR);
|
|
6012
6333
|
}
|
|
@@ -6061,8 +6382,7 @@ const DeleteDrawingsShortcutItem = {
|
|
|
6061
6382
|
mac: _univerjs_ui.KeyCode.BACKSPACE
|
|
6062
6383
|
};
|
|
6063
6384
|
|
|
6064
|
-
|
|
6065
|
-
//#region src/controllers/ui.controller.ts
|
|
6385
|
+
// src/controllers/ui.controller.ts
|
|
6066
6386
|
/**
|
|
6067
6387
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
6068
6388
|
*
|
|
@@ -6137,8 +6457,7 @@ SheetDrawingUIController = __decorate([
|
|
|
6137
6457
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))
|
|
6138
6458
|
], SheetDrawingUIController);
|
|
6139
6459
|
|
|
6140
|
-
|
|
6141
|
-
//#region src/menu/mobile-drawing-popup-menu.controller.ts
|
|
6460
|
+
// src/menu/mobile-drawing-popup-menu.controller.ts
|
|
6142
6461
|
const MOBILE_IMAGE_ACTIONS_DIALOG_ID = "sheet-mobile-image-actions";
|
|
6143
6462
|
const MOBILE_DRAWING_LONG_PRESS_DURATION = 500;
|
|
6144
6463
|
let MobileDrawingPopupMenuController = class MobileDrawingPopupMenuController extends _univerjs_core.RxDisposable {
|
|
@@ -6391,11 +6710,13 @@ let MobileDrawingPopupMenuController = class MobileDrawingPopupMenuController ex
|
|
|
6391
6710
|
_getFloatingObjectMenuItems() {
|
|
6392
6711
|
return this._menuManagerService.getFlatMenuByPositionKey(_univerjs_ui.FloatingObjectToolbarPosition.SHEET).flatMap(({ item }, index) => {
|
|
6393
6712
|
if (!item || item.type !== _univerjs_ui.MenuItemType.BUTTON || !item.title) return [];
|
|
6713
|
+
const { icon, params } = item;
|
|
6394
6714
|
return [{
|
|
6395
6715
|
label: item.title,
|
|
6716
|
+
...typeof icon === "string" ? { icon } : {},
|
|
6396
6717
|
index: 100 + index,
|
|
6397
6718
|
commandId: item.commandId ?? item.id,
|
|
6398
|
-
commandParams: typeof
|
|
6719
|
+
commandParams: typeof params === "function" ? params.call(item) : params,
|
|
6399
6720
|
disable: false
|
|
6400
6721
|
}];
|
|
6401
6722
|
});
|
|
@@ -6416,8 +6737,7 @@ MobileDrawingPopupMenuController = __decorate([
|
|
|
6416
6737
|
__decorateParam(11, _univerjs_ui.ILayoutService)
|
|
6417
6738
|
], MobileDrawingPopupMenuController);
|
|
6418
6739
|
|
|
6419
|
-
|
|
6420
|
-
//#region src/menu/mobile-schema.ts
|
|
6740
|
+
// src/menu/mobile-schema.ts
|
|
6421
6741
|
const mobileMenuSchema = {
|
|
6422
6742
|
[_univerjs_ui.RibbonInsertGroup.MEDIA]: { [SHEETS_IMAGE_MENU_ID]: {
|
|
6423
6743
|
order: 0,
|
|
@@ -6457,8 +6777,7 @@ const mobileMenuSchema = {
|
|
|
6457
6777
|
} } }
|
|
6458
6778
|
};
|
|
6459
6779
|
|
|
6460
|
-
|
|
6461
|
-
//#region src/menu/mobile-sheet-drawing-menu.controller.ts
|
|
6780
|
+
// src/menu/mobile-sheet-drawing-menu.controller.ts
|
|
6462
6781
|
/**
|
|
6463
6782
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
6464
6783
|
*
|
|
@@ -6482,8 +6801,7 @@ let MobileSheetDrawingMenuController = class MobileSheetDrawingMenuController ex
|
|
|
6482
6801
|
};
|
|
6483
6802
|
MobileSheetDrawingMenuController = __decorate([__decorateParam(0, _univerjs_ui.IMenuManagerService)], MobileSheetDrawingMenuController);
|
|
6484
6803
|
|
|
6485
|
-
|
|
6486
|
-
//#region src/services/sheet-drawing-hit-test.service.ts
|
|
6804
|
+
// src/services/sheet-drawing-hit-test.service.ts
|
|
6487
6805
|
let SheetDrawingHitTestService = class SheetDrawingHitTestService extends _univerjs_core.Disposable {
|
|
6488
6806
|
constructor(_drawingManagerService, _univerInstanceService, _renderManagerService) {
|
|
6489
6807
|
super();
|
|
@@ -6593,8 +6911,7 @@ SheetDrawingHitTestService = __decorate([
|
|
|
6593
6911
|
__decorateParam(2, _univerjs_engine_render.IRenderManagerService)
|
|
6594
6912
|
], SheetDrawingHitTestService);
|
|
6595
6913
|
|
|
6596
|
-
|
|
6597
|
-
//#region src/mobile-plugin.ts
|
|
6914
|
+
// src/mobile-plugin.ts
|
|
6598
6915
|
let UniverSheetsDrawingMobileUIPlugin = class UniverSheetsDrawingMobileUIPlugin extends _univerjs_core.Plugin {
|
|
6599
6916
|
constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
|
|
6600
6917
|
super();
|
|
@@ -6674,8 +6991,7 @@ UniverSheetsDrawingMobileUIPlugin = __decorate([
|
|
|
6674
6991
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
6675
6992
|
], UniverSheetsDrawingMobileUIPlugin);
|
|
6676
6993
|
|
|
6677
|
-
|
|
6678
|
-
//#region src/controllers/components.controller.ts
|
|
6994
|
+
// src/controllers/components.controller.ts
|
|
6679
6995
|
/**
|
|
6680
6996
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
6681
6997
|
*
|
|
@@ -6704,10 +7020,9 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
6704
7020
|
};
|
|
6705
7021
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))], ComponentsController);
|
|
6706
7022
|
|
|
6707
|
-
|
|
6708
|
-
//#region src/menu/drawing-popup-menu.controller.ts
|
|
7023
|
+
// src/menu/drawing-popup-menu.controller.ts
|
|
6709
7024
|
let DrawingPopupMenuController = class DrawingPopupMenuController extends _univerjs_core.RxDisposable {
|
|
6710
|
-
constructor(_localeService, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _messageService, _menuManagerService, _contextService, _ioService, _commandService) {
|
|
7025
|
+
constructor(_localeService, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _messageService, _menuManagerService, _contextService, _ioService, _commandService, _oleUI, _permissionService) {
|
|
6711
7026
|
super();
|
|
6712
7027
|
this._localeService = _localeService;
|
|
6713
7028
|
this._drawingManagerService = _drawingManagerService;
|
|
@@ -6719,7 +7034,40 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
|
|
|
6719
7034
|
this._contextService = _contextService;
|
|
6720
7035
|
this._ioService = _ioService;
|
|
6721
7036
|
this._commandService = _commandService;
|
|
7037
|
+
this._oleUI = _oleUI;
|
|
7038
|
+
this._permissionService = _permissionService;
|
|
6722
7039
|
_defineProperty(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
7040
|
+
this.disposeWithMe(this._oleUI.registerHost(_univerjs_core.UniverInstanceType.UNIVER_SHEET, {
|
|
7041
|
+
isEditable: (drawing) => {
|
|
7042
|
+
var _this$_permissionServ;
|
|
7043
|
+
return this._drawingManagerService.getDrawingEditable() && ((_this$_permissionServ = this._permissionService.getPermissionPoint(new _univerjs_sheets.WorkbookEditablePermission(drawing.unitId).id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value) !== false;
|
|
7044
|
+
},
|
|
7045
|
+
attach: (object, componentKey, extraProps, _drawing, direction = "top-center") => this._canvasPopManagerService.attachPopupToObject(object, {
|
|
7046
|
+
componentKey,
|
|
7047
|
+
extraProps,
|
|
7048
|
+
direction,
|
|
7049
|
+
portal: true,
|
|
7050
|
+
offset: direction === "top-center" ? [0, 8] : [0, 0]
|
|
7051
|
+
}),
|
|
7052
|
+
rename: (drawing, name) => this._commandService.executeCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
|
|
7053
|
+
unitId: drawing.unitId,
|
|
7054
|
+
drawings: [{
|
|
7055
|
+
...drawing,
|
|
7056
|
+
oleFileName: name
|
|
7057
|
+
}]
|
|
7058
|
+
}),
|
|
7059
|
+
saveOnlineUnit: (drawing, online) => this._commandService.executeCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
|
|
7060
|
+
unitId: drawing.unitId,
|
|
7061
|
+
drawings: [{
|
|
7062
|
+
...drawing,
|
|
7063
|
+
oleOnlineUnit: online
|
|
7064
|
+
}]
|
|
7065
|
+
}),
|
|
7066
|
+
remove: (drawing) => this._commandService.executeCommand(_univerjs_sheets_drawing.RemoveSheetDrawingCommand.id, {
|
|
7067
|
+
unitId: drawing.unitId,
|
|
7068
|
+
drawings: [drawing]
|
|
7069
|
+
})
|
|
7070
|
+
}));
|
|
6723
7071
|
this._init();
|
|
6724
7072
|
}
|
|
6725
7073
|
_init() {
|
|
@@ -6794,7 +7142,7 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
|
|
|
6794
7142
|
const object = selectedObjects.values().next().value;
|
|
6795
7143
|
if (!object) return;
|
|
6796
7144
|
const drawingParam = this._drawingManagerService.getDrawingOKey(object.oKey);
|
|
6797
|
-
if (!drawingParam || drawingParam.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_SHAPE) return;
|
|
7145
|
+
if (!drawingParam || drawingParam.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_SHAPE || drawingParam.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_OLE) return;
|
|
6798
7146
|
const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
|
|
6799
7147
|
const data = drawingParam.data;
|
|
6800
7148
|
if (data && (data.disablePopup || data.version === 1 && typeof data.embedId === "string")) return;
|
|
@@ -6804,7 +7152,10 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
|
|
|
6804
7152
|
constrainToCanvas: true,
|
|
6805
7153
|
direction: this._localeService.getDirection() === "rtl" ? "left" : "horizontal",
|
|
6806
7154
|
offset: [2, 0],
|
|
6807
|
-
extraProps: {
|
|
7155
|
+
extraProps: {
|
|
7156
|
+
menuItems,
|
|
7157
|
+
icon: this._canvasPopManagerService.getFeatureMenuIcon(drawingType)
|
|
7158
|
+
}
|
|
6808
7159
|
}));
|
|
6809
7160
|
}
|
|
6810
7161
|
_getImageMenuItems(unitId, subUnitId, drawingId, drawingType) {
|
|
@@ -6891,11 +7242,13 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
|
|
|
6891
7242
|
_getFloatingObjectMenuItems() {
|
|
6892
7243
|
return this._menuManagerService.getFlatMenuByPositionKey(_univerjs_ui.FloatingObjectToolbarPosition.SHEET).flatMap(({ item }, index) => {
|
|
6893
7244
|
if (!item || item.type !== _univerjs_ui.MenuItemType.BUTTON || !item.title) return [];
|
|
7245
|
+
const { icon, params } = item;
|
|
6894
7246
|
return [{
|
|
6895
7247
|
label: item.title,
|
|
7248
|
+
...typeof icon === "string" ? { icon } : {},
|
|
6896
7249
|
index: 100 + index,
|
|
6897
7250
|
commandId: item.commandId ?? item.id,
|
|
6898
|
-
commandParams: typeof
|
|
7251
|
+
commandParams: typeof params === "function" ? params.call(item) : params,
|
|
6899
7252
|
disable: false
|
|
6900
7253
|
}];
|
|
6901
7254
|
});
|
|
@@ -6911,11 +7264,30 @@ DrawingPopupMenuController = __decorate([
|
|
|
6911
7264
|
__decorateParam(6, _univerjs_ui.IMenuManagerService),
|
|
6912
7265
|
__decorateParam(7, _univerjs_core.IContextService),
|
|
6913
7266
|
__decorateParam(8, _univerjs_core.IImageIoService),
|
|
6914
|
-
__decorateParam(9, _univerjs_core.ICommandService)
|
|
7267
|
+
__decorateParam(9, _univerjs_core.ICommandService),
|
|
7268
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(_univerjs_drawing_ui.OleUIService)),
|
|
7269
|
+
__decorateParam(11, _univerjs_core.IPermissionService)
|
|
6915
7270
|
], DrawingPopupMenuController);
|
|
7271
|
+
function createSheetOlePreview(context) {
|
|
7272
|
+
return (0, _univerjs_drawing_ui.createOlePreviewViewer)({
|
|
7273
|
+
...context,
|
|
7274
|
+
setReadonly: (permissions, unitId) => {
|
|
7275
|
+
for (const point of [new _univerjs_sheets.WorkbookEditablePermission(unitId), new _univerjs_sheets.WorkbookRenameSheetPermission(unitId)]) {
|
|
7276
|
+
if (!permissions.getPermissionPoint(point.id)) permissions.addPermissionPoint(point);
|
|
7277
|
+
permissions.updatePermissionPoint(point.id, false);
|
|
7278
|
+
}
|
|
7279
|
+
},
|
|
7280
|
+
register: (viewer) => {
|
|
7281
|
+
viewer.registerPlugin(_univerjs_sheets.UniverSheetsPlugin);
|
|
7282
|
+
viewer.registerPlugin(_univerjs_sheets_ui.UniverSheetsUIPlugin, { disableEdit: true });
|
|
7283
|
+
viewer.registerPlugin(_univerjs_sheets_drawing.UniverSheetsDrawingPlugin);
|
|
7284
|
+
viewer.registerPlugin(UniverSheetsDrawingUIPlugin);
|
|
7285
|
+
}
|
|
7286
|
+
});
|
|
7287
|
+
}
|
|
7288
|
+
(0, _univerjs_drawing_ui.registerOlePreviewRenderer)(_univerjs_core.UniverInstanceType.UNIVER_SHEET, createSheetOlePreview);
|
|
6916
7289
|
|
|
6917
|
-
|
|
6918
|
-
//#region src/menu/sheet-drawing-menu.controller.ts
|
|
7290
|
+
// src/menu/sheet-drawing-menu.controller.ts
|
|
6919
7291
|
/**
|
|
6920
7292
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
6921
7293
|
*
|
|
@@ -6939,8 +7311,7 @@ let SheetDrawingMenuController = class SheetDrawingMenuController extends _unive
|
|
|
6939
7311
|
};
|
|
6940
7312
|
SheetDrawingMenuController = __decorate([__decorateParam(0, _univerjs_ui.IMenuManagerService)], SheetDrawingMenuController);
|
|
6941
7313
|
|
|
6942
|
-
|
|
6943
|
-
//#region src/plugin.ts
|
|
7314
|
+
// src/plugin.ts
|
|
6944
7315
|
let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends _univerjs_core.Plugin {
|
|
6945
7316
|
constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
|
|
6946
7317
|
super();
|
|
@@ -7019,7 +7390,6 @@ UniverSheetsDrawingUIPlugin = __decorate([
|
|
|
7019
7390
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
7020
7391
|
], UniverSheetsDrawingUIPlugin);
|
|
7021
7392
|
|
|
7022
|
-
//#endregion
|
|
7023
7393
|
exports.AddWorksheetBackgroundImageCommand = AddWorksheetBackgroundImageCommand;
|
|
7024
7394
|
Object.defineProperty(exports, "BatchSaveImagesService", {
|
|
7025
7395
|
enumerable: true,
|