tldraw 3.16.0-canary.7facbd2d2b7f → 3.16.0-canary.806d674b7d7a

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 (90) hide show
  1. package/dist-cjs/index.d.ts +5 -86
  2. package/dist-cjs/index.js +1 -5
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  5. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +2 -3
  6. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  7. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +1 -1
  8. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  9. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
  10. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  11. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js +2 -8
  12. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js.map +2 -2
  13. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +1 -1
  14. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  15. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +3 -2
  16. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  17. package/dist-cjs/lib/shapes/text/PlainTextArea.js +1 -2
  18. package/dist-cjs/lib/shapes/text/PlainTextArea.js.map +2 -2
  19. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -3
  20. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  21. package/dist-cjs/lib/ui/components/A11y.js +1 -1
  22. package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
  23. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  24. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  25. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +1 -1
  26. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
  27. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
  28. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  29. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +3 -3
  30. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  31. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +1 -1
  32. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  33. package/dist-cjs/lib/ui/version.js +3 -3
  34. package/dist-cjs/lib/ui/version.js.map +1 -1
  35. package/dist-esm/index.d.mts +5 -86
  36. package/dist-esm/index.mjs +1 -9
  37. package/dist-esm/index.mjs.map +2 -2
  38. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +2 -3
  39. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  40. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +1 -1
  41. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  42. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +2 -1
  43. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  44. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs +3 -9
  45. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs.map +2 -2
  46. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +2 -2
  47. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  48. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +4 -2
  49. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  50. package/dist-esm/lib/shapes/text/PlainTextArea.mjs +2 -3
  51. package/dist-esm/lib/shapes/text/PlainTextArea.mjs.map +2 -2
  52. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -3
  53. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  54. package/dist-esm/lib/ui/components/A11y.mjs +2 -1
  55. package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
  56. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  57. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  58. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +2 -1
  59. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
  60. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +2 -1
  61. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  62. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +3 -3
  63. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  64. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -1
  65. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  66. package/dist-esm/lib/ui/version.mjs +3 -3
  67. package/dist-esm/lib/ui/version.mjs.map +1 -1
  68. package/package.json +3 -3
  69. package/src/index.ts +0 -7
  70. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +13 -83
  71. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +3 -97
  72. package/src/lib/shapes/arrow/arrow-types.ts +5 -3
  73. package/src/lib/shapes/arrow/arrowTargetState.ts +3 -34
  74. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
  75. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +2 -1
  76. package/src/lib/shapes/frame/components/FrameLabelInput.tsx +3 -10
  77. package/src/lib/shapes/shared/HyperlinkButton.tsx +2 -2
  78. package/src/lib/shapes/shared/useEditablePlainText.ts +5 -2
  79. package/src/lib/shapes/text/PlainTextArea.tsx +2 -3
  80. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +2 -6
  81. package/src/lib/ui/components/A11y.tsx +2 -1
  82. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  83. package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +2 -1
  84. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +2 -1
  85. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +3 -3
  86. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -1
  87. package/src/lib/ui/version.ts +3 -3
  88. package/src/lib/ui.css +1 -14
  89. package/src/test/TestEditor.ts +2 -8
  90. package/tldraw.css +1 -14
