@tldraw/editor 3.16.0-next.df90ce0ff566 → 3.16.0-next.eafb52d15064

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 (52) hide show
  1. package/dist-cjs/index.d.ts +80 -9
  2. package/dist-cjs/index.js +3 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +2 -0
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/config/TLUserPreferences.js +8 -2
  7. package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
  8. package/dist-cjs/lib/editor/Editor.js +19 -9
  9. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  10. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +8 -3
  11. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
  12. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  13. package/dist-cjs/lib/hooks/useStateAttribute.js +35 -0
  14. package/dist-cjs/lib/hooks/useStateAttribute.js.map +7 -0
  15. package/dist-cjs/lib/options.js +1 -0
  16. package/dist-cjs/lib/options.js.map +2 -2
  17. package/dist-cjs/lib/utils/EditorAtom.js +45 -0
  18. package/dist-cjs/lib/utils/EditorAtom.js.map +7 -0
  19. package/dist-cjs/version.js +3 -3
  20. package/dist-cjs/version.js.map +1 -1
  21. package/dist-esm/index.d.mts +80 -9
  22. package/dist-esm/index.mjs +3 -1
  23. package/dist-esm/index.mjs.map +2 -2
  24. package/dist-esm/lib/TldrawEditor.mjs +2 -0
  25. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  26. package/dist-esm/lib/config/TLUserPreferences.mjs +8 -2
  27. package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
  28. package/dist-esm/lib/editor/Editor.mjs +19 -9
  29. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  30. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +8 -3
  31. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
  32. package/dist-esm/lib/hooks/useStateAttribute.mjs +15 -0
  33. package/dist-esm/lib/hooks/useStateAttribute.mjs.map +7 -0
  34. package/dist-esm/lib/options.mjs +1 -0
  35. package/dist-esm/lib/options.mjs.map +2 -2
  36. package/dist-esm/lib/utils/EditorAtom.mjs +25 -0
  37. package/dist-esm/lib/utils/EditorAtom.mjs.map +7 -0
  38. package/dist-esm/version.mjs +3 -3
  39. package/dist-esm/version.mjs.map +1 -1
  40. package/editor.css +2 -0
  41. package/package.json +7 -7
  42. package/src/index.ts +2 -0
  43. package/src/lib/TldrawEditor.tsx +2 -0
  44. package/src/lib/config/TLUserPreferences.ts +7 -0
  45. package/src/lib/editor/Editor.ts +33 -27
  46. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +13 -0
  47. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +5 -0
  48. package/src/lib/editor/types/misc-types.ts +54 -1
  49. package/src/lib/hooks/useStateAttribute.ts +15 -0
  50. package/src/lib/options.ts +2 -0
  51. package/src/lib/utils/EditorAtom.ts +37 -0
  52. package/src/version.ts +3 -3
@@ -46,10 +46,10 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
46
46
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
47
47
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
48
48
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
49
- var _getIsPasteAtCursorMode_dec, _getIsDynamicResizeMode_dec, _getIsWrapMode_dec, _getIsSnapMode_dec, _getColor_dec, _getLocale_dec, _getName_dec, _getId_dec, _getAreKeyboardShortcutsEnabled_dec, _getAnimationSpeed_dec, _getEdgeScrollSpeed_dec, _getIsDarkMode_dec, _getUserPreferences_dec, _init;
49
+ var _getShowUiLabels_dec, _getIsPasteAtCursorMode_dec, _getIsDynamicResizeMode_dec, _getIsWrapMode_dec, _getIsSnapMode_dec, _getColor_dec, _getLocale_dec, _getName_dec, _getId_dec, _getAreKeyboardShortcutsEnabled_dec, _getAnimationSpeed_dec, _getEdgeScrollSpeed_dec, _getIsDarkMode_dec, _getUserPreferences_dec, _init;
50
50
  import { atom, computed } from "@tldraw/state";
51
51
  import { defaultUserPreferences } from "../../../config/TLUserPreferences.mjs";
