@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 +1 -1
- package/dist-cjs/lib/editor/Editor.js +15 -4
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/shared/resizeBox.js +21 -16
- package/dist-cjs/lib/editor/shapes/shared/resizeBox.js.map +2 -2
- package/dist-cjs/lib/hooks/useCursor.js +12 -8
- package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +12 -5
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +17 -5
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/shared/resizeBox.mjs +21 -16
- package/dist-esm/lib/editor/shapes/shared/resizeBox.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCursor.mjs +12 -8
- package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +13 -6
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +17 -19
- package/src/lib/editor/Editor.ts +38 -9
- package/src/lib/editor/shapes/shared/resizeBox.ts +21 -16
- package/src/lib/hooks/useCursor.ts +14 -7
- package/src/lib/test/useCursor.test.tsx +36 -0
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +73 -0
- package/src/lib/utils/sync/TLLocalSyncClient.ts +24 -8
- package/src/version.ts +3 -3
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.
|
|
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 = {
|
|
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
|
|
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(
|