@tldraw/editor 4.3.0-canary.bf87ebaf143a → 4.3.0-canary.c08047039e53
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/README.md +1 -1
- package/dist-cjs/index.d.ts +392 -118
- package/dist-cjs/index.js +7 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/ErrorBoundary.js.map +1 -1
- package/dist-cjs/lib/components/GeometryDebuggingView.js +1 -17
- package/dist-cjs/lib/components/GeometryDebuggingView.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/constants.js +1 -3
- package/dist-cjs/lib/constants.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +301 -278
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +16 -23
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +3 -3
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js +12 -3
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +1 -1
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +5 -6
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +591 -0
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/RBushIndex.js +144 -0
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/RBushIndex.js.map +7 -0
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +181 -0
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +1 -22
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +31 -23
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +3 -3
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
- package/dist-cjs/lib/exports/parseCss.js +1 -1
- package/dist-cjs/lib/exports/parseCss.js.map +2 -2
- package/dist-cjs/lib/hooks/useEvent.js +1 -1
- package/dist-cjs/lib/hooks/useEvent.js.map +2 -2
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +1 -1
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useScreenBounds.js.map +2 -2
- package/dist-cjs/lib/hooks/useStateAttribute.js +4 -1
- package/dist-cjs/lib/hooks/useStateAttribute.js.map +2 -2
- package/dist-cjs/lib/hooks/useTransform.js.map +1 -1
- package/dist-cjs/lib/options.js +4 -1
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +3 -0
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +1 -0
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/utils/rotation.js +1 -1
- package/dist-cjs/lib/utils/rotation.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 +392 -118
- package/dist-esm/index.mjs +7 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/ErrorBoundary.mjs.map +1 -1
- package/dist-esm/lib/components/GeometryDebuggingView.mjs +1 -17
- package/dist-esm/lib/components/GeometryDebuggingView.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/constants.mjs +1 -3
- package/dist-esm/lib/constants.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +302 -281
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +16 -23
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +3 -3
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs +13 -4
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +5 -6
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +573 -0
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SpatialIndexManager/RBushIndex.mjs +114 -0
- package/dist-esm/lib/editor/managers/SpatialIndexManager/RBushIndex.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +161 -0
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +1 -22
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +31 -23
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +3 -3
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
- package/dist-esm/lib/exports/parseCss.mjs +1 -1
- package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEvent.mjs +1 -1
- package/dist-esm/lib/hooks/useEvent.mjs.map +2 -2
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +1 -1
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useScreenBounds.mjs.map +2 -2
- package/dist-esm/lib/hooks/useStateAttribute.mjs +4 -1
- package/dist-esm/lib/hooks/useStateAttribute.mjs.map +2 -2
- package/dist-esm/lib/hooks/useTransform.mjs.map +1 -1
- package/dist-esm/lib/options.mjs +4 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +3 -0
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +1 -0
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/utils/rotation.mjs +1 -1
- package/dist-esm/lib/utils/rotation.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +6 -8
- package/package.json +21 -17
- package/src/index.ts +4 -0
- package/src/lib/components/ErrorBoundary.tsx +1 -1
- package/src/lib/components/GeometryDebuggingView.tsx +1 -19
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -5
- package/src/lib/config/TLUserPreferences.test.ts +40 -0
- package/src/lib/constants.ts +0 -2
- package/src/lib/editor/Editor.test.ts +140 -0
- package/src/lib/editor/Editor.ts +374 -321
- package/src/lib/editor/derivations/notVisibleShapes.ts +21 -33
- package/src/lib/editor/derivations/parentsToChildren.ts +18 -7
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +17 -31
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +129 -79
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +10 -6
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +566 -0
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +0 -4
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +12 -0
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +1 -1
- package/src/lib/editor/managers/SpatialIndexManager/RBushIndex.ts +144 -0
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +215 -0
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +40 -107
- package/src/lib/editor/managers/TickManager/TickManager.ts +2 -32
- package/src/lib/editor/shapes/ShapeUtil.ts +67 -24
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +3 -3
- package/src/lib/exports/parseCss.test.ts +1 -0
- package/src/lib/exports/parseCss.ts +1 -1
- package/src/lib/hooks/useEvent.tsx +1 -1
- package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +1 -1
- package/src/lib/hooks/useGestureEvents.ts +2 -2
- package/src/lib/hooks/usePassThroughMouseOverEvents.ts +1 -1
- package/src/lib/hooks/usePassThroughWheelEvents.ts +1 -1
- package/src/lib/hooks/useScreenBounds.ts +1 -1
- package/src/lib/hooks/useStateAttribute.ts +4 -1
- package/src/lib/hooks/useTransform.ts +1 -1
- package/src/lib/options.ts +19 -0
- package/src/lib/primitives/Box.ts +9 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +1 -0
- package/src/lib/utils/rotation.ts +1 -1
- package/src/version.ts +3 -3
|
@@ -190,7 +190,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
190
190
|
* @param shape - The shape.
|
|
191
191
|
* @public
|
|
192
192
|
*/
|
|
193
|
-
canSnap(
|
|
193
|
+
canSnap(shape: Shape): boolean {
|
|
194
194
|
return true
|
|
195
195
|
}
|
|
196
196
|
|
|
@@ -200,7 +200,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
200
200
|
* @param shape - The shape.
|
|
201
201
|
* @public
|
|
202
202
|
*/
|
|
203
|
-
canTabTo(
|
|
203
|
+
canTabTo(shape: Shape): boolean {
|
|
204
204
|
return true
|
|
205
205
|
}
|
|
206
206
|
|
|
@@ -209,7 +209,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
209
209
|
*
|
|
210
210
|
* @public
|
|
211
211
|
*/
|
|
212
|
-
canScroll(
|
|
212
|
+
canScroll(shape: Shape): boolean {
|
|
213
213
|
return false
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -227,7 +227,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
227
227
|
*
|
|
228
228
|
* @public
|
|
229
229
|
*/
|
|
230
|
-
canEdit(
|
|
230
|
+
canEdit(shape: Shape, info: TLEditStartInfo): boolean {
|
|
231
231
|
return false
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -236,7 +236,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
236
236
|
*
|
|
237
237
|
* @public
|
|
238
238
|
*/
|
|
239
|
-
canResize(
|
|
239
|
+
canResize(shape: Shape): boolean {
|
|
240
240
|
return true
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -245,7 +245,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
245
245
|
*
|
|
246
246
|
* @public
|
|
247
247
|
*/
|
|
248
|
-
canResizeChildren(
|
|
248
|
+
canResizeChildren(shape: Shape): boolean {
|
|
249
249
|
return true
|
|
250
250
|
}
|
|
251
251
|
|
|
@@ -254,7 +254,16 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
254
254
|
*
|
|
255
255
|
* @public
|
|
256
256
|
*/
|
|
257
|
-
canEditInReadonly(
|
|
257
|
+
canEditInReadonly(shape: Shape): boolean {
|
|
258
|
+
return false
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Whether the shape can be edited while locked or while an ancestor is locked.
|
|
263
|
+
*
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
canEditWhileLocked(shape: Shape): boolean {
|
|
258
267
|
return false
|
|
259
268
|
}
|
|
260
269
|
|
|
@@ -263,7 +272,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
263
272
|
*
|
|
264
273
|
* @public
|
|
265
274
|
*/
|
|
266
|
-
canCrop(
|
|
275
|
+
canCrop(shape: Shape): boolean {
|
|
267
276
|
return false
|
|
268
277
|
}
|
|
269
278
|
|
|
@@ -276,7 +285,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
276
285
|
*
|
|
277
286
|
* @public
|
|
278
287
|
*/
|
|
279
|
-
canBeLaidOut(
|
|
288
|
+
canBeLaidOut(shape: Shape, info: TLShapeUtilCanBeLaidOutOpts): boolean {
|
|
280
289
|
return true
|
|
281
290
|
}
|
|
282
291
|
|
|
@@ -287,7 +296,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
287
296
|
*
|
|
288
297
|
* @param shape - The shape.
|
|
289
298
|
*/
|
|
290
|
-
canCull(
|
|
299
|
+
canCull(shape: Shape): boolean {
|
|
291
300
|
return true
|
|
292
301
|
}
|
|
293
302
|
|
|
@@ -300,13 +309,33 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
300
309
|
*
|
|
301
310
|
* @internal
|
|
302
311
|
*/
|
|
303
|
-
providesBackgroundForChildren(
|
|
312
|
+
providesBackgroundForChildren(shape: Shape): boolean {
|
|
304
313
|
return false
|
|
305
314
|
}
|
|
306
315
|
|
|
307
316
|
/**
|
|
308
317
|
* Get the clip path to apply to this shape's children.
|
|
309
318
|
*
|
|
319
|
+
* The returned points should define the **inner** clip boundary - the area where
|
|
320
|
+
* children will be visible. If your shape has a stroke, you should inset the clip
|
|
321
|
+
* path by half the stroke width so children are clipped to the inner edge of the
|
|
322
|
+
* stroke rather than its center line.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* override getClipPath(shape: MyShape): Vec[] | undefined {
|
|
327
|
+
* const strokeWidth = 2
|
|
328
|
+
* const inset = strokeWidth / 2
|
|
329
|
+
* // Return points inset by half the stroke width
|
|
330
|
+
* return [
|
|
331
|
+
* new Vec(inset, inset),
|
|
332
|
+
* new Vec(shape.props.w - inset, inset),
|
|
333
|
+
* new Vec(shape.props.w - inset, shape.props.h - inset),
|
|
334
|
+
* new Vec(inset, shape.props.h - inset),
|
|
335
|
+
* ]
|
|
336
|
+
* }
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
310
339
|
* @param shape - The shape to get the clip path for
|
|
311
340
|
* @returns Array of points defining the clipping polygon in local coordinates, or undefined if no clipping
|
|
312
341
|
* @public
|
|
@@ -333,14 +362,14 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
333
362
|
* @returns boolean indicating if this shape should hide in the minimap
|
|
334
363
|
* @public
|
|
335
364
|
*/
|
|
336
|
-
hideInMinimap?(
|
|
365
|
+
hideInMinimap?(shape: Shape): boolean
|
|
337
366
|
|
|
338
367
|
/**
|
|
339
368
|
* Whether the shape should hide its resize handles when selected.
|
|
340
369
|
*
|
|
341
370
|
* @public
|
|
342
371
|
*/
|
|
343
|
-
hideResizeHandles(
|
|
372
|
+
hideResizeHandles(shape: Shape): boolean {
|
|
344
373
|
return false
|
|
345
374
|
}
|
|
346
375
|
|
|
@@ -349,7 +378,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
349
378
|
*
|
|
350
379
|
* @public
|
|
351
380
|
*/
|
|
352
|
-
hideRotateHandle(
|
|
381
|
+
hideRotateHandle(shape: Shape): boolean {
|
|
353
382
|
return false
|
|
354
383
|
}
|
|
355
384
|
|
|
@@ -358,7 +387,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
358
387
|
*
|
|
359
388
|
* @public
|
|
360
389
|
*/
|
|
361
|
-
hideSelectionBoundsBg(
|
|
390
|
+
hideSelectionBoundsBg(shape: Shape): boolean {
|
|
362
391
|
return false
|
|
363
392
|
}
|
|
364
393
|
|
|
@@ -367,7 +396,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
367
396
|
*
|
|
368
397
|
* @public
|
|
369
398
|
*/
|
|
370
|
-
hideSelectionBoundsFg(
|
|
399
|
+
hideSelectionBoundsFg(shape: Shape): boolean {
|
|
371
400
|
return false
|
|
372
401
|
}
|
|
373
402
|
|
|
@@ -376,7 +405,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
376
405
|
*
|
|
377
406
|
* @public
|
|
378
407
|
*/
|
|
379
|
-
isAspectRatioLocked(
|
|
408
|
+
isAspectRatioLocked(shape: Shape): boolean {
|
|
380
409
|
return false
|
|
381
410
|
}
|
|
382
411
|
|
|
@@ -387,10 +416,10 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
387
416
|
* useful in cases like annotating on top of an image, where you usually want to avoid extra
|
|
388
417
|
* padding around the image if you don't need it.
|
|
389
418
|
*
|
|
390
|
-
* @param
|
|
419
|
+
* @param shape - The shape to check
|
|
391
420
|
* @returns True if this shape should be treated as an export bounds container
|
|
392
421
|
*/
|
|
393
|
-
isExportBoundsContainer(
|
|
422
|
+
isExportBoundsContainer(shape: Shape): boolean {
|
|
394
423
|
return false
|
|
395
424
|
}
|
|
396
425
|
|
|
@@ -439,7 +468,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
439
468
|
* @param type - The shape type.
|
|
440
469
|
* @public
|
|
441
470
|
*/
|
|
442
|
-
canReceiveNewChildrenOfType(
|
|
471
|
+
canReceiveNewChildrenOfType(shape: Shape, _type: TLShape['type']) {
|
|
443
472
|
return false
|
|
444
473
|
}
|
|
445
474
|
|
|
@@ -487,7 +516,7 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
487
516
|
* Get the geometry to use when snapping to this this shape in translate/resize operations. See
|
|
488
517
|
* {@link BoundsSnapGeometry} for details.
|
|
489
518
|
*/
|
|
490
|
-
getBoundsSnapGeometry(
|
|
519
|
+
getBoundsSnapGeometry(shape: Shape): BoundsSnapGeometry {
|
|
491
520
|
return {}
|
|
492
521
|
}
|
|
493
522
|
|
|
@@ -495,15 +524,15 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
495
524
|
* Get the geometry to use when snapping handles to this shape. See {@link HandleSnapGeometry}
|
|
496
525
|
* for details.
|
|
497
526
|
*/
|
|
498
|
-
getHandleSnapGeometry(
|
|
527
|
+
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry {
|
|
499
528
|
return {}
|
|
500
529
|
}
|
|
501
530
|
|
|
502
|
-
getText(
|
|
531
|
+
getText(shape: Shape): string | undefined {
|
|
503
532
|
return undefined
|
|
504
533
|
}
|
|
505
534
|
|
|
506
|
-
getAriaDescriptor(
|
|
535
|
+
getAriaDescriptor(shape: Shape): string | undefined {
|
|
507
536
|
return undefined
|
|
508
537
|
}
|
|
509
538
|
|
|
@@ -931,3 +960,17 @@ export interface TLHandleDragInfo<T extends TLShape> {
|
|
|
931
960
|
isCreatingShape: boolean
|
|
932
961
|
initial?: T | undefined
|
|
933
962
|
}
|
|
963
|
+
|
|
964
|
+
/* --------------------------------- Editing -------------------------------- */
|
|
965
|
+
|
|
966
|
+
/** @public */
|
|
967
|
+
export interface TLEditStartInfo {
|
|
968
|
+
type:
|
|
969
|
+
| 'press_enter'
|
|
970
|
+
| 'click'
|
|
971
|
+
| 'double-click'
|
|
972
|
+
| 'double-click-edge'
|
|
973
|
+
| 'double-click-corner'
|
|
974
|
+
| 'click-header'
|
|
975
|
+
| 'unknown'
|
|
976
|
+
}
|
|
@@ -12,8 +12,8 @@ export class Pointing extends StateNode {
|
|
|
12
12
|
|
|
13
13
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
14
14
|
const { editor } = this
|
|
15
|
-
if (editor.inputs.
|
|
16
|
-
const
|
|
15
|
+
if (editor.inputs.getIsDragging()) {
|
|
16
|
+
const originPagePoint = editor.inputs.getOriginPagePoint()
|
|
17
17
|
|
|
18
18
|
const shapeType = (this.parent as BaseBoxShapeTool)!.shapeType
|
|
19
19
|
|
|
@@ -78,7 +78,7 @@ export class Pointing extends StateNode {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
complete() {
|
|
81
|
-
const
|
|
81
|
+
const originPagePoint = this.editor.inputs.getOriginPagePoint()
|
|
82
82
|
|
|
83
83
|
const shapeType = (this.parent as BaseBoxShapeTool)!.shapeType as TLBaseBoxShape['type']
|
|
84
84
|
|
|
@@ -27,7 +27,7 @@ import { useCallback, useDebugValue, useLayoutEffect, useRef } from 'react'
|
|
|
27
27
|
export function useEvent<Args extends Array<unknown>, Result>(
|
|
28
28
|
handler: (...args: Args) => Result
|
|
29
29
|
): (...args: Args) => Result {
|
|
30
|
-
const handlerRef = useRef<(...args: Args) => Result>()
|
|
30
|
+
const handlerRef = useRef<((...args: Args) => Result) | undefined>(undefined)
|
|
31
31
|
|
|
32
32
|
// In a real implementation, this would run before layout effects
|
|
33
33
|
useLayoutEffect(() => {
|
|
@@ -9,7 +9,7 @@ const IGNORED_TAGS = ['textarea', 'input']
|
|
|
9
9
|
* want this for drawing operations and can disable it by setting 'disableDoubleTapZoom' in the main
|
|
10
10
|
* editor.
|
|
11
11
|
*/
|
|
12
|
-
export function useFixSafariDoubleTapZoomPencilEvents(ref: React.RefObject<HTMLElement>) {
|
|
12
|
+
export function useFixSafariDoubleTapZoomPencilEvents(ref: React.RefObject<HTMLElement | null>) {
|
|
13
13
|
const editor = useEditor()
|
|
14
14
|
|
|
15
15
|
useEffect(() => {
|
|
@@ -75,7 +75,7 @@ const isWheelEndEvent = (time: number) => {
|
|
|
75
75
|
return false
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
|
|
78
|
+
export function useGestureEvents(ref: React.RefObject<HTMLDivElement | null>) {
|
|
79
79
|
const editor = useEditor()
|
|
80
80
|
|
|
81
81
|
const events = React.useMemo(() => {
|
|
@@ -105,7 +105,7 @@ export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
|
|
|
105
105
|
const util = editor.getShapeUtil(shape)
|
|
106
106
|
if (util.canScroll(shape)) {
|
|
107
107
|
const bounds = editor.getShapePageBounds(editingShapeId)
|
|
108
|
-
if (bounds?.containsPoint(editor.inputs.
|
|
108
|
+
if (bounds?.containsPoint(editor.inputs.getCurrentPagePoint())) {
|
|
109
109
|
return
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -4,7 +4,7 @@ import { useContainer } from './useContainer'
|
|
|
4
4
|
import { useMaybeEditor } from './useEditor'
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
|
-
export function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement>) {
|
|
7
|
+
export function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement | null>) {
|
|
8
8
|
if (!ref) throw Error('usePassThroughWheelEvents must be passed a ref')
|
|
9
9
|
const container = useContainer()
|
|
10
10
|
const editor = useMaybeEditor()
|
|
@@ -4,7 +4,7 @@ import { useContainer } from './useContainer'
|
|
|
4
4
|
import { useMaybeEditor } from './useEditor'
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
|
-
export function usePassThroughWheelEvents(ref: RefObject<HTMLElement>) {
|
|
7
|
+
export function usePassThroughWheelEvents(ref: RefObject<HTMLElement | null>) {
|
|
8
8
|
if (!ref) throw Error('usePassThroughWheelEvents must be passed a ref')
|
|
9
9
|
const container = useContainer()
|
|
10
10
|
const editor = useMaybeEditor()
|
|
@@ -2,7 +2,7 @@ import { throttle } from '@tldraw/utils'
|
|
|
2
2
|
import { useLayoutEffect } from 'react'
|
|
3
3
|
import { useEditor } from './useEditor'
|
|
4
4
|
|
|
5
|
-
export function useScreenBounds(ref: React.RefObject<HTMLElement>) {
|
|
5
|
+
export function useScreenBounds(ref: React.RefObject<HTMLElement | null>) {
|
|
6
6
|
const editor = useEditor()
|
|
7
7
|
|
|
8
8
|
useLayoutEffect(() => {
|
|
@@ -9,7 +9,10 @@ export function useStateAttribute() {
|
|
|
9
9
|
// editor mounting and this attribute being applied, because styles may depend on it:
|
|
10
10
|
useLayoutEffect(() => {
|
|
11
11
|
return react('stateAttribute', () => {
|
|
12
|
-
editor.getContainer()
|
|
12
|
+
const container = editor.getContainer()
|
|
13
|
+
const instanceState = editor.getInstanceState()
|
|
14
|
+
container.setAttribute('data-state', editor.getPath())
|
|
15
|
+
container.setAttribute('data-coarse', String(instanceState.isCoarsePointer))
|
|
13
16
|
})
|
|
14
17
|
}, [editor])
|
|
15
18
|
}
|
package/src/lib/options.ts
CHANGED
|
@@ -98,6 +98,22 @@ export interface TldrawOptions {
|
|
|
98
98
|
* Defaults to 300 shapes.
|
|
99
99
|
*/
|
|
100
100
|
readonly debouncedZoomThreshold: number
|
|
101
|
+
/**
|
|
102
|
+
* Whether to allow spacebar panning. When true, the spacebar will pan the camera when held down.
|
|
103
|
+
* When false, the spacebar will not pan the camera.
|
|
104
|
+
*/
|
|
105
|
+
readonly spacebarPanning: boolean
|
|
106
|
+
/**
|
|
107
|
+
* The default padding (in pixels) used when zooming to fit content in the viewport.
|
|
108
|
+
* This affects methods like `zoomToFit()`, `zoomToSelection()`, and `zoomToBounds()`.
|
|
109
|
+
* The actual padding used is the minimum of this value and 28% of the viewport width.
|
|
110
|
+
* Defaults to 128 pixels.
|
|
111
|
+
*/
|
|
112
|
+
readonly zoomToFitPadding: number
|
|
113
|
+
/**
|
|
114
|
+
* The distance (in screen pixels) at which shapes snap to guides and other shapes.
|
|
115
|
+
*/
|
|
116
|
+
readonly snapThreshold: number
|
|
101
117
|
}
|
|
102
118
|
|
|
103
119
|
/** @public */
|
|
@@ -152,4 +168,7 @@ export const defaultTldrawOptions = {
|
|
|
152
168
|
nonce: undefined,
|
|
153
169
|
debouncedZoom: true,
|
|
154
170
|
debouncedZoomThreshold: 500,
|
|
171
|
+
spacebarPanning: true,
|
|
172
|
+
zoomToFitPadding: 128,
|
|
173
|
+
snapThreshold: 8,
|
|
155
174
|
} as const satisfies TldrawOptions
|
|
@@ -180,6 +180,15 @@ export class Box {
|
|
|
180
180
|
return new Vec(this.w, this.h)
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
isValid() {
|
|
184
|
+
return (
|
|
185
|
+
Number.isFinite(this.x) &&
|
|
186
|
+
Number.isFinite(this.y) &&
|
|
187
|
+
Number.isFinite(this.w) &&
|
|
188
|
+
Number.isFinite(this.h)
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
183
192
|
toFixed() {
|
|
184
193
|
this.x = toPrecision(this.x)
|
|
185
194
|
this.y = toPrecision(this.y)
|
|
@@ -140,6 +140,7 @@ export abstract class Geometry2d {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
if (!nearest) throw Error('nearest point not found')
|
|
143
|
+
dist = Math.sqrt(dist) // return the actual distance, not the squared distance
|
|
143
144
|
return this.isClosed && this.isFilled && pointInPolygon(nearest, this.vertices) ? -dist : dist
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -32,7 +32,7 @@ export function getRotationSnapshot({
|
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
34
|
initialPageCenter,
|
|
35
|
-
initialCursorAngle: initialPageCenter.angle(editor.inputs.
|
|
35
|
+
initialCursorAngle: initialPageCenter.angle(editor.inputs.getOriginPagePoint()),
|
|
36
36
|
initialShapesRotation: rotation,
|
|
37
37
|
shapeSnapshots: shapes.map((shape) => ({
|
|
38
38
|
shape,
|
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 = '4.3.0-canary.
|
|
4
|
+
export const version = '4.3.0-canary.c08047039e53'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2025-09-18T14:39:22.803Z',
|
|
7
|
-
minor: '
|
|
8
|
-
patch: '
|
|
7
|
+
minor: '2026-01-21T09:45:12.761Z',
|
|
8
|
+
patch: '2026-01-21T09:45:12.761Z',
|
|
9
9
|
}
|