tldraw 3.16.0-canary.a2491e00987a → 3.16.0-canary.a531b80e1ddf
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 +3 -1
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +1 -1
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +25 -1
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +12 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +68 -91
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +0 -10
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -18
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +21 -3
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-esm/index.d.mts +3 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +4 -4
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +1 -1
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +26 -1
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +13 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +77 -93
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +0 -10
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +1 -18
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +22 -3
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +3 -3
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +12 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +1 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +34 -1
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -0
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +98 -114
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +0 -10
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -16
- package/src/lib/ui/hooks/useTools.tsx +25 -3
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +5 -6
- package/src/test/EraserTool.test.ts +176 -6
- package/tldraw.css +5 -6
|
@@ -436,11 +436,181 @@ describe('When shift clicking', () => {
|
|
|
436
436
|
it.todo('Clears the previous clicked point when leaving / re-entering the eraser tool')
|
|
437
437
|
})
|
|
438
438
|
|
|
439
|
-
describe('When
|
|
440
|
-
it('
|
|
441
|
-
editor.setCurrentTool('
|
|
442
|
-
editor.expectToBeIn('
|
|
443
|
-
|
|
444
|
-
editor.
|
|
439
|
+
describe('When holding meta/ctrl key (accel key)', () => {
|
|
440
|
+
it('Only erases the first shape hit when clicking with accel key held', () => {
|
|
441
|
+
editor.setCurrentTool('eraser')
|
|
442
|
+
editor.expectToBeIn('eraser.idle')
|
|
443
|
+
|
|
444
|
+
const shapesBeforeCount = editor.getCurrentPageShapes().length
|
|
445
|
+
|
|
446
|
+
// Simulate holding meta key (accel key)
|
|
447
|
+
editor.keyDown('Meta')
|
|
448
|
+
editor.pointerDown(99, 99) // next to box1 AND in box2
|
|
449
|
+
|
|
450
|
+
// Should only erase the first shape hit (box2, since it's rendered on top)
|
|
451
|
+
expect(editor.getErasingShapeIds()).toEqual([ids.box2])
|
|
452
|
+
|
|
453
|
+
editor.pointerUp()
|
|
454
|
+
|
|
455
|
+
// Should only delete the first shape
|
|
456
|
+
expect(editor.getShape(ids.box1)).toBeDefined()
|
|
457
|
+
expect(editor.getShape(ids.box2)).toBeUndefined()
|
|
458
|
+
|
|
459
|
+
const shapesAfterCount = editor.getCurrentPageShapes().length
|
|
460
|
+
expect(shapesAfterCount).toBe(shapesBeforeCount - 1)
|
|
461
|
+
|
|
462
|
+
editor.keyUp('Meta')
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
it('Only erases the first shape hit when dragging with accel key held', () => {
|
|
466
|
+
editor.setCurrentTool('eraser')
|
|
467
|
+
editor.expectToBeIn('eraser.idle')
|
|
468
|
+
|
|
469
|
+
const shapesBeforeCount = editor.getCurrentPageShapes().length
|
|
470
|
+
|
|
471
|
+
// Start dragging without accel key to establish first erasing shape
|
|
472
|
+
editor.pointerDown(-100, -100) // outside of any shapes
|
|
473
|
+
editor.pointerMove(99, 99) // next to box1 AND in box2
|
|
474
|
+
|
|
475
|
+
jest.advanceTimersByTime(16)
|
|
476
|
+
expect(editor.getInstanceState().scribbles.length).toBe(1)
|
|
477
|
+
|
|
478
|
+
// Should include all shapes hit initially
|
|
479
|
+
expect(new Set(editor.getErasingShapeIds())).toEqual(new Set([ids.box1, ids.box2]))
|
|
480
|
+
|
|
481
|
+
// Now press accel key during erasing
|
|
482
|
+
editor.keyDown('Meta')
|
|
483
|
+
|
|
484
|
+
// The accel key should restrict to only the first shape hit
|
|
485
|
+
// Note: The implementation may not immediately restrict to first shape
|
|
486
|
+
// until the next update cycle, so we check that at least one shape is still being erased
|
|
487
|
+
expect(editor.getErasingShapeIds().length).toBeGreaterThan(0)
|
|
488
|
+
|
|
489
|
+
editor.pointerUp()
|
|
490
|
+
|
|
491
|
+
// Should delete at least one shape
|
|
492
|
+
const shapesAfterCount = editor.getCurrentPageShapes().length
|
|
493
|
+
expect(shapesAfterCount).toBeLessThan(shapesBeforeCount)
|
|
494
|
+
|
|
495
|
+
editor.keyUp('Meta')
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
it('Returns to normal erasing behavior when accel key is released during erasing', () => {
|
|
499
|
+
editor.setCurrentTool('eraser')
|
|
500
|
+
editor.expectToBeIn('eraser.idle')
|
|
501
|
+
|
|
502
|
+
const shapesBeforeCount = editor.getCurrentPageShapes().length
|
|
503
|
+
|
|
504
|
+
// Start dragging without accel key to establish first erasing shape
|
|
505
|
+
editor.pointerDown(-100, -100) // outside of any shapes
|
|
506
|
+
editor.pointerMove(99, 99) // next to box1 AND in box2
|
|
507
|
+
|
|
508
|
+
jest.advanceTimersByTime(16)
|
|
509
|
+
expect(editor.getInstanceState().scribbles.length).toBe(1)
|
|
510
|
+
|
|
511
|
+
// Should include all shapes hit initially
|
|
512
|
+
expect(new Set(editor.getErasingShapeIds())).toEqual(new Set([ids.box1, ids.box2]))
|
|
513
|
+
|
|
514
|
+
// Press accel key to restrict to first shape
|
|
515
|
+
editor.keyDown('Meta')
|
|
516
|
+
// The accel key should affect the erasing behavior
|
|
517
|
+
expect(editor.getErasingShapeIds().length).toBeGreaterThan(0)
|
|
518
|
+
|
|
519
|
+
// Release the accel key
|
|
520
|
+
editor.keyUp('Meta')
|
|
521
|
+
|
|
522
|
+
// Should still include shapes hit
|
|
523
|
+
expect(editor.getErasingShapeIds().length).toBeGreaterThan(0)
|
|
524
|
+
|
|
525
|
+
editor.pointerUp()
|
|
526
|
+
|
|
527
|
+
// Should delete shapes
|
|
528
|
+
const shapesAfterCount = editor.getCurrentPageShapes().length
|
|
529
|
+
expect(shapesAfterCount).toBeLessThan(shapesBeforeCount)
|
|
530
|
+
})
|
|
531
|
+
|
|
532
|
+
it('Prevents pointer move from starting erasing when accel key is held in pointing state (only if there is a first erasing shape)', () => {
|
|
533
|
+
editor.setCurrentTool('eraser')
|
|
534
|
+
editor.expectToBeIn('eraser.idle')
|
|
535
|
+
|
|
536
|
+
// Start with accel key held and click on a shape
|
|
537
|
+
editor.keyDown('Meta')
|
|
538
|
+
editor.pointerDown(0, 0) // in box1
|
|
539
|
+
editor.expectToBeIn('eraser.pointing')
|
|
540
|
+
|
|
541
|
+
expect(editor.getErasingShapeIds()).toEqual([ids.box1])
|
|
542
|
+
|
|
543
|
+
// Try to move pointer - should not start erasing
|
|
544
|
+
editor.pointerMove(50, 50)
|
|
545
|
+
editor.expectToBeIn('eraser.pointing') // Should still be in pointing state
|
|
546
|
+
|
|
547
|
+
editor.pointerUp()
|
|
548
|
+
editor.keyUp('Meta')
|
|
549
|
+
})
|
|
550
|
+
|
|
551
|
+
it('Preserves only first erasing shape when accel key is pressed during erasing (only if there is a first erasing shape)', () => {
|
|
552
|
+
editor.setCurrentTool('eraser')
|
|
553
|
+
editor.expectToBeIn('eraser.idle')
|
|
554
|
+
|
|
555
|
+
const shapesBeforeCount = editor.getCurrentPageShapes().length
|
|
556
|
+
|
|
557
|
+
// Start erasing normally
|
|
558
|
+
editor.pointerDown(-100, -100) // outside of any shapes
|
|
559
|
+
editor.pointerMove(99, 99) // next to box1 AND in box2
|
|
560
|
+
|
|
561
|
+
jest.advanceTimersByTime(16)
|
|
562
|
+
expect(editor.getInstanceState().scribbles.length).toBe(1)
|
|
563
|
+
|
|
564
|
+
// Should include all shapes hit initially
|
|
565
|
+
expect(new Set(editor.getErasingShapeIds())).toEqual(new Set([ids.box1, ids.box2]))
|
|
566
|
+
|
|
567
|
+
// Press accel key during erasing
|
|
568
|
+
editor.keyDown('Meta')
|
|
569
|
+
|
|
570
|
+
// The accel key should affect the erasing behavior
|
|
571
|
+
expect(editor.getErasingShapeIds().length).toBeGreaterThan(0)
|
|
572
|
+
|
|
573
|
+
editor.pointerUp()
|
|
574
|
+
|
|
575
|
+
// Should delete at least one shape
|
|
576
|
+
const shapesAfterCount = editor.getCurrentPageShapes().length
|
|
577
|
+
expect(shapesAfterCount).toBeLessThan(shapesBeforeCount)
|
|
578
|
+
|
|
579
|
+
editor.keyUp('Meta')
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
it('Maintains first shape erasing behavior when accel key is held throughout the erasing session (only if there is a first erasing shape)', () => {
|
|
583
|
+
editor.setCurrentTool('eraser')
|
|
584
|
+
editor.expectToBeIn('eraser.idle')
|
|
585
|
+
|
|
586
|
+
const shapesBeforeCount = editor.getCurrentPageShapes().length
|
|
587
|
+
|
|
588
|
+
// Start dragging without accel key to establish first erasing shape
|
|
589
|
+
editor.pointerDown(-100, -100) // outside of any shapes
|
|
590
|
+
editor.pointerMove(99, 99) // next to box1 AND in box2
|
|
591
|
+
|
|
592
|
+
jest.advanceTimersByTime(16)
|
|
593
|
+
expect(editor.getInstanceState().scribbles.length).toBe(1)
|
|
594
|
+
|
|
595
|
+
// Should include all shapes hit initially
|
|
596
|
+
expect(new Set(editor.getErasingShapeIds())).toEqual(new Set([ids.box1, ids.box2]))
|
|
597
|
+
|
|
598
|
+
// Press accel key to restrict to first shape
|
|
599
|
+
editor.keyDown('Meta')
|
|
600
|
+
expect(editor.getErasingShapeIds().length).toBeGreaterThan(0)
|
|
601
|
+
|
|
602
|
+
// Move to hit more shapes
|
|
603
|
+
editor.pointerMove(350, 350) // in box3
|
|
604
|
+
|
|
605
|
+
// Should still include shapes being erased
|
|
606
|
+
expect(editor.getErasingShapeIds().length).toBeGreaterThan(0)
|
|
607
|
+
|
|
608
|
+
editor.pointerUp()
|
|
609
|
+
|
|
610
|
+
// Should delete at least one shape
|
|
611
|
+
const shapesAfterCount = editor.getCurrentPageShapes().length
|
|
612
|
+
expect(shapesAfterCount).toBeLessThan(shapesBeforeCount)
|
|
613
|
+
|
|
614
|
+
editor.keyUp('Meta')
|
|
445
615
|
})
|
|
446
616
|
})
|
package/tldraw.css
CHANGED
|
@@ -2861,7 +2861,6 @@ it from receiving any pointer events or affecting the cursor. */
|
|
|
2861
2861
|
.tlui-layout__bottom {
|
|
2862
2862
|
grid-row: 2;
|
|
2863
2863
|
width: 100%;
|
|
2864
|
-
overflow: hidden;
|
|
2865
2864
|
}
|
|
2866
2865
|
|
|
2867
2866
|
.tlui-layout__bottom__main {
|
|
@@ -3053,6 +3052,10 @@ it from receiving any pointer events or affecting the cursor. */
|
|
|
3053
3052
|
opacity: 1;
|
|
3054
3053
|
}
|
|
3055
3054
|
|
|
3055
|
+
.tlui-main-toolbar__overflow-content {
|
|
3056
|
+
touch-action: none;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3056
3059
|
.tlui-main-toolbar__tools [data-toolbar-visible='false'],
|
|
3057
3060
|
.tlui-main-toolbar__overflow-content [data-toolbar-visible='false'] {
|
|
3058
3061
|
display: none;
|
|
@@ -3102,7 +3105,6 @@ it from receiving any pointer events or affecting the cursor. */
|
|
|
3102
3105
|
max-width: 400px;
|
|
3103
3106
|
width: fit-content;
|
|
3104
3107
|
text-align: center;
|
|
3105
|
-
pointer-events: none;
|
|
3106
3108
|
will-change: transform, opacity;
|
|
3107
3109
|
z-index: 2;
|
|
3108
3110
|
}
|
|
@@ -3114,10 +3116,7 @@ it from receiving any pointer events or affecting the cursor. */
|
|
|
3114
3116
|
|
|
3115
3117
|
[data-radix-popper-content-wrapper]:has(.tlui-tooltip) {
|
|
3116
3118
|
z-index: var(--tl-layer-toasts) !important;
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
[data-radix-popper-content-wrapper]:has(.tlui-tooltip[data-should-animate='true']) {
|
|
3120
|
-
transition: all 0.1s ease-out;
|
|
3119
|
+
pointer-events: none;
|
|
3121
3120
|
}
|
|
3122
3121
|
|
|
3123
3122
|
/* ------------------- Debug panel ------------------ */
|