@tldraw/editor 3.15.1 → 3.16.0-canary.03ed24d72068

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 (105) hide show
  1. package/dist-cjs/index.d.ts +181 -9
  2. package/dist-cjs/index.js +5 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +3 -1
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/components/MenuClickCapture.js +0 -5
  7. package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
  8. package/dist-cjs/lib/components/Shape.js +4 -26
  9. package/dist-cjs/lib/components/Shape.js.map +2 -2
  10. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +1 -1
  11. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +1 -1
  12. package/dist-cjs/lib/components/default-components/DefaultScribble.js +1 -1
  13. package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +2 -2
  14. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +9 -1
  15. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
  16. package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js +53 -0
  17. package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js.map +7 -0
  18. package/dist-cjs/lib/config/TLUserPreferences.js +8 -2
  19. package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
  20. package/dist-cjs/lib/editor/Editor.js +100 -58
  21. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  22. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +8 -3
  23. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
  24. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  25. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  26. package/dist-cjs/lib/exports/getSvgJsx.js +1 -2
  27. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  28. package/dist-cjs/lib/hooks/useCanvasEvents.js +24 -20
  29. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  30. package/dist-cjs/lib/hooks/useEditorComponents.js +2 -0
  31. package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
  32. package/dist-cjs/lib/hooks/useStateAttribute.js +35 -0
  33. package/dist-cjs/lib/hooks/useStateAttribute.js.map +7 -0
  34. package/dist-cjs/lib/license/Watermark.js +6 -6
  35. package/dist-cjs/lib/license/Watermark.js.map +1 -1
  36. package/dist-cjs/lib/options.js +1 -0
  37. package/dist-cjs/lib/options.js.map +2 -2
  38. package/dist-cjs/lib/utils/EditorAtom.js +45 -0
  39. package/dist-cjs/lib/utils/EditorAtom.js.map +7 -0
  40. package/dist-cjs/version.js +3 -3
  41. package/dist-cjs/version.js.map +1 -1
  42. package/dist-esm/index.d.mts +181 -9
  43. package/dist-esm/index.mjs +7 -1
  44. package/dist-esm/index.mjs.map +2 -2
  45. package/dist-esm/lib/TldrawEditor.mjs +3 -1
  46. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  47. package/dist-esm/lib/components/MenuClickCapture.mjs +0 -5
  48. package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
  49. package/dist-esm/lib/components/Shape.mjs +4 -26
  50. package/dist-esm/lib/components/Shape.mjs.map +2 -2
  51. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +1 -1
  52. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +1 -1
  53. package/dist-esm/lib/components/default-components/DefaultScribble.mjs +1 -1
  54. package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +2 -2
  55. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +9 -1
  56. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
  57. package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs +23 -0
  58. package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs.map +7 -0
  59. package/dist-esm/lib/config/TLUserPreferences.mjs +8 -2
  60. package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
  61. package/dist-esm/lib/editor/Editor.mjs +100 -58
  62. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  63. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +8 -3
  64. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
  65. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  66. package/dist-esm/lib/exports/getSvgJsx.mjs +2 -2
  67. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  68. package/dist-esm/lib/hooks/useCanvasEvents.mjs +25 -21
  69. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  70. package/dist-esm/lib/hooks/useEditorComponents.mjs +4 -0
  71. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
  72. package/dist-esm/lib/hooks/useStateAttribute.mjs +15 -0
  73. package/dist-esm/lib/hooks/useStateAttribute.mjs.map +7 -0
  74. package/dist-esm/lib/license/Watermark.mjs +6 -6
  75. package/dist-esm/lib/license/Watermark.mjs.map +1 -1
  76. package/dist-esm/lib/options.mjs +1 -0
  77. package/dist-esm/lib/options.mjs.map +2 -2
  78. package/dist-esm/lib/utils/EditorAtom.mjs +25 -0
  79. package/dist-esm/lib/utils/EditorAtom.mjs.map +7 -0
  80. package/dist-esm/version.mjs +3 -3
  81. package/dist-esm/version.mjs.map +1 -1
  82. package/editor.css +297 -311
  83. package/package.json +7 -7
  84. package/src/index.ts +7 -0
  85. package/src/lib/TldrawEditor.tsx +7 -5
  86. package/src/lib/components/MenuClickCapture.tsx +0 -8
  87. package/src/lib/components/Shape.tsx +6 -21
  88. package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
  89. package/src/lib/components/default-components/DefaultScribble.tsx +1 -1
  90. package/src/lib/components/default-components/DefaultShapeIndicator.tsx +5 -1
  91. package/src/lib/components/default-components/DefaultShapeWrapper.tsx +35 -0
  92. package/src/lib/config/TLUserPreferences.ts +7 -0
  93. package/src/lib/editor/Editor.ts +130 -81
  94. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +13 -0
  95. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +5 -0
  96. package/src/lib/editor/shapes/ShapeUtil.ts +57 -0
  97. package/src/lib/editor/types/misc-types.ts +73 -1
  98. package/src/lib/exports/getSvgJsx.tsx +2 -2
  99. package/src/lib/hooks/useCanvasEvents.ts +39 -32
  100. package/src/lib/hooks/useEditorComponents.tsx +7 -1
  101. package/src/lib/hooks/useStateAttribute.ts +15 -0
  102. package/src/lib/license/Watermark.tsx +6 -6
  103. package/src/lib/options.ts +2 -0
  104. package/src/lib/utils/EditorAtom.ts +37 -0
  105. package/src/version.ts +3 -3
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useStateAttribute_exports = {};
20
+ __export(useStateAttribute_exports, {
21
+ useStateAttribute: () => useStateAttribute
22
+ });
23
+ module.exports = __toCommonJS(useStateAttribute_exports);
24
+ var import_state = require("@tldraw/state");
25
+ var import_react = require("react");
26
+ var import_useEditor = require("./useEditor");
27
+ function useStateAttribute() {
28
+ const editor = (0, import_useEditor.useEditor)();
29
+ (0, import_react.useLayoutEffect)(() => {
30
+ return (0, import_state.react)("stateAttribute", () => {
31
+ editor.getContainer().setAttribute("data-state", editor.getPath());
32
+ });
33
+ }, [editor]);
34
+ }
35
+ //# sourceMappingURL=useStateAttribute.js.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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,mBAAgC;AAChC,uBAA0B;AAEnB,SAAS,oBAAoB;AACnC,QAAM,aAAS,4BAAU;AAIzB,oCAAgB,MAAM;AACrB,eAAO,oBAAM,kBAAkB,MAAM;AACpC,aAAO,aAAa,EAAE,aAAa,cAAc,OAAO,QAAQ,CAAC;AAAA,IAClE,CAAC;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AACZ;",
6
+ "names": []
7
+ }
@@ -99,15 +99,15 @@ To remove the watermark, please purchase a license at tldraw.dev.
99
99
 
