@univerjs/sheets-drawing 1.0.0-alpha.8 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -154,7 +154,6 @@ const InsertSheetDrawingCommand = {
154
154
  id: "sheet.command.insert-sheet-image",
155
155
  type: _univerjs_core.CommandType.COMMAND,
156
156
  handler: (accessor, params) => {
157
- var _intercepted$preRedos, _intercepted$preUndos;
158
157
  if (!params) return false;
159
158
  const commandService = accessor.get(_univerjs_core.ICommandService);
160
159
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
@@ -167,7 +166,7 @@ const InsertSheetDrawingCommand = {
167
166
  params
168
167
  });
169
168
  const redoMutations = [
170
- ...(_intercepted$preRedos = intercepted.preRedos) !== null && _intercepted$preRedos !== void 0 ? _intercepted$preRedos : [],
169
+ ...intercepted.preRedos ?? [],
171
170
  {
172
171
  id: SetDrawingApplyMutation.id,
173
172
  params: {
@@ -185,7 +184,7 @@ const InsertSheetDrawingCommand = {
185
184
  ...intercepted.redos
186
185
  ];
187
186
  const undoMutations = [
188
- ...(_intercepted$preUndos = intercepted.preUndos) !== null && _intercepted$preUndos !== void 0 ? _intercepted$preUndos : [],
187
+ ...intercepted.preUndos ?? [],
189
188
  {
190
189
  id: SetDrawingApplyMutation.id,
191
190
  params: {
@@ -220,7 +219,6 @@ const RemoveSheetDrawingCommand = {
220
219
  id: "sheet.command.remove-sheet-image",
221
220
  type: _univerjs_core.CommandType.COMMAND,
222
221
  handler: (accessor, params) => {
223
- var _intercepted$preRedos, _intercepted$preUndos;
224
222
  if (!params) return false;
225
223
  const commandService = accessor.get(_univerjs_core.ICommandService);
226
224
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
@@ -234,7 +232,7 @@ const RemoveSheetDrawingCommand = {
234
232
  params
235
233
  });
236
234
  const redoMutations = [
237
- ...(_intercepted$preRedos = intercepted.preRedos) !== null && _intercepted$preRedos !== void 0 ? _intercepted$preRedos : [],
235
+ ...intercepted.preRedos ?? [],
238
236
  {
239
237
  id: SetDrawingApplyMutation.id,
240
238
  params: {
@@ -252,7 +250,7 @@ const RemoveSheetDrawingCommand = {
252
250
  ...intercepted.redos
253
251
  ];
254
252
  const undoMutations = [
255
- ...(_intercepted$preUndos = intercepted.preUndos) !== null && _intercepted$preUndos !== void 0 ? _intercepted$preUndos : [],
253
+ ...intercepted.preUndos ?? [],
256
254
  {
257
255
  id: SetDrawingApplyMutation.id,
258
256
  params: {
@@ -291,17 +289,18 @@ const SetDrawingArrangeCommand = {
291
289
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
292
290
  if (!params) return false;
293
291
  const sheetDrawingService = accessor.get(ISheetDrawingService);
294
- const { unitId, subUnitId, drawingIds, arrangeType } = params;
292
+ const { unitId, subUnitId, drawingIds } = params;
295
293
  const drawingOrderMapParam = {
296
294
  unitId,
297
295
  subUnitId,
298
296
  drawingIds
299
297
  };
300
298
  let jsonOp;
301
- if (arrangeType === _univerjs_core.ArrangeTypeEnum.forward) jsonOp = sheetDrawingService.getForwardDrawingsOp(drawingOrderMapParam);
302
- else if (arrangeType === _univerjs_core.ArrangeTypeEnum.backward) jsonOp = sheetDrawingService.getBackwardDrawingOp(drawingOrderMapParam);
303
- else if (arrangeType === _univerjs_core.ArrangeTypeEnum.front) jsonOp = sheetDrawingService.getFrontDrawingsOp(drawingOrderMapParam);
304
- else if (arrangeType === _univerjs_core.ArrangeTypeEnum.back) jsonOp = sheetDrawingService.getBackDrawingsOp(drawingOrderMapParam);
299
+ if (params.zOrder !== void 0) jsonOp = sheetDrawingService.getDrawingOrderOp(drawingOrderMapParam, params.zOrder);
300
+ else if (params.arrangeType === _univerjs_core.ArrangeTypeEnum.forward) jsonOp = sheetDrawingService.getForwardDrawingsOp(drawingOrderMapParam);
301
+ else if (params.arrangeType === _univerjs_core.ArrangeTypeEnum.backward) jsonOp = sheetDrawingService.getBackwardDrawingOp(drawingOrderMapParam);
302
+ else if (params.arrangeType === _univerjs_core.ArrangeTypeEnum.front) jsonOp = sheetDrawingService.getFrontDrawingsOp(drawingOrderMapParam);
303
+ else if (params.arrangeType === _univerjs_core.ArrangeTypeEnum.back) jsonOp = sheetDrawingService.getBackDrawingsOp(drawingOrderMapParam);
305
304
  if (jsonOp == null) return false;
306
305
  const { objects, redo, undo } = jsonOp;
307
306
  if (commandService.syncExecuteCommand(SetDrawingApplyMutation.id, {
@@ -340,6 +339,226 @@ const SetDrawingArrangeCommand = {
340
339
  }
341
340
  };
342
341
 
342
+ //#endregion
343
+ //#region src/services/sheet-drawing-placement.ts
344
+ function getSheetDrawingPlacement(drawing) {
345
+ var _drawing$transform5, _drawing$transform6;
346
+ const anchorType = drawing.anchorType ?? "0";
347
+ if (anchorType === "2") {
348
+ var _drawing$transform, _drawing$transform2, _drawing$transform3, _drawing$transform4;
349
+ return {
350
+ kind: "2",
351
+ left: ((_drawing$transform = drawing.transform) === null || _drawing$transform === void 0 ? void 0 : _drawing$transform.left) ?? 0,
352
+ top: ((_drawing$transform2 = drawing.transform) === null || _drawing$transform2 === void 0 ? void 0 : _drawing$transform2.top) ?? 0,
353
+ width: ((_drawing$transform3 = drawing.transform) === null || _drawing$transform3 === void 0 ? void 0 : _drawing$transform3.width) ?? 0,
354
+ height: ((_drawing$transform4 = drawing.transform) === null || _drawing$transform4 === void 0 ? void 0 : _drawing$transform4.height) ?? 0
355
+ };
356
+ }
357
+ if (anchorType === "1") return {
358
+ kind: "1",
359
+ from: { ...drawing.sheetTransform.from },
360
+ to: { ...drawing.sheetTransform.to }
361
+ };
362
+ return {
363
+ kind: "0",
364
+ from: { ...drawing.sheetTransform.from },
365
+ width: ((_drawing$transform5 = drawing.transform) === null || _drawing$transform5 === void 0 ? void 0 : _drawing$transform5.width) ?? 0,
366
+ height: ((_drawing$transform6 = drawing.transform) === null || _drawing$transform6 === void 0 ? void 0 : _drawing$transform6.height) ?? 0
367
+ };
368
+ }
369
+ function applySheetDrawingPlacement(drawing, input, skeleton) {
370
+ const placement = normalizeSheetDrawingPlacement(input, skeleton);
371
+ if (placement.kind === "2") {
372
+ const transform = withExistingTransform(drawing.transform, placement);
373
+ const sheetTransform = absoluteSheetTransform(placement, drawing.sheetTransform);
374
+ return {
375
+ ...drawing,
376
+ anchorType: "2",
377
+ transform,
378
+ sheetTransform,
379
+ axisAlignSheetTransform: sheetTransform
380
+ };
381
+ }
382
+ if (!skeleton) throw new Error("SHEET_DRAWING_PLACEMENT_SKELETON_REQUIRED");
383
+ if (placement.kind === "0") {
384
+ const converted = (0, _univerjs_sheets.convertPositionCellToSheetOverGrid)(drawing.unitId, drawing.subUnitId, placement.from, placement.width, placement.height, skeleton);
385
+ const sheetTransform = withExistingSheetTransform(drawing.sheetTransform, converted.sheetTransform);
386
+ const transform = withExistingTransform(drawing.transform, converted.transform);
387
+ return {
388
+ ...drawing,
389
+ anchorType: "0",
390
+ sheetTransform,
391
+ transform,
392
+ axisAlignSheetTransform: transformToAxisAlignPosition(transform, skeleton)
393
+ };
394
+ }
395
+ const sheetTransform = withExistingSheetTransform(drawing.sheetTransform, {
396
+ from: placement.from,
397
+ to: placement.to
398
+ });
399
+ const bounds = (0, _univerjs_sheets.convertPositionSheetOverGridToAbsolute)(drawing.unitId, drawing.subUnitId, sheetTransform, skeleton);
400
+ const transform = withExistingTransform(drawing.transform, bounds);
401
+ return {
402
+ ...drawing,
403
+ anchorType: "1",
404
+ sheetTransform,
405
+ transform,
406
+ axisAlignSheetTransform: transformToAxisAlignPosition(transform, skeleton)
407
+ };
408
+ }
409
+ /**
410
+ * Normalize exact markers or model-space bounds to the authoritative
411
+ * Position, Both, or None Placement.
412
+ */
413
+ function normalizeSheetDrawingPlacement(input, skeleton) {
414
+ if (!("bounds" in input)) {
415
+ validatePlacement(input);
416
+ if (input.kind === "1" && skeleton) validateBounds((0, _univerjs_sheets.convertPositionSheetOverGridToAbsolute)(skeleton.worksheet.getUnitId(), skeleton.worksheet.getSheetId(), {
417
+ from: input.from,
418
+ to: input.to
419
+ }, skeleton));
420
+ return input;
421
+ }
422
+ validateBounds(input.bounds);
423
+ if (input.kind === "2") return {
424
+ kind: "2",
425
+ ...input.bounds
426
+ };
427
+ if (!skeleton) throw new Error("SHEET_DRAWING_PLACEMENT_SKELETON_REQUIRED");
428
+ const sheetTransform = transformToDrawingPosition(input.bounds, skeleton);
429
+ if (input.kind === "0") return {
430
+ kind: "0",
431
+ from: sheetTransform.from,
432
+ width: input.bounds.width,
433
+ height: input.bounds.height
434
+ };
435
+ if (input.kind === "1") return {
436
+ kind: "1",
437
+ from: sheetTransform.from,
438
+ to: sheetTransform.to
439
+ };
440
+ throw new Error("SHEET_DRAWING_PLACEMENT_KIND_INVALID");
441
+ }
442
+ function withExistingSheetTransform(current, placement) {
443
+ return {
444
+ ...current,
445
+ from: { ...placement.from },
446
+ to: { ...placement.to }
447
+ };
448
+ }
449
+ function withExistingTransform(current, bounds) {
450
+ return {
451
+ ...current,
452
+ left: bounds.left,
453
+ top: bounds.top,
454
+ width: bounds.width,
455
+ height: bounds.height
456
+ };
457
+ }
458
+ function absoluteSheetTransform(placement, current) {
459
+ return {
460
+ ...current,
461
+ from: {
462
+ column: 0,
463
+ columnOffset: placement.left,
464
+ row: 0,
465
+ rowOffset: placement.top
466
+ },
467
+ to: {
468
+ column: 0,
469
+ columnOffset: placement.left + placement.width,
470
+ row: 0,
471
+ rowOffset: placement.top + placement.height
472
+ }
473
+ };
474
+ }
475
+ function validatePlacement(placement) {
476
+ if (placement.kind === "0") {
477
+ validateCellPosition(placement.from);
478
+ validateExtent(placement.width, placement.height);
479
+ return;
480
+ }
481
+ if (placement.kind === "1") {
482
+ validateCellPosition(placement.from);
483
+ validateCellPosition(placement.to);
484
+ return;
485
+ }
486
+ if (placement.kind === "2") {
487
+ if (!Number.isFinite(placement.left) || !Number.isFinite(placement.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
488
+ validateExtent(placement.width, placement.height);
489
+ return;
490
+ }
491
+ throw new Error("SHEET_DRAWING_PLACEMENT_KIND_INVALID");
492
+ }
493
+ function validateBounds(bounds) {
494
+ if (!Number.isFinite(bounds.left) || !Number.isFinite(bounds.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
495
+ validateExtent(bounds.width, bounds.height);
496
+ }
497
+ function validateCellPosition(position) {
498
+ if (!Number.isInteger(position.row) || !Number.isInteger(position.column) || position.row < 0 || position.column < 0 || !Number.isFinite(position.rowOffset) || !Number.isFinite(position.columnOffset)) throw new Error("SHEET_DRAWING_PLACEMENT_CELL_INVALID");
499
+ }
500
+ function validateExtent(width, height) {
501
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) throw new Error("SHEET_DRAWING_PLACEMENT_EXTENT_INVALID");
502
+ }
503
+
504
+ //#endregion
505
+ //#region src/commands/commands/set-sheet-drawing-placement.command.ts
506
+ const SetSheetDrawingPlacementCommand = {
507
+ id: "sheet.command.set-drawing-placement",
508
+ type: _univerjs_core.CommandType.COMMAND,
509
+ handler: (accessor, params) => {
510
+ if (!(params === null || params === void 0 ? void 0 : params.drawings.length)) return false;
511
+ const commandService = accessor.get(_univerjs_core.ICommandService);
512
+ const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
513
+ const drawingService = accessor.get(ISheetDrawingService);
514
+ const skeleton = params.drawings.every(({ placement }) => placement.kind === "2") ? void 0 : accessor.get(_univerjs_sheets.SheetSkeletonService).ensureSkeleton(params.unitId, params.subUnitId);
515
+ const updatedDrawings = [];
516
+ for (const { drawingId, placement } of params.drawings) {
517
+ const drawing = drawingService.getDrawingByParam({
518
+ unitId: params.unitId,
519
+ subUnitId: params.subUnitId,
520
+ drawingId
521
+ });
522
+ if (!drawing) return false;
523
+ updatedDrawings.push(applySheetDrawingPlacement(drawing, placement, skeleton));
524
+ }
525
+ const { unitId, subUnitId, undo, redo, objects } = drawingService.getBatchUpdateOp(updatedDrawings);
526
+ const redoMutations = [{
527
+ id: SetDrawingApplyMutation.id,
528
+ params: {
529
+ unitId,
530
+ subUnitId,
531
+ op: redo,
532
+ objects,
533
+ type: 2
534
+ }
535
+ }, {
536
+ id: ClearSheetDrawingTransformerOperation.id,
537
+ params: [unitId]
538
+ }];
539
+ const undoMutations = [{
540
+ id: SetDrawingApplyMutation.id,
541
+ params: {
542
+ unitId,
543
+ subUnitId,
544
+ op: undo,
545
+ objects,
546
+ type: 2
547
+ }
548
+ }, {
549
+ id: ClearSheetDrawingTransformerOperation.id,
550
+ params: [unitId]
551
+ }];
552
+ if (!(0, _univerjs_core.sequenceExecute)(redoMutations, commandService).result) return false;
553
+ undoRedoService.pushUndoRedo({
554
+ unitID: unitId,
555
+ undoMutations,
556
+ redoMutations
557
+ });
558
+ return true;
559
+ }
560
+ };
561
+
343
562
  //#endregion
344
563
  //#region src/common/rotate-enabled.ts
345
564
  function isKnownSheetNonRotatableDrawingType(drawingType) {
@@ -347,10 +566,7 @@ function isKnownSheetNonRotatableDrawingType(drawingType) {
347
566
  }
348
567
  function resolveSheetDrawingRotateEnabled(drawing, drawingService, getChildren) {
349
568
  return (0, _univerjs_drawing.resolveDrawingRotateEnabled)(drawing, {
350
- getChildren: (current) => {
351
- var _getChildren;
352
- return (_getChildren = getChildren === null || getChildren === void 0 ? void 0 : getChildren(current)) !== null && _getChildren !== void 0 ? _getChildren : drawingService.getDrawingsByGroup(current);
353
- },
569
+ getChildren: (current) => (getChildren === null || getChildren === void 0 ? void 0 : getChildren(current)) ?? drawingService.getDrawingsByGroup(current),
354
570
  isKnownNonRotatableType: isKnownSheetNonRotatableDrawingType
355
571
  });
356
572
  }
@@ -364,7 +580,7 @@ function hasIncomingAngle(drawing) {
364
580
  function preserveAngle(incoming, current) {
365
581
  const currentAngle = current === null || current === void 0 ? void 0 : current.angle;
366
582
  const next = {
367
- ...current !== null && current !== void 0 ? current : {},
583
+ ...current ?? {},
368
584
  ...incoming
369
585
  };
370
586
  if (currentAngle === void 0) delete next.angle;
@@ -372,7 +588,7 @@ function preserveAngle(incoming, current) {
372
588
  return next;
373
589
  }
374
590
  function normalizeNonRotatableAngleUpdate(drawing, sheetDrawingService) {
375
- var _drawing$drawingType, _drawing$transform2, _drawing$sheetTransfo2, _drawing$axisAlignShe2;
591
+ var _drawing$transform2, _drawing$sheetTransfo2, _drawing$axisAlignShe2;
376
592
  if (!drawing.drawingId || !drawing.unitId || !drawing.subUnitId || !hasIncomingAngle(drawing)) return drawing;
377
593
  const current = sheetDrawingService.getDrawingByParam({
378
594
  unitId: drawing.unitId,
@@ -383,7 +599,7 @@ function normalizeNonRotatableAngleUpdate(drawing, sheetDrawingService) {
383
599
  if (resolveSheetDrawingRotateEnabled({
384
600
  ...current,
385
601
  ...drawing,
386
- drawingType: (_drawing$drawingType = drawing.drawingType) !== null && _drawing$drawingType !== void 0 ? _drawing$drawingType : current.drawingType,
602
+ drawingType: drawing.drawingType ?? current.drawingType,
387
603
  transform: {
388
604
  ...current.transform,
389
605
  ...drawing.transform
@@ -399,7 +615,6 @@ const SetSheetDrawingCommand = {
399
615
  id: "sheet.command.set-sheet-image",
400
616
  type: _univerjs_core.CommandType.COMMAND,
401
617
  handler: (accessor, params) => {
402
- var _intercepted$preRedos, _intercepted$preUndos;
403
618
  if (!params) return false;
404
619
  const commandService = accessor.get(_univerjs_core.ICommandService);
405
620
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
@@ -417,7 +632,7 @@ const SetSheetDrawingCommand = {
417
632
  params: normalizedParams
418
633
  });
419
634
  const redoMutations = [
420
- ...(_intercepted$preRedos = intercepted.preRedos) !== null && _intercepted$preRedos !== void 0 ? _intercepted$preRedos : [],
635
+ ...intercepted.preRedos ?? [],
421
636
  {
422
637
  id: SetDrawingApplyMutation.id,
423
638
  params: {
@@ -435,7 +650,7 @@ const SetSheetDrawingCommand = {
435
650
  ...intercepted.redos
436
651
  ];
437
652
  const undoMutations = [
438
- ...(_intercepted$preUndos = intercepted.preUndos) !== null && _intercepted$preUndos !== void 0 ? _intercepted$preUndos : [],
653
+ ...intercepted.preUndos ?? [],
439
654
  {
440
655
  id: SetDrawingApplyMutation.id,
441
656
  params: {
@@ -519,6 +734,7 @@ let SheetsDrawingLoadController = class SheetsDrawingLoadController extends _uni
519
734
  InsertSheetDrawingCommand,
520
735
  RemoveSheetDrawingCommand,
521
736
  SetDrawingArrangeCommand,
737
+ SetSheetDrawingPlacementCommand,
522
738
  ClearSheetDrawingTransformerOperation
523
739
  ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
524
740
  }
@@ -653,7 +869,7 @@ SheetsDrawingLoadController = __decorate([
653
869
  //#endregion
654
870
  //#region package.json
655
871
  var name = "@univerjs/sheets-drawing";
656
- var version = "1.0.0-alpha.8";
872
+ var version = "1.0.0-beta.1";
657
873
 
658
874
  //#endregion
659
875
  //#region src/config/config.ts
@@ -734,10 +950,7 @@ var SheetDrawingTransformPlanService = class {
734
950
  }
735
951
  register(extension) {
736
952
  this._extensions.push(extension);
737
- this._extensions.sort((a, b) => {
738
- var _b$priority, _a$priority;
739
- return ((_b$priority = b.priority) !== null && _b$priority !== void 0 ? _b$priority : 0) - ((_a$priority = a.priority) !== null && _a$priority !== void 0 ? _a$priority : 0);
740
- });
953
+ this._extensions.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
741
954
  return (0, _univerjs_core.toDisposable)(() => {
742
955
  const index = this._extensions.indexOf(extension);
743
956
  if (index >= 0) this._extensions.splice(index, 1);
@@ -745,13 +958,12 @@ var SheetDrawingTransformPlanService = class {
745
958
  }
746
959
  transform(plan) {
747
960
  return this._extensions.reduce((all, extension) => {
748
- var _next$preRedos, _next$redos, _next$preUndos, _next$undos;
749
961
  const next = extension.transform(plan);
750
962
  if (!next) return all;
751
- all.preRedos.push(...(_next$preRedos = next.preRedos) !== null && _next$preRedos !== void 0 ? _next$preRedos : []);
752
- all.redos.push(...(_next$redos = next.redos) !== null && _next$redos !== void 0 ? _next$redos : []);
753
- all.preUndos.push(...(_next$preUndos = next.preUndos) !== null && _next$preUndos !== void 0 ? _next$preUndos : []);
754
- all.undos.push(...(_next$undos = next.undos) !== null && _next$undos !== void 0 ? _next$undos : []);
963
+ all.preRedos.push(...next.preRedos ?? []);
964
+ all.redos.push(...next.redos ?? []);
965
+ all.preUndos.push(...next.preUndos ?? []);
966
+ all.undos.push(...next.undos ?? []);
755
967
  return all;
756
968
  }, createEmptyResult());
757
969
  }
@@ -948,7 +1160,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
948
1160
  deletes: new Set(deletes.map(({ drawingId }) => drawingId).filter((drawingId) => Boolean(drawingId)))
949
1161
  };
950
1162
  updates.forEach((patch) => {
951
- var _patch$sheetTransform, _patch$axisAlignSheet;
952
1163
  if (!patch.drawingId) return;
953
1164
  const original = originals.get(patch.drawingId);
954
1165
  if (!original) return;
@@ -959,8 +1170,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
959
1170
  ...original.transform,
960
1171
  ...patch.transform
961
1172
  },
962
- sheetTransform: (_patch$sheetTransform = patch.sheetTransform) !== null && _patch$sheetTransform !== void 0 ? _patch$sheetTransform : original.sheetTransform,
963
- axisAlignSheetTransform: (_patch$axisAlignSheet = patch.axisAlignSheetTransform) !== null && _patch$axisAlignSheet !== void 0 ? _patch$axisAlignSheet : original.axisAlignSheetTransform
1173
+ sheetTransform: patch.sheetTransform ?? original.sheetTransform,
1174
+ axisAlignSheetTransform: patch.axisAlignSheetTransform ?? original.axisAlignSheetTransform
964
1175
  });
965
1176
  });
966
1177
  const feature = this._transformPlanService.transform(plan);
@@ -1102,7 +1313,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1102
1313
  drawingId
1103
1314
  });
1104
1315
  else {
1105
- var _param$axisAlignSheet;
1106
1316
  const param = this._shrinkCol(startColumn, endColumn, {
1107
1317
  sheetSkeletonParam,
1108
1318
  sheetTransform,
@@ -1111,7 +1321,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1111
1321
  });
1112
1322
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1113
1323
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1114
- axisAlignSheetTransform = (_param$axisAlignSheet = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet !== void 0 ? _param$axisAlignSheet : void 0;
1324
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1115
1325
  }
1116
1326
  else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn) if (fromRow >= startRow && toRow <= endRow) deleteDrawings.push({
1117
1327
  unitId,
@@ -1119,7 +1329,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1119
1329
  drawingId
1120
1330
  });
1121
1331
  else {
1122
- var _param$axisAlignSheet2;
1123
1332
  const param = this._shrinkRow(startRow, endRow, {
1124
1333
  sheetSkeletonParam,
1125
1334
  sheetTransform,
@@ -1128,10 +1337,9 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1128
1337
  });
1129
1338
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1130
1339
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1131
- axisAlignSheetTransform = (_param$axisAlignSheet2 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet2 !== void 0 ? _param$axisAlignSheet2 : void 0;
1340
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1132
1341
  }
1133
1342
  else if (type === 2) {
1134
- var _param$axisAlignSheet3;
1135
1343
  const param = this._expandRow(startRow, endRow, {
1136
1344
  sheetSkeletonParam,
1137
1345
  sheetTransform,
@@ -1140,9 +1348,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1140
1348
  });
1141
1349
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1142
1350
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1143
- axisAlignSheetTransform = (_param$axisAlignSheet3 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet3 !== void 0 ? _param$axisAlignSheet3 : void 0;
1351
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1144
1352
  } else if (type === 3) {
1145
- var _param$axisAlignSheet4;
1146
1353
  const param = this._expandCol(startColumn, endColumn, {
1147
1354
  sheetSkeletonParam,
1148
1355
  sheetTransform,
@@ -1151,7 +1358,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1151
1358
  });
1152
1359
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1153
1360
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1154
- axisAlignSheetTransform = (_param$axisAlignSheet4 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet4 !== void 0 ? _param$axisAlignSheet4 : void 0;
1361
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1155
1362
  }
1156
1363
  if (newSheetTransform && newTransform) {
1157
1364
  const newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
@@ -1548,7 +1755,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1548
1755
  let newTransform;
1549
1756
  let axisAlignSheetTransform;
1550
1757
  if (type === "insert") {
1551
- var _param$axisAlignSheet5;
1552
1758
  const param = this._expandRow(rowStartIndex, rowEndIndex, {
1553
1759
  sheetSkeletonParam,
1554
1760
  sheetTransform,
@@ -1557,7 +1763,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1557
1763
  });
1558
1764
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1559
1765
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1560
- axisAlignSheetTransform = (_param$axisAlignSheet5 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet5 !== void 0 ? _param$axisAlignSheet5 : void 0;
1766
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1561
1767
  } else {
1562
1768
  const { from, to } = sheetTransform;
1563
1769
  const { row: fromRow } = from;
@@ -1568,7 +1774,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1568
1774
  drawingId
1569
1775
  });
1570
1776
  else {
1571
- var _param$axisAlignSheet6;
1572
1777
  const param = this._shrinkRow(rowStartIndex, rowEndIndex, {
1573
1778
  sheetSkeletonParam,
1574
1779
  sheetTransform,
@@ -1577,7 +1782,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1577
1782
  });
1578
1783
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1579
1784
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1580
- axisAlignSheetTransform = (_param$axisAlignSheet6 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet6 !== void 0 ? _param$axisAlignSheet6 : void 0;
1785
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1581
1786
  }
1582
1787
  }
1583
1788
  if (!newSheetTransform || !newTransform) return;
@@ -1618,7 +1823,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1618
1823
  let newTransform;
1619
1824
  let axisAlignSheetTransform;
1620
1825
  if (type === "insert") {
1621
- var _param$axisAlignSheet7;
1622
1826
  const param = this._expandCol(colStartIndex, colEndIndex, {
1623
1827
  sheetSkeletonParam,
1624
1828
  sheetTransform,
@@ -1627,7 +1831,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1627
1831
  });
1628
1832
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1629
1833
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1630
- axisAlignSheetTransform = (_param$axisAlignSheet7 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet7 !== void 0 ? _param$axisAlignSheet7 : void 0;
1834
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1631
1835
  } else {
1632
1836
  const { from, to } = sheetTransform;
1633
1837
  const { column: fromColumn } = from;
@@ -1638,7 +1842,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1638
1842
  drawingId
1639
1843
  });
1640
1844
  else {
1641
- var _param$axisAlignSheet8;
1642
1845
  const param = this._shrinkCol(colStartIndex, colEndIndex, {
1643
1846
  sheetSkeletonParam,
1644
1847
  sheetTransform,
@@ -1647,7 +1850,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1647
1850
  });
1648
1851
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1649
1852
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1650
- axisAlignSheetTransform = (_param$axisAlignSheet8 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet8 !== void 0 ? _param$axisAlignSheet8 : void 0;
1853
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1651
1854
  }
1652
1855
  }
1653
1856
  if (!newSheetTransform || !newTransform) return;
@@ -1984,9 +2187,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1984
2187
  }));
1985
2188
  }
1986
2189
  _refreshDrawingTransform(command, unitId, subUnitId, ranges) {
1987
- var _this$_drawingManager;
1988
2190
  const sheetSkeletonParam = this._getCalculatedSkeletonParam(unitId, subUnitId);
1989
- const drawingData = (_this$_drawingManager = this._drawingManagerService.getDrawingData(unitId, subUnitId)) !== null && _this$_drawingManager !== void 0 ? _this$_drawingManager : {};
2191
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId) ?? {};
1990
2192
  const updateDrawings = [];
1991
2193
  Object.keys(drawingData).forEach((drawingId) => {
1992
2194
  const drawing = drawingData[drawingId];
@@ -2081,6 +2283,7 @@ exports.SHEET_DRAWING_PLUGIN = SHEET_DRAWING_PLUGIN;
2081
2283
  exports.SetDrawingApplyMutation = SetDrawingApplyMutation;
2082
2284
  exports.SetDrawingArrangeCommand = SetDrawingArrangeCommand;
2083
2285
  exports.SetSheetDrawingCommand = SetSheetDrawingCommand;
2286
+ exports.SetSheetDrawingPlacementCommand = SetSheetDrawingPlacementCommand;
2084
2287
  exports.SheetDrawingAnchorType = SheetDrawingAnchorType;
2085
2288
  exports.SheetDrawingService = SheetDrawingService;
2086
2289
  exports.SheetDrawingTransformPlanService = SheetDrawingTransformPlanService;
@@ -2090,8 +2293,11 @@ Object.defineProperty(exports, 'UniverSheetsDrawingPlugin', {
2090
2293
  return UniverSheetsDrawingPlugin;
2091
2294
  }
2092
2295
  });
2296
+ exports.applySheetDrawingPlacement = applySheetDrawingPlacement;
2093
2297
  exports.drawingPositionToTransform = drawingPositionToTransform;
2298
+ exports.getSheetDrawingPlacement = getSheetDrawingPlacement;
2094
2299
  exports.isKnownSheetNonRotatableDrawingType = isKnownSheetNonRotatableDrawingType;
2300
+ exports.normalizeSheetDrawingPlacement = normalizeSheetDrawingPlacement;
2095
2301
  exports.resolveSheetDrawingRotateEnabled = resolveSheetDrawingRotateEnabled;
2096
2302
  exports.transformToAxisAlignPosition = transformToAxisAlignPosition;
2097
2303
  exports.transformToDrawingPosition = transformToDrawingPosition;