52
- _getUserPreferences_dec = [computed], _getIsDarkMode_dec = [computed], _getEdgeScrollSpeed_dec = [computed], _getAnimationSpeed_dec = [computed], _getAreKeyboardShortcutsEnabled_dec = [computed], _getId_dec = [computed], _getName_dec = [computed], _getLocale_dec = [computed], _getColor_dec = [computed], _getIsSnapMode_dec = [computed], _getIsWrapMode_dec = [computed], _getIsDynamicResizeMode_dec = [computed], _getIsPasteAtCursorMode_dec = [computed];
52
+ _getUserPreferences_dec = [computed], _getIsDarkMode_dec = [computed], _getEdgeScrollSpeed_dec = [computed], _getAnimationSpeed_dec = [computed], _getAreKeyboardShortcutsEnabled_dec = [computed], _getId_dec = [computed], _getName_dec = [computed], _getLocale_dec = [computed], _getColor_dec = [computed], _getIsSnapMode_dec = [computed], _getIsWrapMode_dec = [computed], _getIsDynamicResizeMode_dec = [computed], _getIsPasteAtCursorMode_dec = [computed], _getShowUiLabels_dec = [computed];
53
53
  class UserPreferencesManager {
54
54
  constructor(user, inferDarkMode) {
55
55
  this.user = user;
@@ -93,7 +93,8 @@ class UserPreferencesManager {
93
93
  colorScheme: this.user.userPreferences.get().colorScheme,
94
94
  isDarkMode: this.getIsDarkMode(),
95
95
  isWrapMode: this.getIsWrapMode(),
96
- isDynamicResizeMode: this.getIsDynamicResizeMode()
96
+ isDynamicResizeMode: this.getIsDynamicResizeMode(),
97
+ showUiLabels: this.getShowUiLabels()
97
98
  };
98
99
  }
99
100
  getIsDarkMode() {
@@ -141,6 +142,9 @@ class UserPreferencesManager {
141
142
  getIsPasteAtCursorMode() {
142
143
  return this.user.userPreferences.get().isPasteAtCursorMode ?? defaultUserPreferences.isPasteAtCursorMode;
143
144
  }
145
+ getShowUiLabels() {
146
+ return this.user.userPreferences.get().showUiLabels ?? defaultUserPreferences.showUiLabels;
147
+ }
144
148
  }
145
149
  _init = __decoratorStart(null);
146
150
  __decorateElement(_init, 1, "getUserPreferences", _getUserPreferences_dec, UserPreferencesManager);
@@ -156,6 +160,7 @@ __decorateElement(_init, 1, "getIsSnapMode", _getIsSnapMode_dec, UserPreferences
156
160
  __decorateElement(_init, 1, "getIsWrapMode", _getIsWrapMode_dec, UserPreferencesManager);
157
161
  __decorateElement(_init, 1, "getIsDynamicResizeMode", _getIsDynamicResizeMode_dec, UserPreferencesManager);
158
162
  __decorateElement(_init, 1, "getIsPasteAtCursorMode", _getIsPasteAtCursorMode_dec, UserPreferencesManager);
163
+ __decorateElement(_init, 1, "getShowUiLabels", _getShowUiLabels_dec, UserPreferencesManager);
159
164
  __decoratorMetadata(_init, UserPreferencesManager);
160
165
  export {
161
166
  UserPreferencesManager
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts"],
4
- "sourcesContent": ["import { atom, computed } from '@tldraw/state'\nimport { TLUserPreferences, defaultUserPreferences } from '../../../config/TLUserPreferences'\nimport { TLUser } from '../../../config/createTLUser'\n\n/** @public */\nexport class UserPreferencesManager {\n\tsystemColorScheme = atom<'dark' | 'light'>('systemColorScheme', 'light')\n\tdisposables = new Set<() => void>()\n\tdispose() {\n\t\tthis.disposables.forEach((d) => d())\n\t}\n\tconstructor(\n\t\tprivate readonly user: TLUser,\n\t\tprivate readonly inferDarkMode: boolean\n\t) {\n\t\tif (typeof window === 'undefined' || !('matchMedia' in window)) return\n\n\t\tconst darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)')\n\t\tif (darkModeMediaQuery?.matches) {\n\t\t\tthis.systemColorScheme.set('dark')\n\t\t}\n\t\tconst handleChange = (e: MediaQueryListEvent) => {\n\t\t\tif (e.matches) {\n\t\t\t\tthis.systemColorScheme.set('dark')\n\t\t\t} else {\n\t\t\t\tthis.systemColorScheme.set('light')\n\t\t\t}\n\t\t}\n\t\tdarkModeMediaQuery?.addEventListener('change', handleChange)\n\t\tthis.disposables.add(() => darkModeMediaQuery?.removeEventListener('change', handleChange))\n\t}\n\n\tupdateUserPreferences(userPreferences: Partial<TLUserPreferences>) {\n\t\tthis.user.setUserPreferences({\n\t\t\t...this.user.userPreferences.get(),\n\t\t\t...userPreferences,\n\t\t})\n\t}\n\t@computed getUserPreferences() {\n\t\treturn {\n\t\t\tid: this.getId(),\n\t\t\tname: this.getName(),\n\t\t\tlocale: this.getLocale(),\n\t\t\tcolor: this.getColor(),\n\t\t\tanimationSpeed: this.getAnimationSpeed(),\n\t\t\tareKeyboardShortcutsEnabled: this.getAreKeyboardShortcutsEnabled(),\n\t\t\tisSnapMode: this.getIsSnapMode(),\n\t\t\tcolorScheme: this.user.userPreferences.get().colorScheme,\n\t\t\tisDarkMode: this.getIsDarkMode(),\n\t\t\tisWrapMode: this.getIsWrapMode(),\n\t\t\tisDynamicResizeMode: this.getIsDynamicResizeMode(),\n\t\t}\n\t}\n\n\t@computed getIsDarkMode() {\n\t\tswitch (this.user.userPreferences.get().colorScheme) {\n\t\t\tcase 'dark':\n\t\t\t\treturn true\n\t\t\tcase 'light':\n\t\t\t\treturn false\n\t\t\tcase 'system':\n\t\t\t\treturn this.systemColorScheme.get() === 'dark'\n\t\t\tdefault:\n\t\t\t\treturn this.inferDarkMode ? this.systemColorScheme.get() === 'dark' : false\n\t\t}\n\t}\n\n\t/**\n\t * The speed at which the user can scroll by dragging toward the edge of the screen.\n\t */\n\t@computed getEdgeScrollSpeed() {\n\t\treturn this.user.userPreferences.get().edgeScrollSpeed ?? defaultUserPreferences.edgeScrollSpeed\n\t}\n\n\t@computed getAnimationSpeed() {\n\t\treturn this.user.userPreferences.get().animationSpeed ?? defaultUserPreferences.animationSpeed\n\t}\n\n\t@computed getAreKeyboardShortcutsEnabled() {\n\t\treturn (\n\t\t\tthis.user.userPreferences.get().areKeyboardShortcutsEnabled ??\n\t\t\tdefaultUserPreferences.areKeyboardShortcutsEnabled\n\t\t)\n\t}\n\n\t@computed getId() {\n\t\treturn this.user.userPreferences.get().id\n\t}\n\n\t@computed getName() {\n\t\treturn this.user.userPreferences.get().name?.trim() ?? defaultUserPreferences.name\n\t}\n\n\t@computed getLocale() {\n\t\treturn this.user.userPreferences.get().locale ?? defaultUserPreferences.locale\n\t}\n\n\t@computed getColor() {\n\t\treturn this.user.userPreferences.get().color ?? defaultUserPreferences.color\n\t}\n\n\t@computed getIsSnapMode() {\n\t\treturn this.user.userPreferences.get().isSnapMode ?? defaultUserPreferences.isSnapMode\n\t}\n\n\t@computed getIsWrapMode() {\n\t\treturn this.user.userPreferences.get().isWrapMode ?? defaultUserPreferences.isWrapMode\n\t}\n\n\t@computed getIsDynamicResizeMode() {\n\t\treturn (\n\t\t\tthis.user.userPreferences.get().isDynamicSizeMode ?? defaultUserPreferences.isDynamicSizeMode\n\t\t)\n\t}\n\n\t@computed getIsPasteAtCursorMode() {\n\t\treturn (\n\t\t\tthis.user.userPreferences.get().isPasteAtCursorMode ??\n\t\t\tdefaultUserPreferences.isPasteAtCursorMode\n\t\t)\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,MAAM,gBAAgB;AAC/B,SAA4B,8BAA8B;AAqCzD,2BAAC,WAgBD,sBAAC,WAgBD,2BAAC,WAID,0BAAC,WAID,uCAAC,WAOD,cAAC,WAID,gBAAC,WAID,kBAAC,WAID,iBAAC,WAID,sBAAC,WAID,sBAAC,WAID,+BAAC,WAMD,+BAAC;AA9GK,MA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IAAI,EAAE,uBAChC,uBAAuB;AAAA,EAEzB;AACD;AApHO;AAiCI,kDAAV,yBAjCY;AAiDF,6CAAV,oBAjDY;AAiEF,kDAAV,yBAjEY;AAqEF,iDAAV,wBArEY;AAyEF,8DAAV,qCAzEY;AAgFF,qCAAV,YAhFY;AAoFF,uCAAV,cApFY;AAwFF,yCAAV,gBAxFY;AA4FF,wCAAV,eA5FY;AAgGF,6CAAV,oBAhGY;AAoGF,6CAAV,oBApGY;AAwGF,sDAAV,6BAxGY;AA8GF,sDAAV,6BA9GY;AAAN,2BAAM;",
4
+ "sourcesContent": ["import { atom, computed } from '@tldraw/state'\nimport { TLUserPreferences, defaultUserPreferences } from '../../../config/TLUserPreferences'\nimport { TLUser } from '../../../config/createTLUser'\n\n/** @public */\nexport class UserPreferencesManager {\n\tsystemColorScheme = atom<'dark' | 'light'>('systemColorScheme', 'light')\n\tdisposables = new Set<() => void>()\n\tdispose() {\n\t\tthis.disposables.forEach((d) => d())\n\t}\n\tconstructor(\n\t\tprivate readonly user: TLUser,\n\t\tprivate readonly inferDarkMode: boolean\n\t) {\n\t\tif (typeof window === 'undefined' || !('matchMedia' in window)) return\n\n\t\tconst darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)')\n\t\tif (darkModeMediaQuery?.matches) {\n\t\t\tthis.systemColorScheme.set('dark')\n\t\t}\n\t\tconst handleChange = (e: MediaQueryListEvent) => {\n\t\t\tif (e.matches) {\n\t\t\t\tthis.systemColorScheme.set('dark')\n\t\t\t} else {\n\t\t\t\tthis.systemColorScheme.set('light')\n\t\t\t}\n\t\t}\n\t\tdarkModeMediaQuery?.addEventListener('change', handleChange)\n\t\tthis.disposables.add(() => darkModeMediaQuery?.removeEventListener('change', handleChange))\n\t}\n\n\tupdateUserPreferences(userPreferences: Partial<TLUserPreferences>) {\n\t\tthis.user.setUserPreferences({\n\t\t\t...this.user.userPreferences.get(),\n\t\t\t...userPreferences,\n\t\t})\n\t}\n\t@computed getUserPreferences() {\n\t\treturn {\n\t\t\tid: this.getId(),\n\t\t\tname: this.getName(),\n\t\t\tlocale: this.getLocale(),\n\t\t\tcolor: this.getColor(),\n\t\t\tanimationSpeed: this.getAnimationSpeed(),\n\t\t\tareKeyboardShortcutsEnabled: this.getAreKeyboardShortcutsEnabled(),\n\t\t\tisSnapMode: this.getIsSnapMode(),\n\t\t\tcolorScheme: this.user.userPreferences.get().colorScheme,\n\t\t\tisDarkMode: this.getIsDarkMode(),\n\t\t\tisWrapMode: this.getIsWrapMode(),\n\t\t\tisDynamicResizeMode: this.getIsDynamicResizeMode(),\n\t\t\tshowUiLabels: this.getShowUiLabels(),\n\t\t}\n\t}\n\n\t@computed getIsDarkMode() {\n\t\tswitch (this.user.userPreferences.get().colorScheme) {\n\t\t\tcase 'dark':\n\t\t\t\treturn true\n\t\t\tcase 'light':\n\t\t\t\treturn false\n\t\t\tcase 'system':\n\t\t\t\treturn this.systemColorScheme.get() === 'dark'\n\t\t\tdefault:\n\t\t\t\treturn this.inferDarkMode ? this.systemColorScheme.get() === 'dark' : false\n\t\t}\n\t}\n\n\t/**\n\t * The speed at which the user can scroll by dragging toward the edge of the screen.\n\t */\n\t@computed getEdgeScrollSpeed() {\n\t\treturn this.user.userPreferences.get().edgeScrollSpeed ?? defaultUserPreferences.edgeScrollSpeed\n\t}\n\n\t@computed getAnimationSpeed() {\n\t\treturn this.user.userPreferences.get().animationSpeed ?? defaultUserPreferences.animationSpeed\n\t}\n\n\t@computed getAreKeyboardShortcutsEnabled() {\n\t\treturn (\n\t\t\tthis.user.userPreferences.get().areKeyboardShortcutsEnabled ??\n\t\t\tdefaultUserPreferences.areKeyboardShortcutsEnabled\n\t\t)\n\t}\n\n\t@computed getId() {\n\t\treturn this.user.userPreferences.get().id\n\t}\n\n\t@computed getName() {\n\t\treturn this.user.userPreferences.get().name?.trim() ?? defaultUserPreferences.name\n\t}\n\n\t@computed getLocale() {\n\t\treturn this.user.userPreferences.get().locale ?? defaultUserPreferences.locale\n\t}\n\n\t@computed getColor() {\n\t\treturn this.user.userPreferences.get().color ?? defaultUserPreferences.color\n\t}\n\n\t@computed getIsSnapMode() {\n\t\treturn this.user.userPreferences.get().isSnapMode ?? defaultUserPreferences.isSnapMode\n\t}\n\n\t@computed getIsWrapMode() {\n\t\treturn this.user.userPreferences.get().isWrapMode ?? defaultUserPreferences.isWrapMode\n\t}\n\n\t@computed getIsDynamicResizeMode() {\n\t\treturn (\n\t\t\tthis.user.userPreferences.get().isDynamicSizeMode ?? defaultUserPreferences.isDynamicSizeMode\n\t\t)\n\t}\n\n\t@computed getIsPasteAtCursorMode() {\n\t\treturn (\n\t\t\tthis.user.userPreferences.get().isPasteAtCursorMode ??\n\t\t\tdefaultUserPreferences.isPasteAtCursorMode\n\t\t)\n\t}\n\n\t@computed getShowUiLabels() {\n\t\treturn this.user.userPreferences.get().showUiLabels ?? defaultUserPreferences.showUiLabels\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,MAAM,gBAAgB;AAC/B,SAA4B,8BAA8B;AAqCzD,2BAAC,WAiBD,sBAAC,WAgBD,2BAAC,WAID,0BAAC,WAID,uCAAC,WAOD,cAAC,WAID,gBAAC,WAID,kBAAC,WAID,iBAAC,WAID,sBAAC,WAID,sBAAC,WAID,+BAAC,WAMD,+BAAC,WAOD,wBAAC;AAtHK,MAAM,uBAAuB;AAAA,EAMnC,YACkB,MACA,eAChB;AAFgB;AACA;AARZ;AACN,6CAAoB,KAAuB,qBAAqB,OAAO;AACvE,uCAAc,oBAAI,IAAgB;AAQjC,QAAI,OAAO,WAAW,eAAe,EAAE,gBAAgB,QAAS;AAEhE,UAAM,qBAAqB,OAAO,WAAW,8BAA8B;AAC3E,QAAI,oBAAoB,SAAS;AAChC,WAAK,kBAAkB,IAAI,MAAM;AAAA,IAClC;AACA,UAAM,eAAe,CAAC,MAA2B;AAChD,UAAI,EAAE,SAAS;AACd,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AAV,gBAzFY;AA6FF,wCAAV,eA7FY;AAiGF,6CAAV,oBAjGY;AAqGF,6CAAV,oBArGY;AAyGF,sDAAV,6BAzGY;AA+GF,sDAAV,6BA/GY;AAsHF,+CAAV,sBAtHY;AAAN,2BAAM;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,15 @@
1
+ import { react } from "@tldraw/state";
2
+ import { useLayoutEffect } from "react";
3
+ import { useEditor } from "./useEditor.mjs";
4
+ function useStateAttribute() {
5
+ const editor = useEditor();
6
+ useLayoutEffect(() => {
7
+ return react("stateAttribute", () => {
8
+ editor.getContainer().setAttribute("data-state", editor.getPath());
9
+ });
10
+ }, [editor]);
11
+ }
12
+ export {
13
+ useStateAttribute
14
+ };
15
+ //# sourceMappingURL=useStateAttribute.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/hooks/useStateAttribute.ts"],
4
+ "sourcesContent": ["import { react } from '@tldraw/state'\nimport { useLayoutEffect } from 'react'\nimport { useEditor } from './useEditor'\n\nexport function useStateAttribute() {\n\tconst editor = useEditor()\n\n\t// we use a layout effect because we don't want there to be any perceptible delay between the\n\t// editor mounting and this attribute being applied, because styles may depend on it:\n\tuseLayoutEffect(() => {\n\t\treturn react('stateAttribute', () => {\n\t\t\teditor.getContainer().setAttribute('data-state', editor.getPath())\n\t\t})\n\t}, [editor])\n}\n"],
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAEnB,SAAS,oBAAoB;AACnC,QAAM,SAAS,UAAU;AAIzB,kBAAgB,MAAM;AACrB,WAAO,MAAM,kBAAkB,MAAM;AACpC,aAAO,aAAa,EAAE,aAAa,cAAc,OAAO,QAAQ,CAAC;AAAA,IAClE,CAAC;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AACZ;",
6
+ "names": []
7
+ }
@@ -38,6 +38,7 @@ const defaultTldrawOptions = {
38
38
  flattenImageBoundsPadding: 16,
39
39
  laserDelayMs: 1200,
40
40
  maxExportDelayMs: 5e3,
41
+ tooltipDelayMs: 700,
41
42
  temporaryAssetPreviewLifetimeMs: 18e4,
42
43
  actionShortcutsLocation: "swap",
43
44
  createTextOnCanvasDoubleClick: true,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/options.ts"],
4
- "sourcesContent": ["import { ComponentType, Fragment } from 'react'\n\n/**\n * Options for configuring tldraw. For defaults, see {@link defaultTldrawOptions}.\n *\n * @example\n * ```tsx\n * const options: Partial<TldrawOptions> = {\n * maxPages: 3,\n * maxShapesPerPage: 1000,\n * }\n *\n * function MyTldrawComponent() {\n * return <Tldraw options={options} />\n * }\n * ```\n *\n * @public\n */\nexport interface TldrawOptions {\n\treadonly maxShapesPerPage: number\n\treadonly maxFilesAtOnce: number\n\treadonly maxPages: number\n\treadonly animationMediumMs: number\n\treadonly followChaseViewportSnap: number\n\treadonly doubleClickDurationMs: number\n\treadonly multiClickDurationMs: number\n\treadonly coarseDragDistanceSquared: number\n\treadonly dragDistanceSquared: number\n\treadonly defaultSvgPadding: number\n\treadonly cameraSlideFriction: number\n\treadonly gridSteps: readonly {\n\t\treadonly min: number\n\t\treadonly mid: number\n\t\treadonly step: number\n\t}[]\n\treadonly collaboratorInactiveTimeoutMs: number\n\treadonly collaboratorIdleTimeoutMs: number\n\treadonly collaboratorCheckIntervalMs: number\n\treadonly cameraMovingTimeoutMs: number\n\treadonly hitTestMargin: number\n\treadonly edgeScrollDelay: number\n\treadonly edgeScrollEaseDuration: number\n\treadonly edgeScrollSpeed: number\n\treadonly edgeScrollDistance: number\n\treadonly coarsePointerWidth: number\n\treadonly coarseHandleRadius: number\n\treadonly handleRadius: number\n\treadonly longPressDurationMs: number\n\treadonly textShadowLod: number\n\treadonly adjacentShapeMargin: number\n\treadonly flattenImageBoundsExpand: number\n\treadonly flattenImageBoundsPadding: number\n\treadonly laserDelayMs: number\n\treadonly maxExportDelayMs: number\n\t/**\n\t * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before\n\t * they expire? Defaults to 3 minutes.\n\t */\n\treadonly temporaryAssetPreviewLifetimeMs: number\n\treadonly actionShortcutsLocation: 'menu' | 'toolbar' | 'swap'\n\treadonly createTextOnCanvasDoubleClick: boolean\n\t/**\n\t * The react provider to use when exporting an image. This is useful if your shapes depend on\n\t * external context providers. By default, this is `React.Fragment`.\n\t */\n\treadonly exportProvider: ComponentType<{ children: React.ReactNode }>\n\t/**\n\t * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.\n\t */\n\treadonly enableToolbarKeyboardShortcuts: boolean\n\t/**\n\t * The maximum number of fonts that will be loaded while blocking the main rendering of the\n\t * canvas. If there are more than this number of fonts needed, we'll just show the canvas right\n\t * away and let the fonts load in in the background.\n\t */\n\treadonly maxFontsToLoadBeforeRender: number\n\t/**\n\t * If you have a CSP policy that blocks inline styles, you can use this prop to provide a\n\t * nonce to use in the editor's styles.\n\t */\n\treadonly nonce: string | undefined\n\t/**\n\t * Branding name of the app, currently only used for adding aria-label for the application.\n\t */\n\treadonly branding?: string\n}\n\n/** @public */\nexport const defaultTldrawOptions = {\n\tmaxShapesPerPage: 4000,\n\tmaxFilesAtOnce: 100,\n\tmaxPages: 40,\n\tanimationMediumMs: 320,\n\tfollowChaseViewportSnap: 2,\n\tdoubleClickDurationMs: 450,\n\tmultiClickDurationMs: 200,\n\tcoarseDragDistanceSquared: 36, // 6 squared\n\tdragDistanceSquared: 16, // 4 squared\n\tdefaultSvgPadding: 32,\n\tcameraSlideFriction: 0.09,\n\tgridSteps: [\n\t\t{ min: -1, mid: 0.15, step: 64 },\n\t\t{ min: 0.05, mid: 0.375, step: 16 },\n\t\t{ min: 0.15, mid: 1, step: 4 },\n\t\t{ min: 0.7, mid: 2.5, step: 1 },\n\t],\n\tcollaboratorInactiveTimeoutMs: 60000,\n\tcollaboratorIdleTimeoutMs: 3000,\n\tcollaboratorCheckIntervalMs: 1200,\n\tcameraMovingTimeoutMs: 64,\n\thitTestMargin: 8,\n\tedgeScrollDelay: 200,\n\tedgeScrollEaseDuration: 200,\n\tedgeScrollSpeed: 25,\n\tedgeScrollDistance: 8,\n\tcoarsePointerWidth: 12,\n\tcoarseHandleRadius: 20,\n\thandleRadius: 12,\n\tlongPressDurationMs: 500,\n\ttextShadowLod: 0.35,\n\tadjacentShapeMargin: 10,\n\tflattenImageBoundsExpand: 64,\n\tflattenImageBoundsPadding: 16,\n\tlaserDelayMs: 1200,\n\tmaxExportDelayMs: 5000,\n\ttemporaryAssetPreviewLifetimeMs: 180000,\n\tactionShortcutsLocation: 'swap',\n\tcreateTextOnCanvasDoubleClick: true,\n\texportProvider: Fragment,\n\tenableToolbarKeyboardShortcuts: true,\n\tmaxFontsToLoadBeforeRender: Infinity,\n\tnonce: undefined,\n} as const satisfies TldrawOptions\n"],
5
- "mappings": "AAAA,SAAwB,gBAAgB;AAyFjC,MAAM,uBAAuB;AAAA,EACnC,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA;AAAA,EAC3B,qBAAqB;AAAA;AAAA,EACrB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,WAAW;AAAA,IACV,EAAE,KAAK,IAAI,KAAK,MAAM,MAAM,GAAG;AAAA,IAC/B,EAAE,KAAK,MAAM,KAAK,OAAO,MAAM,GAAG;AAAA,IAClC,EAAE,KAAK,MAAM,KAAK,GAAG,MAAM,EAAE;AAAA,IAC7B,EAAE,KAAK,KAAK,KAAK,KAAK,MAAM,EAAE;AAAA,EAC/B;AAAA,EACA,+BAA+B;AAAA,EAC/B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,iCAAiC;AAAA,EACjC,yBAAyB;AAAA,EACzB,+BAA+B;AAAA,EAC/B,gBAAgB;AAAA,EAChB,gCAAgC;AAAA,EAChC,4BAA4B;AAAA,EAC5B,OAAO;AACR;",
4
+ "sourcesContent": ["import { ComponentType, Fragment } from 'react'\n\n/**\n * Options for configuring tldraw. For defaults, see {@link defaultTldrawOptions}.\n *\n * @example\n * ```tsx\n * const options: Partial<TldrawOptions> = {\n * maxPages: 3,\n * maxShapesPerPage: 1000,\n * }\n *\n * function MyTldrawComponent() {\n * return <Tldraw options={options} />\n * }\n * ```\n *\n * @public\n */\nexport interface TldrawOptions {\n\treadonly maxShapesPerPage: number\n\treadonly maxFilesAtOnce: number\n\treadonly maxPages: number\n\treadonly animationMediumMs: number\n\treadonly followChaseViewportSnap: number\n\treadonly doubleClickDurationMs: number\n\treadonly multiClickDurationMs: number\n\treadonly coarseDragDistanceSquared: number\n\treadonly dragDistanceSquared: number\n\treadonly defaultSvgPadding: number\n\treadonly cameraSlideFriction: number\n\treadonly gridSteps: readonly {\n\t\treadonly min: number\n\t\treadonly mid: number\n\t\treadonly step: number\n\t}[]\n\treadonly collaboratorInactiveTimeoutMs: number\n\treadonly collaboratorIdleTimeoutMs: number\n\treadonly collaboratorCheckIntervalMs: number\n\treadonly cameraMovingTimeoutMs: number\n\treadonly hitTestMargin: number\n\treadonly edgeScrollDelay: number\n\treadonly edgeScrollEaseDuration: number\n\treadonly edgeScrollSpeed: number\n\treadonly edgeScrollDistance: number\n\treadonly coarsePointerWidth: number\n\treadonly coarseHandleRadius: number\n\treadonly handleRadius: number\n\treadonly longPressDurationMs: number\n\treadonly textShadowLod: number\n\treadonly adjacentShapeMargin: number\n\treadonly flattenImageBoundsExpand: number\n\treadonly flattenImageBoundsPadding: number\n\treadonly laserDelayMs: number\n\treadonly maxExportDelayMs: number\n\treadonly tooltipDelayMs: number\n\t/**\n\t * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before\n\t * they expire? Defaults to 3 minutes.\n\t */\n\treadonly temporaryAssetPreviewLifetimeMs: number\n\treadonly actionShortcutsLocation: 'menu' | 'toolbar' | 'swap'\n\treadonly createTextOnCanvasDoubleClick: boolean\n\t/**\n\t * The react provider to use when exporting an image. This is useful if your shapes depend on\n\t * external context providers. By default, this is `React.Fragment`.\n\t */\n\treadonly exportProvider: ComponentType<{ children: React.ReactNode }>\n\t/**\n\t * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.\n\t */\n\treadonly enableToolbarKeyboardShortcuts: boolean\n\t/**\n\t * The maximum number of fonts that will be loaded while blocking the main rendering of the\n\t * canvas. If there are more than this number of fonts needed, we'll just show the canvas right\n\t * away and let the fonts load in in the background.\n\t */\n\treadonly maxFontsToLoadBeforeRender: number\n\t/**\n\t * If you have a CSP policy that blocks inline styles, you can use this prop to provide a\n\t * nonce to use in the editor's styles.\n\t */\n\treadonly nonce: string | undefined\n\t/**\n\t * Branding name of the app, currently only used for adding aria-label for the application.\n\t */\n\treadonly branding?: string\n}\n\n/** @public */\nexport const defaultTldrawOptions = {\n\tmaxShapesPerPage: 4000,\n\tmaxFilesAtOnce: 100,\n\tmaxPages: 40,\n\tanimationMediumMs: 320,\n\tfollowChaseViewportSnap: 2,\n\tdoubleClickDurationMs: 450,\n\tmultiClickDurationMs: 200,\n\tcoarseDragDistanceSquared: 36, // 6 squared\n\tdragDistanceSquared: 16, // 4 squared\n\tdefaultSvgPadding: 32,\n\tcameraSlideFriction: 0.09,\n\tgridSteps: [\n\t\t{ min: -1, mid: 0.15, step: 64 },\n\t\t{ min: 0.05, mid: 0.375, step: 16 },\n\t\t{ min: 0.15, mid: 1, step: 4 },\n\t\t{ min: 0.7, mid: 2.5, step: 1 },\n\t],\n\tcollaboratorInactiveTimeoutMs: 60000,\n\tcollaboratorIdleTimeoutMs: 3000,\n\tcollaboratorCheckIntervalMs: 1200,\n\tcameraMovingTimeoutMs: 64,\n\thitTestMargin: 8,\n\tedgeScrollDelay: 200,\n\tedgeScrollEaseDuration: 200,\n\tedgeScrollSpeed: 25,\n\tedgeScrollDistance: 8,\n\tcoarsePointerWidth: 12,\n\tcoarseHandleRadius: 20,\n\thandleRadius: 12,\n\tlongPressDurationMs: 500,\n\ttextShadowLod: 0.35,\n\tadjacentShapeMargin: 10,\n\tflattenImageBoundsExpand: 64,\n\tflattenImageBoundsPadding: 16,\n\tlaserDelayMs: 1200,\n\tmaxExportDelayMs: 5000,\n\ttooltipDelayMs: 700,\n\ttemporaryAssetPreviewLifetimeMs: 180000,\n\tactionShortcutsLocation: 'swap',\n\tcreateTextOnCanvasDoubleClick: true,\n\texportProvider: Fragment,\n\tenableToolbarKeyboardShortcuts: true,\n\tmaxFontsToLoadBeforeRender: Infinity,\n\tnonce: undefined,\n} as const satisfies TldrawOptions\n"],
5
+ "mappings": "AAAA,SAAwB,gBAAgB;AA0FjC,MAAM,uBAAuB;AAAA,EACnC,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA;AAAA,EAC3B,qBAAqB;AAAA;AAAA,EACrB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,WAAW;AAAA,IACV,EAAE,KAAK,IAAI,KAAK,MAAM,MAAM,GAAG;AAAA,IAC/B,EAAE,KAAK,MAAM,KAAK,OAAO,MAAM,GAAG;AAAA,IAClC,EAAE,KAAK,MAAM,KAAK,GAAG,MAAM,EAAE;AAAA,IAC7B,EAAE,KAAK,KAAK,KAAK,KAAK,MAAM,EAAE;AAAA,EAC/B;AAAA,EACA,+BAA+B;AAAA,EAC/B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,iCAAiC;AAAA,EACjC,yBAAyB;AAAA,EACzB,+BAA+B;AAAA,EAC/B,gBAAgB;AAAA,EAChB,gCAAgC;AAAA,EAChC,4BAA4B;AAAA,EAC5B,OAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,25 @@
1
+ import { atom } from "@tldraw/state";
2
+ import { WeakCache } from "@tldraw/utils";
3
+ class EditorAtom {
4
+ constructor(name, getInitialState) {
5
+ this.name = name;
6
+ this.getInitialState = getInitialState;
7
+ }
8
+ states = new WeakCache();
9
+ getAtom(editor) {
10
+ return this.states.get(editor, () => atom(this.name, this.getInitialState(editor)));
11
+ }
12
+ get(editor) {
13
+ return this.getAtom(editor).get();
14
+ }
15
+ update(editor, update) {
16
+ return this.getAtom(editor).update(update);
17
+ }
18
+ set(editor, state) {
19
+ return this.getAtom(editor).set(state);
20
+ }
21
+ }
22
+ export {
23
+ EditorAtom
24
+ };
25
+ //# sourceMappingURL=EditorAtom.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/utils/EditorAtom.ts"],
4
+ "sourcesContent": ["import { atom, Atom } from '@tldraw/state'\nimport { WeakCache } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\n\n/**\n * An Atom that is scoped to the lifetime of an Editor.\n *\n * This is useful for storing UI state for tldraw applications. Keeping state scoped to an editor\n * instead of stored in a global atom can prevent issues with state being shared between editors\n * when navigating between pages, or when multiple editor instances are used on the same page.\n *\n * @public\n */\nexport class EditorAtom<T> {\n\tprivate states = new WeakCache<Editor, Atom<T>>()\n\n\tconstructor(\n\t\tprivate name: string,\n\t\tprivate getInitialState: (editor: Editor) => T\n\t) {}\n\n\tgetAtom(editor: Editor): Atom<T> {\n\t\treturn this.states.get(editor, () => atom(this.name, this.getInitialState(editor)))\n\t}\n\n\tget(editor: Editor): T {\n\t\treturn this.getAtom(editor).get()\n\t}\n\n\tupdate(editor: Editor, update: (state: T) => T): T {\n\t\treturn this.getAtom(editor).update(update)\n\t}\n\n\tset(editor: Editor, state: T): T {\n\t\treturn this.getAtom(editor).set(state)\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAkB;AAC3B,SAAS,iBAAiB;AAYnB,MAAM,WAAc;AAAA,EAG1B,YACS,MACA,iBACP;AAFO;AACA;AAAA,EACN;AAAA,EALK,SAAS,IAAI,UAA2B;AAAA,EAOhD,QAAQ,QAAyB;AAChC,WAAO,KAAK,OAAO,IAAI,QAAQ,MAAM,KAAK,KAAK,MAAM,KAAK,gBAAgB,MAAM,CAAC,CAAC;AAAA,EACnF;AAAA,EAEA,IAAI,QAAmB;AACtB,WAAO,KAAK,QAAQ,MAAM,EAAE,IAAI;AAAA,EACjC;AAAA,EAEA,OAAO,QAAgB,QAA4B;AAClD,WAAO,KAAK,QAAQ,MAAM,EAAE,OAAO,MAAM;AAAA,EAC1C;AAAA,EAEA,IAAI,QAAgB,OAAa;AAChC,WAAO,KAAK,QAAQ,MAAM,EAAE,IAAI,KAAK;AAAA,EACtC;AACD;",
6
+ "names": []
7
+ }
@@ -1,8 +1,8 @@
1
- const version = "3.16.0-next.df90ce0ff566";
1
+ const version = "3.16.0-next.eafb52d15064";
2
2
  const publishDates = {
3
3
  major: "2024-09-13T14:36:29.063Z",
4
- minor: "2025-07-30T14:02:35.815Z",
5
- patch: "2025-07-30T14:02:35.815Z"
4
+ minor: "2025-08-08T12:19:11.878Z",
5
+ patch: "2025-08-08T12:19:11.878Z"
6
6
  };
7
7
  export {
8
8
  publishDates,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/version.ts"],
4
- "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-next.df90ce0ff566'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-07-30T14:02:35.815Z',\n\tpatch: '2025-07-30T14:02:35.815Z',\n}\n"],
4
+ "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-next.eafb52d15064'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-08-08T12:19:11.878Z',\n\tpatch: '2025-08-08T12:19:11.878Z',\n}\n"],
5
5
  "mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
package/editor.css CHANGED
@@ -163,6 +163,7 @@
163
163
  --color-selected: hsl(214, 84%, 56%);
164
164
  --color-selected-contrast: hsl(0, 0%, 100%);
165
165
  --color-focus: hsl(219, 65%, 50%);
166
+ --color-tooltip: hsla(200, 14%, 4%, 1);
166
167
  /* Text */
167
168
  --color-text: hsl(0, 0%, 0%);
168
169
  --color-text-0: hsl(0, 0%, 11%);
@@ -218,6 +219,7 @@
218
219
  --color-selected: hsl(217, 89%, 61%);
219
220
  --color-selected-contrast: hsl(0, 0%, 100%);
220
221
  --color-focus: hsl(217, 76%, 80%);
222
+ --color-tooltip: hsla(0, 0%, 100%, 1);
221
223
  /* Text */
222
224
  --color-text: hsl(210, 17%, 98%);
223
225
  --color-text-0: hsl(0, 9%, 94%);
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-next.df90ce0ff566",
4
+ "version": "3.16.0-next.eafb52d15064",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -49,12 +49,12 @@
49
49
  "@tiptap/core": "^2.9.1",
50
50
  "@tiptap/pm": "^2.9.1",
51
51
  "@tiptap/react": "^2.9.1",
52
- "@tldraw/state": "3.16.0-next.df90ce0ff566",
53
- "@tldraw/state-react": "3.16.0-next.df90ce0ff566",
54
- "@tldraw/store": "3.16.0-next.df90ce0ff566",
55
- "@tldraw/tlschema": "3.16.0-next.df90ce0ff566",
56
- "@tldraw/utils": "3.16.0-next.df90ce0ff566",
57
- "@tldraw/validate": "3.16.0-next.df90ce0ff566",
52
+ "@tldraw/state": "3.16.0-next.eafb52d15064",
53
+ "@tldraw/state-react": "3.16.0-next.eafb52d15064",
54
+ "@tldraw/store": "3.16.0-next.eafb52d15064",
55
+ "@tldraw/tlschema": "3.16.0-next.eafb52d15064",
56
+ "@tldraw/utils": "3.16.0-next.eafb52d15064",
57
+ "@tldraw/validate": "3.16.0-next.eafb52d15064",
58
58
  "@types/core-js": "^2.5.8",
59
59
  "@use-gesture/react": "^10.3.1",
60
60
  "classnames": "^2.5.1",
package/src/index.ts CHANGED
@@ -265,6 +265,7 @@ export {
265
265
  type TLCameraMoveOptions,
266
266
  type TLCameraOptions,
267
267
  type TLExportType,
268
+ type TLGetShapeAtPointOptions,
268
269
  type TLImageExportOptions,
269
270
  type TLSvgExportOptions,
270
271
  type TLSvgOptions,
@@ -450,6 +451,7 @@ export {
450
451
  setPointerCapture,
451
452
  stopEventPropagation,
452
453
  } from './lib/utils/dom'
454
+ export { EditorAtom } from './lib/utils/EditorAtom'
453
455
  export { getIncrementedName } from './lib/utils/getIncrementedName'
454
456
  export { getPointerInfo } from './lib/utils/getPointerInfo'
455
457
  export { getSvgPathFromPoints } from './lib/utils/getSvgPathFromPoints'
@@ -39,6 +39,7 @@ import { useForceUpdate } from './hooks/useForceUpdate'
39
39
  import { useShallowObjectIdentity } from './hooks/useIdentity'
40
40
  import { useLocalStore } from './hooks/useLocalStore'
41
41
  import { useRefState } from './hooks/useRefState'
42
+ import { useStateAttribute } from './hooks/useStateAttribute'
42
43
  import { useZoomCss } from './hooks/useZoomCss'
43
44
  import { LicenseProvider } from './license/LicenseProvider'
44
45
  import { Watermark } from './license/Watermark'
@@ -646,6 +647,7 @@ function Layout({ children, onMount }: { children: ReactNode; onMount?: TLOnMoun
646
647
  useCursor()
647
648
  useDarkMode()
648
649
  useForceUpdate()
650
+ useStateAttribute()
649
651
  useOnMount((editor) => {
650
652
  const teardownStore = editor.store.props.onMount(editor)
651
653
  const teardownCallback = onMount?.(editor)
@@ -24,6 +24,7 @@ export interface TLUserPreferences {
24
24
  isWrapMode?: boolean | null
25
25
  isDynamicSizeMode?: boolean | null
26
26
  isPasteAtCursorMode?: boolean | null
27
+ showUiLabels?: boolean | null
27
28
  }
28
29
 
29
30
  interface UserDataSnapshot {
@@ -52,6 +53,7 @@ export const userTypeValidator: T.Validator<TLUserPreferences> = T.object<TLUser
52
53
  isWrapMode: T.boolean.nullable().optional(),
53
54
  isDynamicSizeMode: T.boolean.nullable().optional(),
54
55
  isPasteAtCursorMode: T.boolean.nullable().optional(),
56
+ showUiLabels: T.boolean.nullable().optional(),
55
57
  })
56
58
 
57
59
  const Versions = {
@@ -64,6 +66,7 @@ const Versions = {
64
66
  AllowSystemColorScheme: 7,
65
67
  AddPasteAtCursor: 8,
66
68
  AddKeyboardShortcuts: 9,
69
+ AddShowUiLabels: 10,
67
70
  } as const
68
71
 
69
72
  const CURRENT_VERSION = Math.max(...Object.values(Versions))
@@ -102,6 +105,9 @@ function migrateSnapshot(data: { version: number; user: any }) {
102
105
  if (data.version < Versions.AddKeyboardShortcuts) {
103
106
  data.user.areKeyboardShortcutsEnabled = true
104
107
  }
108
+ if (data.version < Versions.AddShowUiLabels) {
109
+ data.user.showUiLabels = false
110
+ }
105
111
 
106
112
  // finally
107
113
  data.version = CURRENT_VERSION
@@ -150,6 +156,7 @@ export const defaultUserPreferences = Object.freeze({
150
156
  isWrapMode: false,
151
157
  isDynamicSizeMode: false,
152
158
  isPasteAtCursorMode: false,
159
+ showUiLabels: false,
153
160
  colorScheme: 'light',
154
161
  }) satisfies Readonly<Omit<TLUserPreferences, 'id'>>
155
162
 
@@ -176,6 +176,7 @@ import {
176
176
  RequiredKeys,
177
177
  TLCameraMoveOptions,
178
178
  TLCameraOptions,
179
+ TLGetShapeAtPointOptions,
179
180
  TLImageExportOptions,
180
181
  TLSvgExportOptions,
181
182
  TLUpdatePointerOptions,
@@ -5154,20 +5155,7 @@ export class Editor extends EventEmitter<TLEventMap> {
5154
5155
  *
5155
5156
  * @returns The shape at the given point, or undefined if there is no shape at the point.
5156
5157
  */
5157
- getShapeAtPoint(
5158
- point: VecLike,
5159
- opts = {} as {
5160
- renderingOnly?: boolean
5161
- margin?: number
5162
- hitInside?: boolean
5163
- hitLocked?: boolean
5164
- // TODO: we probably need to rename this, we don't quite _always_
5165
- // respect this esp. in the part below that does "Check labels first"
5166
- hitLabels?: boolean
5167
- hitFrameInside?: boolean
5168
- filter?(shape: TLShape): boolean
5169
- }
5170
- ): TLShape | undefined {
5158
+ getShapeAtPoint(point: VecLike, opts: TLGetShapeAtPointOptions = {}): TLShape | undefined {
5171
5159
  const zoomLevel = this.getZoomLevel()
5172
5160
  const viewportPageBounds = this.getViewportPageBounds()
5173
5161
  const {
@@ -5179,6 +5167,8 @@ export class Editor extends EventEmitter<TLEventMap> {
5179
5167
  hitFrameInside = false,
5180
5168
  } = opts
5181
5169
 
5170
+ const [innerMargin, outerMargin] = Array.isArray(margin) ? margin : [margin, margin]
5171
+
5182
5172
  let inHollowSmallestArea = Infinity
5183
5173
  let inHollowSmallestAreaHit: TLShape | null = null
5184
5174
 
@@ -5198,7 +5188,7 @@ export class Editor extends EventEmitter<TLEventMap> {
5198
5188
  return false
5199
5189
  const pageMask = this.getShapeMask(shape)
5200
5190
  if (pageMask && !pointInPolygon(point, pageMask)) return false
5201
- if (filter) return filter(shape)
5191
+ if (filter && !filter(shape)) return false
5202
5192
  return true
5203
5193
  })
5204
5194
 
@@ -5224,13 +5214,18 @@ export class Editor extends EventEmitter<TLEventMap> {
5224
5214
  }
5225
5215
  }
5226
5216
 
5227
- if (this.isShapeOfType(shape, 'frame')) {
5217
+ if (this.isShapeOfType<TLFrameShape>(shape, 'frame')) {
5228
5218
  // On the rare case that we've hit a frame (not its label), test again hitInside to be forced true;
5229
5219
  // this prevents clicks from passing through the body of a frame to shapes behind it.
5230
5220
 
5231
5221
  // If the hit is within the frame's outer margin, then select the frame
5232
- const distance = geometry.distanceToPoint(pointInShapeSpace, hitInside)
5233
- if (Math.abs(distance) <= margin) {
5222
+ const distance = geometry.distanceToPoint(pointInShapeSpace, hitFrameInside)
5223
+ if (
5224
+ hitFrameInside
5225
+ ? (distance > 0 && distance <= outerMargin) ||
5226
+ (distance <= 0 && distance > -innerMargin)
5227
+ : distance > 0 && distance <= outerMargin
5228
+ ) {
5234
5229
  return inMarginClosestToEdgeHit || shape
5235
5230
  }
5236
5231
 
@@ -5269,11 +5264,11 @@ export class Editor extends EventEmitter<TLEventMap> {
5269
5264
  // If the margin is zero and the geometry has a very small width or height,
5270
5265
  // then check the actual distance. This is to prevent a bug where straight
5271
5266
  // lines would never pass the broad phase (point-in-bounds) check.
5272
- if (margin === 0 && (geometry.bounds.w < 1 || geometry.bounds.h < 1)) {
5267
+ if (outerMargin === 0 && (geometry.bounds.w < 1 || geometry.bounds.h < 1)) {
5273
5268
  distance = geometry.distanceToPoint(pointInShapeSpace, hitInside)
5274
5269
  } else {
5275
5270
  // Broad phase
5276
- if (geometry.bounds.containsPoint(pointInShapeSpace, margin)) {
5271
+ if (geometry.bounds.containsPoint(pointInShapeSpace, outerMargin)) {
5277
5272
  // Narrow phase (actual distance)
5278
5273
  distance = geometry.distanceToPoint(pointInShapeSpace, hitInside)
5279
5274
  } else {
@@ -5288,7 +5283,8 @@ export class Editor extends EventEmitter<TLEventMap> {
5288
5283
  // the shape or negative if inside of the shape. If the distance
5289
5284
  // is greater than the margin, then it's a miss. Otherwise...
5290
5285
 
5291
- if (distance <= margin) {
5286
+ // Are we close to the shape's edge?
5287
+ if (distance <= outerMargin || (hitInside && distance <= 0 && distance > -innerMargin)) {
5292
5288
  if (geometry.isFilled || (isGroup && geometry.children[0].isFilled)) {
5293
5289
  // If the shape is filled, then it's a hit. Remember, we're
5294
5290
  // starting from the TOP-MOST shape in z-index order, so any
@@ -5298,11 +5294,21 @@ export class Editor extends EventEmitter<TLEventMap> {
5298
5294
  // If the shape is bigger than the viewport, then skip it.
5299
5295
  if (this.getShapePageBounds(shape)!.contains(viewportPageBounds)) continue
5300
5296
 
5301
- // For hollow shapes...
5302
- if (Math.abs(distance) < margin) {
5303
- // We want to preference shapes where we're inside of the
5304
- // shape margin; and we would want to hit the shape with the
5305
- // edge closest to the point.
5297
+ // If we're close to the edge of the shape, and if it's the closest edge among
5298
+ // all the edges that we've gotten close to so far, then we will want to hit the
5299
+ // shape unless we hit something else or closer in later iterations.
5300
+ if (
5301
+ hitInside
5302
+ ? // On hitInside, the distance will be negative for hits inside
5303
+ // If the distance is positive, check against the outer margin
5304
+ (distance > 0 && distance <= outerMargin) ||
5305
+ // If the distance is negative, check against the inner margin
5306
+ (distance <= 0 && distance > -innerMargin)
5307
+ : // If hitInside is false, then sadly _we do not know_ whether the
5308
+ // point is inside or outside of the shape, so we check against
5309
+ // the max of the two margins
5310
+ Math.abs(distance) <= Math.max(innerMargin, outerMargin)
5311
+ ) {
5306
5312
  if (Math.abs(distance) < inMarginClosestToEdgeDistance) {
5307
5313
  inMarginClosestToEdgeDistance = Math.abs(distance)
5308
5314
  inMarginClosestToEdgeHit = shape
@@ -5324,6 +5330,7 @@ export class Editor extends EventEmitter<TLEventMap> {
5324
5330
  } else {
5325
5331
  // For open shapes (e.g. lines or draw shapes) always use the margin.
5326
5332
  // If the distance is less than the margin, return the shape as the hit.
5333
+ // Use the editor's configurable hit test margin.
5327
5334
  if (distance < this.options.hitTestMargin / zoomLevel) {
5328
5335
  return shape
5329
5336
  }
@@ -7380,7 +7387,6 @@ export class Editor extends EventEmitter<TLEventMap> {
7380
7387
  if (
7381
7388
  !this.getShapeUtil(shape).canBeLaidOut?.(shape, {
7382
7389
  type: 'stretch',
7383
- shapes: shapesToStretchFirstPass,
7384
7390
  })
7385
7391
  ) {
7386
7392
  continue
@@ -25,6 +25,7 @@ describe('UserPreferencesManager', () => {
25
25
  locale: 'en',
26
26
  animationSpeed: 1,
27
27
  areKeyboardShortcutsEnabled: true,
28
+ showUiLabels: false,
28
29
  edgeScrollSpeed: 1,
29
30
  colorScheme: 'light',
30
31
  isSnapMode: false,
@@ -231,6 +232,7 @@ describe('UserPreferencesManager', () => {
231
232
  color: mockUserPreferences.color,
232
233
  animationSpeed: mockUserPreferences.animationSpeed,
233
234
  areKeyboardShortcutsEnabled: mockUserPreferences.areKeyboardShortcutsEnabled,
235
+ showUiLabels: mockUserPreferences.showUiLabels,
234
236
  isSnapMode: mockUserPreferences.isSnapMode,
235
237
  colorScheme: mockUserPreferences.colorScheme,
236
238
  isDarkMode: false, // light mode
@@ -379,6 +381,17 @@ describe('UserPreferencesManager', () => {
379
381
  })
380
382
  })
381
383
 
384
+ describe('getShowUiLabels', () => {
385
+ it('should return user show ui labels setting', () => {
386
+ expect(userPreferencesManager.getShowUiLabels()).toBe(mockUserPreferences.showUiLabels)
387
+ })
388
+
389
+ it('should return default show ui labels when null', () => {
390
+ userPreferencesAtom.set({ ...mockUserPreferences, showUiLabels: null })
391
+ expect(userPreferencesManager.getShowUiLabels()).toBe(defaultUserPreferences.showUiLabels)
392
+ })
393
+ })
394
+
382
395
  describe('getEdgeScrollSpeed', () => {
383
396
  it('should return user edge scroll speed', () => {
384
397
  expect(userPreferencesManager.getEdgeScrollSpeed()).toBe(
@@ -49,6 +49,7 @@ export class UserPreferencesManager {
49
49
  isDarkMode: this.getIsDarkMode(),
50
50
  isWrapMode: this.getIsWrapMode(),
51
51
  isDynamicResizeMode: this.getIsDynamicResizeMode(),
52
+ showUiLabels: this.getShowUiLabels(),
52
53
  }
53
54
  }
54
55
 
@@ -119,4 +120,8 @@ export class UserPreferencesManager {
119
120
  defaultUserPreferences.isPasteAtCursorMode
120
121
  )
121
122
  }
123
+
124
+ @computed getShowUiLabels() {
125
+ return this.user.userPreferences.get().showUiLabels ?? defaultUserPreferences.showUiLabels
126
+ }
122
127
  }
@@ -1,4 +1,4 @@
1
- import { BoxModel } from '@tldraw/tlschema'
1
+ import { BoxModel, TLShape } from '@tldraw/tlschema'
2
2
  import { Box } from '../../primitives/Box'
3
3
  import { VecLike } from '../../primitives/Vec'
4
4
 
@@ -206,3 +206,56 @@ export interface TLUpdatePointerOptions {
206
206
  isPen?: boolean
207
207
  button?: number
208
208
  }
209
+
210
+ /**
211
+ * Options to {@link Editor.getShapeAtPoint}.
212
+ *
213
+ * @public
214
+ */
215
+ export interface TLGetShapeAtPointOptions {
216
+ /**
217
+ * The margin to apply to the shape.
218
+ * If a number, it will be applied to both the inside and outside of the shape.
219
+ * If an array, the first element will be applied to the inside of the shape, and the second element will be applied to the outside.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * // Get the shape at the center of the screen
224
+ * const shape = editor.getShapeAtProps({
225
+ * margin: 10,
226
+ * })
227
+ *
228
+ * // Get the shape at the center of the screen with a 10px inner margin and a 5px outer margin
229
+ * const shape = editor.getShapeAtProps({
230
+ * margin: [10, 5],
231
+ * })
232
+ * ```
233
+ */
234
+ margin?: number | [number, number]
235
+ /**
236
+ * Whether to register hits inside of shapes (beyond the margin), such as the inside of a solid shape.
237
+ */
238
+ hitInside?: boolean
239
+ /**
240
+ * Whether to register hits on locked shapes.
241
+ */
242
+ hitLocked?: boolean
243
+ /**
244
+ * Whether to register hits on labels.
245
+ */
246
+ hitLabels?: boolean
247
+ /**
248
+ * Whether to only return hits on shapes that are currently being rendered.
249
+ * todo: rename this to hitCulled or hitNotRendering
250
+ */
251
+ renderingOnly?: boolean
252
+ /**
253
+ * Whether to register hits on the inside of frame shapes.
254
+ * todo: rename this to hitInsideFrames
255
+ */
256
+ hitFrameInside?: boolean
257
+ /**
258
+ * A filter function to apply to the shapes.
259
+ */
260
+ filter?(shape: TLShape): boolean
261
+ }
@@ -0,0 +1,15 @@
1
+ import { react } from '@tldraw/state'
2
+ import { useLayoutEffect } from 'react'
3
+ import { useEditor } from './useEditor'
4
+
5
+ export function useStateAttribute() {
6
+ const editor = useEditor()
7
+
8
+ // we use a layout effect because we don't want there to be any perceptible delay between the
9
+ // editor mounting and this attribute being applied, because styles may depend on it:
10
+ useLayoutEffect(() => {
11
+ return react('stateAttribute', () => {
12
+ editor.getContainer().setAttribute('data-state', editor.getPath())
13
+ })
14
+ }, [editor])
15
+ }
@@ -53,6 +53,7 @@ export interface TldrawOptions {
53
53
  readonly flattenImageBoundsPadding: number
54
54
  readonly laserDelayMs: number
55
55
  readonly maxExportDelayMs: number
56
+ readonly tooltipDelayMs: number
56
57
  /**
57
58
  * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before
58
59
  * they expire? Defaults to 3 minutes.
@@ -124,6 +125,7 @@ export const defaultTldrawOptions = {
124
125
  flattenImageBoundsPadding: 16,
125
126
  laserDelayMs: 1200,
126
127
  maxExportDelayMs: 5000,
128
+ tooltipDelayMs: 700,
127
129
  temporaryAssetPreviewLifetimeMs: 180000,
128
130
  actionShortcutsLocation: 'swap',
129
131
  createTextOnCanvasDoubleClick: true,