100
100
  .${className} {
101
101
  position: absolute;
102
- bottom: var(--space-2);
103
- right: var(--space-2);
102
+ bottom: var(--tl-space-2);
103
+ right: var(--tl-space-2);
104
104
  width: 96px;
105
105
  height: 32px;
106
106
  display: flex;
107
107
  align-items: center;
108
108
  justify-content: center;
109
- z-index: var(--layer-watermark) !important;
110
- background-color: color-mix(in srgb, var(--color-background) 62%, transparent);
109
+ z-index: var(--tl-layer-watermark) !important;
110
+ background-color: color-mix(in srgb, var(--tl-color-background) 62%, transparent);
111
111
  opacity: 1;
112
112
  border-radius: 5px;
113
113
  pointer-events: all;
@@ -121,7 +121,7 @@ To remove the watermark, please purchase a license at tldraw.dev.
121
121
  height: 32px;
122
122
  pointer-events: all;
123
123
  cursor: inherit;
124
- color: var(--color-text);
124
+ color: var(--tl-color-text);
125
125
  opacity: .38;
126
126
  border: 0;
127
127
  padding: 0;
@@ -150,7 +150,7 @@ To remove the watermark, please purchase a license at tldraw.dev.
150
150
  }
151
151
 
152
152
  .${className}:hover {
153
- background-color: var(--color-background);
153
+ background-color: var(--tl-color-background);
154
154
  transition: background-color 0.2s ease-in-out;
155
155
  transition-delay: 0.32s;
156
156
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/license/Watermark.tsx"],
4
- "sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { memo, useRef } from 'react'\nimport { useCanvasEvents } from '../hooks/useCanvasEvents'\nimport { useEditor } from '../hooks/useEditor'\nimport { usePassThroughWheelEvents } from '../hooks/usePassThroughWheelEvents'\nimport { preventDefault, stopEventPropagation } from '../utils/dom'\nimport { runtime } from '../utils/runtime'\nimport { watermarkDesktopSvg, watermarkMobileSvg } from '../watermarks'\nimport { LicenseManager } from './LicenseManager'\nimport { useLicenseContext } from './LicenseProvider'\nimport { useLicenseManagerState } from './useLicenseManagerState'\n\nconst WATERMARK_DESKTOP_LOCAL_SRC = `data:image/svg+xml;utf8,${encodeURIComponent(watermarkDesktopSvg)}`\nconst WATERMARK_MOBILE_LOCAL_SRC = `data:image/svg+xml;utf8,${encodeURIComponent(watermarkMobileSvg)}`\n\n/** @internal */\nexport const Watermark = memo(function Watermark() {\n\tconst licenseManager = useLicenseContext()\n\tconst editor = useEditor()\n\tconst isMobile = useValue('is mobile', () => editor.getViewportScreenBounds().width < 700, [\n\t\teditor,\n\t])\n\n\tconst licenseManagerState = useLicenseManagerState(licenseManager)\n\n\tif (!['licensed-with-watermark', 'unlicensed'].includes(licenseManagerState)) return null\n\n\treturn (\n\t\t<>\n\t\t\t<LicenseStyles />\n\t\t\t<WatermarkInner src={isMobile ? WATERMARK_MOBILE_LOCAL_SRC : WATERMARK_DESKTOP_LOCAL_SRC} />\n\t\t</>\n\t)\n})\n\nconst WatermarkInner = memo(function WatermarkInner({ src }: { src: string }) {\n\tconst editor = useEditor()\n\tconst isDebugMode = useValue('debug mode', () => editor.getInstanceState().isDebugMode, [editor])\n\tconst isMobile = useValue('is mobile', () => editor.getViewportScreenBounds().width < 700, [\n\t\teditor,\n\t])\n\tconst events = useCanvasEvents()\n\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(ref)\n\n\tconst maskCss = `url('${src}') center 100% / 100% no-repeat`\n\tconst url = 'https://tldraw.dev/?utm_source=dotcom&utm_medium=organic&utm_campaign=watermark'\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={LicenseManager.className}\n\t\t\tdata-debug={isDebugMode}\n\t\t\tdata-mobile={isMobile}\n\t\t\tdraggable={false}\n\t\t\t{...events}\n\t\t>\n\t\t\t<button\n\t\t\t\tdraggable={false}\n\t\t\t\trole=\"button\"\n\t\t\t\tonPointerDown={(e) => {\n\t\t\t\t\tstopEventPropagation(e)\n\t\t\t\t\tpreventDefault(e)\n\t\t\t\t}}\n\t\t\t\ttitle=\"made with tldraw\"\n\t\t\t\tonClick={() => runtime.openWindow(url, '_blank')}\n\t\t\t\tstyle={{ mask: maskCss, WebkitMask: maskCss }}\n\t\t\t/>\n\t\t</div>\n\t)\n})\n\nconst LicenseStyles = memo(function LicenseStyles() {\n\tconst editor = useEditor()\n\tconst className = LicenseManager.className\n\n\tconst CSS = `/* ------------------- SEE LICENSE -------------------\nThe tldraw watermark is part of tldraw's license. It is shown for unlicensed\nor \"licensed-with-watermark\" users. By using this library, you agree to\npreserve the watermark's behavior, keeping it visible, unobscured, and\navailable to user-interaction.\n\nTo remove the watermark, please purchase a license at tldraw.dev.\n*/\n\n\t.${className} {\n\t\tposition: absolute;\n\t\tbottom: var(--space-2);\n\t\tright: var(--space-2);\n\t\twidth: 96px;\n\t\theight: 32px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: var(--layer-watermark) !important;\n\t\tbackground-color: color-mix(in srgb, var(--color-background) 62%, transparent);\n\t\topacity: 1;\n\t\tborder-radius: 5px;\n\t\tpointer-events: all;\n\t\tpadding: 2px;\n\t\tbox-sizing: content-box;\n\t}\n\n\t.${className} > button {\n\t\tposition: absolute;\n\t\twidth: 96px;\n\t\theight: 32px;\n\t\tpointer-events: all;\n\t\tcursor: inherit;\n\t\tcolor: var(--color-text);\n\t\topacity: .38;\n\t\tborder: 0;\n\t\tpadding: 0;\n\t\tbackground-color: currentColor;\n\t}\n\n\t.${className}[data-debug='true'] {\n\t\tbottom: 46px;\n\t}\n\n\t.${className}[data-mobile='true'] {\n\t\tborder-radius: 4px 0px 0px 4px;\n\t\tright: -2px;\n\t\twidth: 8px;\n\t\theight: 48px;\n\t}\n\n\t.${className}[data-mobile='true'] > button {\n\t\twidth: 8px;\n\t\theight: 32px;\n\t}\n\n\t@media (hover: hover) {\n\t\t.${className} > button {\n\t\t\tpointer-events: none;\n\t\t}\n\n\t\t.${className}:hover {\n\t\t\tbackground-color: var(--color-background);\n\t\t\ttransition: background-color 0.2s ease-in-out;\n\t\t\ttransition-delay: 0.32s;\n\t\t}\n\n\t\t.${className}:hover > button {\n\t\t\tanimation: ${className}_delayed_link 0.2s forwards ease-in-out;\n\t\t\tanimation-delay: 0.32s;\n\t\t}\n\n\t\t.${className} > button:focus-visible {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\n\n\t@keyframes ${className}_delayed_link {\n\t\t0% {\n\t\t\tcursor: inherit;\n\t\t\topacity: .38;\n\t\t\tpointer-events: none;\n\t\t}\n\t\t100% {\n\t\t\tcursor: pointer;\n\t\t\topacity: 1;\n\t\t\tpointer-events: all;\n\t\t}\n\t}`\n\n\treturn <style nonce={editor.options.nonce}>{CSS}</style>\n})\n"],
4
+ "sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { memo, useRef } from 'react'\nimport { useCanvasEvents } from '../hooks/useCanvasEvents'\nimport { useEditor } from '../hooks/useEditor'\nimport { usePassThroughWheelEvents } from '../hooks/usePassThroughWheelEvents'\nimport { preventDefault, stopEventPropagation } from '../utils/dom'\nimport { runtime } from '../utils/runtime'\nimport { watermarkDesktopSvg, watermarkMobileSvg } from '../watermarks'\nimport { LicenseManager } from './LicenseManager'\nimport { useLicenseContext } from './LicenseProvider'\nimport { useLicenseManagerState } from './useLicenseManagerState'\n\nconst WATERMARK_DESKTOP_LOCAL_SRC = `data:image/svg+xml;utf8,${encodeURIComponent(watermarkDesktopSvg)}`\nconst WATERMARK_MOBILE_LOCAL_SRC = `data:image/svg+xml;utf8,${encodeURIComponent(watermarkMobileSvg)}`\n\n/** @internal */\nexport const Watermark = memo(function Watermark() {\n\tconst licenseManager = useLicenseContext()\n\tconst editor = useEditor()\n\tconst isMobile = useValue('is mobile', () => editor.getViewportScreenBounds().width < 700, [\n\t\teditor,\n\t])\n\n\tconst licenseManagerState = useLicenseManagerState(licenseManager)\n\n\tif (!['licensed-with-watermark', 'unlicensed'].includes(licenseManagerState)) return null\n\n\treturn (\n\t\t<>\n\t\t\t<LicenseStyles />\n\t\t\t<WatermarkInner src={isMobile ? WATERMARK_MOBILE_LOCAL_SRC : WATERMARK_DESKTOP_LOCAL_SRC} />\n\t\t</>\n\t)\n})\n\nconst WatermarkInner = memo(function WatermarkInner({ src }: { src: string }) {\n\tconst editor = useEditor()\n\tconst isDebugMode = useValue('debug mode', () => editor.getInstanceState().isDebugMode, [editor])\n\tconst isMobile = useValue('is mobile', () => editor.getViewportScreenBounds().width < 700, [\n\t\teditor,\n\t])\n\tconst events = useCanvasEvents()\n\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(ref)\n\n\tconst maskCss = `url('${src}') center 100% / 100% no-repeat`\n\tconst url = 'https://tldraw.dev/?utm_source=dotcom&utm_medium=organic&utm_campaign=watermark'\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={LicenseManager.className}\n\t\t\tdata-debug={isDebugMode}\n\t\t\tdata-mobile={isMobile}\n\t\t\tdraggable={false}\n\t\t\t{...events}\n\t\t>\n\t\t\t<button\n\t\t\t\tdraggable={false}\n\t\t\t\trole=\"button\"\n\t\t\t\tonPointerDown={(e) => {\n\t\t\t\t\tstopEventPropagation(e)\n\t\t\t\t\tpreventDefault(e)\n\t\t\t\t}}\n\t\t\t\ttitle=\"made with tldraw\"\n\t\t\t\tonClick={() => runtime.openWindow(url, '_blank')}\n\t\t\t\tstyle={{ mask: maskCss, WebkitMask: maskCss }}\n\t\t\t/>\n\t\t</div>\n\t)\n})\n\nconst LicenseStyles = memo(function LicenseStyles() {\n\tconst editor = useEditor()\n\tconst className = LicenseManager.className\n\n\tconst CSS = `/* ------------------- SEE LICENSE -------------------\nThe tldraw watermark is part of tldraw's license. It is shown for unlicensed\nor \"licensed-with-watermark\" users. By using this library, you agree to\npreserve the watermark's behavior, keeping it visible, unobscured, and\navailable to user-interaction.\n\nTo remove the watermark, please purchase a license at tldraw.dev.\n*/\n\n\t.${className} {\n\t\tposition: absolute;\n\t\tbottom: var(--tl-space-2);\n\t\tright: var(--tl-space-2);\n\t\twidth: 96px;\n\t\theight: 32px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t\tz-index: var(--tl-layer-watermark) !important;\n\t\tbackground-color: color-mix(in srgb, var(--tl-color-background) 62%, transparent);\n\t\topacity: 1;\n\t\tborder-radius: 5px;\n\t\tpointer-events: all;\n\t\tpadding: 2px;\n\t\tbox-sizing: content-box;\n\t}\n\n\t.${className} > button {\n\t\tposition: absolute;\n\t\twidth: 96px;\n\t\theight: 32px;\n\t\tpointer-events: all;\n\t\tcursor: inherit;\n\t\tcolor: var(--tl-color-text);\n\t\topacity: .38;\n\t\tborder: 0;\n\t\tpadding: 0;\n\t\tbackground-color: currentColor;\n\t}\n\n\t.${className}[data-debug='true'] {\n\t\tbottom: 46px;\n\t}\n\n\t.${className}[data-mobile='true'] {\n\t\tborder-radius: 4px 0px 0px 4px;\n\t\tright: -2px;\n\t\twidth: 8px;\n\t\theight: 48px;\n\t}\n\n\t.${className}[data-mobile='true'] > button {\n\t\twidth: 8px;\n\t\theight: 32px;\n\t}\n\n\t@media (hover: hover) {\n\t\t.${className} > button {\n\t\t\tpointer-events: none;\n\t\t}\n\n\t\t.${className}:hover {\n\t\t\tbackground-color: var(--tl-color-background);\n\t\t\ttransition: background-color 0.2s ease-in-out;\n\t\t\ttransition-delay: 0.32s;\n\t\t}\n\n\t\t.${className}:hover > button {\n\t\t\tanimation: ${className}_delayed_link 0.2s forwards ease-in-out;\n\t\t\tanimation-delay: 0.32s;\n\t\t}\n\n\t\t.${className} > button:focus-visible {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\n\n\t@keyframes ${className}_delayed_link {\n\t\t0% {\n\t\t\tcursor: inherit;\n\t\t\topacity: .38;\n\t\t\tpointer-events: none;\n\t\t}\n\t\t100% {\n\t\t\tcursor: pointer;\n\t\t\topacity: 1;\n\t\t\tpointer-events: all;\n\t\t}\n\t}`\n\n\treturn <style nonce={editor.options.nonce}>{CSS}</style>\n})\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BE;AA5BF,yBAAyB;AACzB,mBAA6B;AAC7B,6BAAgC;AAChC,uBAA0B;AAC1B,uCAA0C;AAC1C,iBAAqD;AACrD,qBAAwB;AACxB,wBAAwD;AACxD,4BAA+B;AAC/B,6BAAkC;AAClC,oCAAuC;AAEvC,MAAM,8BAA8B,2BAA2B,mBAAmB,qCAAmB,CAAC;AACtG,MAAM,6BAA6B,2BAA2B,mBAAmB,oCAAkB,CAAC;AAG7F,MAAM,gBAAY,mBAAK,SAASA,aAAY;AAClD,QAAM,qBAAiB,0CAAkB;AACzC,QAAM,aAAS,4BAAU;AACzB,QAAM,eAAW,6BAAS,aAAa,MAAM,OAAO,wBAAwB,EAAE,QAAQ,KAAK;AAAA,IAC1F;AAAA,EACD,CAAC;AAED,QAAM,0BAAsB,sDAAuB,cAAc;AAEjE,MAAI,CAAC,CAAC,2BAA2B,YAAY,EAAE,SAAS,mBAAmB,EAAG,QAAO;AAErF,SACC,4EACC;AAAA,gDAAC,iBAAc;AAAA,IACf,4CAAC,kBAAe,KAAK,WAAW,6BAA6B,6BAA6B;AAAA,KAC3F;AAEF,CAAC;AAED,MAAM,qBAAiB,mBAAK,SAASC,gBAAe,EAAE,IAAI,GAAoB;AAC7E,QAAM,aAAS,4BAAU;AACzB,QAAM,kBAAc,6BAAS,cAAc,MAAM,OAAO,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC;AAChG,QAAM,eAAW,6BAAS,aAAa,MAAM,OAAO,wBAAwB,EAAE,QAAQ,KAAK;AAAA,IAC1F;AAAA,EACD,CAAC;AACD,QAAM,aAAS,wCAAgB;AAE/B,QAAM,UAAM,qBAAuB,IAAI;AACvC,kEAA0B,GAAG;AAE7B,QAAM,UAAU,QAAQ,GAAG;AAC3B,QAAM,MAAM;AAEZ,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,WAAW,qCAAe;AAAA,MAC1B,cAAY;AAAA,MACZ,eAAa;AAAA,MACb,WAAW;AAAA,MACV,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACA,WAAW;AAAA,UACX,MAAK;AAAA,UACL,eAAe,CAAC,MAAM;AACrB,iDAAqB,CAAC;AACtB,2CAAe,CAAC;AAAA,UACjB;AAAA,UACA,OAAM;AAAA,UACN,SAAS,MAAM,uBAAQ,WAAW,KAAK,QAAQ;AAAA,UAC/C,OAAO,EAAE,MAAM,SAAS,YAAY,QAAQ;AAAA;AAAA,MAC7C;AAAA;AAAA,EACD;AAEF,CAAC;AAED,MAAM,oBAAgB,mBAAK,SAASC,iBAAgB;AACnD,QAAM,aAAS,4BAAU;AACzB,QAAM,YAAY,qCAAe;AAEjC,QAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAST,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAaT,SAAS;AAAA;AAAA;AAAA;AAAA,IAIT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAMR,SAAS;AAAA;AAAA;AAAA;AAAA,KAIT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAMT,SAAS;AAAA,gBACE,SAAS;AAAA;AAAA;AAAA;AAAA,KAIpB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAMA,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAatB,SAAO,4CAAC,WAAM,OAAO,OAAO,QAAQ,OAAQ,eAAI;AACjD,CAAC;",
6
6
  "names": ["Watermark", "WatermarkInner", "LicenseStyles"]
