@tldraw/editor 3.8.0-canary.13edafe3f1e3 → 3.8.0-canary.14f2faba6b93

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 (50) hide show
  1. package/dist-cjs/index.d.ts +29 -13
  2. package/dist-cjs/index.js +2 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/editor/Editor.js +5 -3
  5. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  6. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +13 -0
  7. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  8. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  9. package/dist-cjs/lib/hooks/useCanvasEvents.js +19 -8
  10. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  11. package/dist-cjs/lib/hooks/useDocumentEvents.js +1 -3
  12. package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
  13. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +4 -0
  14. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +3 -3
  15. package/dist-cjs/lib/options.js +0 -2
  16. package/dist-cjs/lib/options.js.map +2 -2
  17. package/dist-cjs/lib/utils/dom.js +6 -0
  18. package/dist-cjs/lib/utils/dom.js.map +2 -2
  19. package/dist-cjs/version.js +3 -3
  20. package/dist-cjs/version.js.map +1 -1
  21. package/dist-esm/index.d.mts +29 -13
  22. package/dist-esm/index.mjs +3 -1
  23. package/dist-esm/index.mjs.map +2 -2
  24. package/dist-esm/lib/editor/Editor.mjs +5 -3
  25. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  26. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +13 -0
  27. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  28. package/dist-esm/lib/hooks/useCanvasEvents.mjs +19 -8
  29. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  30. package/dist-esm/lib/hooks/useDocumentEvents.mjs +2 -4
  31. package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
  32. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +4 -0
  33. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +3 -3
  34. package/dist-esm/lib/options.mjs +0 -2
  35. package/dist-esm/lib/options.mjs.map +2 -2
  36. package/dist-esm/lib/utils/dom.mjs +6 -0
  37. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  38. package/dist-esm/version.mjs +3 -3
  39. package/dist-esm/version.mjs.map +1 -1
  40. package/package.json +7 -7
  41. package/src/index.ts +3 -0
  42. package/src/lib/editor/Editor.ts +6 -4
  43. package/src/lib/editor/shapes/ShapeUtil.ts +19 -0
  44. package/src/lib/editor/types/external-content.ts +14 -0
  45. package/src/lib/hooks/useCanvasEvents.ts +20 -8
  46. package/src/lib/hooks/useDocumentEvents.ts +2 -11
  47. package/src/lib/hooks/usePassThroughWheelEvents.ts +7 -0
  48. package/src/lib/options.ts +0 -8
  49. package/src/lib/utils/dom.ts +12 -0
  50. package/src/version.ts +3 -3
@@ -117,16 +117,28 @@ export function useCanvasEvents() {
117
117
  async function onDrop(e: React.DragEvent<Element>) {
118
118
  preventDefault(e)
119
119
  stopEventPropagation(e)
120
- if (!e.dataTransfer?.files?.length) return
121
120
 
122
- const files = Array.from(e.dataTransfer.files)
121
+ if (e.dataTransfer?.files?.length) {
122
+ const files = Array.from(e.dataTransfer.files)
123
123
 
124
- await editor.putExternalContent({
125
- type: 'files',
126
- files,
127
- point: editor.screenToPage({ x: e.clientX, y: e.clientY }),
128
- ignoreParent: false,
129
- })
124
+ await editor.putExternalContent({
125
+ type: 'files',
126
+ files,
127
+ point: editor.screenToPage({ x: e.clientX, y: e.clientY }),
128
+ ignoreParent: false,
129
+ })
130
+ return
131
+ }
132
+
133
+ const url = e.dataTransfer.getData('url')
134
+ if (url) {
135
+ await editor.putExternalContent({
136
+ type: 'url',
137
+ url,
138
+ point: editor.screenToPage({ x: e.clientX, y: e.clientY }),
139
+ })
140
+ return
141
+ }
130
142
  }
131
143
 
132
144
  function onClick(e: React.MouseEvent) {
@@ -2,7 +2,7 @@ import { useValue } from '@tldraw/state-react'
2
2
  import { useEffect } from 'react'
3
3
  import { Editor } from '../editor/Editor'
4
4
  import { TLKeyboardEventInfo } from '../editor/types/event-types'
5
- import { preventDefault, stopEventPropagation } from '../utils/dom'
5
+ import { activeElementShouldCaptureKeys, preventDefault, stopEventPropagation } from '../utils/dom'
6
6
  import { isAccelKey } from '../utils/keyboard'
7
7
  import { useContainer } from './useContainer'
8
8
  import { useEditor } from './useEditor'
@@ -274,15 +274,6 @@ export function useDocumentEvents() {
274
274
  }, [editor, container, isAppFocused])
275
275
  }
