@tldraw/editor 3.16.0-canary.b33662a7aefb → 3.16.0-canary.b534f7a12bd2

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 (69) hide show
  1. package/dist-cjs/index.d.ts +7 -101
  2. package/dist-cjs/index.js +3 -5
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +0 -4
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/editor/Editor.js +3 -99
  7. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  8. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  9. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +4 -1
  10. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
  11. package/dist-cjs/lib/license/LicenseManager.js +120 -50
  12. package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
  13. package/dist-cjs/lib/license/LicenseProvider.js +22 -0
  14. package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
  15. package/dist-cjs/lib/license/Watermark.js +68 -6
  16. package/dist-cjs/lib/license/Watermark.js.map +3 -3
  17. package/dist-cjs/lib/license/useLicenseManagerState.js.map +2 -2
  18. package/dist-cjs/lib/primitives/Vec.js +0 -4
  19. package/dist-cjs/lib/primitives/Vec.js.map +2 -2
  20. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +26 -18
  21. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  22. package/dist-cjs/lib/primitives/geometry/Group2d.js +3 -0
  23. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  24. package/dist-cjs/lib/utils/reparenting.js +2 -35
  25. package/dist-cjs/lib/utils/reparenting.js.map +3 -3
  26. package/dist-cjs/version.js +3 -3
  27. package/dist-cjs/version.js.map +1 -1
  28. package/dist-esm/index.d.mts +7 -101
  29. package/dist-esm/index.mjs +3 -5
  30. package/dist-esm/index.mjs.map +2 -2
  31. package/dist-esm/lib/TldrawEditor.mjs +0 -4
  32. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  33. package/dist-esm/lib/editor/Editor.mjs +3 -99
  34. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  35. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +4 -1
  36. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
  37. package/dist-esm/lib/license/LicenseManager.mjs +121 -51
  38. package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
  39. package/dist-esm/lib/license/LicenseProvider.mjs +23 -1
  40. package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
  41. package/dist-esm/lib/license/Watermark.mjs +68 -6
  42. package/dist-esm/lib/license/Watermark.mjs.map +3 -3
  43. package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
  44. package/dist-esm/lib/primitives/Vec.mjs +0 -4
  45. package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
  46. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +29 -19
  47. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  48. package/dist-esm/lib/primitives/geometry/Group2d.mjs +3 -0
  49. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  50. package/dist-esm/lib/utils/reparenting.mjs +3 -40
  51. package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
  52. package/dist-esm/version.mjs +3 -3
  53. package/dist-esm/version.mjs.map +1 -1
  54. package/package.json +7 -7
  55. package/src/index.ts +2 -9
  56. package/src/lib/TldrawEditor.tsx +0 -11
  57. package/src/lib/editor/Editor.ts +1 -125
  58. package/src/lib/editor/types/misc-types.ts +0 -6
  59. package/src/lib/hooks/usePassThroughMouseOverEvents.ts +4 -1
  60. package/src/lib/license/LicenseManager.test.ts +645 -382
  61. package/src/lib/license/LicenseManager.ts +173 -53
  62. package/src/lib/license/LicenseProvider.tsx +34 -1
  63. package/src/lib/license/Watermark.tsx +73 -6
  64. package/src/lib/license/useLicenseManagerState.ts +2 -2
  65. package/src/lib/primitives/Vec.ts +0 -5
  66. package/src/lib/primitives/geometry/Geometry2d.ts +49 -19
  67. package/src/lib/primitives/geometry/Group2d.ts +4 -0
  68. package/src/lib/utils/reparenting.ts +3 -69
  69. package/src/version.ts +3 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tldraw/editor",
3
3
  "description": "tldraw infinite canvas SDK (editor).",
4
- "version": "3.16.0-canary.b33662a7aefb",
4
+ "version": "3.16.0-canary.b534f7a12bd2",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -50,12 +50,12 @@
50
50
  "@tiptap/core": "^2.9.1",
51
51
  "@tiptap/pm": "^2.9.1",
52
52
  "@tiptap/react": "^2.9.1",