7
7
  }
@@ -61,6 +61,7 @@ const defaultTldrawOptions = {
61
61
  flattenImageBoundsPadding: 16,
62
62
  laserDelayMs: 1200,
63
63
  maxExportDelayMs: 5e3,
64
+ tooltipDelayMs: 700,
64
65
  temporaryAssetPreviewLifetimeMs: 18e4,
65
66
  actionShortcutsLocation: "swap",
66
67
  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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwC;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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwC;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,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var EditorAtom_exports = {};
20
+ __export(EditorAtom_exports, {
21
+ EditorAtom: () => EditorAtom
22
+ });
23
+ module.exports = __toCommonJS(EditorAtom_exports);
24
+ var import_state = require("@tldraw/state");
25
+ var import_utils = require("@tldraw/utils");
26
+ class EditorAtom {
27
+ constructor(name, getInitialState) {
28
+ this.name = name;
29
+ this.getInitialState = getInitialState;
30
+ }
31
+ states = new import_utils.WeakCache();
32
+ getAtom(editor) {
33
+ return this.states.get(editor, () => (0, import_state.atom)(this.name, this.getInitialState(editor)));
34
+ }
35
+ get(editor) {
36
+ return this.getAtom(editor).get();
37
+ }
38
+ update(editor, update) {
39
+ return this.getAtom(editor).update(update);
40
+ }
41
+ set(editor, state) {
42
+ return this.getAtom(editor).set(state);
43
+ }
44
+ }
45
+ //# sourceMappingURL=EditorAtom.js.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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAC3B,mBAA0B;AAYnB,MAAM,WAAc;AAAA,EAG1B,YACS,MACA,iBACP;AAFO;AACA;AAAA,EACN;AAAA,EALK,SAAS,IAAI,uBAA2B;AAAA,EAOhD,QAAQ,QAAyB;AAChC,WAAO,KAAK,OAAO,IAAI,QAAQ,UAAM,mBAAK,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
+ }
@@ -22,10 +22,10 @@ __export(version_exports, {
22
22
  version: () => version
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- const version = "3.15.1";
25
+ const version = "3.16.0-canary.03ed24d72068";
26
26
  const publishDates = {
27
27
  major: "2024-09-13T14:36:29.063Z",
28
- minor: "2025-07-30T09:07:27.887Z",
29
- patch: "2025-08-06T09:33:59.683Z"
28
+ minor: "2025-08-13T15:17:41.559Z",
29
+ patch: "2025-08-13T15:17:41.559Z"
30
30
  };
31
31
  //# sourceMappingURL=version.js.map
@@ -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.15.1'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-07-30T09:07:27.887Z',\n\tpatch: '2025-08-06T09:33:59.683Z',\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-canary.03ed24d72068'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-08-13T15:17:41.559Z',\n\tpatch: '2025-08-13T15:17:41.559Z',\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -7,6 +7,7 @@ import { Editor as Editor_2 } from '@tiptap/core';
7
7
  import { EditorProviderProps as EditorProviderProps_2 } from '@tiptap/react';
8
8
  import EventEmitter from 'eventemitter3';
9
9
  import { ExoticComponent } from 'react';
10
+ import { ForwardRefExoticComponent } from 'react';
10
11
  import { HistoryEntry } from '@tldraw/store';
11
12
  import { IndexKey } from '@tldraw/utils';
12
13
  import { JsonObject } from '@tldraw/utils';
@@ -23,6 +24,7 @@ import { ReactElement } from 'react';
23
24
  import { ReactNode } from 'react';
24
25
  import { RecordProps } from '@tldraw/tlschema';
25
26
  import { RecordsDiff } from '@tldraw/store';
27
+ import { RefAttributes } from 'react';
26
28
  import { RefObject } from 'react';
27
29
  import { SerializedSchema } from '@tldraw/store';
28
30
  import { SerializedStore } from '@tldraw/store';
@@ -817,6 +819,9 @@ export declare const DefaultShapeIndicator: NamedExoticComponent<TLShapeIndicato
817
819
  /** @public @react */
818
820
  export declare const DefaultShapeIndicators: NamedExoticComponent<TLShapeIndicatorsProps>;
819
821
 
822
+ /** @public @react */
823
+ export declare const DefaultShapeWrapper: ForwardRefExoticComponent<TLShapeWrapperProps & RefAttributes<HTMLDivElement>>;
824
+
820
825
  /** @public @react */
821
826
  export declare function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps): JSX_2.Element;
822
827
 
@@ -884,6 +889,7 @@ export declare const defaultTldrawOptions: {
884
889
  readonly nonce: undefined;
885
890
  readonly temporaryAssetPreviewLifetimeMs: 180000;
886
891
  readonly textShadowLod: 0.35;
892
+ readonly tooltipDelayMs: 700;
887
893
  };
888
894
 
889
895
  /** @public */
@@ -899,6 +905,7 @@ export declare const defaultUserPreferences: Readonly<{
899
905
  isWrapMode: false;
900
906
  locale: "ar" | "bn" | "ca" | "cs" | "da" | "de" | "el" | "en" | "es" | "fa" | "fi" | "fr" | "gl" | "gu-in" | "he" | "hi-in" | "hr" | "hu" | "id" | "it" | "ja" | "km-kh" | "kn" | "ko-kr" | "ml" | "mr" | "ms" | "ne" | "nl" | "no" | "pa" | "pl" | "pt-br" | "pt-pt" | "ro" | "ru" | "sl" | "so" | "sv" | "ta" | "te" | "th" | "tl" | "tr" | "uk" | "ur" | "vi" | "zh-cn" | "zh-tw";
901
907
  name: "";
908
+ showUiLabels: false;
902
909
  }>;
903
910
 
904
911
  /**
@@ -2685,15 +2692,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2685
2692
  *
2686
2693
  * @returns The shape at the given point, or undefined if there is no shape at the point.
2687
2694
  */
2688
- getShapeAtPoint(point: VecLike, opts?: {
2689
- filter?(shape: TLShape): boolean;
2690
- hitFrameInside?: boolean;
2691
- hitInside?: boolean;
2692
- hitLabels?: boolean;
2693
- hitLocked?: boolean;
2694
- margin?: number;
2695
- renderingOnly?: boolean;
2696
- }): TLShape | undefined;
2695
+ getShapeAtPoint(point: VecLike, opts?: TLGetShapeAtPointOptions): TLShape | undefined;
2697
2696
  /**
2698
2697
  * Get the shapes, if any, at a given page point.
2699
2698
  *
@@ -3793,6 +3792,21 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3793
3792
  * @public
3794
3793
  */
3795
3794
  complete(): this;
3795
+ /**
3796
+ * Dispatch a pointer move event in the current position of the pointer. This is useful when
3797
+ * external circumstances have changed (e.g. the camera moved or a shape was moved) and you want
3798
+ * the current interaction to respond to that change.
3799
+ *
3800
+ * @example
3801
+ * ```ts
3802
+ * editor.updatePointer()
3803
+ * ```
3804
+ *
3805
+ * @param options - The options for updating the pointer.
3806
+ * @returns The editor instance.
3807
+ * @public
3808
+ */
3809
+ updatePointer(options?: TLUpdatePointerOptions): this;
3796
3810
  /**
3797
3811
  * Puts the editor into focused mode.
3798
3812
  *
@@ -4016,6 +4030,26 @@ export declare class Editor extends EventEmitter<TLEventMap> {
4016
4030
  /* Excluded from this release type: maybeTrackPerformance */
4017
4031
  }
