@univerjs/sheets-drawing 1.0.0-rc.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/facade.js CHANGED
@@ -2,11 +2,11 @@ import { ArrangeTypeEnum, CanceledError, DrawingTypeEnum, ICommandService, IUndo
2
2
  import { FBase, FEnum, FEventName, FUniver } from "@univerjs/core/facade";
3
3
  import { IDrawingManagerService, SetDrawingSelectedOperation, getImageSize, isGroupableDrawingType } from "@univerjs/drawing";
4
4
  import { SheetSkeletonService, convertPositionCellToSheetOverGrid, convertPositionSheetOverGridToAbsolute } from "@univerjs/sheets";
5
- import { DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SheetDrawingAnchorType, applySheetDrawingPlacement, getSheetDrawingPlacement, normalizeSheetDrawingPlacement, transformToAxisAlignPosition } from "@univerjs/sheets-drawing";
5
+ import { DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SheetDrawingAnchorType, applySheetDrawingPlacement, getSheetDrawingPlacement, normalizeSheetDrawingPlacement, transformToAxisAlignPosition } from "@univerjs/sheets-drawing";
6
6
  import { getGroupState, transformObjectOutOfGroup } from "@univerjs/engine-render";
7
7
  import { FWorksheet } from "@univerjs/sheets/facade";
8
8
 
9
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
9
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
10
10
  function _typeof(o) {
11
11
  "@babel/helpers - typeof";
12
12
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -17,7 +17,7 @@ function _typeof(o) {
17
17
  }
18
18
 
19
19
  //#endregion
20
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
20
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
21
21
  function toPrimitive(t, r) {
22
22
  if ("object" != _typeof(t) || !t) return t;
23
23
  var e = t[Symbol.toPrimitive];
@@ -30,14 +30,14 @@ function toPrimitive(t, r) {
30
30
  }
31
31
 
32
32
  //#endregion
33
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
33
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
34
34
  function toPropertyKey(t) {
35
35
  var i = toPrimitive(t, "string");
36
36
  return "symbol" == _typeof(i) ? i : i + "";
37
37
  }
38
38
 
39
39
  //#endregion
40
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
40
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
41
41
  function _defineProperty(e, r, t) {
42
42
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
43
43
  value: t,
@@ -48,7 +48,7 @@ function _defineProperty(e, r, t) {
48
48
  }
49
49
 
50
50
  //#endregion
51
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
51
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
52
52
  function __decorateParam(paramIndex, decorator) {
53
53
  return function(target, key) {
54
54
  decorator(target, key, paramIndex);
@@ -56,7 +56,7 @@ function __decorateParam(paramIndex, decorator) {
56
56
  }
57
57
 
58
58
  //#endregion
59
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
59
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
60
60
  function __decorate(decorators, target, key, desc) {
61
61
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
62
62
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -660,14 +660,38 @@ let FOverGridImageBuilder = class FOverGridImageBuilder {
660
660
  this._image.angle = angle;
661
661
  return this;
662
662
  }
663
+ /**
664
+ * Sets the workbook unit ID of the image to build.
665
+ * @param {string} unitId The target workbook unit ID.
666
+ * @returns {FOverGridImageBuilder} This builder, for chaining.
667
+ */
663
668
  setUnitId(unitId) {
664
669
  this._image.unitId = unitId;
665
670
  return this;
666
671
  }
672
+ /**
673
+ * Sets the worksheet ID of the image to build.
674
+ * @param {string} subUnitId The target worksheet ID.
675
+ * @returns {FOverGridImageBuilder} This builder, for chaining.
676
+ */
667
677
  setSubUnitId(subUnitId) {
668
678
  this._image.subUnitId = subUnitId;
669
679
  return this;
670
680
  }
681
+ /**
682
+ * Builds image data for insertion or updating; this does not insert the image.
683
+ * An explicit placement takes precedence over the individual position and size fields.
684
+ * Without explicit placement, zero width or height is filled from the source image's intrinsic size.
685
+ * @returns {Promise<ISheetImage>} A promise resolving to the built sheet image data.
686
+ * @example
687
+ * ```ts
688
+ * const sheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
689
+ * if (sheet) {
690
+ * const image = await sheet.newOverGridImage().setSource('https://example.com/image.png').buildAsync();
691
+ * sheet.insertImages([image]);
692
+ * }
693
+ * ```
694
+ */
671
695
  async buildAsync() {
672
696
  var _this$_placement;
673
697
  const sheetSkeletonService = this._sheetSkeletonService;
@@ -694,7 +718,7 @@ let FOverGridImageBuilder = class FOverGridImageBuilder {
694
718
  rowOffset: top + height
695
719
  }
696
720
  };
697
- return applySheetDrawingPlacement({
721
+ const image = {
698
722
  ...this._image,
699
723
  transform: {
700
724
  left,
@@ -709,7 +733,8 @@ let FOverGridImageBuilder = class FOverGridImageBuilder {
709
733
  },
710
734
  sheetTransform,
711
735
  axisAlignSheetTransform: sheetTransform
712
- }, this._placement);
736
+ };
737
+ return applySheetDrawingPlacement(image, this._placement);
713
738
  }
714
739
  const image = convertFOverGridImageToSheetImage(this._image, sheetSkeletonService);
715
740
  if (!this._placement) return image;
@@ -779,11 +804,12 @@ let FOverGridImage = class FOverGridImage extends FBase {
779
804
  * ```
780
805
  */
781
806
  getPlacement() {
782
- return getSheetDrawingPlacement(this._sheetDrawingService.getDrawingByParam({
807
+ const current = this._sheetDrawingService.getDrawingByParam({
783
808
  unitId: this._image.unitId,
784
809
  subUnitId: this._image.subUnitId,
785
810
  drawingId: this._image.drawingId
786
- }) ?? this._image);
811
+ });
812
+ return getSheetDrawingPlacement(current ?? this._image);
787
813
  }
788
814
  /**
789
815
  * Set this image's explicit placement through the drawing command.
@@ -904,7 +930,7 @@ let FOverGridImage = class FOverGridImage extends FBase {
904
930
  * Set the size of the image
905
931
  * @param {number} width - The width of the image, pixel unit
906
932
  * @param {number} height - The height of the image, pixel unit
907
- * @returns {boolean} true if the size is set successfully, otherwise false
933
+ * @returns {Promise<boolean>} A promise resolving to whether the image update succeeded.
908
934
  * @example
909
935
  * ```ts
910
936
  * // set the image width 120px and height 50px
@@ -912,7 +938,7 @@ let FOverGridImage = class FOverGridImage extends FBase {
912
938
  * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
913
939
  * if (!fWorksheet) return;
914
940
  * const image = fWorksheet.getImages()[0];
915
- * const result = image?.setSizeAsync(120, 50);
941
+ * const result = await image?.setSizeAsync(120, 50);
916
942
  * console.log(result);
917
943
  * ```
918
944
  */
@@ -928,10 +954,10 @@ let FOverGridImage = class FOverGridImage extends FBase {
928
954
  }
929
955
  /**
930
956
  * Set the cropping region of the image by defining the top, bottom, left, and right edges, thereby displaying the specific part of the image you want.
931
- * @param {number} top - The number of pixels to crop from the top of the image
932
- * @param {number} left - The number of pixels to crop from the left side of the image
933
- * @param {number} bottom - The number of pixels to crop from the bottom of the image
934
- * @param {number} right - The number of pixels to crop from the right side of the image
957
+ * @param {number} [top] - The number of pixels to crop from the top of the image
958
+ * @param {number} [left] - The number of pixels to crop from the left side of the image
959
+ * @param {number} [bottom] - The number of pixels to crop from the bottom of the image
960
+ * @param {number} [right] - The number of pixels to crop from the right side of the image
935
961
  * @returns {boolean} true if the crop is set successfully, otherwise false
936
962
  * @example
937
963
  * ```ts
@@ -1092,6 +1118,29 @@ var FWorksheetDrawingMixin = class extends FWorksheet {
1092
1118
  get _undoRedoService() {
1093
1119
  return this._injector.get(IUndoRedoService);
1094
1120
  }
1121
+ getBackgroundImage() {
1122
+ const backgroundImage = this._worksheet.getConfig().backgroundImage;
1123
+ return backgroundImage ? { ...backgroundImage } : null;
1124
+ }
1125
+ setBackgroundImage(source, imageSourceType = ImageSourceType.URL) {
1126
+ this._commandService.syncExecuteCommand(SetWorksheetBackgroundImageCommand.id, {
1127
+ unitId: this._fWorkbook.getId(),
1128
+ subUnitId: this.getSheetId(),
1129
+ backgroundImage: {
1130
+ source,
1131
+ imageSourceType
1132
+ }
1133
+ });
1134
+ return this;
1135
+ }
1136
+ deleteBackgroundImage() {
1137
+ this._commandService.syncExecuteCommand(SetWorksheetBackgroundImageCommand.id, {
1138
+ unitId: this._fWorkbook.getId(),
1139
+ subUnitId: this.getSheetId(),
1140
+ backgroundImage: null
1141
+ });
1142
+ return this;
1143
+ }
1095
1144
  async insertImage(url, column, row, offsetX, offsetY) {
1096
1145
  const imageBuilder = this.newOverGridImage();
1097
1146
  if (typeof url === "string") imageBuilder.setSource(url);
package/lib/index.js CHANGED
@@ -126,7 +126,6 @@ const SetDrawingApplyMutation = {
126
126
  case 5:
127
127
  drawingManagerService.ungroupUpdateNotification(objects);
128
128
  sheetDrawingService.ungroupUpdateNotification(objects);
129
- break;
130
129
  }
131
130
  return true;
132
131
  }
@@ -595,7 +594,7 @@ function normalizeNonRotatableAngleUpdate(drawing, sheetDrawingService) {
595
594
  drawingId: drawing.drawingId
596
595
  });
597
596
  if (!current) return drawing;
598
- if (resolveSheetDrawingRotateEnabled({
597
+ const resolveTarget = {
599
598
  ...current,
600
599
  ...drawing,
601
600
  drawingType: drawing.drawingType ?? current.drawingType,
@@ -603,7 +602,8 @@ function normalizeNonRotatableAngleUpdate(drawing, sheetDrawingService) {
603
602
  ...current.transform,
604
603
  ...drawing.transform
605
604
  }
606
- }, sheetDrawingService)) return drawing;
605
+ };
606
+ if (resolveSheetDrawingRotateEnabled(resolveTarget, sheetDrawingService)) return drawing;
607
607
  const normalized = { ...drawing };
608
608
  if (((_drawing$transform2 = drawing.transform) === null || _drawing$transform2 === void 0 ? void 0 : _drawing$transform2.angle) !== void 0) normalized.transform = preserveAngle(drawing.transform, current.transform);
609
609
  if (((_drawing$sheetTransfo2 = drawing.sheetTransform) === null || _drawing$sheetTransfo2 === void 0 ? void 0 : _drawing$sheetTransfo2.angle) !== void 0) normalized.sheetTransform = preserveAngle(drawing.sheetTransform, current.sheetTransform);
@@ -679,7 +679,63 @@ const SetSheetDrawingCommand = {
679
679
  };
680
680
 
681
681
  //#endregion
682
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
682
+ //#region src/commands/mutations/set-worksheet-background-image.mutation.ts
683
+ const SetWorksheetBackgroundImageMutation = {
684
+ id: "sheet.mutation.set-worksheet-background-image",
685
+ type: CommandType.MUTATION,
686
+ handler: (accessor, params) => {
687
+ const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
688
+ if (!target) return false;
689
+ const config = target.worksheet.getConfig();
690
+ if (params.backgroundImage) config.backgroundImage = { ...params.backgroundImage };
691
+ else delete config.backgroundImage;
692
+ return true;
693
+ }
694
+ };
695
+
696
+ //#endregion
697
+ //#region src/commands/commands/set-worksheet-background-image.command.ts
698
+ const SetWorksheetBackgroundImageCommand = {
699
+ id: "sheet.command.set-worksheet-background-image",
700
+ type: CommandType.COMMAND,
701
+ handler: (accessor, params) => {
702
+ if (!params) return false;
703
+ const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
704
+ if (!target) return false;
705
+ const { unitId, subUnitId, worksheet } = target;
706
+ const previous = worksheet.getConfig().backgroundImage;
707
+ const next = params.backgroundImage;
708
+ if ((previous === null || previous === void 0 ? void 0 : previous.source) === (next === null || next === void 0 ? void 0 : next.source) && (previous === null || previous === void 0 ? void 0 : previous.imageSourceType) === (next === null || next === void 0 ? void 0 : next.imageSourceType)) return false;
709
+ const commandService = accessor.get(ICommandService);
710
+ const undoRedoService = accessor.get(IUndoRedoService);
711
+ const redoParams = {
712
+ unitId,
713
+ subUnitId,
714
+ backgroundImage: next ? { ...next } : null
715
+ };
716
+ const undoParams = {
717
+ unitId,
718
+ subUnitId,
719
+ backgroundImage: previous ? { ...previous } : null
720
+ };
721
+ if (!commandService.syncExecuteCommand(SetWorksheetBackgroundImageMutation.id, redoParams)) return false;
722
+ undoRedoService.pushUndoRedo({
723
+ unitID: unitId,
724
+ undoMutations: [{
725
+ id: SetWorksheetBackgroundImageMutation.id,
726
+ params: undoParams
727
+ }],
728
+ redoMutations: [{
729
+ id: SetWorksheetBackgroundImageMutation.id,
730
+ params: redoParams
731
+ }]
732
+ });
733
+ return true;
734
+ }
735
+ };
736
+
737
+ //#endregion
738
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
683
739
  function __decorateParam(paramIndex, decorator) {
684
740
  return function(target, key) {
685
741
  decorator(target, key, paramIndex);
@@ -687,7 +743,7 @@ function __decorateParam(paramIndex, decorator) {
687
743
  }
688
744
 
689
745
  //#endregion
690
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
746
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
691
747
  function __decorate(decorators, target, key, desc) {
692
748
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
693
749
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -726,6 +782,7 @@ let SheetsDrawingLoadController = class SheetsDrawingLoadController extends Disp
726
782
  this._initSnapshot();
727
783
  this._initSheetChange();
728
784
  this.disposeWithMe(this._commandService.registerCommand(SetDrawingApplyMutation));
785
+ this.disposeWithMe(this._commandService.registerCommand(SetWorksheetBackgroundImageMutation));
729
786
  }
730
787
  _initCommands() {
731
788
  [
@@ -734,6 +791,7 @@ let SheetsDrawingLoadController = class SheetsDrawingLoadController extends Disp
734
791
  RemoveSheetDrawingCommand,
735
792
  SetDrawingArrangeCommand,
736
793
  SetSheetDrawingPlacementCommand,
794
+ SetWorksheetBackgroundImageCommand,
737
795
  ClearSheetDrawingTransformerOperation
738
796
  ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
739
797
  }
@@ -816,7 +874,8 @@ let SheetsDrawingLoadController = class SheetsDrawingLoadController extends Disp
816
874
  redos: [],
817
875
  undos: []
818
876
  };
819
- const drawings = getOrCreateDrawingCopyPlan(copyContext, getDrawingsInOrder(this._sheetDrawingService.getDrawingData(unitId, subUnitId), this._sheetDrawingService.getDrawingOrder(unitId, subUnitId)), {
877
+ const sourceDrawings = getDrawingsInOrder(this._sheetDrawingService.getDrawingData(unitId, subUnitId), this._sheetDrawingService.getDrawingOrder(unitId, subUnitId));
878
+ const drawings = getOrCreateDrawingCopyPlan(copyContext, sourceDrawings, {
820
879
  unitId,
821
880
  sourceSubUnitId: subUnitId,
822
881
  targetSubUnitId
@@ -868,7 +927,7 @@ SheetsDrawingLoadController = __decorate([
868
927
  //#endregion
869
928
  //#region package.json
870
929
  var name = "@univerjs/sheets-drawing";
871
- var version = "1.0.0-rc.0";
930
+ var version = "1.0.1";
872
931
 
873
932
  //#endregion
874
933
  //#region src/config/config.ts
@@ -892,7 +951,7 @@ const configSymbol = Symbol(SHEETS_DRAWING_PLUGIN_CONFIG_KEY);
892
951
  const defaultPluginConfig = {};
893
952
 
894
953
  //#endregion
895
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
954
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
896
955
  function _typeof(o) {
897
956
  "@babel/helpers - typeof";
898
957
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -903,7 +962,7 @@ function _typeof(o) {
903
962
  }
904
963
 
905
964
  //#endregion
906
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
965
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
907
966
  function toPrimitive(t, r) {
908
967
  if ("object" != _typeof(t) || !t) return t;
909
968
  var e = t[Symbol.toPrimitive];
@@ -916,14 +975,14 @@ function toPrimitive(t, r) {
916
975
  }
917
976
 
918
977
  //#endregion
919
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
978
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
920
979
  function toPropertyKey(t) {
921
980
  var i = toPrimitive(t, "string");
922
981
  return "symbol" == _typeof(i) ? i : i + "";
923
982
  }
924
983
 
925
984
  //#endregion
926
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
985
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
927
986
  function _defineProperty(e, r, t) {
928
987
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
929
988
  value: t,
@@ -1306,39 +1365,41 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1306
1365
  let newSheetTransform = null;
1307
1366
  let newTransform = null;
1308
1367
  let axisAlignSheetTransform;
1309
- if (type === 0 && fromRow >= startRow && toRow <= endRow) if (fromColumn >= startColumn && toColumn <= endColumn) deleteDrawings.push({
1310
- unitId,
1311
- subUnitId,
1312
- drawingId
1313
- });
1314
- else {
1315
- const param = this._shrinkCol(startColumn, endColumn, {
1316
- sheetSkeletonParam,
1317
- sheetTransform,
1318
- transform,
1319
- anchorType
1368
+ if (type === 0 && fromRow >= startRow && toRow <= endRow) {
1369
+ if (fromColumn >= startColumn && toColumn <= endColumn) deleteDrawings.push({
1370
+ unitId,
1371
+ subUnitId,
1372
+ drawingId
1320
1373
  });
1321
- newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1322
- newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1323
- axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1324
- }
1325
- else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn) if (fromRow >= startRow && toRow <= endRow) deleteDrawings.push({
1326
- unitId,
1327
- subUnitId,
1328
- drawingId
1329
- });
1330
- else {
1331
- const param = this._shrinkRow(startRow, endRow, {
1332
- sheetSkeletonParam,
1333
- sheetTransform,
1334
- transform,
1335
- anchorType
1374
+ else {
1375
+ const param = this._shrinkCol(startColumn, endColumn, {
1376
+ sheetSkeletonParam,
1377
+ sheetTransform,
1378
+ transform,
1379
+ anchorType
1380
+ });
1381
+ newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1382
+ newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1383
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1384
+ }
1385
+ } else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn) {
1386
+ if (fromRow >= startRow && toRow <= endRow) deleteDrawings.push({
1387
+ unitId,
1388
+ subUnitId,
1389
+ drawingId
1336
1390
  });
1337
- newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1338
- newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1339
- axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1340
- }
1341
- else if (type === 2) {
1391
+ else {
1392
+ const param = this._shrinkRow(startRow, endRow, {
1393
+ sheetSkeletonParam,
1394
+ sheetTransform,
1395
+ transform,
1396
+ anchorType
1397
+ });
1398
+ newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1399
+ newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1400
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1401
+ }
1402
+ } else if (type === 2) {
1342
1403
  const param = this._expandRow(startRow, endRow, {
1343
1404
  sheetSkeletonParam,
1344
1405
  sheetTransform,
@@ -1893,20 +1954,22 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1893
1954
  };
1894
1955
  newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
1895
1956
  axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
1896
- } else if (toColumn >= colEndIndex) if (anchorType === "1") {
1897
- newSheetTransform = {
1898
- from: { ...from },
1899
- to: {
1900
- ...to,
1901
- column: toColumn + colCount
1902
- }
1957
+ } else if (toColumn >= colEndIndex) {
1958
+ if (anchorType === "1") {
1959
+ newSheetTransform = {
1960
+ from: { ...from },
1961
+ to: {
1962
+ ...to,
1963
+ column: toColumn + colCount
1964
+ }
1965
+ };
1966
+ newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
1967
+ } else return {
1968
+ newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
1969
+ newTransform: transform,
1970
+ axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
1903
1971
  };
1904
- newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
1905
- } else return {
1906
- newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
1907
- newTransform: transform,
1908
- axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
1909
- };
1972
+ }
1910
1973
  if (newSheetTransform && newTransform) return {
1911
1974
  newSheetTransform,
1912
1975
  newTransform,
@@ -1942,21 +2005,22 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1942
2005
  };
1943
2006
  newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
1944
2007
  } else if (fromColumn >= colStartIndex && toColumn <= colEndIndex) return null;
1945
- else if (fromColumn < colStartIndex && toColumn > colEndIndex) if (anchorType === "1") {
1946
- newSheetTransform = {
1947
- from: { ...from },
1948
- to: {
1949
- ...to,
1950
- column: toColumn - colCount
1951
- }
2008
+ else if (fromColumn < colStartIndex && toColumn > colEndIndex) {
2009
+ if (anchorType === "1") {
2010
+ newSheetTransform = {
2011
+ from: { ...from },
2012
+ to: {
2013
+ ...to,
2014
+ column: toColumn - colCount
2015
+ }
2016
+ };
2017
+ newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
2018
+ } else return {
2019
+ newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
2020
+ newTransform: transform,
2021
+ axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
1952
2022
  };
1953
- newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
1954
- } else return {
1955
- newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
1956
- newTransform: transform,
1957
- axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
1958
- };
1959
- else if (fromColumn >= colStartIndex && fromColumn <= colEndIndex) {
2023
+ } else if (fromColumn >= colStartIndex && fromColumn <= colEndIndex) {
1960
2024
  if (anchorType === "1") {
1961
2025
  newSheetTransform = {
1962
2026
  from: {
@@ -2043,20 +2107,22 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
2043
2107
  };
2044
2108
  newSheetTransform = transformToDrawingPosition(newTransform, skeleton);
2045
2109
  axisAlignSheetTransform = transformToAxisAlignPosition(newTransform, skeleton);
2046
- } else if (toRow >= rowEndIndex) if (anchorType === "1") {
2047
- newSheetTransform = {
2048
- from: { ...from },
2049
- to: {
2050
- ...to,
2051
- row: toRow + rowCount
2052
- }
2110
+ } else if (toRow >= rowEndIndex) {
2111
+ if (anchorType === "1") {
2112
+ newSheetTransform = {
2113
+ from: { ...from },
2114
+ to: {
2115
+ ...to,
2116
+ row: toRow + rowCount
2117
+ }
2118
+ };
2119
+ newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
2120
+ } else return {
2121
+ newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
2122
+ newTransform: transform,
2123
+ axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
2053
2124
  };
2054
- newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
2055
- } else return {
2056
- newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
2057
- newTransform: transform,
2058
- axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
2059
- };
2125
+ }
2060
2126
  if (newSheetTransform && newTransform) return {
2061
2127
  newSheetTransform,
2062
2128
  newTransform,
@@ -2092,21 +2158,22 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
2092
2158
  };
2093
2159
  newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
2094
2160
  } else if (fromRow >= rowStartIndex && toRow <= rowEndIndex) return null;
2095
- else if (fromRow < rowStartIndex && toRow > rowEndIndex) if (anchorType === "1") {
2096
- newSheetTransform = {
2097
- from: { ...from },
2098
- to: {
2099
- ...to,
2100
- row: toRow - rowCount
2101
- }
2161
+ else if (fromRow < rowStartIndex && toRow > rowEndIndex) {
2162
+ if (anchorType === "1") {
2163
+ newSheetTransform = {
2164
+ from: { ...from },
2165
+ to: {
2166
+ ...to,
2167
+ row: toRow - rowCount
2168
+ }
2169
+ };
2170
+ newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
2171
+ } else return {
2172
+ newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
2173
+ newTransform: transform,
2174
+ axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
2102
2175
  };
2103
- newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
2104
- } else return {
2105
- newSheetTransform: transformToDrawingPosition({ ...transform }, skeleton),
2106
- newTransform: transform,
2107
- axisAlignSheetTransform: transformToAxisAlignPosition({ ...transform }, skeleton)
2108
- };
2109
- else if (fromRow >= rowStartIndex && fromRow <= rowEndIndex) {
2176
+ } else if (fromRow >= rowStartIndex && fromRow <= rowEndIndex) {
2110
2177
  if (anchorType === "1") {
2111
2178
  newSheetTransform = {
2112
2179
  from: {
@@ -2273,4 +2340,4 @@ UniverSheetsDrawingPlugin = __decorate([
2273
2340
  ], UniverSheetsDrawingPlugin);
2274
2341
 
2275
2342
  //#endregion
2276
- export { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SHEET_DRAWING_PLUGIN, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SheetDrawingAnchorType, SheetDrawingService, SheetDrawingTransformPlanService, UniverSheetsDrawingPlugin, applySheetDrawingPlacement, drawingPositionToTransform, getSheetDrawingPlacement, isKnownSheetNonRotatableDrawingType, normalizeSheetDrawingPlacement, resolveSheetDrawingRotateEnabled, transformToAxisAlignPosition, transformToDrawingPosition };
2343
+ export { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SHEET_DRAWING_PLUGIN, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, SheetDrawingService, SheetDrawingTransformPlanService, UniverSheetsDrawingPlugin, applySheetDrawingPlacement, drawingPositionToTransform, getSheetDrawingPlacement, isKnownSheetNonRotatableDrawingType, normalizeSheetDrawingPlacement, resolveSheetDrawingRotateEnabled, transformToAxisAlignPosition, transformToDrawingPosition };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ICommand, IWorksheetBackgroundImage, Nullable } from '@univerjs/core';
17
+ export interface ISetWorksheetBackgroundImageCommandParams {
18
+ unitId?: string;
19
+ subUnitId?: string;
20
+ backgroundImage: Nullable<IWorksheetBackgroundImage>;
21
+ }
22
+ export declare const SetWorksheetBackgroundImageCommand: ICommand<ISetWorksheetBackgroundImageCommandParams>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IMutation, IWorksheetBackgroundImage, Nullable } from '@univerjs/core';
17
+ export interface ISetWorksheetBackgroundImageMutationParams {
18
+ unitId: string;
19
+ subUnitId: string;
20
+ backgroundImage: Nullable<IWorksheetBackgroundImage>;
21
+ }
22
+ export declare const SetWorksheetBackgroundImageMutation: IMutation<ISetWorksheetBackgroundImageMutationParams>;