@univerjs/sheets-drawing 1.0.0-alpha.7 → 1.0.0-beta.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/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, InsertColCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, MoveColsCommand, MoveRangeCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, RemoveSheetCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetColWidthMutation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService, attachRangeWithCoord, convertPositionSheetOverGridToAbsolute, getSheetCommandTarget } from "@univerjs/sheets";
1
+ import { CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, InsertColCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, MoveColsCommand, MoveRangeCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, RemoveSheetCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetColWidthMutation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, attachRangeWithCoord, convertPositionCellToSheetOverGrid, convertPositionSheetOverGridToAbsolute, getSheetCommandTarget } from "@univerjs/sheets";
2
2
  import { ArrangeTypeEnum, CommandType, DependentOn, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, Plugin, RANGE_TYPE, Rectangle, UniverInstanceType, createIdentifier, merge, sequenceExecute, toDisposable } from "@univerjs/core";
3
3
  import { IDrawingManagerService, UnitDrawingService, UniverDrawingPlugin, getOrCreateDrawingCopyPlan, resolveDrawingRotateEnabled } from "@univerjs/drawing";
4
4
  import { IRenderManagerService } from "@univerjs/engine-render";
@@ -141,7 +141,7 @@ const ClearSheetDrawingTransformerOperation = {
141
141
  const renderManagerService = accessor.get(IRenderManagerService);
142
142
  params.forEach((unitId) => {
143
143
  var _renderManagerService;
144
- (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 || (_renderManagerService = _renderManagerService.scene.getTransformer()) === null || _renderManagerService === void 0 || _renderManagerService.debounceRefreshControls();
144
+ (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 || (_renderManagerService = _renderManagerService.scene.getTransformer()) === null || _renderManagerService === void 0 || _renderManagerService.debounceRefreshControls();
145
145
  });
146
146
  return true;
147
147
  }
@@ -153,7 +153,6 @@ const InsertSheetDrawingCommand = {
153
153
  id: "sheet.command.insert-sheet-image",
154
154
  type: CommandType.COMMAND,
155
155
  handler: (accessor, params) => {
156
- var _intercepted$preRedos, _intercepted$preUndos;
157
156
  if (!params) return false;
158
157
  const commandService = accessor.get(ICommandService);
159
158
  const undoRedoService = accessor.get(IUndoRedoService);
@@ -166,7 +165,7 @@ const InsertSheetDrawingCommand = {
166
165
  params
167
166
  });
168
167
  const redoMutations = [
169
- ...(_intercepted$preRedos = intercepted.preRedos) !== null && _intercepted$preRedos !== void 0 ? _intercepted$preRedos : [],
168
+ ...intercepted.preRedos ?? [],
170
169
  {
171
170
  id: SetDrawingApplyMutation.id,
172
171
  params: {
@@ -184,7 +183,7 @@ const InsertSheetDrawingCommand = {
184
183
  ...intercepted.redos
185
184
  ];
186
185
  const undoMutations = [
187
- ...(_intercepted$preUndos = intercepted.preUndos) !== null && _intercepted$preUndos !== void 0 ? _intercepted$preUndos : [],
186
+ ...intercepted.preUndos ?? [],
188
187
  {
189
188
  id: SetDrawingApplyMutation.id,
190
189
  params: {
@@ -219,7 +218,6 @@ const RemoveSheetDrawingCommand = {
219
218
  id: "sheet.command.remove-sheet-image",
220
219
  type: CommandType.COMMAND,
221
220
  handler: (accessor, params) => {
222
- var _intercepted$preRedos, _intercepted$preUndos;
223
221
  if (!params) return false;
224
222
  const commandService = accessor.get(ICommandService);
225
223
  const undoRedoService = accessor.get(IUndoRedoService);
@@ -233,7 +231,7 @@ const RemoveSheetDrawingCommand = {
233
231
  params
234
232
  });
235
233
  const redoMutations = [
236
- ...(_intercepted$preRedos = intercepted.preRedos) !== null && _intercepted$preRedos !== void 0 ? _intercepted$preRedos : [],
234
+ ...intercepted.preRedos ?? [],
237
235
  {
238
236
  id: SetDrawingApplyMutation.id,
239
237
  params: {
@@ -251,7 +249,7 @@ const RemoveSheetDrawingCommand = {
251
249
  ...intercepted.redos
252
250
  ];
253
251
  const undoMutations = [
254
- ...(_intercepted$preUndos = intercepted.preUndos) !== null && _intercepted$preUndos !== void 0 ? _intercepted$preUndos : [],
252
+ ...intercepted.preUndos ?? [],
255
253
  {
256
254
  id: SetDrawingApplyMutation.id,
257
255
  params: {
@@ -339,6 +337,226 @@ const SetDrawingArrangeCommand = {
339
337
  }
340
338
  };
341
339
 
340
+ //#endregion
341
+ //#region src/services/sheet-drawing-placement.ts
342
+ function getSheetDrawingPlacement(drawing) {
343
+ var _drawing$transform5, _drawing$transform6;
344
+ const anchorType = drawing.anchorType ?? "0";
345
+ if (anchorType === "2") {
346
+ var _drawing$transform, _drawing$transform2, _drawing$transform3, _drawing$transform4;
347
+ return {
348
+ kind: "2",
349
+ left: ((_drawing$transform = drawing.transform) === null || _drawing$transform === void 0 ? void 0 : _drawing$transform.left) ?? 0,
350
+ top: ((_drawing$transform2 = drawing.transform) === null || _drawing$transform2 === void 0 ? void 0 : _drawing$transform2.top) ?? 0,
351
+ width: ((_drawing$transform3 = drawing.transform) === null || _drawing$transform3 === void 0 ? void 0 : _drawing$transform3.width) ?? 0,
352
+ height: ((_drawing$transform4 = drawing.transform) === null || _drawing$transform4 === void 0 ? void 0 : _drawing$transform4.height) ?? 0
353
+ };
354
+ }
355
+ if (anchorType === "1") return {
356
+ kind: "1",
357
+ from: { ...drawing.sheetTransform.from },
358
+ to: { ...drawing.sheetTransform.to }
359
+ };
360
+ return {
361
+ kind: "0",
362
+ from: { ...drawing.sheetTransform.from },
363
+ width: ((_drawing$transform5 = drawing.transform) === null || _drawing$transform5 === void 0 ? void 0 : _drawing$transform5.width) ?? 0,
364
+ height: ((_drawing$transform6 = drawing.transform) === null || _drawing$transform6 === void 0 ? void 0 : _drawing$transform6.height) ?? 0
365
+ };
366
+ }
367
+ function applySheetDrawingPlacement(drawing, input, skeleton) {
368
+ const placement = normalizeSheetDrawingPlacement(input, skeleton);
369
+ if (placement.kind === "2") {
370
+ const transform = withExistingTransform(drawing.transform, placement);
371
+ const sheetTransform = absoluteSheetTransform(placement, drawing.sheetTransform);
372
+ return {
373
+ ...drawing,
374
+ anchorType: "2",
375
+ transform,
376
+ sheetTransform,
377
+ axisAlignSheetTransform: sheetTransform
378
+ };
379
+ }
380
+ if (!skeleton) throw new Error("SHEET_DRAWING_PLACEMENT_SKELETON_REQUIRED");
381
+ if (placement.kind === "0") {
382
+ const converted = convertPositionCellToSheetOverGrid(drawing.unitId, drawing.subUnitId, placement.from, placement.width, placement.height, skeleton);
383
+ const sheetTransform = withExistingSheetTransform(drawing.sheetTransform, converted.sheetTransform);
384
+ const transform = withExistingTransform(drawing.transform, converted.transform);
385
+ return {
386
+ ...drawing,
387
+ anchorType: "0",
388
+ sheetTransform,
389
+ transform,
390
+ axisAlignSheetTransform: transformToAxisAlignPosition(transform, skeleton)
391
+ };
392
+ }
393
+ const sheetTransform = withExistingSheetTransform(drawing.sheetTransform, {
394
+ from: placement.from,
395
+ to: placement.to
396
+ });
397
+ const bounds = convertPositionSheetOverGridToAbsolute(drawing.unitId, drawing.subUnitId, sheetTransform, skeleton);
398
+ const transform = withExistingTransform(drawing.transform, bounds);
399
+ return {
400
+ ...drawing,
401
+ anchorType: "1",
402
+ sheetTransform,
403
+ transform,
404
+ axisAlignSheetTransform: transformToAxisAlignPosition(transform, skeleton)
405
+ };
406
+ }
407
+ /**
408
+ * Normalize exact markers or model-space bounds to the authoritative
409
+ * Position, Both, or None Placement.
410
+ */
411
+ function normalizeSheetDrawingPlacement(input, skeleton) {
412
+ if (!("bounds" in input)) {
413
+ validatePlacement(input);
414
+ if (input.kind === "1" && skeleton) validateBounds(convertPositionSheetOverGridToAbsolute(skeleton.worksheet.getUnitId(), skeleton.worksheet.getSheetId(), {
415
+ from: input.from,
416
+ to: input.to
417
+ }, skeleton));
418
+ return input;
419
+ }
420
+ validateBounds(input.bounds);
421
+ if (input.kind === "2") return {
422
+ kind: "2",
423
+ ...input.bounds
424
+ };
425
+ if (!skeleton) throw new Error("SHEET_DRAWING_PLACEMENT_SKELETON_REQUIRED");
426
+ const sheetTransform = transformToDrawingPosition(input.bounds, skeleton);
427
+ if (input.kind === "0") return {
428
+ kind: "0",
429
+ from: sheetTransform.from,
430
+ width: input.bounds.width,
431
+ height: input.bounds.height
432
+ };
433
+ if (input.kind === "1") return {
434
+ kind: "1",
435
+ from: sheetTransform.from,
436
+ to: sheetTransform.to
437
+ };
438
+ throw new Error("SHEET_DRAWING_PLACEMENT_KIND_INVALID");
439
+ }
440
+ function withExistingSheetTransform(current, placement) {
441
+ return {
442
+ ...current,
443
+ from: { ...placement.from },
444
+ to: { ...placement.to }
445
+ };
446
+ }
447
+ function withExistingTransform(current, bounds) {
448
+ return {
449
+ ...current,
450
+ left: bounds.left,
451
+ top: bounds.top,
452
+ width: bounds.width,
453
+ height: bounds.height
454
+ };
455
+ }
456
+ function absoluteSheetTransform(placement, current) {
457
+ return {
458
+ ...current,
459
+ from: {
460
+ column: 0,
461
+ columnOffset: placement.left,
462
+ row: 0,
463
+ rowOffset: placement.top
464
+ },
465
+ to: {
466
+ column: 0,
467
+ columnOffset: placement.left + placement.width,
468
+ row: 0,
469
+ rowOffset: placement.top + placement.height
470
+ }
471
+ };
472
+ }
473
+ function validatePlacement(placement) {
474
+ if (placement.kind === "0") {
475
+ validateCellPosition(placement.from);
476
+ validateExtent(placement.width, placement.height);
477
+ return;
478
+ }
479
+ if (placement.kind === "1") {
480
+ validateCellPosition(placement.from);
481
+ validateCellPosition(placement.to);
482
+ return;
483
+ }
484
+ if (placement.kind === "2") {
485
+ if (!Number.isFinite(placement.left) || !Number.isFinite(placement.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
486
+ validateExtent(placement.width, placement.height);
487
+ return;
488
+ }
489
+ throw new Error("SHEET_DRAWING_PLACEMENT_KIND_INVALID");
490
+ }
491
+ function validateBounds(bounds) {
492
+ if (!Number.isFinite(bounds.left) || !Number.isFinite(bounds.top)) throw new TypeError("SHEET_DRAWING_PLACEMENT_POSITION_INVALID");
493
+ validateExtent(bounds.width, bounds.height);
494
+ }
495
+ function validateCellPosition(position) {
496
+ 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");
497
+ }
498
+ function validateExtent(width, height) {
499
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) throw new Error("SHEET_DRAWING_PLACEMENT_EXTENT_INVALID");
500
+ }
501
+
502
+ //#endregion
503
+ //#region src/commands/commands/set-sheet-drawing-placement.command.ts
504
+ const SetSheetDrawingPlacementCommand = {
505
+ id: "sheet.command.set-drawing-placement",
506
+ type: CommandType.COMMAND,
507
+ handler: (accessor, params) => {
508
+ if (!(params === null || params === void 0 ? void 0 : params.drawings.length)) return false;
509
+ const commandService = accessor.get(ICommandService);
510
+ const undoRedoService = accessor.get(IUndoRedoService);
511
+ const drawingService = accessor.get(ISheetDrawingService);
512
+ const skeleton = params.drawings.every(({ placement }) => placement.kind === "2") ? void 0 : accessor.get(SheetSkeletonService).ensureSkeleton(params.unitId, params.subUnitId);
513
+ const updatedDrawings = [];
514
+ for (const { drawingId, placement } of params.drawings) {
515
+ const drawing = drawingService.getDrawingByParam({
516
+ unitId: params.unitId,
517
+ subUnitId: params.subUnitId,
518
+ drawingId
519
+ });
520
+ if (!drawing) return false;
521
+ updatedDrawings.push(applySheetDrawingPlacement(drawing, placement, skeleton));
522
+ }
523
+ const { unitId, subUnitId, undo, redo, objects } = drawingService.getBatchUpdateOp(updatedDrawings);
524
+ const redoMutations = [{
525
+ id: SetDrawingApplyMutation.id,
526
+ params: {
527
+ unitId,
528
+ subUnitId,
529
+ op: redo,
530
+ objects,
531
+ type: 2
532
+ }
533
+ }, {
534
+ id: ClearSheetDrawingTransformerOperation.id,
535
+ params: [unitId]
536
+ }];
537
+ const undoMutations = [{
538
+ id: SetDrawingApplyMutation.id,
539
+ params: {
540
+ unitId,
541
+ subUnitId,
542
+ op: undo,
543
+ objects,
544
+ type: 2
545
+ }
546
+ }, {
547
+ id: ClearSheetDrawingTransformerOperation.id,
548
+ params: [unitId]
549
+ }];
550
+ if (!sequenceExecute(redoMutations, commandService).result) return false;
551
+ undoRedoService.pushUndoRedo({
552
+ unitID: unitId,
553
+ undoMutations,
554
+ redoMutations
555
+ });
556
+ return true;
557
+ }
558
+ };
559
+
342
560
  //#endregion
343
561
  //#region src/common/rotate-enabled.ts
344
562
  function isKnownSheetNonRotatableDrawingType(drawingType) {
@@ -346,10 +564,7 @@ function isKnownSheetNonRotatableDrawingType(drawingType) {
346
564
  }
347
565
  function resolveSheetDrawingRotateEnabled(drawing, drawingService, getChildren) {
348
566
  return resolveDrawingRotateEnabled(drawing, {
349
- getChildren: (current) => {
350
- var _getChildren;
351
- return (_getChildren = getChildren === null || getChildren === void 0 ? void 0 : getChildren(current)) !== null && _getChildren !== void 0 ? _getChildren : drawingService.getDrawingsByGroup(current);
352
- },
567
+ getChildren: (current) => (getChildren === null || getChildren === void 0 ? void 0 : getChildren(current)) ?? drawingService.getDrawingsByGroup(current),
353
568
  isKnownNonRotatableType: isKnownSheetNonRotatableDrawingType
354
569
  });
355
570
  }
@@ -363,7 +578,7 @@ function hasIncomingAngle(drawing) {
363
578
  function preserveAngle(incoming, current) {
364
579
  const currentAngle = current === null || current === void 0 ? void 0 : current.angle;
365
580
  const next = {
366
- ...current !== null && current !== void 0 ? current : {},
581
+ ...current ?? {},
367
582
  ...incoming
368
583
  };
369
584
  if (currentAngle === void 0) delete next.angle;
@@ -371,7 +586,7 @@ function preserveAngle(incoming, current) {
371
586
  return next;
372
587
  }
373
588
  function normalizeNonRotatableAngleUpdate(drawing, sheetDrawingService) {
374
- var _drawing$drawingType, _drawing$transform2, _drawing$sheetTransfo2, _drawing$axisAlignShe2;
589
+ var _drawing$transform2, _drawing$sheetTransfo2, _drawing$axisAlignShe2;
375
590
  if (!drawing.drawingId || !drawing.unitId || !drawing.subUnitId || !hasIncomingAngle(drawing)) return drawing;
376
591
  const current = sheetDrawingService.getDrawingByParam({
377
592
  unitId: drawing.unitId,
@@ -382,7 +597,7 @@ function normalizeNonRotatableAngleUpdate(drawing, sheetDrawingService) {
382
597
  if (resolveSheetDrawingRotateEnabled({
383
598
  ...current,
384
599
  ...drawing,
385
- drawingType: (_drawing$drawingType = drawing.drawingType) !== null && _drawing$drawingType !== void 0 ? _drawing$drawingType : current.drawingType,
600
+ drawingType: drawing.drawingType ?? current.drawingType,
386
601
  transform: {
387
602
  ...current.transform,
388
603
  ...drawing.transform
@@ -398,7 +613,6 @@ const SetSheetDrawingCommand = {
398
613
  id: "sheet.command.set-sheet-image",
399
614
  type: CommandType.COMMAND,
400
615
  handler: (accessor, params) => {
401
- var _intercepted$preRedos, _intercepted$preUndos;
402
616
  if (!params) return false;
403
617
  const commandService = accessor.get(ICommandService);
404
618
  const undoRedoService = accessor.get(IUndoRedoService);
@@ -416,7 +630,7 @@ const SetSheetDrawingCommand = {
416
630
  params: normalizedParams
417
631
  });
418
632
  const redoMutations = [
419
- ...(_intercepted$preRedos = intercepted.preRedos) !== null && _intercepted$preRedos !== void 0 ? _intercepted$preRedos : [],
633
+ ...intercepted.preRedos ?? [],
420
634
  {
421
635
  id: SetDrawingApplyMutation.id,
422
636
  params: {
@@ -434,7 +648,7 @@ const SetSheetDrawingCommand = {
434
648
  ...intercepted.redos
435
649
  ];
436
650
  const undoMutations = [
437
- ...(_intercepted$preUndos = intercepted.preUndos) !== null && _intercepted$preUndos !== void 0 ? _intercepted$preUndos : [],
651
+ ...intercepted.preUndos ?? [],
438
652
  {
439
653
  id: SetDrawingApplyMutation.id,
440
654
  params: {
@@ -464,7 +678,7 @@ const SetSheetDrawingCommand = {
464
678
  };
465
679
 
466
680
  //#endregion
467
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
681
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
468
682
  function __decorateParam(paramIndex, decorator) {
469
683
  return function(target, key) {
470
684
  decorator(target, key, paramIndex);
@@ -472,7 +686,7 @@ function __decorateParam(paramIndex, decorator) {
472
686
  }
473
687
 
474
688
  //#endregion
475
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
689
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
476
690
  function __decorate(decorators, target, key, desc) {
477
691
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
478
692
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -518,6 +732,7 @@ let SheetsDrawingLoadController = class SheetsDrawingLoadController extends Disp
518
732
  InsertSheetDrawingCommand,
519
733
  RemoveSheetDrawingCommand,
520
734
  SetDrawingArrangeCommand,
735
+ SetSheetDrawingPlacementCommand,
521
736
  ClearSheetDrawingTransformerOperation
522
737
  ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
523
738
  }
@@ -652,7 +867,7 @@ SheetsDrawingLoadController = __decorate([
652
867
  //#endregion
653
868
  //#region package.json
654
869
  var name = "@univerjs/sheets-drawing";
655
- var version = "1.0.0-alpha.7";
870
+ var version = "1.0.0-beta.0";
656
871
 
657
872
  //#endregion
658
873
  //#region src/config/config.ts
@@ -676,7 +891,7 @@ const configSymbol = Symbol(SHEETS_DRAWING_PLUGIN_CONFIG_KEY);
676
891
  const defaultPluginConfig = {};
677
892
 
678
893
  //#endregion
679
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
894
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
680
895
  function _typeof(o) {
681
896
  "@babel/helpers - typeof";
682
897
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -687,7 +902,7 @@ function _typeof(o) {
687
902
  }
688
903
 
689
904
  //#endregion
690
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
905
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
691
906
  function toPrimitive(t, r) {
692
907
  if ("object" != _typeof(t) || !t) return t;
693
908
  var e = t[Symbol.toPrimitive];
@@ -700,14 +915,14 @@ function toPrimitive(t, r) {
700
915
  }
701
916
 
702
917
  //#endregion
703
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
918
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
704
919
  function toPropertyKey(t) {
705
920
  var i = toPrimitive(t, "string");
706
921
  return "symbol" == _typeof(i) ? i : i + "";
707
922
  }
708
923
 
709
924
  //#endregion
710
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
925
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
711
926
  function _defineProperty(e, r, t) {
712
927
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
713
928
  value: t,
@@ -733,10 +948,7 @@ var SheetDrawingTransformPlanService = class {
733
948
  }
734
949
  register(extension) {
735
950
  this._extensions.push(extension);
736
- this._extensions.sort((a, b) => {
737
- var _b$priority, _a$priority;
738
- 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);
739
- });
951
+ this._extensions.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
740
952
  return toDisposable(() => {
741
953
  const index = this._extensions.indexOf(extension);
742
954
  if (index >= 0) this._extensions.splice(index, 1);
@@ -744,13 +956,12 @@ var SheetDrawingTransformPlanService = class {
744
956
  }
745
957
  transform(plan) {
746
958
  return this._extensions.reduce((all, extension) => {
747
- var _next$preRedos, _next$redos, _next$preUndos, _next$undos;
748
959
  const next = extension.transform(plan);
749
960
  if (!next) return all;
750
- all.preRedos.push(...(_next$preRedos = next.preRedos) !== null && _next$preRedos !== void 0 ? _next$preRedos : []);
751
- all.redos.push(...(_next$redos = next.redos) !== null && _next$redos !== void 0 ? _next$redos : []);
752
- all.preUndos.push(...(_next$preUndos = next.preUndos) !== null && _next$preUndos !== void 0 ? _next$preUndos : []);
753
- all.undos.push(...(_next$undos = next.undos) !== null && _next$undos !== void 0 ? _next$undos : []);
961
+ all.preRedos.push(...next.preRedos ?? []);
962
+ all.redos.push(...next.redos ?? []);
963
+ all.preUndos.push(...next.preUndos ?? []);
964
+ all.undos.push(...next.undos ?? []);
754
965
  return all;
755
966
  }, createEmptyResult());
756
967
  }
@@ -947,7 +1158,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
947
1158
  deletes: new Set(deletes.map(({ drawingId }) => drawingId).filter((drawingId) => Boolean(drawingId)))
948
1159
  };
949
1160
  updates.forEach((patch) => {
950
- var _patch$sheetTransform, _patch$axisAlignSheet;
951
1161
  if (!patch.drawingId) return;
952
1162
  const original = originals.get(patch.drawingId);
953
1163
  if (!original) return;
@@ -958,8 +1168,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
958
1168
  ...original.transform,
959
1169
  ...patch.transform
960
1170
  },
961
- sheetTransform: (_patch$sheetTransform = patch.sheetTransform) !== null && _patch$sheetTransform !== void 0 ? _patch$sheetTransform : original.sheetTransform,
962
- axisAlignSheetTransform: (_patch$axisAlignSheet = patch.axisAlignSheetTransform) !== null && _patch$axisAlignSheet !== void 0 ? _patch$axisAlignSheet : original.axisAlignSheetTransform
1171
+ sheetTransform: patch.sheetTransform ?? original.sheetTransform,
1172
+ axisAlignSheetTransform: patch.axisAlignSheetTransform ?? original.axisAlignSheetTransform
963
1173
  });
964
1174
  });
965
1175
  const feature = this._transformPlanService.transform(plan);
@@ -1101,7 +1311,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1101
1311
  drawingId
1102
1312
  });
1103
1313
  else {
1104
- var _param$axisAlignSheet;
1105
1314
  const param = this._shrinkCol(startColumn, endColumn, {
1106
1315
  sheetSkeletonParam,
1107
1316
  sheetTransform,
@@ -1110,7 +1319,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1110
1319
  });
1111
1320
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1112
1321
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1113
- axisAlignSheetTransform = (_param$axisAlignSheet = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet !== void 0 ? _param$axisAlignSheet : void 0;
1322
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1114
1323
  }
1115
1324
  else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn) if (fromRow >= startRow && toRow <= endRow) deleteDrawings.push({
1116
1325
  unitId,
@@ -1118,7 +1327,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1118
1327
  drawingId
1119
1328
  });
1120
1329
  else {
1121
- var _param$axisAlignSheet2;
1122
1330
  const param = this._shrinkRow(startRow, endRow, {
1123
1331
  sheetSkeletonParam,
1124
1332
  sheetTransform,
@@ -1127,10 +1335,9 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1127
1335
  });
1128
1336
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1129
1337
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1130
- axisAlignSheetTransform = (_param$axisAlignSheet2 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet2 !== void 0 ? _param$axisAlignSheet2 : void 0;
1338
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1131
1339
  }
1132
1340
  else if (type === 2) {
1133
- var _param$axisAlignSheet3;
1134
1341
  const param = this._expandRow(startRow, endRow, {
1135
1342
  sheetSkeletonParam,
1136
1343
  sheetTransform,
@@ -1139,9 +1346,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1139
1346
  });
1140
1347
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1141
1348
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1142
- axisAlignSheetTransform = (_param$axisAlignSheet3 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet3 !== void 0 ? _param$axisAlignSheet3 : void 0;
1349
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1143
1350
  } else if (type === 3) {
1144
- var _param$axisAlignSheet4;
1145
1351
  const param = this._expandCol(startColumn, endColumn, {
1146
1352
  sheetSkeletonParam,
1147
1353
  sheetTransform,
@@ -1150,7 +1356,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1150
1356
  });
1151
1357
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1152
1358
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1153
- axisAlignSheetTransform = (_param$axisAlignSheet4 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet4 !== void 0 ? _param$axisAlignSheet4 : void 0;
1359
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1154
1360
  }
1155
1361
  if (newSheetTransform && newTransform) {
1156
1362
  const newTransform = drawingPositionToTransform(newSheetTransform, sheetSkeletonParam);
@@ -1547,7 +1753,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1547
1753
  let newTransform;
1548
1754
  let axisAlignSheetTransform;
1549
1755
  if (type === "insert") {
1550
- var _param$axisAlignSheet5;
1551
1756
  const param = this._expandRow(rowStartIndex, rowEndIndex, {
1552
1757
  sheetSkeletonParam,
1553
1758
  sheetTransform,
@@ -1556,7 +1761,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1556
1761
  });
1557
1762
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1558
1763
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1559
- axisAlignSheetTransform = (_param$axisAlignSheet5 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet5 !== void 0 ? _param$axisAlignSheet5 : void 0;
1764
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1560
1765
  } else {
1561
1766
  const { from, to } = sheetTransform;
1562
1767
  const { row: fromRow } = from;
@@ -1567,7 +1772,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1567
1772
  drawingId
1568
1773
  });
1569
1774
  else {
1570
- var _param$axisAlignSheet6;
1571
1775
  const param = this._shrinkRow(rowStartIndex, rowEndIndex, {
1572
1776
  sheetSkeletonParam,
1573
1777
  sheetTransform,
@@ -1576,7 +1780,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1576
1780
  });
1577
1781
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1578
1782
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1579
- axisAlignSheetTransform = (_param$axisAlignSheet6 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet6 !== void 0 ? _param$axisAlignSheet6 : void 0;
1783
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1580
1784
  }
1581
1785
  }
1582
1786
  if (!newSheetTransform || !newTransform) return;
@@ -1617,7 +1821,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1617
1821
  let newTransform;
1618
1822
  let axisAlignSheetTransform;
1619
1823
  if (type === "insert") {
1620
- var _param$axisAlignSheet7;
1621
1824
  const param = this._expandCol(colStartIndex, colEndIndex, {
1622
1825
  sheetSkeletonParam,
1623
1826
  sheetTransform,
@@ -1626,7 +1829,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1626
1829
  });
1627
1830
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1628
1831
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1629
- axisAlignSheetTransform = (_param$axisAlignSheet7 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet7 !== void 0 ? _param$axisAlignSheet7 : void 0;
1832
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1630
1833
  } else {
1631
1834
  const { from, to } = sheetTransform;
1632
1835
  const { column: fromColumn } = from;
@@ -1637,7 +1840,6 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1637
1840
  drawingId
1638
1841
  });
1639
1842
  else {
1640
- var _param$axisAlignSheet8;
1641
1843
  const param = this._shrinkCol(colStartIndex, colEndIndex, {
1642
1844
  sheetSkeletonParam,
1643
1845
  sheetTransform,
@@ -1646,7 +1848,7 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1646
1848
  });
1647
1849
  newSheetTransform = param === null || param === void 0 ? void 0 : param.newSheetTransform;
1648
1850
  newTransform = param === null || param === void 0 ? void 0 : param.newTransform;
1649
- axisAlignSheetTransform = (_param$axisAlignSheet8 = param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) !== null && _param$axisAlignSheet8 !== void 0 ? _param$axisAlignSheet8 : void 0;
1851
+ axisAlignSheetTransform = (param === null || param === void 0 ? void 0 : param.axisAlignSheetTransform) ?? void 0;
1650
1852
  }
1651
1853
  }
1652
1854
  if (!newSheetTransform || !newTransform) return;
@@ -1983,9 +2185,8 @@ let SheetDrawingTransformAffectedController = class SheetDrawingTransformAffecte
1983
2185
  }));
1984
2186
  }
1985
2187
  _refreshDrawingTransform(command, unitId, subUnitId, ranges) {
1986
- var _this$_drawingManager;
1987
2188
  const sheetSkeletonParam = this._getCalculatedSkeletonParam(unitId, subUnitId);
1988
- const drawingData = (_this$_drawingManager = this._drawingManagerService.getDrawingData(unitId, subUnitId)) !== null && _this$_drawingManager !== void 0 ? _this$_drawingManager : {};
2189
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId) ?? {};
1989
2190
  const updateDrawings = [];
1990
2191
  Object.keys(drawingData).forEach((drawingId) => {
1991
2192
  const drawing = drawingData[drawingId];
@@ -2065,10 +2266,10 @@ _defineProperty(UniverSheetsDrawingPlugin, "packageName", name);
2065
2266
  _defineProperty(UniverSheetsDrawingPlugin, "version", version);
2066
2267
  _defineProperty(UniverSheetsDrawingPlugin, "type", UniverInstanceType.UNIVER_SHEET);
2067
2268
  UniverSheetsDrawingPlugin = __decorate([
2068
- DependentOn(UniverDrawingPlugin),
2269
+ DependentOn(UniverDrawingPlugin, UniverSheetsPlugin),
2069
2270
  __decorateParam(1, Inject(Injector)),
2070
2271
  __decorateParam(2, IConfigService)
2071
2272
  ], UniverSheetsDrawingPlugin);
2072
2273
 
2073
2274
  //#endregion
2074
- export { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SHEET_DRAWING_PLUGIN, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SheetDrawingAnchorType, SheetDrawingService, SheetDrawingTransformPlanService, UniverSheetsDrawingPlugin, drawingPositionToTransform, isKnownSheetNonRotatableDrawingType, resolveSheetDrawingRotateEnabled, transformToAxisAlignPosition, transformToDrawingPosition };
2275
+ 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 };