4018
4032
 
4033
+ /**
4034
+ * An Atom that is scoped to the lifetime of an Editor.
4035
+ *
4036
+ * This is useful for storing UI state for tldraw applications. Keeping state scoped to an editor
4037
+ * instead of stored in a global atom can prevent issues with state being shared between editors
4038
+ * when navigating between pages, or when multiple editor instances are used on the same page.
4039
+ *
4040
+ * @public
4041
+ */
4042
+ export declare class EditorAtom<T> {
4043
+ private name;
4044
+ private getInitialState;
4045
+ private states;
4046
+ constructor(name: string, getInitialState: (editor: Editor) => T);
4047
+ getAtom(editor: Editor): Atom<T>;
4048
+ get(editor: Editor): T;
4049
+ update(editor: Editor, update: (state: T) => T): T;
4050
+ set(editor: Editor, state: T): T;
4051
+ }
4052
+
4019
4053
  /** @public */
4020
4054
  export declare const EditorContext: React_3.Context<Editor | null>;
4021
4055
 
@@ -5418,6 +5452,14 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
5418
5452
  * @public
5419
5453
  */
5420
5454
  onResizeEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void;
5455
+ /**
5456
+ * A callback called when a shape resize is cancelled.
5457
+ *
5458
+ * @param initial - The shape at the start of the resize.
5459
+ * @param current - The current shape.
5460
+ * @public
5461
+ */
5462
+ onResizeCancel?(initial: Shape, current: Shape): void;
5421
5463
  /**
5422
5464
  * A callback called when a shape starts being translated.
5423
5465
  *
@@ -5444,6 +5486,23 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
5444
5486
  * @public
5445
5487
  */
