@tldraw/editor 5.5.0 → 5.6.0-canary.669b4c97f643

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/dist-cjs/index.js CHANGED
@@ -392,7 +392,7 @@ var import_uniq = require("./lib/utils/uniq");
392
392
  var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
393
393
  (0, import_utils.registerTldrawLibraryVersion)(
394
394
  "@tldraw/editor",
395
- "5.5.0",
395
+ "5.6.0-canary.669b4c97f643",
396
396
  "cjs"
397
397
  );
398
398
  //# sourceMappingURL=index.js.map
@@ -3657,7 +3657,9 @@ class Editor extends import_eventemitter3.default {
3657
3657
  const id = typeof page === "string" ? page : page.id;
3658
3658
  const freshPage = this.getPage(id);
3659
3659
  if (!freshPage) return this;
3660
- const prevCamera = { ...this.getCamera() };
3660
+ const prevCamera = {
3661
+ ...this.store.get(import_tlschema.CameraRecordType.createId(freshPage.id)) ?? this.getCamera()
3662
+ };
3661
3663
  const content = this.getContentFromCurrentPage(this.getSortedChildIdsForParent(freshPage.id));
3662
3664
  this.run(() => {
3663
3665
  const pages = this.getPages();
@@ -3666,7 +3668,7 @@ class Editor extends import_eventemitter3.default {
3666
3668
  this.setCurrentPage(createId);
3667
3669
  this.setCamera(prevCamera);
3668
3670
  if (content) {
3669
- return this.putContentOntoCurrentPage(content);
3671
+ return this.putContentOntoCurrentPage(content, { preservePosition: true });
3670
3672
  }
3671
3673
  });
3672
3674
  return this;
@@ -6030,11 +6032,20 @@ class Editor extends import_eventemitter3.default {
6030
6032
  initialShape: options.initialShape,
6031
6033
  initialBounds: options.initialBounds,
6032
6034
  isAspectRatioLocked: options.isAspectRatioLocked,
6033
- initialPageTransform: options.initialPageTransform
6035
+ initialPageTransform: options.initialPageTransform,
6036
+ dragHandle: options.dragHandle,
6037
+ mode: options.mode,
6038
+ // this is one frame of the same resize, not a new one, so don't fire start/end again
6039
+ skipStartAndEndCallbacks: options.skipStartAndEndCallbacks
6034
6040
  });
6035
6041
  if (Math.sign(scale.x) * Math.sign(scale.y) < 0) {
6036
6042
  const parentRotation = this.getShapeParentTransform(id).rotation();
6037
- const rotation = -options.initialShape.rotation - 2 * parentRotation;
6043
+ const parentDelta = (0, import_utils2.shortAngleDist)(
6044
+ import_Mat.Mat.Cast(options.initialPageTransform).rotation() - options.initialShape.rotation,
6045
+ parentRotation
6046
+ );
6047
+ const initialParentRotation = parentRotation - parentDelta;
6048
+ const rotation = 2 * options.scaleAxisRotation - options.initialShape.rotation - 2 * initialParentRotation - parentDelta;
6038
6049
  this.updateShapes([{ id, type, rotation }]);
6039
6050
  }
6040
6051
  const preScaleShapePageCenter = import_Mat.Mat.applyToPoint(