@tldraw/editor 4.3.0-canary.8940b1312107 → 4.3.0-canary.8cd1f74e02ef
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.d.ts +15 -0
- package/dist-cjs/index.js +2 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +24 -1
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/globals/environment.js +45 -9
- package/dist-cjs/lib/globals/environment.js.map +2 -2
- package/dist-cjs/lib/hooks/useCoarsePointer.js +14 -29
- package/dist-cjs/lib/hooks/useCoarsePointer.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +15 -0
- package/dist-esm/index.mjs +3 -2
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +24 -1
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/globals/environment.mjs +45 -9
- package/dist-esm/lib/globals/environment.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCoarsePointer.mjs +15 -30
- package/dist-esm/lib/hooks/useCoarsePointer.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +1 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -0
- package/src/lib/editor/Editor.ts +29 -1
- package/src/lib/editor/types/emit-types.ts +3 -1
- package/src/lib/globals/environment.ts +65 -10
- package/src/lib/hooks/useCoarsePointer.ts +16 -59
- package/src/version.ts +3 -3
|
@@ -895,6 +895,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
895
895
|
this.disposables.clear();
|
|
896
896
|
this.store.dispose();
|
|
897
897
|
this.isDisposed = true;
|
|
898
|
+
this.emit("dispose");
|
|
898
899
|
}
|
|
899
900
|
getShapeUtil(arg) {
|
|
900
901
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
@@ -2804,14 +2805,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
2804
2805
|
}
|
|
2805
2806
|
if (_willSetInitialBounds) {
|
|
2806
2807
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2808
|
+
this.emit("resize", screenBounds.toJson());
|
|
2807
2809
|
this.setCamera(this.getCamera());
|
|
2808
2810
|
} else {
|
|
2809
2811
|
if (center && !this.getInstanceState().followingUserId) {
|
|
2810
2812
|
const before = this.getViewportPageBounds().center;
|
|
2811
2813
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2814
|
+
this.emit("resize", screenBounds.toJson());
|
|
2812
2815
|
this.centerOnPoint(before);
|
|
2813
2816
|
} else {
|
|
2814
2817
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2818
|
+
this.emit("resize", screenBounds.toJson());
|
|
2815
2819
|
this._setCamera(Vec.From({ ...this.getCamera() }));
|
|
2816
2820
|
}
|
|
2817
2821
|
}
|
|
@@ -6686,6 +6690,25 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6686
6690
|
}
|
|
6687
6691
|
}
|
|
6688
6692
|
}
|
|
6693
|
+
if (point) {
|
|
6694
|
+
const shapesById = new Map(shapes.map((shape) => [shape.id, shape]));
|
|
6695
|
+
const rootShapesFromContent = compact(rootShapeIds.map((id) => shapesById.get(id)));
|
|
6696
|
+
if (rootShapesFromContent.length > 0) {
|
|
6697
|
+
const targetParent = this.getShapeAtPoint(point, {
|
|
6698
|
+
hitInside: true,
|
|
6699
|
+
hitFrameInside: true,
|
|
6700
|
+
hitLocked: true,
|
|
6701
|
+
filter: (shape) => {
|
|
6702
|
+
const util = this.getShapeUtil(shape);
|
|
6703
|
+
if (!util.canReceiveNewChildrenOfType) return false;
|
|
6704
|
+
return rootShapesFromContent.every(
|
|
6705
|
+
(rootShape) => util.canReceiveNewChildrenOfType(shape, rootShape.type)
|
|
6706
|
+
);
|
|
6707
|
+
}
|
|
6708
|
+
});
|
|
6709
|
+
pasteParentId = targetParent ? targetParent.id : currentPageId;
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6689
6712
|
let isDuplicating = false;
|
|
6690
6713
|
if (!isPageId(pasteParentId)) {
|
|
6691
6714
|
const parent = this.getShape(pasteParentId);
|
|
@@ -7504,8 +7527,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
7504
7527
|
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7505
7528
|
}
|
|
7506
7529
|
}
|
|
7507
|
-
this.emit("event", info);
|
|
7508
7530
|
this.root.handleEvent(info);
|
|
7531
|
+
this.emit("event", info);
|
|
7509
7532
|
return;
|
|
7510
7533
|
}
|
|
7511
7534
|
if (info.shiftKey) {
|