53
- "@tldraw/state": "3.16.0-canary.b33662a7aefb",
54
- "@tldraw/state-react": "3.16.0-canary.b33662a7aefb",
55
- "@tldraw/store": "3.16.0-canary.b33662a7aefb",
56
- "@tldraw/tlschema": "3.16.0-canary.b33662a7aefb",
57
- "@tldraw/utils": "3.16.0-canary.b33662a7aefb",
58
- "@tldraw/validate": "3.16.0-canary.b33662a7aefb",
53
+ "@tldraw/state": "3.16.0-canary.b534f7a12bd2",
54
+ "@tldraw/state-react": "3.16.0-canary.b534f7a12bd2",
55
+ "@tldraw/store": "3.16.0-canary.b534f7a12bd2",
56
+ "@tldraw/tlschema": "3.16.0-canary.b534f7a12bd2",
57
+ "@tldraw/utils": "3.16.0-canary.b534f7a12bd2",
58
+ "@tldraw/validate": "3.16.0-canary.b534f7a12bd2",
59
59
  "@types/core-js": "^2.5.8",
60
60
  "@use-gesture/react": "^10.3.1",
61
61
  "classnames": "^2.5.1",
package/src/index.ts CHANGED
@@ -268,7 +268,6 @@ export {
268
268
  type TLGetShapeAtPointOptions,
269
269
  type TLImageExportOptions,
270
270
  type TLSvgExportOptions,
271
- type TLSvgOptions,
272
271
  type TLUpdatePointerOptions,
273
272
  } from './lib/editor/types/misc-types'
