@tldraw/editor 3.14.0-canary.db789786fb06 → 3.14.0-canary.dd6c729c17b0
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 +13 -98
- package/dist-cjs/index.js +1 -4
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +23 -56
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +1 -3
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +2 -3
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +10 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +6 -10
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +3 -3
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +2 -6
- package/dist-cjs/lib/primitives/geometry/Geometry2d.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 +13 -98
- package/dist-esm/index.mjs +1 -4
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +23 -56
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +1 -3
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +2 -3
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +10 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +6 -10
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +3 -3
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +2 -6
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +11 -10
- package/package.json +7 -7
- package/src/index.ts +0 -5
- package/src/lib/editor/Editor.ts +33 -73
- package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +1 -3
- package/src/lib/editor/managers/TextManager/TextManager.ts +2 -4
- package/src/lib/editor/shapes/ShapeUtil.ts +15 -47
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +17 -22
- package/src/lib/editor/types/emit-types.ts +0 -4
- package/src/lib/primitives/geometry/Geometry2d.ts +2 -7
- package/src/version.ts +3 -3
- package/dist-cjs/lib/utils/reparenting.js +0 -232
- package/dist-cjs/lib/utils/reparenting.js.map +0 -7
- package/dist-esm/lib/utils/reparenting.mjs +0 -216
- package/dist-esm/lib/utils/reparenting.mjs.map +0 -7
- package/src/lib/utils/reparenting.ts +0 -383
|
@@ -4165,7 +4165,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4165
4165
|
if (!id) return void 0;
|
|
4166
4166
|
const freshShape = this.getShape(id);
|
|
4167
4167
|
if (freshShape === void 0 || !isShapeId(freshShape.parentId)) return void 0;
|
|
4168
|
-
return this.
|
|
4168
|
+
return this.store.get(freshShape.parentId);
|
|
4169
4169
|
}
|
|
4170
4170
|
/**
|
|
4171
4171
|
* If siblingShape and targetShape are siblings, this returns targetShape. If targetShape has an
|
|
@@ -4297,9 +4297,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4297
4297
|
if (!pagePoint) continue;
|
|
4298
4298
|
const newPoint = invertedParentTransform.applyToPoint(pagePoint);
|
|
4299
4299
|
const newRotation = pageTransform.rotation() - parentPageRotation;
|
|
4300
|
-
if (shape.id === parentId) {
|
|
4301
|
-
throw Error("Attempted to reparent a shape to itself!");
|
|
4302
|
-
}
|
|
4303
4300
|
changes.push({
|
|
4304
4301
|
id: shape.id,
|
|
4305
4302
|
type: shape.type,
|
|
@@ -4392,10 +4389,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4392
4389
|
}
|
|
4393
4390
|
return shapeIds;
|
|
4394
4391
|
}
|
|
4395
|
-
/** @deprecated Use {@link Editor.getDraggingOverShape} instead */
|
|
4396
|
-
getDroppingOverShape(point, droppingShapes) {
|
|
4397
|
-
return this.getDraggingOverShape(point, droppingShapes);
|
|
4398
|
-
}
|
|
4399
4392
|
/**
|
|
4400
4393
|
* Get the shape that some shapes should be dropped on at a given point.
|
|
4401
4394
|
*
|
|
@@ -4406,20 +4399,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4406
4399
|
*
|
|
4407
4400
|
* @public
|
|
4408
4401
|
*/
|
|
4409
|
-
|
|
4410
|
-
const
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4402
|
+
getDroppingOverShape(point, droppingShapes = []) {
|
|
4403
|
+
const currentPageShapesSorted = this.getCurrentPageShapesSorted();
|
|
4404
|
+
for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) {
|
|
4405
|
+
const shape = currentPageShapesSorted[i];
|
|
4406
|
+
if (
|
|
4407
|
+
// ignore hidden shapes
|
|
4408
|
+
this.isShapeHidden(shape) || // don't allow dropping on selected shapes
|
|
4409
|
+
this.getSelectedShapeIds().includes(shape.id) || // only allow shapes that can receive children
|
|
4410
|
+
!this.getShapeUtil(shape).canDropShapes(shape, droppingShapes) || // don't allow dropping a shape on itself or one of it's children
|
|
4411
|
+
droppingShapes.find((s) => s.id === shape.id || this.hasAncestor(shape, s.id))
|
|
4412
|
+
) {
|
|
4413
|
+
continue;
|
|
4414
|
+
}
|
|
4415
|
+
const maskedPageBounds = this.getShapeMaskedPageBounds(shape.id);
|
|
4416
|
+
if (maskedPageBounds && maskedPageBounds.containsPoint(point) && this.getShapeGeometry(shape).hitTestPoint(this.getPointInShapeSpace(shape, point), 0, true)) {
|
|
4417
|
+
return shape;
|
|
4423
4418
|
}
|
|
4424
4419
|
}
|
|
4425
4420
|
}
|
|
@@ -4761,7 +4756,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4761
4756
|
shape.index = index;
|
|
4762
4757
|
});
|
|
4763
4758
|
const shapesToCreate = shapesToCreateWithOriginals.map(({ shape }) => shape);
|
|
4764
|
-
|
|
4759
|
+
const maxShapesReached = shapesToCreate.length + this.getCurrentPageShapeIds().size > this.options.maxShapesPerPage;
|
|
4760
|
+
if (maxShapesReached) {
|
|
4765
4761
|
alertMaxShapes(this);
|
|
4766
4762
|
return;
|
|
4767
4763
|
}
|
|
@@ -5776,26 +5772,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5776
5772
|
getInitialMetaForShape(_shape) {
|
|
5777
5773
|
return {};
|
|
5778
5774
|
}
|
|
5779
|
-
/**
|
|
5780
|
-
* Get whether the provided shape can be created.
|
|
5781
|
-
*
|
|
5782
|
-
* @param shape - The shape or shape IDs to check.
|
|
5783
|
-
*
|
|
5784
|
-
* @public
|
|
5785
|
-
*/
|
|
5786
|
-
canCreateShape(shape) {
|
|
5787
|
-
return this.canCreateShapes([shape]);
|
|
5788
|
-
}
|
|
5789
|
-
/**
|
|
5790
|
-
* Get whether the provided shapes can be created.
|
|
5791
|
-
*
|
|
5792
|
-
* @param shapes - The shapes or shape IDs to create.
|
|
5793
|
-
*
|
|
5794
|
-
* @public
|
|
5795
|
-
*/
|
|
5796
|
-
canCreateShapes(shapes) {
|
|
5797
|
-
return shapes.length + this.getCurrentPageShapeIds().size <= this.options.maxShapesPerPage;
|
|
5798
|
-
}
|
|
5799
5775
|
/**
|
|
5800
5776
|
* Create a single shape.
|
|
5801
5777
|
*
|
|
@@ -5849,8 +5825,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5849
5825
|
let parentId = this.getFocusedGroupId();
|
|
5850
5826
|
for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) {
|
|
5851
5827
|
const parent = currentPageShapesSorted[i];
|
|
5852
|
-
|
|
5853
|
-
if (util.canReceiveNewChildrenOfType(parent, partial.type) && !this.isShapeHidden(parent) && this.isPointInShape(
|
|
5828
|
+
if (!this.isShapeHidden(parent) && this.getShapeUtil(parent).canReceiveNewChildrenOfType(parent, partial.type) && this.isPointInShape(
|
|
5854
5829
|
parent,
|
|
5855
5830
|
// If no parent is provided, then we can treat the
|
|
5856
5831
|
// shape's provided x/y as being in the page's space.
|
|
@@ -5925,8 +5900,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5925
5900
|
...shape.meta
|
|
5926
5901
|
};
|
|
5927
5902
|
});
|
|
5928
|
-
this.emit("created-shapes", shapeRecordsToCreate);
|
|
5929
|
-
this.emit("edit");
|
|
5930
5903
|
this.store.put(shapeRecordsToCreate);
|
|
5931
5904
|
});
|
|
5932
5905
|
return this;
|
|
@@ -6168,8 +6141,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6168
6141
|
updated = this.getShapeUtil(shape).onBeforeUpdate?.(shape, updated) ?? updated;
|
|
6169
6142
|
updates.push(updated);
|
|
6170
6143
|
}
|
|
6171
|
-
this.emit("edited-shapes", updates);
|
|
6172
|
-
this.emit("edit");
|
|
6173
6144
|
this.store.put(updates);
|
|
6174
6145
|
});
|
|
6175
6146
|
}
|
|
@@ -6191,8 +6162,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6191
6162
|
allShapeIdsToDelete.add(childId);
|
|
6192
6163
|
});
|
|
6193
6164
|
}
|
|
6194
|
-
this.emit("deleted-shapes", [...allShapeIdsToDelete]);
|
|
6195
|
-
this.emit("edit");
|
|
6196
6165
|
return this.run(() => this.store.remove([...allShapeIdsToDelete]));
|
|
6197
6166
|
}
|
|
6198
6167
|
deleteShape(_id) {
|
|
@@ -6961,9 +6930,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6961
6930
|
previousScreenPoint,
|
|
6962
6931
|
previousPagePoint,
|
|
6963
6932
|
currentScreenPoint,
|
|
6964
|
-
currentPagePoint
|
|
6965
|
-
originScreenPoint,
|
|
6966
|
-
originPagePoint
|
|
6933
|
+
currentPagePoint
|
|
6967
6934
|
} = this.inputs;
|
|
6968
6935
|
const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID);
|
|
6969
6936
|
const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera());
|
|
@@ -6981,8 +6948,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6981
6948
|
this.inputs.isPen = info.type === "pointer" && info.isPen;
|
|
6982
6949
|
if (info.name === "pointer_down" || this.inputs.isPinching) {
|
|
6983
6950
|
pointerVelocity.set(0, 0);
|
|
6984
|
-
originScreenPoint.setTo(currentScreenPoint);
|
|
6985
|
-
originPagePoint.setTo(currentPagePoint);
|
|
6951
|
+
this.inputs.originScreenPoint.setTo(currentScreenPoint);
|
|
6952
|
+
this.inputs.originPagePoint.setTo(currentPagePoint);
|
|
6986
6953
|
}
|
|
6987
6954
|
this.run(
|
|
6988
6955
|
() => {
|