@tldraw/editor 3.16.0-canary.b33662a7aefb → 3.16.0-canary.b534f7a12bd2
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 +7 -101
- package/dist-cjs/index.js +3 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +0 -4
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +3 -99
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +4 -1
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
- package/dist-cjs/lib/license/LicenseManager.js +120 -50
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/lib/license/LicenseProvider.js +22 -0
- package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +68 -6
- package/dist-cjs/lib/license/Watermark.js.map +3 -3
- package/dist-cjs/lib/license/useLicenseManagerState.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +0 -4
- package/dist-cjs/lib/primitives/Vec.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +26 -18
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Group2d.js +3 -0
- package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +2 -35
- package/dist-cjs/lib/utils/reparenting.js.map +3 -3
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +7 -101
- package/dist-esm/index.mjs +3 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +0 -4
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +3 -99
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +4 -1
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseManager.mjs +121 -51
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseProvider.mjs +23 -1
- package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +68 -6
- package/dist-esm/lib/license/Watermark.mjs.map +3 -3
- package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +0 -4
- package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +29 -19
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Group2d.mjs +3 -0
- package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +3 -40
- package/dist-esm/lib/utils/reparenting.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 +2 -9
- package/src/lib/TldrawEditor.tsx +0 -11
- package/src/lib/editor/Editor.ts +1 -125
- package/src/lib/editor/types/misc-types.ts +0 -6
- package/src/lib/hooks/usePassThroughMouseOverEvents.ts +4 -1
- package/src/lib/license/LicenseManager.test.ts +645 -382
- package/src/lib/license/LicenseManager.ts +173 -53
- package/src/lib/license/LicenseProvider.tsx +34 -1
- package/src/lib/license/Watermark.tsx +73 -6
- package/src/lib/license/useLicenseManagerState.ts +2 -2
- package/src/lib/primitives/Vec.ts +0 -5
- package/src/lib/primitives/geometry/Geometry2d.ts +49 -19
- package/src/lib/primitives/geometry/Group2d.ts +4 -0
- package/src/lib/utils/reparenting.ts +3 -69
- package/src/version.ts +3 -3
|
@@ -2,15 +2,7 @@ import { EMPTY_ARRAY } from '@tldraw/state'
|
|
|
2
2
|
import { TLGroupShape, TLParentId, TLShape, TLShapeId } from '@tldraw/tlschema'
|
|
3
3
|
import { IndexKey, compact, getIndexAbove, getIndexBetween } from '@tldraw/utils'
|
|
4
4
|
import { Editor } from '../editor/Editor'
|
|
5
|
-
import {
|
|
6
|
-
import { Geometry2d } from '../primitives/geometry/Geometry2d'
|
|
7
|
-
import { Group2d } from '../primitives/geometry/Group2d'
|
|
8
|
-
import {
|
|
9
|
-
intersectPolygonPolygon,
|
|
10
|
-
polygonIntersectsPolyline,
|
|
11
|
-
polygonsIntersect,
|
|
12
|
-
} from '../primitives/intersect'
|
|
13
|
-
import { pointInPolygon } from '../primitives/utils'
|
|
5
|
+
import { intersectPolygonPolygon } from '../primitives/intersect'
|
|
14
6
|
|
|
15
7
|
/**
|
|
16
8
|
* Reparents shapes that are no longer contained within their parent shapes.
|
|
@@ -189,68 +181,10 @@ function getOverlappingShapes<T extends TLShape[] | TLShapeId[]>(
|
|
|
189
181
|
|
|
190
182
|
const geometry = editor.getShapeGeometry(childId)
|
|
191
183
|
|
|
192
|
-
return
|
|
184
|
+
return geometry.overlapsPolygon(parentPolygonInShapeShape)
|
|
193
185
|
})
|
|
194
186
|
}
|
|
195
187
|
|
|
196
|
-
/**
|
|
197
|
-
* @public
|
|
198
|
-
*/
|
|
199
|
-
export function doesGeometryOverlapPolygon(
|
|
200
|
-
geometry: Geometry2d,
|
|
201
|
-
parentCornersInShapeSpace: Vec[]
|
|
202
|
-
): boolean {
|
|
203
|
-
// If the child is a group, check if any of its children overlap the box
|
|
204
|
-
if (geometry instanceof Group2d) {
|
|
205
|
-
return geometry.children.some((childGeometry) =>
|
|
206
|
-
doesGeometryOverlapPolygon(childGeometry, parentCornersInShapeSpace)
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Otherwise, check if the geometry overlaps the box
|
|
211
|
-
const { vertices, center, isFilled, isEmptyLabel, isClosed } = geometry
|
|
212
|
-
|
|
213
|
-
// We'll do things in order of cheapest to most expensive checks
|
|
214
|
-
|
|
215
|
-
// Skip empty labels
|
|
216
|
-
if (isEmptyLabel) return false
|
|
217
|
-
|
|
218
|
-
// If any of the shape's vertices are inside the occluder, it's inside
|
|
219
|
-
if (vertices.some((v) => pointInPolygon(v, parentCornersInShapeSpace))) {
|
|
220
|
-
return true
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// If the shape is filled and closed and its center is inside the parent, it's inside
|
|
224
|
-
if (isClosed) {
|
|
225
|
-
if (isFilled) {
|
|
226
|
-
// If closed and filled, check if the center is inside the parent
|
|
227
|
-
if (pointInPolygon(center, parentCornersInShapeSpace)) {
|
|
228
|
-
return true
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// ..then, slightly more expensive check, see the shape covers the entire parent but not its center
|
|
232
|
-
if (parentCornersInShapeSpace.every((v) => pointInPolygon(v, vertices))) {
|
|
233
|
-
return true
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// If any the shape's vertices intersect the edge of the occluder, it's inside.
|
|
238
|
-
// for example when a rotated rectangle is moved over the corner of a parent rectangle
|
|
239
|
-
// If the child shape is closed, intersect as a polygon
|
|
240
|
-
if (polygonsIntersect(parentCornersInShapeSpace, vertices)) {
|
|
241
|
-
return true
|
|
242
|
-
}
|
|
243
|
-
} else {
|
|
244
|
-
// if the child shape is not closed, intersect as a polyline
|
|
245
|
-
if (polygonIntersectsPolyline(parentCornersInShapeSpace, vertices)) {
|
|
246
|
-
return true
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// If none of the above checks passed, the shape is outside the parent
|
|
251
|
-
return false
|
|
252
|
-
}
|
|
253
|
-
|
|
254
188
|
/**
|
|
255
189
|
* Get the shapes that will be reparented to new parents when the shapes are dropped.
|
|
256
190
|
*
|
|
@@ -354,7 +288,7 @@ export function getDroppedShapesToNewParents(
|
|
|
354
288
|
.applyToPoints(parentPagePolygon)
|
|
355
289
|
|
|
356
290
|
// If the shape overlaps the parent polygon, reparent it to that parent
|
|
357
|
-
if (
|
|
291
|
+
if (editor.getShapeGeometry(shape).overlapsPolygon(parentPolygonInShapeSpace)) {
|
|
358
292
|
// Use the util to check if the shape can be reparented to the parent
|
|
359
293
|
if (
|
|
360
294
|
!editor.getShapeUtil(parentShape).canReceiveNewChildrenOfType?.(parentShape, shape.type)
|
package/src/version.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is automatically generated by internal/scripts/refresh-assets.ts.
|
|
2
2
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
3
3
|
|
|
4
|
-
export const version = '3.16.0-canary.
|
|
4
|
+
export const version = '3.16.0-canary.b534f7a12bd2'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-
|
|
8
|
-
patch: '2025-
|
|
7
|
+
minor: '2025-09-05T15:45:11.861Z',
|
|
8
|
+
patch: '2025-09-05T15:45:11.861Z',
|
|
9
9
|
}
|