274
273
  export {
@@ -331,9 +330,11 @@ export {
331
330
  type InvalidLicenseReason,
332
331
  type LicenseFromKeyResult,
333
332
  type LicenseInfo,
333
+ type LicenseState,
334
334
  type TestEnvironment,
335
335
  type ValidLicenseKeyResult,
336
336
  } from './lib/license/LicenseManager'
337
+ export { LICENSE_TIMEOUT } from './lib/license/LicenseProvider'
337
338
  export { defaultTldrawOptions, type TldrawOptions } from './lib/options'
338
339
  export {
339
340
  Box,
@@ -485,14 +486,6 @@ export { type TLStoreWithStatus } from './lib/utils/sync/StoreWithStatus'
485
486
  export { uniq } from './lib/utils/uniq'
486
487
  export { openWindow } from './lib/utils/window-open'
487
488
 
488
- /**
489
- * @deprecated Licensing is now enabled in the tldraw SDK.
490
- * @public */
491
- export function debugEnableLicensing() {
492
- // noop
493
- return
494
- }
495
-
496
489
  registerTldrawLibraryVersion(
497
490
  (globalThis as any).TLDRAW_LIBRARY_NAME,
498
491
  (globalThis as any).TLDRAW_LIBRARY_VERSION,
@@ -189,13 +189,6 @@ export interface TldrawEditorBaseProps {
189
189
  */
190
190
  deepLinks?: true | TLDeepLinkOptions
191
191
 
192
- /**
193
- * Predicate for whether or not a shape should be hidden.
194
- *
195
- * @deprecated Use {@link TldrawEditorBaseProps#getShapeVisibility} instead.
196
- */
197
- isShapeHidden?(shape: TLShape, editor: Editor): boolean
198
-
199
192
  /**
200
193
  * Provides a way to hide shapes.
201
194
  *
@@ -412,8 +405,6 @@ function TldrawEditorWithReadyStore({
412
405
  options,
413
406
  licenseKey,
414
407
  deepLinks: _deepLinks,
415
- // eslint-disable-next-line @typescript-eslint/no-deprecated
416
- isShapeHidden,
417
408
  getShapeVisibility,
418
409
  assetUrls,
419
410
  }: Required<
@@ -473,7 +464,6 @@ function TldrawEditorWithReadyStore({
473
464
  textOptions,
474
465
  options,
475
466
  licenseKey,
476
- isShapeHidden,
477
467
  getShapeVisibility,
478
468
  fontAssetUrls: assetUrls?.fonts,
479
469
  })
@@ -509,7 +499,6 @@ function TldrawEditorWithReadyStore({
509
499
  user,
510
500
  setEditor,
511
501
  licenseKey,
512
- isShapeHidden,
513
502
  getShapeVisibility,
514
503
  textOptions,
515
504
  assetUrls,
@@ -116,7 +116,6 @@ import {
116
116
  } from '../constants'
117
117
  import { exportToSvg } from '../exports/exportToSvg'
118
118
  import { getSvgAsImage } from '../exports/getSvgAsImage'
119
- import { tlenv } from '../globals/environment'
120
119
  import { tlmenus } from '../globals/menus'
121
120
  import { tltime } from '../globals/time'
122
121
  import { TldrawOptions, defaultTldrawOptions } from '../options'
@@ -244,16 +243,6 @@ export interface TLEditorOptions {
244
243
  options?: Partial<TldrawOptions>
245
244
  licenseKey?: string
246
245
  fontAssetUrls?: { [key: string]: string | undefined }
247
- /**
248
- * A predicate that should return true if the given shape should be hidden.
249
- *
250
- * @deprecated Use {@link Editor#getShapeVisibility} instead.
251
- *
252
- * @param shape - The shape to check.
253
- * @param editor - The editor instance.
254
- */
255
- isShapeHidden?(shape: TLShape, editor: Editor): boolean
256
-
257
246
  /**
258
247
  * Provides a way to hide shapes.
259
248
  *
@@ -309,21 +298,12 @@ export class Editor extends EventEmitter<TLEventMap> {
309
298
  autoFocus,
310
299
  inferDarkMode,
311
300
  options,
312
- // eslint-disable-next-line @typescript-eslint/no-deprecated
313
- isShapeHidden,
314
301
  getShapeVisibility,
315
302
  fontAssetUrls,
316
303
  }: TLEditorOptions) {
317
304
  super()
318
- assert(
319
- !(isShapeHidden && getShapeVisibility),
320
- 'Cannot use both isShapeHidden and getShapeVisibility'
321
- )
322
305
 
323
- this._getShapeVisibility = isShapeHidden
324
- ? // eslint-disable-next-line @typescript-eslint/no-deprecated
325
- (shape: TLShape, editor: Editor) => (isShapeHidden(shape, editor) ? 'hidden' : 'inherit')
326
- : getShapeVisibility
306
+ this._getShapeVisibility = getShapeVisibility
327
307
 
328
308
  this.options = { ...defaultTldrawOptions, ...options }
329
309
 
@@ -907,14 +887,6 @@ export class Editor extends EventEmitter<TLEventMap> {
907
887
  */
908
888
  readonly fonts: FontManager
909
889
 
910
- /**
911
- * A manager for the editor's environment.
912
- *
913
- * @deprecated This is deprecated and will be removed in a future version. Use the `tlenv` global export instead.
914
- * @public
915
- */
916
- readonly environment = tlenv
917
-
918
890
  /**
919
891
  * A manager for the editor's scribbles.
920
892
  *
@@ -1119,35 +1091,6 @@ export class Editor extends EventEmitter<TLEventMap> {
1119
1091
  return this.history.getNumRedos() > 0
1120
1092
  }
1121
1093
 
1122
- /**
1123
- * Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
1124
- * any redos.
1125
- *
1126
- * @example
1127
- * ```ts
1128
- * editor.mark()
1129
- * editor.mark('flip shapes')
1130
- * ```
1131
- *
1132
- * @param markId - The mark's id, usually the reason for adding the mark.
1133
- *
1134
- * @public
1135
- * @deprecated use {@link Editor.markHistoryStoppingPoint} instead
1136
- */
1137
- mark(markId?: string): this {
1138
- if (typeof markId === 'string') {
1139
- console.warn(
1140
- `[tldraw] \`editor.history.mark("${markId}")\` is deprecated. Please use \`const myMarkId = editor.markHistoryStoppingPoint()\` instead.`
1141
- )
1142
- } else {
1143
- console.warn(
1144
- '[tldraw] `editor.mark()` is deprecated. Use `editor.markHistoryStoppingPoint()` instead.'
1145
- )
1146
- }
1147
- this.history._mark(markId ?? uniqueId())
1148
- return this
1149
- }
1150
-
1151
1094
  /**
1152
1095
  * Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
1153
1096
  * any redos. You typically want to do this just before a user interaction begins or is handled.
@@ -1272,13 +1215,6 @@ export class Editor extends EventEmitter<TLEventMap> {
1272
1215
  return this
1273
1216
  }
1274
1217
 
1275
- /**
1276
- * @deprecated Use `Editor.run` instead.
1277
- */
1278
- batch(fn: () => void, opts?: TLEditorRunOptions): this {
1279
- return this.run(fn, opts)
1280
- }
1281
-
1282
1218
  /* --------------------- Errors --------------------- */
1283
1219
 
1284
1220
  /** @internal */
@@ -1580,54 +1516,6 @@ export class Editor extends EventEmitter<TLEventMap> {
1580
1516
 
1581
1517
  menus = tlmenus.forContext(this.contextId)
1582
1518
 
1583
- /**
1584
- * @deprecated Use `editor.menus.getOpenMenus` instead.
1585
- *
1586
- * @public
1587
- */
1588
- @computed getOpenMenus(): string[] {
1589
- return this.menus.getOpenMenus()
1590
- }
1591
-
1592
- /**
1593
- * @deprecated Use `editor.menus.addOpenMenu` instead.
1594
- *
1595
- * @public
1596
- */
1597
- addOpenMenu(id: string): this {
1598
- this.menus.addOpenMenu(id)
1599
- return this
1600
- }
1601
-
1602
- /**
1603
- * @deprecated Use `editor.menus.deleteOpenMenu` instead.
1604
- *
1605
- * @public
1606
- */
1607
- deleteOpenMenu(id: string): this {
1608
- this.menus.deleteOpenMenu(id)
1609
- return this
1610
- }
1611
-
1612
- /**
1613
- * @deprecated Use `editor.menus.clearOpenMenus` instead.
1614
- *
1615
- * @public
1616
- */
1617
- clearOpenMenus(): this {
1618
- this.menus.clearOpenMenus()
1619
- return this
1620
- }
1621
-
1622
- /**
1623
- * @deprecated Use `editor.menus.hasAnyOpenMenus` instead.
1624
- *
1625
- * @public
1626
- */
1627
- @computed getIsMenuOpen(): boolean {
1628
- return this.menus.hasAnyOpenMenus()
1629
- }
1630
-
1631
1519
  /* --------------------- Cursor --------------------- */
1632
1520
 
1633
1521
  /**
@@ -5839,11 +5727,6 @@ export class Editor extends EventEmitter<TLEventMap> {
5839
5727
  return shapeIds
5840
5728
  }
5841
5729
 
5842
- /** @deprecated Use {@link Editor.getDraggingOverShape} instead */
5843
- getDroppingOverShape(point: Vec, droppingShapes: TLShape[]): TLShape | undefined {
5844
- return this.getDraggingOverShape(point, droppingShapes)
5845
- }
5846
-
5847
5730
  /**
5848
5731
  * Get the shape that some shapes should be dropped on at a given point.
5849
5732
  *
@@ -9459,13 +9342,6 @@ export class Editor extends EventEmitter<TLEventMap> {
9459
9342
  }
9460
9343
  }
9461
9344
 
9462
- /** @deprecated Use {@link Editor.getSvgString} or {@link Editor.getSvgElement} instead. */
9463
- async getSvg(shapes: TLShapeId[] | TLShape[], opts: TLSvgExportOptions = {}) {
9464
- const result = await this.getSvgElement(shapes, opts)
9465
- if (!result) return undefined
9466
- return result.svg
9467
- }
9468
-
9469
9345
  /**
9470
9346
  * Get an exported image of the given shapes.
9471
9347
  *
@@ -72,12 +72,6 @@ export interface TLImageExportOptions extends TLSvgExportOptions {
72
72
  format?: TLExportType
73
73
  }
74
74
 
75
- /**
76
- * @public
77
- * @deprecated use {@link TLImageExportOptions} instead
78
- */
79
- export type TLSvgOptions = TLImageExportOptions
80
-
81
75
  /** @public */
82
76
  export interface TLCameraMoveOptions {
83
77
  /** Whether to move the camera immediately, rather than on the next tick. */
@@ -1,14 +1,17 @@
1
1
  import { RefObject, useEffect } from 'react'
2
2
  import { preventDefault } from '../utils/dom'
3
3
  import { useContainer } from './useContainer'
4
+ import { useMaybeEditor } from './useEditor'
4
5
 
5
6
  /** @public */
6
7
  export function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement>) {
7
8
  if (!ref) throw Error('usePassThroughWheelEvents must be passed a ref')
8
9
  const container = useContainer()
10
+ const editor = useMaybeEditor()
9
11
 
10
12
  useEffect(() => {
11
13
  function onMouseOver(e: MouseEvent) {
14
+ if (!editor?.getInstanceState().isFocused) return
12
15
  if ((e as any).isSpecialRedispatchedEvent) return
13
16
  preventDefault(e)
14
17
  const cvs = container.querySelector('.tl-canvas')
@@ -25,5 +28,5 @@ export function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement>) {
25
28
  return () => {
26
29
  elm.removeEventListener('mouseover', onMouseOver)
27
30
  }
28
- }, [container, ref])
31
+ }, [container, editor, ref])
29
32
  }