5446
5488
  onTranslateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void;
5489
+ /**
5490
+ * A callback called when a shape translation is cancelled.
5491
+ *
5492
+ * @param initial - The shape at the start of the translation.
5493
+ * @param current - The current shape.
5494
+ * @public
5495
+ */
5496
+ onTranslateCancel?(initial: Shape, current: Shape): void;
5497
+ /**
5498
+ * A callback called when a shape's handle starts being dragged.
5499
+ *
5500
+ * @param shape - The shape.
5501
+ * @param info - An object containing the handle and whether the handle is 'precise' or not.
5502
+ * @returns A change to apply to the shape, or void.
5503
+ * @public
5504
+ */
5505
+ onHandleDragStart?(shape: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void;
5447
5506
  /**
5448
5507
  * A callback called when a shape's handle changes.
5449
5508
  *
@@ -5453,6 +5512,23 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
5453
5512
  * @public
5454
5513
  */
5455
5514
  onHandleDrag?(shape: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void;
5515
+ /**
5516
+ * A callback called when a shape's handle finishes being dragged.
5517
+ *
5518
+ * @param current - The current shape.
5519
+ * @param info - An object containing the handle and whether the handle is 'precise' or not.
5520
+ * @returns A change to apply to the shape, or void.
5521
+ * @public
5522
+ */
5523
+ onHandleDragEnd?(current: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void;
5524
+ /**
5525
+ * A callback called when a shape's handle drag is cancelled.
5526
+ *
5527
+ * @param current - The current shape.
5528
+ * @param info - An object containing the handle and whether the handle is 'precise' or not.
5529
+ * @public
5530
+ */
5531
+ onHandleDragCancel?(current: Shape, info: TLHandleDragInfo<Shape>): void;
5456
5532
  /**
5457
5533
  * A callback called when a shape starts being rotated.
5458
5534
  *
@@ -5479,6 +5555,14 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
5479
5555
  * @public
5480
5556
  */
5481
5557
  onRotateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void;
5558
+ /**
5559
+ * A callback called when a shape rotation is cancelled.
5560
+ *
5561
+ * @param initial - The shape at the start of the rotation.
5562
+ * @param current - The current shape.
5563
+ * @public
5564
+ */
5565
+ onRotateCancel?(initial: Shape, current: Shape): void;
5482
5566
  /* Excluded from this release type: onBindingChange */
5483
5567
  /**
5484
5568
  * A callback called when a shape's children change.
@@ -6364,6 +6448,7 @@ export declare interface TldrawOptions {
6364
6448
  readonly flattenImageBoundsPadding: number;
6365
6449
  readonly laserDelayMs: number;
6366
6450
  readonly maxExportDelayMs: number;
6451
+ readonly tooltipDelayMs: number;
6367
6452
  /**
6368
6453
  * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before
6369
6454
  * they expire? Defaults to 3 minutes.
@@ -6429,6 +6514,7 @@ export declare interface TLEditorComponents {
6429
6514
  SelectionForeground?: ComponentType<TLSelectionForegroundProps> | null;
6430
6515
  ShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null;
6431
6516
  ShapeIndicators?: ComponentType | null;
6517
+ ShapeWrapper?: ComponentType<TLShapeWrapperProps & RefAttributes<HTMLDivElement>> | null;
6432
6518
  SnapIndicator?: ComponentType<TLSnapIndicatorProps> | null;
6433
6519
  Spinner?: ComponentType<React.SVGProps<SVGSVGElement>> | null;
6434
6520
  SvgDefs?: ComponentType | null;
@@ -6764,6 +6850,59 @@ export declare interface TLGeometryOpts {
6764
6850
  context?: string;
6765
6851
  }
6766
6852
 
6853
+ /**
6854
+ * Options to {@link Editor.getShapeAtPoint}.
6855
+ *
6856
+ * @public
6857
+ */
6858
+ export declare interface TLGetShapeAtPointOptions {
6859
+ /**
6860
+ * The margin to apply to the shape.
6861
+ * If a number, it will be applied to both the inside and outside of the shape.
6862
+ * 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.
6863
+ *
6864
+ * @example
6865
+ * ```ts
6866
+ * // Get the shape at the center of the screen
6867
+ * const shape = editor.getShapeAtProps({
6868
+ * margin: 10,
6869
+ * })
6870
+ *
6871
+ * // Get the shape at the center of the screen with a 10px inner margin and a 5px outer margin
6872
+ * const shape = editor.getShapeAtProps({
6873
+ * margin: [10, 5],
6874
+ * })
6875
+ * ```
6876
+ */
6877
+ margin?: [number, number] | number;
6878
+ /**
6879
+ * Whether to register hits inside of shapes (beyond the margin), such as the inside of a solid shape.
6880
+ */
6881
+ hitInside?: boolean;
6882
+ /**
6883
+ * Whether to register hits on locked shapes.
6884
+ */
6885
+ hitLocked?: boolean;
6886
+ /**
6887
+ * Whether to register hits on labels.
6888
+ */
6889
+ hitLabels?: boolean;
6890
+ /**
6891
+ * Whether to only return hits on shapes that are currently being rendered.
6892
+ * todo: rename this to hitCulled or hitNotRendering
6893
+ */
6894
+ renderingOnly?: boolean;
6895
+ /**
6896
+ * Whether to register hits on the inside of frame shapes.
6897
+ * todo: rename this to hitInsideFrames
6898
+ */
6899
+ hitFrameInside?: boolean;
6900
+ /**
6901
+ * A filter function to apply to the shapes.
6902
+ */
6903
+ filter?(shape: TLShape): boolean;
6904
+ }
6905
+
6767
6906
  /** @public */
6768
6907
  export declare interface TLGridProps {
6769
6908
  x: number;
@@ -6776,6 +6915,7 @@ export declare interface TLGridProps {
6776
6915
  export declare interface TLHandleDragInfo<T extends TLShape> {
6777
6916
  handle: TLHandle;
6778
6917
  isPrecise: boolean;
6918
+ isCreatingShape: boolean;
6779
6919
  initial?: T | undefined;
6780
6920
  }
6781
6921
 
@@ -7302,6 +7442,16 @@ export declare interface TLShapeUtilConstructor<T extends TLUnknownShape, U exte
7302
7442
  migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
7303
7443
  }
7304
7444
 
7445
+ /** @public */
7446
+ export declare interface TLShapeWrapperProps extends React.HTMLAttributes<HTMLDivElement> {
7447
+ /** The shape being rendered. */
7448
+ shape: TLShape;
7449
+ /** Whether this is the shapes regular, or background component. */
7450
+ isBackground: boolean;
7451
+ /** The shape's rendered component. */
7452
+ children: ReactNode;
7453
+ }
7454
+
7305
7455
  /** @public */
7306
7456
  export declare interface TLSnapIndicatorProps {
7307
7457
  className?: string;
@@ -7484,6 +7634,25 @@ export declare interface TLTldrawExternalContentSource {
7484
7634
  data: TLContent;
7485
7635
  }
7486
7636
 
7637
+ /** @public */
7638
+ export declare interface TLUpdatePointerOptions {
7639
+ /** Whether to update the pointer immediately, rather than on the next tick. */
7640
+ immediate?: boolean;
7641
+ /**
7642
+ * The point, in screen-space, to update the pointer to. Defaults to the position of the last
7643
+ * pointer event.
7644
+ */
7645
+ point?: VecLike;
7646
+ pointerId?: number;
7647
+ ctrlKey?: boolean;
7648
+ altKey?: boolean;
7649
+ shiftKey?: boolean;
7650
+ metaKey?: boolean;
7651
+ accelKey?: boolean;
7652
+ isPen?: boolean;
7653
+ button?: number;
7654
+ }
7655
+
7487
7656
  /** @public */
7488
7657
  export declare interface TLUrlExternalAsset {
7489
7658
  type: 'url';
@@ -7520,6 +7689,7 @@ export declare interface TLUserPreferences {
7520
7689
  isWrapMode?: boolean | null;
7521
7690
  isDynamicSizeMode?: boolean | null;
7522
7691
  isPasteAtCursorMode?: boolean | null;
7692
+ showUiLabels?: boolean | null;
7523
7693
  }
7524
7694
 
7525
7695
  /** @public */
@@ -7692,6 +7862,7 @@ export declare class UserPreferencesManager {
7692
7862
  isWrapMode: boolean;
7693
7863
  locale: string;
7694
7864
  name: string;
7865
+ showUiLabels: boolean;
7695
7866
  };
7696
7867
  getIsDarkMode(): boolean;
7697
7868
  /**
@@ -7708,6 +7879,7 @@ export declare class UserPreferencesManager {
7708
7879
  getIsWrapMode(): boolean;
7709
7880
  getIsDynamicResizeMode(): boolean;
7710
7881
  getIsPasteAtCursorMode(): boolean;
7882
+ getShowUiLabels(): boolean;
7711
7883
  }
7712
7884
 
7713
7885
  /** @public */
@@ -46,6 +46,9 @@ import {
46
46
  import {
47
47
  DefaultShapeIndicators
48
48
  } from "./lib/components/default-components/DefaultShapeIndicators.mjs";
49
+ import {
50
+ DefaultShapeWrapper
51
+ } from "./lib/components/default-components/DefaultShapeWrapper.mjs";
49
52
  import {
50
53
  DefaultSnapIndicator
51
54
  } from "./lib/components/default-components/DefaultSnapIndictor.mjs";
@@ -270,6 +273,7 @@ import {
270
273
  setPointerCapture,
271
274
  stopEventPropagation
272
275
  } from "./lib/utils/dom.mjs";
276
+ import { EditorAtom } from "./lib/utils/EditorAtom.mjs";
273
277
  import { getIncrementedName } from "./lib/utils/getIncrementedName.mjs";
274
278
  import { getPointerInfo } from "./lib/utils/getPointerInfo.mjs";
275
279
  import { getSvgPathFromPoints } from "./lib/utils/getSvgPathFromPoints.mjs";
@@ -299,7 +303,7 @@ function debugEnableLicensing() {
299
303
  }
300
304
  registerTldrawLibraryVersion(
301
305
  "@tldraw/editor",
302
- "3.15.1",
306
+ "3.16.0-canary.03ed24d72068",
303
307
  "esm"
304
308
  );
305
309
  export {
@@ -330,6 +334,7 @@ export {
330
334
  DefaultSelectionForeground,
331
335
  DefaultShapeIndicator,
332
336
  DefaultShapeIndicators,
337
+ DefaultShapeWrapper,
333
338
  DefaultSnapIndicator,
334
339
  DefaultSpinner,
335
340
  DefaultSvgDefs,
@@ -338,6 +343,7 @@ export {
338
343
  Edge2d,
339
344
  EdgeScrollManager,
340
345
  Editor,
346
+ EditorAtom,
341
347
  EditorContext,
342
348
  EditorProvider,
343
349
  Ellipse2d,