276
276
 
277
- const INPUTS = ['input', 'select', 'button', 'textarea']
278
-
279
277
  function areShortcutsDisabled(editor: Editor) {
280
- const { activeElement } = document
281
-
282
- return (
283
- editor.menus.hasOpenMenus() ||
284
- (activeElement &&
285
- (activeElement.getAttribute('contenteditable') ||
286
- INPUTS.indexOf(activeElement.tagName.toLowerCase()) > -1))
287
- )
278
+ return editor.menus.hasOpenMenus() || activeElementShouldCaptureKeys()
288
279
  }
@@ -11,6 +11,13 @@ export function usePassThroughWheelEvents(ref: RefObject<HTMLElement>) {
11
11
  useEffect(() => {
12
12
  function onWheel(e: WheelEvent) {
13
13
  if ((e as any).isSpecialRedispatchedEvent) return
14
+
15
+ // if the element is scrollable, don't redispatch the event
16
+ const elm = ref.current
17
+ if (elm && elm.scrollHeight > elm.clientHeight) {
18
+ return
19
+ }
20
+
14
21
  preventDefault(e)
15
22
  const cvs = container.querySelector('.tl-canvas')
16
23
  if (!cvs) return
@@ -29,7 +29,6 @@ export interface TldrawOptions {
29
29
  readonly dragDistanceSquared: number
30
30
  readonly defaultSvgPadding: number
31
31
  readonly cameraSlideFriction: number
32
- readonly maxPointsPerDrawShape: number
33
32
  readonly gridSteps: readonly {
34
33
  readonly min: number
35
34
  readonly mid: number
@@ -66,11 +65,6 @@ export interface TldrawOptions {
66
65
  * external context providers. By default, this is `React.Fragment`.
67
66
  */
68
67
  readonly exportProvider: ComponentType<{ children: React.ReactNode }>
69
- /**
70
- * How should the note shape resize? By default it does not resize (except automatically based on its text content),
71
- * but you can set it to be user-resizable using scale.
72
- */
73
- readonly noteShapeResizeMode: 'none' | 'scale'
74
68
  /**
75
69
  * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.
76
70
  */
@@ -90,7 +84,6 @@ export const defaultTldrawOptions = {
90
84
  dragDistanceSquared: 16, // 4 squared
91
85
  defaultSvgPadding: 32,
92
86
  cameraSlideFriction: 0.09,
93
- maxPointsPerDrawShape: 500,
94
87
  gridSteps: [
95
88
  { min: -1, mid: 0.15, step: 64 },
96
89
  { min: 0.05, mid: 0.375, step: 16 },
@@ -120,6 +113,5 @@ export const defaultTldrawOptions = {
120
113
  actionShortcutsLocation: 'swap',
121
114
  createTextOnCanvasDoubleClick: true,
122
115
  exportProvider: Fragment,
123
- noteShapeResizeMode: 'none',
124
116
  enableToolbarKeyboardShortcuts: true,
125
117
  } as const satisfies TldrawOptions
@@ -90,3 +90,15 @@ export const setStyleProperty = (
90
90
  if (!elm) return
91
91
  elm.style.setProperty(property, value as string)
92
92
  }
93
+
94
+ const INPUTS = ['input', 'select', 'button', 'textarea']
95
+
96
+ /** @internal */
97
+ export function activeElementShouldCaptureKeys() {
98
+ const { activeElement } = document
99
+ return !!(
100
+ activeElement &&
101
+ (activeElement.getAttribute('contenteditable') ||
102
+ INPUTS.indexOf(activeElement.tagName.toLowerCase()) > -1)
103
+ )
104
+ }
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.8.0-canary.13edafe3f1e3'
4
+ export const version = '3.8.0-canary.14f2faba6b93'
5
5
  export const publishDates = {
6
6
  major: '2024-09-13T14:36:29.063Z',
7
- minor: '2025-02-05T15:53:12.008Z',
8
- patch: '2025-02-05T15:53:12.008Z',
7
+ minor: '2025-02-12T14:18:01.831Z',
8
+ patch: '2025-02-12T14:18:01.831Z',
9
9
  }