tldraw 4.1.0-canary.e23ee15a46bc → 4.1.0-canary.e259b517a450

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.
Files changed (56) hide show
  1. package/dist-cjs/index.d.ts +16 -2
  2. package/dist-cjs/index.js +3 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/defaultEmbedDefinitions.js +2 -1
  5. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  6. package/dist-cjs/lib/defaultExternalContentHandlers.js +8 -31
  7. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  8. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +8 -82
  9. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  10. package/dist-cjs/lib/shapes/bookmark/bookmarks.js +137 -0
  11. package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +7 -0
  12. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +9 -1
  13. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  14. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -2
  15. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  16. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js +1 -1
  17. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +1 -1
  18. package/dist-cjs/lib/ui/context/actions.js +23 -29
  19. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  20. package/dist-cjs/lib/ui/version.js +3 -3
  21. package/dist-cjs/lib/ui/version.js.map +1 -1
  22. package/dist-esm/index.d.mts +16 -2
  23. package/dist-esm/index.mjs +3 -1
  24. package/dist-esm/index.mjs.map +2 -2
  25. package/dist-esm/lib/defaultEmbedDefinitions.mjs +2 -1
  26. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  27. package/dist-esm/lib/defaultExternalContentHandlers.mjs +8 -31
  28. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  29. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +10 -81
  30. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  31. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs +123 -0
  32. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +7 -0
  33. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +11 -2
  34. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  35. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -2
  36. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  37. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs +1 -1
  38. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +1 -1
  39. package/dist-esm/lib/ui/context/actions.mjs +23 -29
  40. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  41. package/dist-esm/lib/ui/version.mjs +3 -3
  42. package/dist-esm/lib/ui/version.mjs.map +1 -1
  43. package/package.json +3 -3
  44. package/src/index.ts +1 -0
  45. package/src/lib/defaultEmbedDefinitions.ts +2 -1
  46. package/src/lib/defaultExternalContentHandlers.ts +10 -35
  47. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +9 -112
  48. package/src/lib/shapes/bookmark/bookmarks.ts +170 -0
  49. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +13 -1
  50. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +6 -2
  51. package/src/lib/ui/components/StylePanel/StylePanelButtonPicker.tsx +1 -1
  52. package/src/lib/ui/context/actions.tsx +27 -31
  53. package/src/lib/ui/version.ts +3 -3
  54. package/src/lib/utils/embeds/embeds.test.ts +16 -0
  55. package/src/test/bookmark-shapes.test.ts +123 -1
  56. package/src/test/customSnapping.test.tsx +55 -11
@@ -173,6 +173,7 @@ describe('custom handle snapping', () => {
173
173
  handlePoints: VecModel[] | 'default'
174
174
  selfSnapOutline: VecModel[] | 'default'
175
175
  selfSnapPoints: VecModel[] | 'default'
176
+ handleSnapType?: 'point' | 'align'
176
177
  }
177
178
  >
178
179
  class TestShapeUtil extends BaseBoxShapeUtil<TestShape> {
@@ -213,17 +214,23 @@ describe('custom handle snapping', () => {
213
214
  }
214
215
  }
215
216
  override getHandles(shape: TestShape): TLHandle[] {
216
- return [
217
- {
218
- id: 'handle',
219
- label: 'handle',
220
- type: 'vertex',
221
- x: shape.props.ownHandle.x,
222
- y: shape.props.ownHandle.y,
223
- index: ZERO_INDEX_KEY,
224
- canSnap: true,
225
- },
226
- ]
217
+ const handle: TLHandle = {
218
+ id: 'handle',
219
+ label: 'handle',
220
+ type: 'vertex',
221
+ x: shape.props.ownHandle.x,
222
+ y: shape.props.ownHandle.y,
223
+ index: ZERO_INDEX_KEY,
224
+ }
225
+
226
+ if (shape.props.handleSnapType) {
227
+ handle.snapType = shape.props.handleSnapType
228
+ } else {
229
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
230
+ handle.canSnap = true
231
+ }
232
+
233
+ return [handle]
227
234
  }
228
235
  override onHandleDrag(shape: TestShape, { handle }: TLHandleDragInfo<TestShape>) {
229
236
  return { ...shape, props: { ...shape.props, ownHandle: { x: handle.x, y: handle.y } } }
@@ -495,5 +502,42 @@ describe('custom handle snapping', () => {
495
502
  expect(ownHandlePosition()).toMatchObject({ x: 20, y: 50 })
496
503
  })
497
504
  })
505
+
506
+ describe('with snapType set to align', () => {
507
+ beforeEach(() => {
508
+ editor.updateShape<TestShape>({
509
+ id: ids.test,
510
+ type: 'test',
511
+ props: {
512
+ selfSnapPoints: [
513
+ { x: 20, y: 50 },
514
+ { x: 60, y: 10 },
515
+ ],
516
+ handleSnapType: 'align',
517
+ },
518
+ })
519
+ })
520
+
521
+ test('snaps to the y axis', () => {
522
+ startDraggingOwnHandle()
523
+ editor.pointerMove(18, 0, undefined, { ctrlKey: true })
524
+ expect(editor.snaps.getIndicators()).toHaveLength(1)
525
+ expect(ownHandlePosition()).toMatchObject({ x: 20, y: 0 })
526
+ })
527
+
528
+ test('snaps to the x axis', () => {
529
+ startDraggingOwnHandle()
530
+ editor.pointerMove(0, 48, undefined, { ctrlKey: true })
531
+ expect(editor.snaps.getIndicators()).toHaveLength(1)
532
+ expect(ownHandlePosition()).toMatchObject({ x: 0, y: 50 })
533
+ })
534
+
535
+ test('snaps to both axes', () => {
536
+ startDraggingOwnHandle()
537
+ editor.pointerMove(18, 9, undefined, { ctrlKey: true })
538
+ expect(editor.snaps.getIndicators()).toHaveLength(2)
539
+ expect(ownHandlePosition()).toMatchObject({ x: 20, y: 10 })
540
+ })
541
+ })
498
542
  })
499
543
  })