@@ -163,7 +163,7 @@ export class Pointing extends StateNode {
163
163
  const endHandle = handles.find((h) => h.id === 'end')!
164
164
  const change = util.onHandleDrag?.(this.editor.getShape(shape)!, {
165
165
  handle: { ...endHandle, x: point.x, y: point.y },
166
- isPrecise: this.isPrecise,
166
+ isPrecise: false,
167
167
  isCreatingShape: true,
168
168
  initial: initial,
169
169
  })
@@ -13,6 +13,7 @@ import {
13
13
  debounce,
14
14
  getHashForString,
15
15
  lerp,
16
+ markEventAsHandled,
16
17
  tlenv,
17
18
  toDomPrecision,
18
19
  useEditor,
@@ -133,7 +134,7 @@ function BookmarkShapeComponent({ shape }: { shape: TLBookmarkShape }) {
133
134
 
134
135
  const markAsHandledOnShiftKey = useCallback<PointerEventHandler>(
135
136
  (e) => {
136
- if (!editor.inputs.shiftKey) editor.markEventAsHandled(e)
137
+ if (!editor.inputs.shiftKey) markEventAsHandled(e)
137
138
  },
138
139
  [editor]
139
140
  )
@@ -1,4 +1,4 @@
1
- import { TLFrameShape, TLShapeId, useEditor } from '@tldraw/editor'
1
+ import { TLFrameShape, TLShapeId, markEventAsHandled, useEditor } from '@tldraw/editor'
2
2
  import { forwardRef, useCallback } from 'react'
3
3
  import { defaultEmptyAs } from '../FrameShapeUtil'
4
4
 
@@ -8,19 +8,12 @@ export const FrameLabelInput = forwardRef<
8
8
  >(({ id, name, isEditing }, ref) => {
9
9
  const editor = useEditor()
10
10
 
11
- const handlePointerDown = useCallback(
12
- (e: React.PointerEvent) => {
13
- if (isEditing) editor.markEventAsHandled(e)
14
- },
15
- [editor, isEditing]
16
- )
17
-
18
11
  const handleKeyDown = useCallback(
19
12
  (e: React.KeyboardEvent<HTMLInputElement>) => {
20
13
  if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
21
14
  // need to prevent the enter keydown making it's way up to the Idle state
22
15
  // and sending us back into edit mode
23
- editor.markEventAsHandled(e)
16
+ markEventAsHandled(e)
24
17
  e.currentTarget.blur()
25
18
  editor.setEditingShape(null)
26
19
  }
@@ -81,7 +74,7 @@ export const FrameLabelInput = forwardRef<
81
74
  onKeyDown={handleKeyDown}
82
75
  onBlur={handleBlur}
83
76
  onChange={handleChange}
84
- onPointerDown={handlePointerDown}
77
+ onPointerDown={isEditing ? markEventAsHandled : undefined}
85
78
  draggable={false}
86
79
  />
87
80
  {defaultEmptyAs(name, 'Frame') + String.fromCharCode(8203)}
@@ -1,4 +1,4 @@
1
- import { useEditor, useValue } from '@tldraw/editor'
1
+ import { markEventAsHandled, useEditor, useValue } from '@tldraw/editor'
2
2
  import classNames from 'classnames'
3
3
  import { PointerEventHandler, useCallback } from 'react'
4
4
 
@@ -10,7 +10,7 @@ export function HyperlinkButton({ url }: { url: string }) {
10
10
  const hideButton = useValue('zoomLevel', () => editor.getZoomLevel() < 0.32, [editor])
11
11
  const markAsHandledOnShiftKey = useCallback<PointerEventHandler>(
12
12
  (e) => {
13
- if (!editor.inputs.shiftKey) editor.markEventAsHandled(e)
13
+ if (!editor.inputs.shiftKey) markEventAsHandled(e)
14
14
  },
15
15
  [editor]
16
16
  )
@@ -3,6 +3,7 @@ import {
3
3
  TLShapeId,
4
4
  TLUnknownShape,
5
5
  getPointerInfo,
6
+ markEventAsHandled,
6
7
  noop,
7
8
  preventDefault,
8
9
  tlenv,
@@ -128,7 +129,7 @@ export function useEditableTextCommon(shapeId: TLShapeId) {
128
129
  // partially if we didn't dispatch/stop below.
129
130
 
130
131
  editor.dispatch({
131
- ...getPointerInfo(editor, e),
132
+ ...getPointerInfo(e),
132
133
  type: 'pointer',
133
134
  name: 'pointer_down',
134
135
  target: 'shape',
@@ -156,11 +157,13 @@ export function useEditableTextCommon(shapeId: TLShapeId) {
156
157
  [editor, shapeId]
157
158
  )
158
159
 
160
+ const handleDoubleClick: (e: React.MouseEvent) => void = markEventAsHandled
161
+
159
162
  return {
160
163
  handleFocus: noop,
161
164
  handleBlur: noop,
162
165
  handleInputPointerDown,
163
- handleDoubleClick: editor.markEventAsHandled,
166
+ handleDoubleClick,
164
167
  handlePaste,
165
168
  isEditing,
166
169
  isReadyForEditing,
@@ -1,4 +1,4 @@
1
- import { preventDefault, useEditor } from '@tldraw/editor'
1
+ import { markEventAsHandled, preventDefault } from '@tldraw/editor'
2
2
  import React from 'react'
3
3
  import { TextAreaProps } from './RichTextArea'
4
4
 
@@ -21,7 +21,6 @@ export const PlainTextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps
21
21
  },
22
22
  ref
23
23
  ) {
24
- const editor = useEditor()
25
24
  const onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
26
25
  handleChange({ plaintext: e.target.value })
27
26
  }
@@ -47,7 +46,7 @@ export const PlainTextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps
47
46
  onChange={onChange}
48
47
  onKeyDown={(e) => handleKeyDown(e.nativeEvent)}
49
48
  onBlur={handleBlur}
50
- onTouchEnd={editor.markEventAsHandled}
49
+ onTouchEnd={markEventAsHandled}
51
50
  onContextMenu={isEditing ? (e) => e.stopPropagation() : undefined}
52
51
  onPointerDown={handleInputPointerDown}
53
52
  onPaste={handlePaste}
@@ -13,7 +13,6 @@ import {
13
13
  sortByIndex,
14
14
  structuredClone,
15
15
  } from '@tldraw/editor'
16
- import { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'
17
16
  import { clearArrowTargetState } from '../../../shapes/arrow/arrowTargetState'
18
17
  import { getArrowBindings } from '../../../shapes/arrow/shared'
19
18
 
@@ -136,13 +135,10 @@ export class DraggingHandle extends StateNode {
136
135
  }
137
136
 
138
137
  // Only relevant to arrows
139
- private exactTimeout = -1
138
+ private exactTimeout = -1 as any
140
139
 
141
140
  // Only relevant to arrows
142
141
  private resetExactTimeout() {
143
- const arrowUtil = this.editor.getShapeUtil<ArrowShapeUtil>('arrow')
144
- const timeoutValue = arrowUtil.options.pointingPreciseTimeout
145
-
146
142
  if (this.exactTimeout !== -1) {
147
143
  this.clearExactTimeout()
148
144
  }
@@ -154,7 +150,7 @@ export class DraggingHandle extends StateNode {
154
150
  this.update()
155
151
  }
156
152
  this.exactTimeout = -1
157
- }, timeoutValue)
153
+ }, 750)
158
154
  }
159
155
 
160
156
  // Only relevant to arrows
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  debugFlags,
3
3
  Editor,
4
+ markEventAsHandled,
4
5
  TLGeoShape,
5
6
  TLShapeId,
6
7
  unsafe__withoutCapture,
@@ -22,7 +23,7 @@ export function SkipToMainContent() {
22
23
 
23
24
  const handleNavigateToFirstShape = useCallback(
24
25
  (e: MouseEvent | KeyboardEvent) => {
25
- editor.markEventAsHandled(e)
26
+ markEventAsHandled(e)
26
27
  button.current?.blur()
27
28
  const shapes = editor.getCurrentPageShapesInReadingOrder()
28
29
  if (!shapes.length) return
@@ -159,7 +159,7 @@ export function DefaultMinimap() {
159
159
  type: 'pointer',
160
160
  target: 'canvas',
161
161
  name: 'pointer_move',
162
- ...getPointerInfo(editor, e),
162
+ ...getPointerInfo(e),
163
163
  point: screenPoint,
164
164
  isPen: editor.getInstanceState().isPenMode,
165
165
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  PageRecordType,
3
3
  TLPageId,
4
+ markEventAsHandled,
4
5
  releasePointerCapture,
5
6
  setPointerCapture,
6
7
  tlenv,
@@ -450,7 +451,7 @@ export const DefaultPageMenu = memo(function DefaultPageMenu() {
450
451
  if (e.key === 'Enter') {
451
452
  if (page.id === currentPage.id) {
452
453
  toggleEditing()
453
- editor.markEventAsHandled(e)
454
+ markEventAsHandled(e)
454
455
  }
455
456
  }
456
457
  }}
@@ -3,6 +3,7 @@ import {
3
3
  Box,
4
4
  clamp,
5
5
  Editor,
6
+ markEventAsHandled,
6
7
  react,
7
8
  useAtom,
8
9
  useEditor,
@@ -169,7 +170,7 @@ export const TldrawUiContextualToolbar = ({
169
170
  data-visible={false}
170
171
  data-testid="contextual-toolbar"
171
172
  className={classNames('tlui-contextual-toolbar', className)}
172
- onPointerDown={editor.markEventAsHandled}
173
+ onPointerDown={markEventAsHandled}
173
174
  >
174
175
  <TldrawUiToolbar
175
176
  orientation="horizontal"
@@ -333,7 +333,7 @@ function useDraggableEvents(
333
333
  type: 'pointer',
334
334
  target: 'canvas',
335
335
  name: 'pointer_down',
336
- ...getPointerInfo(editor, e),
336
+ ...getPointerInfo(e),
337
337
  point: screenSpaceStart,
338
338
  })
339
339
 
@@ -345,7 +345,7 @@ function useDraggableEvents(
345
345
  type: 'pointer',
346
346
  target: 'canvas',
347
347
  name: 'pointer_move',
348
- ...getPointerInfo(editor, e),
348
+ ...getPointerInfo(e),
349
349
  point: screenSpaceStart,
350
350
  })
351
351
 
@@ -365,7 +365,7 @@ function useDraggableEvents(
365
365
  type: 'pointer',
366
366
  target: 'canvas',
367
367
  name: 'pointer_up',
368
- ...getPointerInfo(editor, e),
368
+ ...getPointerInfo(e),
369
369
  })
370
370
  }
371
371
 
@@ -7,6 +7,7 @@ import {
7
7
  assert,
8
8
  compact,
9
9
  isDefined,
10
+ markEventAsHandled,
10
11
  preventDefault,
11
12
  uniq,
12
13
  useEditor,
@@ -762,7 +763,7 @@ export function useNativeClipboardEvents() {
762
763
 
763
764
  const paste = (e: ClipboardEvent) => {
764
765
  if (disablingMiddleClickPaste) {
765
- editor.markEventAsHandled(e)
766
+ markEventAsHandled(e)
766
767
  return
767
768
  }
768
769
 
@@ -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.7facbd2d2b7f'
4
+ export const version = '3.16.0-canary.806d674b7d7a'
5
5
  export const publishDates = {
6
6
  major: '2024-09-13T14:36:29.063Z',
7
- minor: '2025-09-18T12:50:07.641Z',
8
- patch: '2025-09-18T12:50:07.641Z',
7
+ minor: '2025-09-17T14:09:40.471Z',
8
+ patch: '2025-09-17T14:09:40.471Z',
9
9
  }
package/src/lib/ui.css CHANGED
@@ -168,7 +168,7 @@
168
168
  min-height: 40px;
169
169
  width: 100%;
170
170
  gap: 8px;
171
- margin-top: -4px;
171
+ margin: -4px 0px;
172
172
  }
173
173
 
174
174
  .tlui-button__menu::after {
@@ -1039,19 +1039,6 @@ tldraw? probably.
1039
1039
  display: none;
1040
1040
  }
1041
1041
 
1042
- /*
1043
- * This is used in a couple places, like Align and Vertical Align.
1044
- * It's because we have a toolbar with a Toggle Group but then an adjacent button
1045
- * next to it that opens a popup.
1046
- */
1047
- .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) {
1048
- flex-wrap: wrap;
1049
- }
1050
-
1051
- .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) .tlui-style-panel__subheading {
1052
- margin-left: -2px;
1053
- }
1054
-
1055
1042
  .tlui-style-panel__section__common:not(:only-child) {
1056
1043
  margin-bottom: 7px;
1057
1044
  border-bottom: 1px solid var(--tl-color-divider);
@@ -86,14 +86,8 @@ export class TestEditor extends Editor {
86
86
  elm.tabIndex = 0
87
87
  elm.getBoundingClientRect = () => bounds as DOMRect
88
88
 
89
- const shapeUtilsWithDefaults = [
90
- ...defaultShapeUtils.filter((s) => !options.shapeUtils?.some((su) => su.type === s.type)),
91
- ...(options.shapeUtils ?? []),
92
- ]
93
- const bindingUtilsWithDefaults = [
94
- ...defaultBindingUtils.filter((b) => !options.bindingUtils?.some((bu) => bu.type === b.type)),
95
- ...(options.bindingUtils ?? []),
96
- ]
89
+ const shapeUtilsWithDefaults = [...defaultShapeUtils, ...(options.shapeUtils ?? [])]
90
+ const bindingUtilsWithDefaults = [...defaultBindingUtils, ...(options.bindingUtils ?? [])]
97
91
 
98
92
  super({
99
93
  ...options,
package/tldraw.css CHANGED
@@ -1964,7 +1964,7 @@ it from receiving any pointer events or affecting the cursor. */
1964
1964
  min-height: 40px;
1965
1965
  width: 100%;
1966
1966
  gap: 8px;
1967
- margin-top: -4px;
1967
+ margin: -4px 0px;
1968
1968
  }
1969
1969
 
1970
1970
  .tlui-button__menu::after {
@@ -2835,19 +2835,6 @@ tldraw? probably.
2835
2835
  display: none;
2836
2836
  }
2837
2837
 
2838
- /*
2839
- * This is used in a couple places, like Align and Vertical Align.
2840
- * It's because we have a toolbar with a Toggle Group but then an adjacent button
2841
- * next to it that opens a popup.
2842
- */
2843
- .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) {
2844
- flex-wrap: wrap;
2845
- }
2846
-
2847
- .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) .tlui-style-panel__subheading {
2848
- margin-left: -2px;
2849
- }
2850
-
2851
2838
  .tlui-style-panel__section__common:not(:only-child) {
2852
2839
  margin-bottom: 7px;
2853
2840
  border-bottom: 1px solid var(--tl-color-divider);