tldraw 4.3.0-next.2d181ae353a2 → 4.3.0-next.40e4536afc8e

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 (561) hide show
  1. package/README.md +0 -2
  2. package/dist-cjs/index.d.ts +297 -237
  3. package/dist-cjs/index.js +13 -5
  4. package/dist-cjs/index.js.map +2 -2
  5. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
  6. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  7. package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
  8. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  9. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
  10. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  11. package/dist-cjs/lib/defaultSideEffects.js +6 -1
  12. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  13. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +14 -13
  14. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  15. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  16. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
  17. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  18. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  19. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  20. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
  21. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
  22. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
  23. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  24. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
  25. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  26. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
  27. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  28. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
  29. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
  31. package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
  32. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
  33. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
  34. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
  35. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  36. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +6 -5
  37. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  38. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
  39. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  40. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
  41. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  42. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
  43. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  44. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +23 -21
  45. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  46. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
  47. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  48. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +6 -11
  49. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  50. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
  51. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  52. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
  53. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  54. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
  55. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
  56. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
  57. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
  58. package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
  59. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  60. package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
  61. package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
  62. package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
  63. package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
  64. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
  65. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  66. package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
  67. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  68. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
  69. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  70. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
  71. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  72. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
  73. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  74. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
  75. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  76. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +4 -5
  77. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  78. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
  79. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  80. package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
  81. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  82. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
  83. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
  84. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
  85. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
  86. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
  87. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
  88. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +9 -7
  89. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  90. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
  91. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  92. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
  93. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  94. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
  95. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  96. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
  97. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  98. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
  99. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  100. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
  101. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
  102. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
  103. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
  104. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +7 -5
  105. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  106. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
  107. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  108. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
  109. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  110. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
  111. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  112. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
  113. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  114. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
  115. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  116. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
  117. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  118. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
  119. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  120. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
  121. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  122. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
  123. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  124. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
  125. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  126. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
  127. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  128. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +7 -6
  129. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  130. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
  131. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  132. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
  133. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  134. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
  135. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
  136. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
  137. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
  138. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
  139. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
  140. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
  141. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  142. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
  143. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
  144. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
  145. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
  146. package/dist-cjs/lib/ui/TldrawUi.js +2 -2
  147. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  148. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
  149. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
  150. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
  151. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  152. package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
  153. package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
  154. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +1 -21
  155. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
  156. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
  157. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
  159. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  160. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  161. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
  162. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
  163. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
  164. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
  165. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
  166. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  167. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
  168. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
  169. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
  170. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
  171. package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
  172. package/dist-cjs/lib/ui/components/menu-items.js +3 -1
  173. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  174. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
  175. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  176. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
  177. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  178. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +149 -93
  179. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  180. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
  181. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
  182. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +14 -7
  183. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  184. package/dist-cjs/lib/ui/context/actions.js +6 -6
  185. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  186. package/dist-cjs/lib/ui/context/components.js +1 -2
  187. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  188. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
  189. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  190. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  191. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  192. package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
  193. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  194. package/dist-cjs/lib/ui/version.js +3 -3
  195. package/dist-cjs/lib/ui/version.js.map +1 -1
  196. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -6
  197. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  198. package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
  199. package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
  200. package/dist-cjs/lib/utils/text/richText.js +15 -19
  201. package/dist-cjs/lib/utils/text/richText.js.map +3 -3
  202. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
  203. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  204. package/dist-esm/index.d.mts +297 -237
  205. package/dist-esm/index.mjs +14 -5
  206. package/dist-esm/index.mjs.map +2 -2
  207. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
  208. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  209. package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
  210. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  211. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
  212. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  213. package/dist-esm/lib/defaultSideEffects.mjs +6 -1
  214. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  215. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
  216. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  217. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
  218. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  219. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  220. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  221. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
  222. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
  223. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
  224. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  225. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
  226. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  227. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
  228. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  229. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
  230. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  231. package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
  232. package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
  233. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
  234. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
  235. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
  236. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  237. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +6 -5
  238. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  239. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
  240. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  241. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
  242. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  243. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
  244. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  245. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +24 -22
  246. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  247. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
  248. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  249. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +7 -12
  250. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  251. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
  252. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  253. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
  254. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  255. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
  256. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  257. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
  258. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  259. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
  260. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  261. package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
  262. package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
  263. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
  264. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
  265. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
  266. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  267. package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
  268. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  269. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
  270. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  271. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
  272. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  273. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
  274. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  275. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
  276. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  277. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +4 -5
  278. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  279. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +2 -4
  280. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  281. package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
  282. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  283. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
  284. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
  285. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
  286. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
  287. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
  288. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
  289. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +9 -7
  290. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  291. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
  292. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  293. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
  294. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  295. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
  296. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  297. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
  298. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  299. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
  300. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  301. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
  302. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
  303. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
  304. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
  305. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +7 -5
  306. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  307. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
  308. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  309. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
  310. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  311. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
  312. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  313. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
  314. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  315. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -15
  316. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  317. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
  318. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  319. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
  320. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  321. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
  322. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  323. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
  324. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  325. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
  326. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  327. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
  328. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  329. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +7 -6
  330. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  331. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
  332. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  333. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
  334. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  335. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
  336. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
  337. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
  338. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
  339. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
  340. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
  341. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
  342. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  343. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
  344. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
  345. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
  346. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
  347. package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
  348. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  349. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
  350. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
  351. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
  352. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  353. package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
  354. package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
  355. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +3 -30
  356. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
  357. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
  358. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
  359. package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
  360. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  361. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  362. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
  363. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
  364. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
  365. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
  366. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
  367. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  368. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
  369. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
  370. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
  371. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
  372. package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
  373. package/dist-esm/lib/ui/components/menu-items.mjs +3 -1
  374. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  375. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
  376. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  377. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
  378. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  379. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +157 -95
  380. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  381. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
  382. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
  383. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +15 -8
  384. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  385. package/dist-esm/lib/ui/context/actions.mjs +6 -6
  386. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  387. package/dist-esm/lib/ui/context/components.mjs +1 -2
  388. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  389. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  390. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  391. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  392. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  393. package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
  394. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  395. package/dist-esm/lib/ui/version.mjs +3 -3
  396. package/dist-esm/lib/ui/version.mjs.map +1 -1
  397. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +9 -6
  398. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  399. package/dist-esm/lib/utils/test-helpers.mjs +21 -0
  400. package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
  401. package/dist-esm/lib/utils/text/richText.mjs +12 -5
  402. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  403. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
  404. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  405. package/package.json +18 -16
  406. package/src/index.ts +6 -2
  407. package/src/lib/Tldraw.test.tsx +46 -1
  408. package/src/lib/canvas/TldrawSelectionForeground.tsx +2 -2
  409. package/src/lib/defaultEmbedDefinitions.ts +2 -1
  410. package/src/lib/defaultExternalContentHandlers.ts +10 -10
  411. package/src/lib/defaultSideEffects.ts +6 -1
  412. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
  413. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
  414. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +15 -15
  415. package/src/lib/shapes/arrow/arrow-types.ts +2 -0
  416. package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
  417. package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
  418. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
  419. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
  420. package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
  421. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +7 -4
  422. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
  423. package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
  424. package/src/lib/shapes/draw/DrawShapeUtil.tsx +31 -27
  425. package/src/lib/shapes/draw/getPath.ts +31 -10
  426. package/src/lib/shapes/draw/toolStates/Drawing.ts +96 -86
  427. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +7 -0
  428. package/src/lib/shapes/frame/FrameShapeUtil.tsx +10 -4
  429. package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
  430. package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
  431. package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
  432. package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
  433. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +25 -24
  434. package/src/lib/shapes/line/toolStates/Pointing.ts +3 -3
  435. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
  436. package/src/lib/shapes/note/noteCloning.test.ts +3 -1
  437. package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
  438. package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
  439. package/src/lib/shapes/shared/PlainTextLabel.tsx +10 -1
  440. package/src/lib/shapes/shared/RichTextLabel.tsx +12 -3
  441. package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
  442. package/src/lib/shapes/shared/interpolate-props.ts +4 -4
  443. package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
  444. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
  445. package/src/lib/shapes/text/RichTextArea.tsx +5 -0
  446. package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
  447. package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
  448. package/src/lib/shapes/text/toolStates/Pointing.ts +7 -7
  449. package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
  450. package/src/lib/tools/EraserTool/childStates/Erasing.ts +4 -5
  451. package/src/lib/tools/EraserTool/childStates/Pointing.ts +2 -4
  452. package/src/lib/tools/HandTool/HandTool.ts +3 -5
  453. package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
  454. package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
  455. package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
  456. package/src/lib/tools/SelectTool/DragAndDropManager.ts +12 -7
  457. package/src/lib/tools/SelectTool/childStates/Brushing.ts +6 -5
  458. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
  459. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +1 -1
  460. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
  461. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
  462. package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
  463. package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
  464. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +7 -5
  465. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +55 -12
  466. package/src/lib/tools/SelectTool/childStates/Idle.ts +58 -71
  467. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +6 -7
  468. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
  469. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +5 -5
  470. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
  471. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
  472. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
  473. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
  474. package/src/lib/tools/SelectTool/childStates/Resizing.ts +6 -6
  475. package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
  476. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +7 -6
  477. package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -12
  478. package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
  479. package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
  480. package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
  481. package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
  482. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
  483. package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
  484. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
  485. package/src/lib/ui/TldrawUi.tsx +5 -2
  486. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
  487. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
  488. package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
  489. package/src/lib/ui/components/DefaultDebugPanel.tsx +3 -42
  490. package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
  491. package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
  492. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  493. package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
  494. package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
  495. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
  496. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
  497. package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
  498. package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
  499. package/src/lib/ui/components/menu-items.tsx +3 -1
  500. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
  501. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
  502. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +208 -113
  503. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
  504. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
  505. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +7 -4
  506. package/src/lib/ui/context/actions.tsx +6 -6
  507. package/src/lib/ui/context/components.tsx +1 -2
  508. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  509. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
  510. package/src/lib/ui/hooks/useTools.tsx +4 -5
  511. package/src/lib/ui/version.ts +3 -3
  512. package/src/lib/ui.css +27 -23
  513. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
  514. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +11 -6
  515. package/src/lib/utils/test-helpers.ts +60 -0
  516. package/src/lib/utils/text/richText.ts +13 -8
  517. package/src/lib/utils/tldr/buildFromV1Document.ts +9 -2
  518. package/src/test/Editor.test.tsx +40 -29
  519. package/src/test/EraserTool.test.ts +10 -12
  520. package/src/test/TestEditor.ts +48 -47
  521. package/src/test/TldrawEditor.test.tsx +6 -4
  522. package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
  523. package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
  524. package/src/test/arrows-megabus.test.tsx +1 -1
  525. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
  526. package/src/test/commands/cameraState.test.ts +299 -0
  527. package/src/test/commands/putContent.test.ts +79 -1
  528. package/src/test/commands/setCamera.test.ts +13 -11
  529. package/src/test/commands/stackShapes.test.ts +34 -8
  530. package/src/test/commands/zoomToBounds.test.ts +19 -3
  531. package/src/test/commands/zoomToSelection.test.ts +14 -3
  532. package/src/test/custom-clipping.test.ts +16 -9
  533. package/src/test/drawing.test.ts +17 -10
  534. package/src/test/flipShapes.test.ts +33 -0
  535. package/src/test/frames.test.ts +92 -0
  536. package/src/test/groups.test.tsx +1 -1
  537. package/src/test/modifiers.test.ts +6 -6
  538. package/src/test/resizing.test.ts +7 -9
  539. package/src/test/selection-omnibus.test.ts +2 -2
  540. package/src/test/spacebarPanning.test.ts +28 -10
  541. package/src/test/test-jsx.tsx +3 -0
  542. package/src/test/ui/BackToContent.test.tsx +111 -0
  543. package/tldraw.css +41 -35
  544. package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
  545. package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
  546. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
  547. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
  548. package/dist-cjs/lib/utils/text/textDirection.js +0 -51
  549. package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
  550. package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
  551. package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
  552. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
  553. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
  554. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
  555. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
  556. package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
  557. package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
  558. package/src/lib/shapes/shared/useForceSolid.ts +0 -6
  559. package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
  560. package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
  561. package/src/lib/utils/text/textDirection.ts +0 -32
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/defaultEmbedDefinitions.ts"],
4
- "sourcesContent": ["import { safeParseUrl } from '@tldraw/editor'\n\n// Only allow multiplayer embeds. If we add additional routes later for example '/help' this won't match\nconst TLDRAW_APP_RE = /(^\\/[f|p|r|ro|s|v]\\/[^/]+\\/?$)/\n\n/** @public */\nexport const DEFAULT_EMBED_DEFINITIONS = [\n\t{\n\t\ttype: 'tldraw',\n\t\ttitle: 'tldraw',\n\t\thostnames: ['beta.tldraw.com', 'tldraw.com', 'localhost:3000'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-top-navigation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: false,\n\t},\n\t{\n\t\ttype: 'figma',\n\t\ttitle: 'Figma',\n\t\thostnames: ['figma.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (\n\t\t\t\t!!url.match(\n\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\t/https:\\/\\/([\\w\\.-]+\\.)?figma.com\\/(file|proto|design)\\/([0-9a-zA-Z]{22,128})(?:\\/.*)?$/\n\t\t\t\t) &&\n\t\t\t\t!url.includes('figma.com/embed')\n\t\t\t) {\n\t\t\t\treturn `https://www.figma.com/embed?embed_host=share&url=${url}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/?$/)) {\n\t\t\t\tconst outUrl = urlObj.searchParams.get('url')\n\t\t\t\tif (outUrl) {\n\t\t\t\t\treturn outUrl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'google_maps',\n\t\ttitle: 'Google Maps',\n\t\thostnames: ['google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (url.includes('/maps/embed?')) {\n\t\t\t\treturn url\n\t\t\t} else if (url.includes('/maps/')) {\n\t\t\t\tconst match = url.match(/@(.*?),(.*?),(.*?)(z|m)/)\n\t\t\t\tlet result: string\n\t\t\t\tif (match) {\n\t\t\t\t\tconst [, lat, lng, zoomOrMeters, mapTypeSymbol] = match\n\t\t\t\t\tconst mapType = mapTypeSymbol === 'z' ? 'roadmap' : 'satellite'\n\t\t\t\t\t// Note: This meters to zoom equation is a rough approximation and not canonical.\n\t\t\t\t\tconst z =\n\t\t\t\t\t\tmapType === 'roadmap'\n\t\t\t\t\t\t\t? zoomOrMeters\n\t\t\t\t\t\t\t: -Math.log2(parseInt(zoomOrMeters) / 14772321) / 0.8\n\t\t\t\t\tconst host = new URL(url).host.replace('www.', '')\n\t\t\t\t\tresult = `https://${host}/maps/embed/v1/view?key=${process.env.NEXT_PUBLIC_GC_API_KEY}&center=${lat},${lng}&zoom=${z}&maptype=${mapType}`\n\t\t\t\t} else {\n\t\t\t\t\tresult = ''\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst matches = urlObj.pathname.match(/^\\/maps\\/embed\\/v1\\/view\\/?$/)\n\t\t\tif (matches && urlObj.searchParams.has('center') && urlObj.searchParams.get('zoom')) {\n\t\t\t\tconst zoom = urlObj.searchParams.get('zoom') ?? '12'\n\t\t\t\tconst mapType = urlObj.searchParams.get('maptype') ?? 'roadmap'\n\t\t\t\t// Note: This zoom to meters equation is a rough approximation and not canonical.\n\t\t\t\tconst zoomOrMeters =\n\t\t\t\t\tmapType === 'roadmap' ? zoom : 14772321 * Math.pow(2, parseInt(zoom) * -0.8)\n\t\t\t\tconst [lat, lon] = urlObj.searchParams.get('center')!.split(',')\n\t\t\t\treturn `https://www.google.com/maps/@${lat},${lon},${zoomOrMeters}${mapType === 'roadmap' ? 'z' : 'm'}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'val_town',\n\t\ttitle: 'Val Town',\n\t\thostnames: ['val.town'],\n\t\tminWidth: 260,\n\t\tminHeight: 100,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/v\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/v/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codesandbox',\n\t\ttitle: 'CodeSandbox',\n\t\thostnames: ['codesandbox.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/s\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/s/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codepen',\n\t\ttitle: 'Codepen',\n\t\thostnames: ['codepen.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_URL_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/pen\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_EMBED_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/pen/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'scratch',\n\t\ttitle: 'Scratch',\n\t\thostnames: ['scratch.mit.edu'],\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: false,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_URL_REGEXP = /https?:\\/\\/scratch.mit.edu\\/projects\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_EMBED_REGEXP = /https:\\/\\/scratch.mit.edu\\/projects\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'youtube',\n\t\ttitle: 'YouTube',\n\t\thostnames: ['*.youtube.com', 'youtube.com', 'youtu.be'],\n\t\twidth: 800,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtu.be') {\n\t\t\t\tconst videoId = urlObj.pathname.split('/').filter(Boolean)[0]\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t} else if (\n\t\t\t\t(hostname === 'youtube.com' || hostname === 'm.youtube.com') &&\n\t\t\t\turlObj.pathname.match(/^\\/watch/)\n\t\t\t) {\n\t\t\t\tconst videoId = urlObj.searchParams.get('v')\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tsearchParams.delete('v')\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtube.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?/)\n\t\t\t\tif (matches) {\n\t\t\t\t\tconst params = new URLSearchParams(urlObj.search)\n\t\t\t\t\tparams.set('v', matches?.[1] ?? '')\n\t\t\t\t\tconst timeStart = params.get('start')\n\t\t\t\t\tif (timeStart) {\n\t\t\t\t\t\tparams.set('t', timeStart)\n\t\t\t\t\t\tparams.delete('start')\n\t\t\t\t\t}\n\t\t\t\t\treturn `https://www.youtube.com/watch?${params.toString()}`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_calendar',\n\t\ttitle: 'Google Calendar',\n\t\thostnames: ['calendar.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\tinstructionLink: 'https://support.google.com/calendar/answer/41207?hl=en',\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst cidQs = urlObj?.searchParams.get('cid')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/u\\/0/) && cidQs) {\n\t\t\t\turlObj.pathname = '/calendar/embed'\n\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('src', cidQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst srcQs = urlObj?.searchParams.get('src')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/embed/) && srcQs) {\n\t\t\t\turlObj.pathname = '/calendar/u/0'\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('cid', srcQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_slides',\n\t\ttitle: 'Google Slides',\n\t\thostnames: ['docs.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/pub\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/pub$/, '/embed')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/embed\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/embed$/, '/pub')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'github_gist',\n\t\ttitle: 'GitHub Gist',\n\t\thostnames: ['gist.github.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\t// Security warning:\n\t\t// Gists allow adding .json extensions to the URL which return JSONP.\n\t\t// Furthermore, the JSONP can include callbacks that execute arbitrary JavaScript.\n\t\t// It _is_ sandboxed by the iframe but we still want to disable it nonetheless.\n\t\t// We restrict the id to only allow hexdecimal characters to prevent this.\n\t\t// Read more:\n\t\t// https://github.com/bhaveshk90/Content-Security-Policy-CSP-Bypass-Techniques\n\t\t// https://github.com/renniepak/CSPBypass\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'replit',\n\t\ttitle: 'Replit',\n\t\thostnames: ['replit.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/)) {\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/) &&\n\t\t\t\turlObj.searchParams.has('embed')\n\t\t\t) {\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'felt',\n\t\ttitle: 'Felt',\n\t\thostnames: ['felt.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/map\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/map\\//)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'spotify',\n\t\ttitle: 'Spotify',\n\t\thostnames: ['open.spotify.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminHeight: 500,\n\t\toverrideOutlineRadius: 12,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'vimeo',\n\t\ttitle: 'Vimeo',\n\t\thostnames: ['vimeo.com', 'player.vimeo.com'],\n\t\twidth: 640,\n\t\theight: 360,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'vimeo.com') {\n\t\t\t\tif (urlObj.pathname.match(/^\\/[0-9]+/)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t'https://player.vimeo.com/video/' + urlObj.pathname.split('/')[1] + '?title=0&byline=0'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'player.vimeo.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/video\\/([^/]+)\\/?$/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn 'https://vimeo.com/' + matches[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'observable',\n\t\ttitle: 'Observable',\n\t\thostnames: ['observablehq.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: false,\n\t\tbackgroundColor: '#fff',\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}/embed${urlObj.pathname}?cell=*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/d\\/([^/]+)\\/?$/)) {\n\t\t\t\tconst pathName = urlObj.pathname.replace(/^\\/d/, '')\n\t\t\t\treturn `${urlObj.origin}/embed${pathName}?cell=*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '')}#cell-*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '/d')}#cell-*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'desmos',\n\t\ttitle: 'Desmos',\n\t\thostnames: ['desmos.com'],\n\t\twidth: 700,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn `${url}?embed`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '?embed' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn url.replace('?embed', '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n] as const satisfies readonly EmbedDefinition[]\n\n/**\n * Permissions with note inline from\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n *\n * @public\n */\nexport const embedShapePermissionDefaults = {\n\t// ========================================================================================\n\t// Disabled permissions\n\t// ========================================================================================\n\t// [MDN] Experimental: Allows for downloads to occur without a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads-without-user-activation': false,\n\t// [MDN] Allows for downloads to occur with a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads': false,\n\t// [MDN] Lets the resource open modal windows.\n\t// [REASON] The <iframe/> could 'window.prompt(\"Enter your tldraw password\")'.\n\t'allow-modals': false,\n\t// [MDN] Lets the resource lock the screen orientation.\n\t// [REASON] Would interfere with the tldraw interface.\n\t'allow-orientation-lock': false,\n\t// [MDN] Lets the resource use the Pointer Lock API.\n\t// [REASON] Maybe we should allow this for games embeds (scratch/codepen/codesandbox).\n\t'allow-pointer-lock': false,\n\t// [MDN] Allows popups (such as window.open(), target=\"_blank\", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.\n\t// [REASON] We want to allow embeds to link back to their original sites (e.g. YouTube).\n\t'allow-popups': true,\n\t// [MDN] Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.\n\t// [REASON] We shouldn't allow popups as a embed could pretend to be us by opening a mocked version of tldraw. This is very unobvious when it is performed as an action within our app.\n\t'allow-popups-to-escape-sandbox': false,\n\t// [MDN] Lets the resource start a presentation session.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-presentation': false,\n\t// [MDN] Experimental: Lets the resource request access to the parent's storage capabilities with the Storage Access API.\n\t// [REASON] We don't want anyone else to access our storage.\n\t'allow-storage-access-by-user-activation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context (the one named _top).\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation-by-user-activation': false,\n\t// ========================================================================================\n\t// Enabled permissions\n\t// ========================================================================================\n\t// [MDN] Lets the resource run scripts (but not create popup windows).\n\t'allow-scripts': true,\n\t// [MDN] If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy (potentially preventing access to data storage/cookies and some JavaScript APIs).\n\t'allow-same-origin': true,\n\t// [MDN] Allows the resource to submit forms. If this keyword is not used, form submission is blocked.\n\t'allow-forms': true,\n} as const\n\n/** @public */\nexport type TLEmbedShapePermissions = { [K in keyof typeof embedShapePermissionDefaults]?: boolean }\n\n/** @public */\nexport interface EmbedDefinition {\n\treadonly type: string\n\treadonly title: string\n\treadonly hostnames: readonly string[]\n\treadonly minWidth?: number\n\treadonly minHeight?: number\n\treadonly width: number\n\treadonly height: number\n\treadonly doesResize: boolean\n\treadonly isAspectRatioLocked?: boolean\n\treadonly overridePermissions?: TLEmbedShapePermissions\n\treadonly instructionLink?: string\n\treadonly backgroundColor?: string\n\treadonly embedOnPaste?: boolean\n\t// TODO: FIXME this is ugly be required because some embeds have their own border radius for example spotify embeds\n\treadonly overrideOutlineRadius?: number\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly toEmbedUrl: (url: string) => string | undefined\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly fromEmbedUrl: (url: string) => string | undefined\n}\n\n/** @public */\nexport interface CustomEmbedDefinition extends EmbedDefinition {\n\treadonly icon: string\n}\n\n/** @public */\nexport type TLEmbedDefinition = EmbedDefinition | CustomEmbedDefinition\n\n/** @public */\nexport type DefaultEmbedDefinitionType = (typeof DEFAULT_EMBED_DEFINITIONS)[number]['type']\n\nconst DEFAULT_EMBED_DEFINITION_TYPES = DEFAULT_EMBED_DEFINITIONS.map(\n\t(def) => def.type\n) as DefaultEmbedDefinitionType[]\n\n/** @public */\nexport function isDefaultEmbedDefinitionType(type: string): type is DefaultEmbedDefinitionType {\n\treturn DEFAULT_EMBED_DEFINITION_TYPES.includes(type as DefaultEmbedDefinitionType)\n}\n\n/** @public */\nexport function isCustomEmbedDefinition(\n\tdef: EmbedDefinition | CustomEmbedDefinition\n): def is CustomEmbedDefinition {\n\treturn 'icon' in def\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAG7B,MAAM,gBAAgB;AAGf,MAAM,4BAA4B;AAAA,EACxC;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAW,CAAC,mBAAmB,cAAc,gBAAgB;AAAA,IAC7D,UAAU;AAAA,IACV,WAAW;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,qBAAqB;AAAA,MACpB,wBAAwB;AAAA,IACzB;AAAA,IACA,YAAY,CAAC,QAAQ;AACpB,YAAM,SAAS,aAAa,GAAG;AAC/B,UAAI,UAAU,OAAO,SAAS,MAAM,aAAa,GAAG;AAEnD,eAAO,aAAa,OAAO,SAAS,MAAM;AAC1C,eAAO;AAAA,MACR;AACA;AAAA,IACD;AAAA,IACA,cAAc,CAAC,QAAQ;AACtB,YAAM,SAAS,aAAa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OAAO,SAAS,IACf;AACD,eAAO,GAAG,GAAG;AAAA,MACd;AACA;AAAA,IACD;AAAA,IACA,cAAc,CAAC,QAAQ;AACtB,YAAM,SAAS,aAAa,GAAG;AAC/B,UACC,UACA,OAAO,aAAa,oBACpB,OAAO,SAAS,MAAM,4BAA4B,KAClD,OAAO,WAAW,YAClB,OAAO,SAAS,IACf;AACD,eAAO,IAAI,QAAQ,UAAU,EAAE;AAAA,MAChC;AACA;AAAA,IACD;AAAA,EACD;AACD;AAQO,MAAM,+BAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3C,2CAA2C;AAAA;AAAA;AAAA,EAG3C,mBAAmB;AAAA;AAAA;AAAA,EAGnB,gBAAgB;AAAA;AAAA;AAAA,EAGhB,0BAA0B;AAAA;AAAA;AAAA,EAG1B,sBAAsB;AAAA;AAAA;AAAA,EAGtB,gBAAgB;AAAA;AAAA;AAAA,EAGhB,kCAAkC;AAAA;AAAA;AAAA,EAGlC,sBAAsB;AAAA;AAAA;AAAA,EAGtB,2CAA2C;AAAA;AAAA;AAAA,EAG3C,wBAAwB;AAAA;AAAA;AAAA,EAGxB,2CAA2C;AAAA;AAAA;AAAA;AAAA;AAAA,EAK3C,iBAAiB;AAAA;AAAA,EAEjB,qBAAqB;AAAA;AAAA,EAErB,eAAe;AAChB;AAuCA,MAAM,iCAAiC,0BAA0B;AAAA,EAChE,CAAC,QAAQ,IAAI;AACd;AAGO,SAAS,6BAA6B,MAAkD;AAC9F,SAAO,+BAA+B,SAAS,IAAkC;AAClF;AAGO,SAAS,wBACf,KAC+B;AAC/B,SAAO,UAAU;AAClB;",
4
+ "sourcesContent": ["import { safeParseUrl } from '@tldraw/editor'\n\n// Only allow multiplayer embeds. If we add additional routes later for example '/help' this won't match\nconst TLDRAW_APP_RE = /(^\\/[f|p|r|ro|s|v]\\/[^/]+\\/?$)/\n\n/** @public */\nexport const DEFAULT_EMBED_DEFINITIONS = [\n\t{\n\t\ttype: 'tldraw',\n\t\ttitle: 'tldraw',\n\t\thostnames: ['beta.tldraw.com', 'tldraw.com', 'localhost:3000'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-top-navigation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: false,\n\t},\n\t{\n\t\ttype: 'figma',\n\t\ttitle: 'Figma',\n\t\thostnames: ['figma.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (\n\t\t\t\t!!url.match(\n\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\t/https:\\/\\/([\\w\\.-]+\\.)?figma.com\\/(file|proto|design)\\/([0-9a-zA-Z]{22,128})(?:\\/.*)?$/\n\t\t\t\t) &&\n\t\t\t\t!url.includes('figma.com/embed')\n\t\t\t) {\n\t\t\t\treturn `https://www.figma.com/embed?embed_host=share&url=${url}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/?$/)) {\n\t\t\t\tconst outUrl = urlObj.searchParams.get('url')\n\t\t\t\tif (outUrl) {\n\t\t\t\t\treturn outUrl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'google_maps',\n\t\ttitle: 'Google Maps',\n\t\thostnames: ['google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (url.includes('/maps/embed?')) {\n\t\t\t\treturn url\n\t\t\t} else if (url.includes('/maps/')) {\n\t\t\t\tconst match = url.match(/@(.*?),(.*?),(.*?)(z|m)/)\n\t\t\t\tlet result: string\n\t\t\t\tif (match) {\n\t\t\t\t\tconst [, lat, lng, zoomOrMeters, mapTypeSymbol] = match\n\t\t\t\t\tconst mapType = mapTypeSymbol === 'z' ? 'roadmap' : 'satellite'\n\t\t\t\t\t// Note: This meters to zoom equation is a rough approximation and not canonical.\n\t\t\t\t\tconst z =\n\t\t\t\t\t\tmapType === 'roadmap'\n\t\t\t\t\t\t\t? zoomOrMeters\n\t\t\t\t\t\t\t: -Math.log2(parseInt(zoomOrMeters) / 14772321) / 0.8\n\t\t\t\t\tconst host = new URL(url).host.replace('www.', '')\n\t\t\t\t\tresult = `https://${host}/maps/embed/v1/view?key=${process.env.NEXT_PUBLIC_GC_API_KEY}&center=${lat},${lng}&zoom=${z}&maptype=${mapType}`\n\t\t\t\t} else {\n\t\t\t\t\tresult = ''\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst matches = urlObj.pathname.match(/^\\/maps\\/embed\\/v1\\/view\\/?$/)\n\t\t\tif (matches && urlObj.searchParams.has('center') && urlObj.searchParams.get('zoom')) {\n\t\t\t\tconst zoom = urlObj.searchParams.get('zoom') ?? '12'\n\t\t\t\tconst mapType = urlObj.searchParams.get('maptype') ?? 'roadmap'\n\t\t\t\t// Note: This zoom to meters equation is a rough approximation and not canonical.\n\t\t\t\tconst zoomOrMeters =\n\t\t\t\t\tmapType === 'roadmap' ? zoom : 14772321 * Math.pow(2, parseInt(zoom) * -0.8)\n\t\t\t\tconst [lat, lon] = urlObj.searchParams.get('center')!.split(',')\n\t\t\t\treturn `https://www.google.com/maps/@${lat},${lon},${zoomOrMeters}${mapType === 'roadmap' ? 'z' : 'm'}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'val_town',\n\t\ttitle: 'Val Town',\n\t\thostnames: ['val.town'],\n\t\tminWidth: 260,\n\t\tminHeight: 100,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/v\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/v/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codesandbox',\n\t\ttitle: 'CodeSandbox',\n\t\thostnames: ['codesandbox.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/s\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/s/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codepen',\n\t\ttitle: 'Codepen',\n\t\thostnames: ['codepen.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_URL_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/pen\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_EMBED_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/pen/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'scratch',\n\t\ttitle: 'Scratch',\n\t\thostnames: ['scratch.mit.edu'],\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: false,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_URL_REGEXP = /https?:\\/\\/scratch.mit.edu\\/projects\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_EMBED_REGEXP = /https:\\/\\/scratch.mit.edu\\/projects\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'youtube',\n\t\ttitle: 'YouTube',\n\t\thostnames: ['*.youtube.com', 'youtube.com', 'youtu.be'],\n\t\twidth: 800,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtu.be') {\n\t\t\t\tconst videoId = urlObj.pathname.split('/').filter(Boolean)[0]\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t} else if (\n\t\t\t\t(hostname === 'youtube.com' || hostname === 'm.youtube.com') &&\n\t\t\t\turlObj.pathname.match(/^\\/watch/)\n\t\t\t) {\n\t\t\t\tconst videoId = urlObj.searchParams.get('v')\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tsearchParams.delete('v')\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtube.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?/)\n\t\t\t\tif (matches) {\n\t\t\t\t\tconst params = new URLSearchParams(urlObj.search)\n\t\t\t\t\tparams.set('v', matches?.[1] ?? '')\n\t\t\t\t\tconst timeStart = params.get('start')\n\t\t\t\t\tif (timeStart) {\n\t\t\t\t\t\tparams.set('t', timeStart)\n\t\t\t\t\t\tparams.delete('start')\n\t\t\t\t\t}\n\t\t\t\t\treturn `https://www.youtube.com/watch?${params.toString()}`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_calendar',\n\t\ttitle: 'Google Calendar',\n\t\thostnames: ['calendar.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\tinstructionLink: 'https://support.google.com/calendar/answer/41207?hl=en',\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst cidQs = urlObj?.searchParams.get('cid')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/u\\/0/) && cidQs) {\n\t\t\t\turlObj.pathname = '/calendar/embed'\n\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('src', cidQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst srcQs = urlObj?.searchParams.get('src')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/embed/) && srcQs) {\n\t\t\t\turlObj.pathname = '/calendar/u/0'\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('cid', srcQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_slides',\n\t\ttitle: 'Google Slides',\n\t\thostnames: ['docs.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/pub\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/pub$/, '/embed')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/embed\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/embed$/, '/pub')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'github_gist',\n\t\ttitle: 'GitHub Gist',\n\t\thostnames: ['gist.github.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\t// Security warning:\n\t\t// Gists allow adding .json extensions to the URL which return JSONP.\n\t\t// Furthermore, the JSONP can include callbacks that execute arbitrary JavaScript.\n\t\t// It _is_ sandboxed by the iframe but we still want to disable it nonetheless.\n\t\t// We restrict the id to only allow hexdecimal characters to prevent this.\n\t\t// Read more:\n\t\t// https://github.com/bhaveshk90/Content-Security-Policy-CSP-Bypass-Techniques\n\t\t// https://github.com/renniepak/CSPBypass\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'replit',\n\t\ttitle: 'Replit',\n\t\thostnames: ['replit.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/)) {\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/) &&\n\t\t\t\turlObj.searchParams.has('embed')\n\t\t\t) {\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'felt',\n\t\ttitle: 'Felt',\n\t\thostnames: ['felt.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/map\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/map\\//)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'spotify',\n\t\ttitle: 'Spotify',\n\t\thostnames: ['open.spotify.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminHeight: 500,\n\t\toverrideOutlineRadius: 12,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'vimeo',\n\t\ttitle: 'Vimeo',\n\t\thostnames: ['vimeo.com', 'player.vimeo.com'],\n\t\twidth: 640,\n\t\theight: 360,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'vimeo.com') {\n\t\t\t\tif (urlObj.pathname.match(/^\\/[0-9]+/)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t'https://player.vimeo.com/video/' + urlObj.pathname.split('/')[1] + '?title=0&byline=0'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'player.vimeo.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/video\\/([^/]+)\\/?$/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn 'https://vimeo.com/' + matches[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'observable',\n\t\ttitle: 'Observable',\n\t\thostnames: ['observablehq.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: false,\n\t\tbackgroundColor: '#fff',\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}/embed${urlObj.pathname}?cell=*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/d\\/([^/]+)\\/?$/)) {\n\t\t\t\tconst pathName = urlObj.pathname.replace(/^\\/d/, '')\n\t\t\t\treturn `${urlObj.origin}/embed${pathName}?cell=*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '')}#cell-*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '/d')}#cell-*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'desmos',\n\t\ttitle: 'Desmos',\n\t\thostnames: ['desmos.com'],\n\t\twidth: 700,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn `${url}?embed`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '?embed' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn url.replace('?embed', '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n] as const satisfies readonly EmbedDefinition[]\n\n/**\n * Permissions with note inline from\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n *\n * @public\n */\nexport const embedShapePermissionDefaults = {\n\t// ========================================================================================\n\t// Disabled permissions\n\t// ========================================================================================\n\t// [MDN] Experimental: Allows for downloads to occur without a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads-without-user-activation': false,\n\t// [MDN] Allows for downloads to occur with a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads': false,\n\t// [MDN] Lets the resource open modal windows.\n\t// [REASON] The <iframe/> could 'window.prompt(\"Enter your tldraw password\")'.\n\t'allow-modals': false,\n\t// [MDN] Lets the resource lock the screen orientation.\n\t// [REASON] Would interfere with the tldraw interface.\n\t'allow-orientation-lock': false,\n\t// [MDN] Lets the resource use the Pointer Lock API.\n\t// [REASON] Maybe we should allow this for games embeds (scratch/codepen/codesandbox).\n\t'allow-pointer-lock': false,\n\t// [MDN] Allows popups (such as window.open(), target=\"_blank\", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.\n\t// [REASON] We want to allow embeds to link back to their original sites (e.g. YouTube).\n\t'allow-popups': true,\n\t// [MDN] Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.\n\t// [REASON] We shouldn't allow popups as an embed could pretend to be us by opening a mocked version of tldraw. This is very unobvious when it is performed as an action within our app.\n\t'allow-popups-to-escape-sandbox': false,\n\t// [MDN] Lets the resource start a presentation session.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-presentation': false,\n\t// [MDN] Experimental: Lets the resource request access to the parent's storage capabilities with the Storage Access API.\n\t// [REASON] We don't want anyone else to access our storage.\n\t'allow-storage-access-by-user-activation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context (the one named _top).\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation-by-user-activation': false,\n\t// ========================================================================================\n\t// Enabled permissions\n\t// ========================================================================================\n\t// [MDN] Lets the resource run scripts (but not create popup windows).\n\t'allow-scripts': true,\n\t// [MDN] If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy (potentially preventing access to data storage/cookies and some JavaScript APIs).\n\t'allow-same-origin': true,\n\t// [MDN] Allows the resource to submit forms. If this keyword is not used, form submission is blocked.\n\t'allow-forms': true,\n} as const\n\n/** @public */\nexport type TLEmbedShapePermissions = { [K in keyof typeof embedShapePermissionDefaults]?: boolean }\n\n/** @public */\nexport interface EmbedDefinition {\n\treadonly type: string\n\treadonly title: string\n\treadonly hostnames: readonly string[]\n\treadonly minWidth?: number\n\treadonly minHeight?: number\n\treadonly width: number\n\treadonly height: number\n\treadonly doesResize: boolean\n\treadonly isAspectRatioLocked?: boolean\n\treadonly overridePermissions?: TLEmbedShapePermissions\n\treadonly instructionLink?: string\n\treadonly backgroundColor?: string\n\treadonly embedOnPaste?: boolean\n\treadonly canEditWhileLocked?: boolean\n\t// TODO: FIXME this is ugly be required because some embeds have their own border radius for example spotify embeds\n\treadonly overrideOutlineRadius?: number\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly toEmbedUrl: (url: string) => string | undefined\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly fromEmbedUrl: (url: string) => string | undefined\n}\n\n/** @public */\nexport interface CustomEmbedDefinition extends EmbedDefinition {\n\treadonly icon: string\n}\n\n/** @public */\nexport type TLEmbedDefinition = EmbedDefinition | CustomEmbedDefinition\n\n/** @public */\nexport type DefaultEmbedDefinitionType = (typeof DEFAULT_EMBED_DEFINITIONS)[number]['type']\n\nconst DEFAULT_EMBED_DEFINITION_TYPES = DEFAULT_EMBED_DEFINITIONS.map(\n\t(def) => def.type\n) as DefaultEmbedDefinitionType[]\n\n/** @public */\nexport function isDefaultEmbedDefinitionType(type: string): type is DefaultEmbedDefinitionType {\n\treturn DEFAULT_EMBED_DEFINITION_TYPES.includes(type as DefaultEmbedDefinitionType)\n}\n\n/** @public */\nexport function isCustomEmbedDefinition(\n\tdef: EmbedDefinition | CustomEmbedDefinition\n): def is CustomEmbedDefinition {\n\treturn 'icon' in def\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAG7B,MAAM,gBAAgB;AAGf,MAAM,4BAA4B;AAAA,EACxC;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAW,CAAC,mBAAmB,cAAc,gBAAgB;AAAA,IAC7D,UAAU;AAAA,IACV,WAAW;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,qBAAqB;AAAA,MACpB,wBAAwB;AAAA,IACzB;AAAA,IACA,YAAY,CAAC,QAAQ;AACpB,YAAM,SAAS,aAAa,GAAG;AAC/B,UAAI,UAAU,OAAO,SAAS,MAAM,aAAa,GAAG;AAEnD,eAAO,aAAa,OAAO,SAAS,MAAM;AAC1C,eAAO;AAAA,MACR;AACA;AAAA,IACD;AAAA,IACA,cAAc,CAAC,QAAQ;AACtB,YAAM,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AAW,MAClB,OAAO,SAAS,IACf;AACD,eAAO,GAAG,GAAG;AAAA,MACd;AACA;AAAA,IACD;AAAA,IACA,cAAc,CAAC,QAAQ;AACtB,YAAM,SAAS,aAAa,GAAG;AAC/B,UACC,UACA,OAAO,aAAa,oBACpB,OAAO,SAAS,MAAM,4BAA4B,KAClD,OAAO,WAAW,YAClB,OAAO,SAAS,IACf;AACD,eAAO,IAAI,QAAQ,UAAU,EAAE;AAAA,MAChC;AACA;AAAA,IACD;AAAA,EACD;AACD;AAQO,MAAM,+BAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3C,2CAA2C;AAAA;AAAA;AAAA,EAG3C,mBAAmB;AAAA;AAAA;AAAA,EAGnB,gBAAgB;AAAA;AAAA;AAAA,EAGhB,0BAA0B;AAAA;AAAA;AAAA,EAG1B,sBAAsB;AAAA;AAAA;AAAA,EAGtB,gBAAgB;AAAA;AAAA;AAAA,EAGhB,kCAAkC;AAAA;AAAA;AAAA,EAGlC,sBAAsB;AAAA;AAAA;AAAA,EAGtB,2CAA2C;AAAA;AAAA;AAAA,EAG3C,wBAAwB;AAAA;AAAA;AAAA,EAGxB,2CAA2C;AAAA;AAAA;AAAA;AAAA;AAAA,EAK3C,iBAAiB;AAAA;AAAA,EAEjB,qBAAqB;AAAA;AAAA,EAErB,eAAe;AAChB;AAwCA,MAAM,iCAAiC,0BAA0B;AAAA,EAChE,CAAC,QAAQ,IAAI;AACd;AAGO,SAAS,6BAA6B,MAAkD;AAC9F,SAAO,+BAA+B,SAAS,IAAkC;AAClF;AAGO,SAAS,wBACf,KAC+B;AAC/B,SAAO,UAAU;AAClB;",
6
6
  "names": []
7
7
  }
@@ -177,7 +177,7 @@ async function defaultHandleExternalUrlAsset(editor, { url }, { toasts, msg }) {
177
177
  };
178
178
  }
179
179
  async function defaultHandleExternalSvgTextContent(editor, { point, text }) {
180
- const position = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageBounds().center);
180
+ const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
181
181
  const svg = new DOMParser().parseFromString(text, "image/svg+xml").querySelector("svg");
182
182
  if (!svg) {
183
183
  throw new Error("No <svg/> element present");
@@ -199,7 +199,7 @@ async function defaultHandleExternalSvgTextContent(editor, { point, text }) {
199
199
  createShapesForAssets(editor, [asset], position);
200
200
  }
201
201
  function defaultHandleExternalEmbedContent(editor, { point, url, embed }) {
202
- const position = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageBounds().center);
202
+ const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
203
203
  const { width, height } = embed;
204
204
  const id = createShapeId();
205
205
  const newPoint = maybeSnapToGrid(
@@ -227,7 +227,7 @@ async function defaultHandleExternalFileContent(editor, { point, files }, option
227
227
  toasts.addToast({ title: msg("assets.files.amount-too-many"), severity: "error" });
228
228
  return;
229
229
  }
230
- const position = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageBounds().center);
230
+ const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
231
231
  const pagePoint = new Vec(position.x, position.y);
232
232
  const assetPartials = [];
233
233
  const assetsToUpdate = [];
@@ -266,7 +266,7 @@ async function defaultHandleExternalFileContent(editor, { point, files }, option
266
266
  createShapesForAssets(editor, assetPartials, pagePoint);
267
267
  }
268
268
  async function defaultHandleExternalTextContent(editor, { point, text, html }) {
269
- const p = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageBounds().center);
269
+ const p = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
270
270
  const defaultProps = editor.getShapeUtil("text").getDefaultProps();
271
271
  const cleanedUpPlaintext = cleanupText(text);
272
272
  const richTextToPaste = html ? renderRichTextFromHTML(editor, html) : toRichText(cleanedUpPlaintext);
@@ -338,7 +338,7 @@ async function defaultHandleExternalUrlContent(editor, { point, url }, { toasts,
338
338
  embed: embedInfo.definition
339
339
  });
340
340
  }
341
- const position = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageBounds().center);
341
+ const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
342
342
  const result = await createBookmarkFromUrl(editor, { url, center: position });
343
343
  if (!result.ok) {
344
344
  toasts.addToast({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/defaultExternalContentHandlers.ts"],
4
- "sourcesContent": ["import {\n\tAssetRecordType,\n\tDEFAULT_SUPPORTED_IMAGE_TYPES,\n\tDEFAULT_SUPPORT_VIDEO_TYPES,\n\tEditor,\n\tMediaHelpers,\n\tTLAsset,\n\tTLAssetId,\n\tTLBookmarkAsset,\n\tTLBookmarkShape,\n\tTLContent,\n\tTLFileExternalAsset,\n\tTLFileReplaceExternalContent,\n\tTLImageAsset,\n\tTLImageShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTextShapeProps,\n\tTLUrlExternalAsset,\n\tTLVideoAsset,\n\tVec,\n\tVecLike,\n\tassert,\n\tcreateShapeId,\n\tfetch,\n\tgetHashForBuffer,\n\tgetHashForString,\n\tmaybeSnapToGrid,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { EmbedDefinition } from './defaultEmbedDefinitions'\nimport { createBookmarkFromUrl } from './shapes/bookmark/bookmarks'\nimport { EmbedShapeUtil } from './shapes/embed/EmbedShapeUtil'\nimport { getCroppedImageDataForReplacedImage } from './shapes/shared/crop'\nimport { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from './shapes/shared/default-shape-constants'\nimport { TLUiToastsContextType } from './ui/context/toasts'\nimport { useTranslation } from './ui/hooks/useTranslation/useTranslation'\nimport { containBoxSize } from './utils/assets/assets'\nimport { putExcalidrawContent } from './utils/excalidraw/putExcalidrawContent'\nimport { renderRichTextFromHTML } from './utils/text/richText'\nimport { cleanupText, isRightToLeftLanguage } from './utils/text/text'\n\n/**\n * 5000px\n * @public\n */\nexport const DEFAULT_MAX_IMAGE_DIMENSION = 5000\n/**\n * 10mb\n * @public\n */\nexport const DEFAULT_MAX_ASSET_SIZE = 10 * 1024 * 1024\n\n/** @public */\nexport interface TLExternalContentProps {\n\t/**\n\t * The maximum dimension (width or height) of an image. Images larger than this will be rescaled\n\t * to fit. Defaults to infinity.\n\t */\n\tmaxImageDimension?: number\n\t/**\n\t * The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults\n\t * to 10mb (10 * 1024 * 1024).\n\t */\n\tmaxAssetSize?: number\n\t/**\n\t * The mime types of images that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORTED_IMAGE_TYPES.\n\t */\n\tacceptedImageMimeTypes?: readonly string[]\n\t/**\n\t * The mime types of videos that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORT_VIDEO_TYPES.\n\t */\n\tacceptedVideoMimeTypes?: readonly string[]\n}\n\n/** @public */\nexport interface TLDefaultExternalContentHandlerOpts extends TLExternalContentProps {\n\ttoasts: TLUiToastsContextType\n\tmsg: ReturnType<typeof useTranslation>\n}\n\n/** @public */\nexport function registerDefaultExternalContentHandlers(\n\teditor: Editor,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\t// files -> asset\n\teditor.registerExternalAssetHandler('file', async (externalAsset) => {\n\t\treturn defaultHandleExternalFileAsset(editor, externalAsset, options)\n\t})\n\n\t// urls -> bookmark asset\n\teditor.registerExternalAssetHandler('url', async (externalAsset) => {\n\t\treturn defaultHandleExternalUrlAsset(editor, externalAsset, options)\n\t})\n\n\t// svg text\n\teditor.registerExternalContentHandler('svg-text', async (externalContent) => {\n\t\treturn defaultHandleExternalSvgTextContent(editor, externalContent)\n\t})\n\n\t// embeds\n\teditor.registerExternalContentHandler<'embed', EmbedDefinition>('embed', (externalContent) => {\n\t\treturn defaultHandleExternalEmbedContent(editor, externalContent)\n\t})\n\n\t// files\n\teditor.registerExternalContentHandler('files', async (externalContent) => {\n\t\treturn defaultHandleExternalFileContent(editor, externalContent, options)\n\t})\n\n\t// file-replace -> asset\n\teditor.registerExternalContentHandler('file-replace', async (externalContent) => {\n\t\treturn defaultHandleExternalFileReplaceContent(editor, externalContent, options)\n\t})\n\n\t// text\n\teditor.registerExternalContentHandler('text', async (externalContent) => {\n\t\treturn defaultHandleExternalTextContent(editor, externalContent)\n\t})\n\n\t// url\n\teditor.registerExternalContentHandler('url', async (externalContent) => {\n\t\treturn defaultHandleExternalUrlContent(editor, externalContent, options)\n\t})\n\n\t// tldraw\n\teditor.registerExternalContentHandler('tldraw', async (externalContent) => {\n\t\treturn defaultHandleExternalTldrawContent(editor, externalContent)\n\t})\n\n\t// excalidraw\n\teditor.registerExternalContentHandler('excalidraw', async (externalContent) => {\n\t\treturn defaultHandleExternalExcalidrawContent(editor, externalContent)\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalFileAsset(\n\teditor: Editor,\n\t{ file, assetId }: TLFileExternalAsset,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst assetInfo = await getAssetInfo(file, options, assetId)\n\tconst result = await editor.uploadAsset(assetInfo, file)\n\tassetInfo.props.src = result.src\n\tif (result.meta) assetInfo.meta = { ...assetInfo.meta, ...result.meta }\n\n\treturn AssetRecordType.create(assetInfo)\n}\n\n/** @public */\nexport async function defaultHandleExternalFileReplaceContent(\n\teditor: Editor,\n\t{ file, shapeId, isImage }: TLFileReplaceExternalContent,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst shape = editor.getShape(shapeId)\n\tif (!shape) assert(false, 'Shape not found')\n\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tconst assetId = AssetRecordType.createId(hash)\n\teditor.createTemporaryAssetPreview(assetId, file)\n\tconst assetInfoPartial = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImage /* isImage */,\n\t\t!isImage /* isVideo */\n\t)\n\teditor.createAssets([assetInfoPartial])\n\n\t// And update the shape\n\tif (shape.type === 'image') {\n\t\tconst imageShape = shape as TLImageShape\n\t\tconst currentCrop = imageShape.props.crop\n\n\t\t// Calculate new dimensions that preserve the current visual size of the cropped area\n\t\tlet newWidth = assetInfoPartial.props.w\n\t\tlet newHeight = assetInfoPartial.props.h\n\t\tlet newX = imageShape.x\n\t\tlet newY = imageShape.y\n\t\tlet finalCrop = currentCrop\n\n\t\tif (currentCrop) {\n\t\t\t// Use the dedicated function to calculate the new crop and dimensions\n\t\t\tconst result = getCroppedImageDataForReplacedImage(\n\t\t\t\timageShape,\n\t\t\t\tassetInfoPartial.props.w,\n\t\t\t\tassetInfoPartial.props.h\n\t\t\t)\n\n\t\t\tfinalCrop = result.crop\n\t\t\tnewWidth = result.w\n\t\t\tnewHeight = result.h\n\t\t\tnewX = result.x\n\t\t\tnewY = result.y\n\t\t}\n\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tcrop: finalCrop,\n\t\t\t\t\tw: newWidth,\n\t\t\t\t\th: newHeight,\n\t\t\t\t},\n\t\t\t\tx: newX,\n\t\t\t\ty: newY,\n\t\t\t},\n\t\t])\n\t} else if (shape.type === 'video') {\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tw: assetInfoPartial.props.w,\n\t\t\t\t\th: assetInfoPartial.props.h,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t}\n\n\tconst asset = (await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile,\n\t\tassetId,\n\t})) as TLAsset\n\n\teditor.updateAssets([{ ...asset, id: assetId }])\n\n\treturn asset\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlAsset(\n\teditor: Editor,\n\t{ url }: TLUrlExternalAsset,\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n): Promise<TLBookmarkAsset> {\n\tlet meta: { image: string; favicon: string; title: string; description: string }\n\n\ttry {\n\t\tconst resp = await fetch(url, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t})\n\t\tconst html = await resp.text()\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html')\n\t\tmeta = {\n\t\t\timage: doc.head.querySelector('meta[property=\"og:image\"]')?.getAttribute('content') ?? '',\n\t\t\tfavicon:\n\t\t\t\tdoc.head.querySelector('link[rel=\"apple-touch-icon\"]')?.getAttribute('href') ??\n\t\t\t\tdoc.head.querySelector('link[rel=\"icon\"]')?.getAttribute('href') ??\n\t\t\t\t'',\n\t\t\ttitle: doc.head.querySelector('meta[property=\"og:title\"]')?.getAttribute('content') ?? url,\n\t\t\tdescription:\n\t\t\t\tdoc.head.querySelector('meta[property=\"og:description\"]')?.getAttribute('content') ?? '',\n\t\t}\n\t\tif (!meta.image.startsWith('http')) {\n\t\t\tmeta.image = new URL(meta.image, url).href\n\t\t}\n\t\tif (!meta.favicon.startsWith('http')) {\n\t\t\tmeta.favicon = new URL(meta.favicon, url).href\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(error)\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tmeta = { image: '', favicon: '', title: '', description: '' }\n\t}\n\n\t// Create the bookmark asset from the meta\n\treturn {\n\t\tid: AssetRecordType.createId(getHashForString(url)),\n\t\ttypeName: 'asset',\n\t\ttype: 'bookmark',\n\t\tprops: {\n\t\t\tsrc: url,\n\t\t\tdescription: meta.description,\n\t\t\timage: meta.image,\n\t\t\tfavicon: meta.favicon,\n\t\t\ttitle: meta.title,\n\t\t},\n\t\tmeta: {},\n\t} as TLBookmarkAsset\n}\n\n/** @public */\nexport async function defaultHandleExternalSvgTextContent(\n\teditor: Editor,\n\t{ point, text }: { point?: VecLike; text: string }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')\n\tif (!svg) {\n\t\tthrow new Error('No <svg/> element present')\n\t}\n\n\tlet width = parseFloat(svg.getAttribute('width') || '0')\n\tlet height = parseFloat(svg.getAttribute('height') || '0')\n\n\tif (!(width && height)) {\n\t\tdocument.body.appendChild(svg)\n\t\tconst box = svg.getBoundingClientRect()\n\t\tdocument.body.removeChild(svg)\n\n\t\twidth = box.width\n\t\theight = box.height\n\t}\n\n\tconst asset = await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile: new File([text], 'asset.svg', { type: 'image/svg+xml' }),\n\t})\n\n\tif (!asset) throw Error('Could not create an asset')\n\n\tcreateShapesForAssets(editor, [asset], position)\n}\n\n/** @public */\nexport function defaultHandleExternalEmbedContent<T>(\n\teditor: Editor,\n\t{ point, url, embed }: { point?: VecLike; url: string; embed: T }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst { width, height } = embed as { width: number; height: number }\n\n\tconst id = createShapeId()\n\n\tconst newPoint = maybeSnapToGrid(\n\t\tnew Vec(position.x - (width || 450) / 2, position.y - (height || 450) / 2),\n\t\teditor\n\t)\n\tconst shapePartial: TLShapePartial = {\n\t\tid,\n\t\ttype: 'embed',\n\t\tx: newPoint.x,\n\t\ty: newPoint.y,\n\t\tprops: {\n\t\t\tw: width,\n\t\t\th: height,\n\t\t\turl,\n\t\t},\n\t}\n\n\tif (editor.canCreateShape(shapePartial)) {\n\t\teditor.createShape(shapePartial).select(id)\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalFileContent(\n\teditor: Editor,\n\t{ point, files }: { point?: VecLike; files: File[] },\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst { acceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES, toasts, msg } = options\n\tif (files.length > editor.options.maxFilesAtOnce) {\n\t\ttoasts.addToast({ title: msg('assets.files.amount-too-many'), severity: 'error' })\n\t\treturn\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst pagePoint = new Vec(position.x, position.y)\n\tconst assetPartials: TLAsset[] = []\n\tconst assetsToUpdate: {\n\t\tasset: TLAsset\n\t\tfile: File\n\t}[] = []\n\tfor (const file of files) {\n\t\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\t\tif (!isSuccess) continue\n\n\t\tconst assetInfo = await getAssetInfo(file, options)\n\t\tif (acceptedImageMimeTypes.includes(file.type)) {\n\t\t\teditor.createTemporaryAssetPreview(assetInfo.id, file)\n\t\t}\n\t\tassetPartials.push(assetInfo)\n\t\tassetsToUpdate.push({ asset: assetInfo, file })\n\t}\n\n\tPromise.allSettled(\n\t\tassetsToUpdate.map(async (assetAndFile) => {\n\t\t\ttry {\n\t\t\t\tconst newAsset = await editor.getAssetForExternalContent({\n\t\t\t\t\ttype: 'file',\n\t\t\t\t\tfile: assetAndFile.file,\n\t\t\t\t})\n\n\t\t\t\tif (!newAsset) {\n\t\t\t\t\tthrow Error('Could not create an asset')\n\t\t\t\t}\n\n\t\t\t\t// Save the new asset under the old asset's id\n\t\t\t\teditor.updateAssets([{ ...newAsset, id: assetAndFile.asset.id }])\n\t\t\t} catch (error) {\n\t\t\t\ttoasts.addToast({\n\t\t\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t})\n\t\t\t\tconsole.error(error)\n\t\t\t\teditor.deleteAssets([assetAndFile.asset.id])\n\t\t\t\treturn\n\t\t\t}\n\t\t})\n\t)\n\n\tcreateShapesForAssets(editor, assetPartials, pagePoint)\n}\n\n/** @public */\nexport async function defaultHandleExternalTextContent(\n\teditor: Editor,\n\t{ point, text, html }: { point?: VecLike; text: string; html?: string }\n) {\n\tconst p =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()\n\n\tconst cleanedUpPlaintext = cleanupText(text)\n\tconst richTextToPaste = html\n\t\t? renderRichTextFromHTML(editor, html)\n\t\t: toRichText(cleanedUpPlaintext)\n\n\t// todo: discuss\n\t// If we have one shape with rich text selected, update the shape's text.\n\t// const onlySelectedShape = editor.getOnlySelectedShape()\n\t// if (onlySelectedShape && 'richText' in onlySelectedShape.props) {\n\t// \teditor.updateShapes([\n\t// \t\t{\n\t// \t\t\tid: onlySelectedShape.id,\n\t// \t\t\ttype: onlySelectedShape.type,\n\t// \t\t\tprops: {\n\t// \t\t\t\trichText: richTextToPaste,\n\t// \t\t\t},\n\t// \t\t},\n\t// \t])\n\n\t// \treturn\n\t// }\n\n\t// Measure the text with default values\n\tlet w: number\n\tlet h: number\n\tlet autoSize: boolean\n\tlet align = 'middle' as TLTextShapeProps['textAlign']\n\n\tconst htmlToMeasure = html ?? cleanedUpPlaintext.replace(/\\n/g, '<br>')\n\tconst isMultiLine = html\n\t\t? richTextToPaste.content.length > 1\n\t\t: cleanedUpPlaintext.split('\\n').length > 1\n\n\t// check whether the text contains the most common characters in RTL languages\n\tconst isRtl = isRightToLeftLanguage(cleanedUpPlaintext)\n\n\tif (isMultiLine) {\n\t\talign = isMultiLine ? (isRtl ? 'end' : 'start') : 'middle'\n\t}\n\n\tconst rawSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t...TEXT_PROPS,\n\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\tmaxWidth: null,\n\t})\n\n\tconst minWidth = Math.min(\n\t\tisMultiLine ? editor.getViewportPageBounds().width * 0.9 : 920,\n\t\tMath.max(200, editor.getViewportPageBounds().width * 0.9)\n\t)\n\n\tif (rawSize.w > minWidth) {\n\t\tconst shrunkSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\t\tmaxWidth: minWidth,\n\t\t})\n\t\tw = shrunkSize.w\n\t\th = shrunkSize.h\n\t\tautoSize = false\n\t\talign = isRtl ? 'end' : 'start'\n\t} else {\n\t\t// autosize is fine\n\t\tw = Math.max(rawSize.w, 10)\n\t\th = Math.max(rawSize.h, 10)\n\t\tautoSize = true\n\t}\n\n\tif (p.y - h / 2 < editor.getViewportPageBounds().minY + 40) {\n\t\tp.y = editor.getViewportPageBounds().minY + 40 + h / 2\n\t}\n\n\tconst newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)\n\tconst shapeId = createShapeId()\n\n\t// Allow this to trigger the max shapes reached alert\n\teditor.createShapes([\n\t\t{\n\t\t\tid: shapeId,\n\t\t\ttype: 'text',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\trichText: richTextToPaste,\n\t\t\t\t// if the text has more than one line, align it to the left\n\t\t\t\ttextAlign: align,\n\t\t\t\tautoSize,\n\t\t\t\tw,\n\t\t\t},\n\t\t},\n\t])\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlContent(\n\teditor: Editor,\n\t{ point, url }: { point?: VecLike; url: string },\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n) {\n\t// try to paste as an embed first\n\tconst embedUtil = editor.getShapeUtil('embed') as EmbedShapeUtil | undefined\n\tconst embedInfo = embedUtil?.getEmbedDefinition(url)\n\n\tif (embedInfo && embedInfo.definition.embedOnPaste !== false) {\n\t\treturn editor.putExternalContent({\n\t\t\ttype: 'embed',\n\t\t\turl: embedInfo.url,\n\t\t\tpoint,\n\t\t\tembed: embedInfo.definition,\n\t\t})\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\t// Use the new function to create the bookmark\n\tconst result = await createBookmarkFromUrl(editor, { url, center: position })\n\n\tif (!result.ok) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalTldrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: TLContent }\n) {\n\teditor.run(() => {\n\t\tconst selectionBoundsBefore = editor.getSelectionPageBounds()\n\t\teditor.markHistoryStoppingPoint('paste')\n\n\t\t// Unlock any locked root shapes on paste\n\t\tfor (const shape of content.shapes) {\n\t\t\tif (content.rootShapeIds.includes(shape.id)) {\n\t\t\t\tshape.isLocked = false\n\t\t\t}\n\t\t}\n\n\t\teditor.putContentOntoCurrentPage(content, {\n\t\t\tpoint: point,\n\t\t\tselect: true,\n\t\t})\n\t\tconst selectedBoundsAfter = editor.getSelectionPageBounds()\n\t\tif (\n\t\t\tselectionBoundsBefore &&\n\t\t\tselectedBoundsAfter &&\n\t\t\tselectionBoundsBefore?.collides(selectedBoundsAfter)\n\t\t) {\n\t\t\t// Creates a 'puff' to show content has been pasted\n\t\t\teditor.updateInstanceState({ isChangingStyle: true })\n\t\t\teditor.timers.setTimeout(() => {\n\t\t\t\teditor.updateInstanceState({ isChangingStyle: false })\n\t\t\t}, 150)\n\t\t}\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalExcalidrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: any }\n) {\n\teditor.run(() => {\n\t\tputExcalidrawContent(editor, content, point)\n\t})\n}\n\n/** @public */\nexport async function getMediaAssetInfoPartial(\n\tfile: File,\n\tassetId: TLAssetId,\n\tisImageType: boolean,\n\tisVideoType: boolean,\n\tmaxImageDimension?: number\n) {\n\tlet fileType = file.type\n\n\tif (file.type === 'video/quicktime') {\n\t\t// hack to make .mov videos work\n\t\tfileType = 'video/mp4'\n\t}\n\n\tconst size = isImageType\n\t\t? await MediaHelpers.getImageSize(file)\n\t\t: await MediaHelpers.getVideoSize(file)\n\n\tconst isAnimated = (await MediaHelpers.isAnimated(file)) || isVideoType\n\n\tconst assetInfo = {\n\t\tid: assetId,\n\t\ttype: isImageType ? 'image' : 'video',\n\t\ttypeName: 'asset',\n\t\tprops: {\n\t\t\tname: file.name,\n\t\t\tsrc: '',\n\t\t\tw: size.w,\n\t\t\th: size.h,\n\t\t\tfileSize: file.size,\n\t\t\tmimeType: fileType,\n\t\t\tisAnimated,\n\t\t},\n\t\tmeta: {},\n\t} as TLImageAsset | TLVideoAsset\n\n\tif (maxImageDimension && isFinite(maxImageDimension)) {\n\t\tconst size = { w: assetInfo.props.w, h: assetInfo.props.h }\n\t\tconst resizedSize = containBoxSize(size, { w: maxImageDimension, h: maxImageDimension })\n\t\tif (size !== resizedSize && MediaHelpers.isStaticImageType(file.type)) {\n\t\t\tassetInfo.props.w = resizedSize.w\n\t\t\tassetInfo.props.h = resizedSize.h\n\t\t}\n\t}\n\n\treturn assetInfo\n}\n\n/**\n * A helper function for an external content handler. It creates bookmarks,\n * images or video shapes corresponding to the type of assets provided.\n *\n * @param editor - The editor instance\n *\n * @param assets - An array of asset Ids\n *\n * @param position - the position at which to create the shapes\n *\n * @public\n */\nexport async function createShapesForAssets(\n\teditor: Editor,\n\tassets: TLAsset[],\n\tposition: VecLike\n): Promise<TLShapeId[]> {\n\tif (!assets.length) return []\n\n\tconst currentPoint = Vec.From(position)\n\tconst partials: TLShapePartial[] = []\n\n\tfor (let i = 0; i < assets.length; i++) {\n\t\tconst asset = assets[i]\n\t\tswitch (asset.type) {\n\t\t\tcase 'image': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'video': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'video',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\t// Create any assets\n\t\tconst assetsToCreate = assets.filter((asset) => !editor.getAsset(asset.id))\n\n\t\teditor.store.atomic(() => {\n\t\t\tif (editor.canCreateShapes(partials)) {\n\t\t\t\tif (assetsToCreate.length) {\n\t\t\t\t\teditor.createAssets(assetsToCreate)\n\t\t\t\t}\n\n\t\t\t\t// Create the shapes\n\t\t\t\teditor.createShapes(partials).select(...partials.map((p) => p.id))\n\n\t\t\t\t// Re-position shapes so that the center of the group is at the provided point\n\t\t\t\tcenterSelectionAroundPoint(editor, position)\n\t\t\t}\n\t\t})\n\t})\n\n\treturn partials.map((p) => p.id)\n}\n\n/**\n * Repositions selected shapes do that the center of the group is\n * at the provided position\n *\n * @param editor - The editor instance\n *\n * @param position - the point to center the shapes around\n *\n * @public\n */\nexport function centerSelectionAroundPoint(editor: Editor, position: VecLike) {\n\t// Re-position shapes so that the center of the group is at the provided point\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tlet selectionPageBounds = editor.getSelectionPageBounds()\n\n\tif (selectionPageBounds) {\n\t\tconst offset = selectionPageBounds!.center.sub(position)\n\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst localRotation = editor.getShapeParentTransform(shape).decompose().rotation\n\t\t\t\tconst localDelta = Vec.Rot(offset, -localRotation)\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: shape.x! - localDelta.x,\n\t\t\t\t\ty: shape.y! - localDelta.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\t// align selection with the grid if necessary\n\tif (selectionPageBounds && editor.getInstanceState().isGridMode) {\n\t\tconst gridSize = editor.getDocumentSettings().gridSize\n\t\tconst topLeft = new Vec(selectionPageBounds.minX, selectionPageBounds.minY)\n\t\tconst gridSnappedPoint = topLeft.clone().snapToGrid(gridSize)\n\t\tconst delta = Vec.Sub(topLeft, gridSnappedPoint)\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst newPoint = { x: shape.x! - delta.x, y: shape.y! - delta.y }\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\t// Zoom out to fit the shapes, if necessary\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\tif (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) {\n\t\teditor.zoomToSelection({ animation: { duration: editor.options.animationMediumMs } })\n\t}\n}\n\n/** @public */\nexport function createEmptyBookmarkShape(\n\teditor: Editor,\n\turl: string,\n\tposition: VecLike\n): TLBookmarkShape {\n\tconst partial: TLShapePartial = {\n\t\tid: createShapeId(),\n\t\ttype: 'bookmark',\n\t\tx: position.x - 150,\n\t\ty: position.y - 160,\n\t\topacity: 1,\n\t\tprops: {\n\t\t\tassetId: null,\n\t\t\turl,\n\t\t},\n\t}\n\n\teditor.run(() => {\n\t\t// Allow this to trigger the max shapes reached alert\n\t\teditor.createShape(partial)\n\t\tif (!editor.getShape(partial.id)) return\n\t\teditor.select(partial.id)\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn editor.getShape(partial.id) as TLBookmarkShape\n}\n\n/**\n * Checks if a file is allowed to be uploaded. If it is not, it will show a toast explaining why to the user.\n *\n * @param file - The file to check\n * @param options - The options for the external content handler\n * @returns True if the file is allowed, false otherwise\n * @public\n */\nexport function notifyIfFileNotAllowed(file: File, options: TLDefaultExternalContentHandlerOpts) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxAssetSize = DEFAULT_MAX_ASSET_SIZE,\n\t\ttoasts,\n\t\tmsg,\n\t} = options\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\n\tif (!isImageType && !isVideoType) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.type-not-allowed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\tif (file.size > maxAssetSize) {\n\t\tconst formatBytes = (bytes: number): string => {\n\t\t\tif (bytes === 0) return '0 bytes'\n\n\t\t\tconst units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']\n\t\t\tconst base = 1024\n\t\t\tconst unitIndex = Math.floor(Math.log(bytes) / Math.log(base))\n\n\t\t\tconst value = bytes / Math.pow(base, unitIndex)\n\t\t\tconst formatted = value % 1 === 0 ? value.toString() : value.toFixed(1)\n\n\t\t\treturn `${formatted} ${units[unitIndex]}`\n\t\t}\n\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.size-too-big'),\n\t\t\tdescription: msg('assets.files.maximum-size').replace('{size}', formatBytes(maxAssetSize)),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\t// Use mime type instead of file ext, this is because\n\t// window.navigator.clipboard does not preserve file names\n\t// of copied files.\n\tif (!file.type) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tconsole.error('No mime type')\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/** @public */\nexport async function getAssetInfo(\n\tfile: File,\n\toptions: TLDefaultExternalContentHandlerOpts,\n\tassetId?: TLAssetId\n) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxImageDimension = DEFAULT_MAX_IMAGE_DIMENSION,\n\t} = options\n\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tassetId ??= AssetRecordType.createId(hash)\n\tconst assetInfo = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImageType,\n\t\tisVideoType,\n\t\tmaxImageDimension\n\t)\n\treturn assetInfo\n}\n"],
5
- "mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAgBA;AAAA,EAEA;AAAA,EACA;AAAA,EAC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4
+ "sourcesContent": ["import {\n\tAssetRecordType,\n\tDEFAULT_SUPPORTED_IMAGE_TYPES,\n\tDEFAULT_SUPPORT_VIDEO_TYPES,\n\tEditor,\n\tMediaHelpers,\n\tTLAsset,\n\tTLAssetId,\n\tTLBookmarkAsset,\n\tTLBookmarkShape,\n\tTLContent,\n\tTLFileExternalAsset,\n\tTLFileReplaceExternalContent,\n\tTLImageAsset,\n\tTLImageShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTextShapeProps,\n\tTLUrlExternalAsset,\n\tTLVideoAsset,\n\tVec,\n\tVecLike,\n\tassert,\n\tcreateShapeId,\n\tfetch,\n\tgetHashForBuffer,\n\tgetHashForString,\n\tmaybeSnapToGrid,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { EmbedDefinition } from './defaultEmbedDefinitions'\nimport { createBookmarkFromUrl } from './shapes/bookmark/bookmarks'\nimport { EmbedShapeUtil } from './shapes/embed/EmbedShapeUtil'\nimport { getCroppedImageDataForReplacedImage } from './shapes/shared/crop'\nimport { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from './shapes/shared/default-shape-constants'\nimport { TLUiToastsContextType } from './ui/context/toasts'\nimport { useTranslation } from './ui/hooks/useTranslation/useTranslation'\nimport { containBoxSize } from './utils/assets/assets'\nimport { putExcalidrawContent } from './utils/excalidraw/putExcalidrawContent'\nimport { renderRichTextFromHTML } from './utils/text/richText'\nimport { cleanupText, isRightToLeftLanguage } from './utils/text/text'\n\n/**\n * 5000px\n * @public\n */\nexport const DEFAULT_MAX_IMAGE_DIMENSION = 5000\n/**\n * 10mb\n * @public\n */\nexport const DEFAULT_MAX_ASSET_SIZE = 10 * 1024 * 1024\n\n/** @public */\nexport interface TLExternalContentProps {\n\t/**\n\t * The maximum dimension (width or height) of an image. Images larger than this will be rescaled\n\t * to fit. Defaults to infinity.\n\t */\n\tmaxImageDimension?: number\n\t/**\n\t * The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults\n\t * to 10mb (10 * 1024 * 1024).\n\t */\n\tmaxAssetSize?: number\n\t/**\n\t * The mime types of images that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORTED_IMAGE_TYPES.\n\t */\n\tacceptedImageMimeTypes?: readonly string[]\n\t/**\n\t * The mime types of videos that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORT_VIDEO_TYPES.\n\t */\n\tacceptedVideoMimeTypes?: readonly string[]\n}\n\n/** @public */\nexport interface TLDefaultExternalContentHandlerOpts extends TLExternalContentProps {\n\ttoasts: TLUiToastsContextType\n\tmsg: ReturnType<typeof useTranslation>\n}\n\n/** @public */\nexport function registerDefaultExternalContentHandlers(\n\teditor: Editor,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\t// files -> asset\n\teditor.registerExternalAssetHandler('file', async (externalAsset) => {\n\t\treturn defaultHandleExternalFileAsset(editor, externalAsset, options)\n\t})\n\n\t// urls -> bookmark asset\n\teditor.registerExternalAssetHandler('url', async (externalAsset) => {\n\t\treturn defaultHandleExternalUrlAsset(editor, externalAsset, options)\n\t})\n\n\t// svg text\n\teditor.registerExternalContentHandler('svg-text', async (externalContent) => {\n\t\treturn defaultHandleExternalSvgTextContent(editor, externalContent)\n\t})\n\n\t// embeds\n\teditor.registerExternalContentHandler<'embed', EmbedDefinition>('embed', (externalContent) => {\n\t\treturn defaultHandleExternalEmbedContent(editor, externalContent)\n\t})\n\n\t// files\n\teditor.registerExternalContentHandler('files', async (externalContent) => {\n\t\treturn defaultHandleExternalFileContent(editor, externalContent, options)\n\t})\n\n\t// file-replace -> asset\n\teditor.registerExternalContentHandler('file-replace', async (externalContent) => {\n\t\treturn defaultHandleExternalFileReplaceContent(editor, externalContent, options)\n\t})\n\n\t// text\n\teditor.registerExternalContentHandler('text', async (externalContent) => {\n\t\treturn defaultHandleExternalTextContent(editor, externalContent)\n\t})\n\n\t// url\n\teditor.registerExternalContentHandler('url', async (externalContent) => {\n\t\treturn defaultHandleExternalUrlContent(editor, externalContent, options)\n\t})\n\n\t// tldraw\n\teditor.registerExternalContentHandler('tldraw', async (externalContent) => {\n\t\treturn defaultHandleExternalTldrawContent(editor, externalContent)\n\t})\n\n\t// excalidraw\n\teditor.registerExternalContentHandler('excalidraw', async (externalContent) => {\n\t\treturn defaultHandleExternalExcalidrawContent(editor, externalContent)\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalFileAsset(\n\teditor: Editor,\n\t{ file, assetId }: TLFileExternalAsset,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst assetInfo = await getAssetInfo(file, options, assetId)\n\tconst result = await editor.uploadAsset(assetInfo, file)\n\tassetInfo.props.src = result.src\n\tif (result.meta) assetInfo.meta = { ...assetInfo.meta, ...result.meta }\n\n\treturn AssetRecordType.create(assetInfo)\n}\n\n/** @public */\nexport async function defaultHandleExternalFileReplaceContent(\n\teditor: Editor,\n\t{ file, shapeId, isImage }: TLFileReplaceExternalContent,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst shape = editor.getShape(shapeId)\n\tif (!shape) assert(false, 'Shape not found')\n\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tconst assetId = AssetRecordType.createId(hash)\n\teditor.createTemporaryAssetPreview(assetId, file)\n\tconst assetInfoPartial = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImage /* isImage */,\n\t\t!isImage /* isVideo */\n\t)\n\teditor.createAssets([assetInfoPartial])\n\n\t// And update the shape\n\tif (shape.type === 'image') {\n\t\tconst imageShape = shape as TLImageShape\n\t\tconst currentCrop = imageShape.props.crop\n\n\t\t// Calculate new dimensions that preserve the current visual size of the cropped area\n\t\tlet newWidth = assetInfoPartial.props.w\n\t\tlet newHeight = assetInfoPartial.props.h\n\t\tlet newX = imageShape.x\n\t\tlet newY = imageShape.y\n\t\tlet finalCrop = currentCrop\n\n\t\tif (currentCrop) {\n\t\t\t// Use the dedicated function to calculate the new crop and dimensions\n\t\t\tconst result = getCroppedImageDataForReplacedImage(\n\t\t\t\timageShape,\n\t\t\t\tassetInfoPartial.props.w,\n\t\t\t\tassetInfoPartial.props.h\n\t\t\t)\n\n\t\t\tfinalCrop = result.crop\n\t\t\tnewWidth = result.w\n\t\t\tnewHeight = result.h\n\t\t\tnewX = result.x\n\t\t\tnewY = result.y\n\t\t}\n\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tcrop: finalCrop,\n\t\t\t\t\tw: newWidth,\n\t\t\t\t\th: newHeight,\n\t\t\t\t},\n\t\t\t\tx: newX,\n\t\t\t\ty: newY,\n\t\t\t},\n\t\t])\n\t} else if (shape.type === 'video') {\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tw: assetInfoPartial.props.w,\n\t\t\t\t\th: assetInfoPartial.props.h,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t}\n\n\tconst asset = (await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile,\n\t\tassetId,\n\t})) as TLAsset\n\n\teditor.updateAssets([{ ...asset, id: assetId }])\n\n\treturn asset\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlAsset(\n\teditor: Editor,\n\t{ url }: TLUrlExternalAsset,\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n): Promise<TLBookmarkAsset> {\n\tlet meta: { image: string; favicon: string; title: string; description: string }\n\n\ttry {\n\t\tconst resp = await fetch(url, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t})\n\t\tconst html = await resp.text()\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html')\n\t\tmeta = {\n\t\t\timage: doc.head.querySelector('meta[property=\"og:image\"]')?.getAttribute('content') ?? '',\n\t\t\tfavicon:\n\t\t\t\tdoc.head.querySelector('link[rel=\"apple-touch-icon\"]')?.getAttribute('href') ??\n\t\t\t\tdoc.head.querySelector('link[rel=\"icon\"]')?.getAttribute('href') ??\n\t\t\t\t'',\n\t\t\ttitle: doc.head.querySelector('meta[property=\"og:title\"]')?.getAttribute('content') ?? url,\n\t\t\tdescription:\n\t\t\t\tdoc.head.querySelector('meta[property=\"og:description\"]')?.getAttribute('content') ?? '',\n\t\t}\n\t\tif (!meta.image.startsWith('http')) {\n\t\t\tmeta.image = new URL(meta.image, url).href\n\t\t}\n\t\tif (!meta.favicon.startsWith('http')) {\n\t\t\tmeta.favicon = new URL(meta.favicon, url).href\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(error)\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tmeta = { image: '', favicon: '', title: '', description: '' }\n\t}\n\n\t// Create the bookmark asset from the meta\n\treturn {\n\t\tid: AssetRecordType.createId(getHashForString(url)),\n\t\ttypeName: 'asset',\n\t\ttype: 'bookmark',\n\t\tprops: {\n\t\t\tsrc: url,\n\t\t\tdescription: meta.description,\n\t\t\timage: meta.image,\n\t\t\tfavicon: meta.favicon,\n\t\t\ttitle: meta.title,\n\t\t},\n\t\tmeta: {},\n\t} as TLBookmarkAsset\n}\n\n/** @public */\nexport async function defaultHandleExternalSvgTextContent(\n\teditor: Editor,\n\t{ point, text }: { point?: VecLike; text: string }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')\n\tif (!svg) {\n\t\tthrow new Error('No <svg/> element present')\n\t}\n\n\tlet width = parseFloat(svg.getAttribute('width') || '0')\n\tlet height = parseFloat(svg.getAttribute('height') || '0')\n\n\tif (!(width && height)) {\n\t\tdocument.body.appendChild(svg)\n\t\tconst box = svg.getBoundingClientRect()\n\t\tdocument.body.removeChild(svg)\n\n\t\twidth = box.width\n\t\theight = box.height\n\t}\n\n\tconst asset = await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile: new File([text], 'asset.svg', { type: 'image/svg+xml' }),\n\t})\n\n\tif (!asset) throw Error('Could not create an asset')\n\n\tcreateShapesForAssets(editor, [asset], position)\n}\n\n/** @public */\nexport function defaultHandleExternalEmbedContent<T>(\n\teditor: Editor,\n\t{ point, url, embed }: { point?: VecLike; url: string; embed: T }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst { width, height } = embed as { width: number; height: number }\n\n\tconst id = createShapeId()\n\n\tconst newPoint = maybeSnapToGrid(\n\t\tnew Vec(position.x - (width || 450) / 2, position.y - (height || 450) / 2),\n\t\teditor\n\t)\n\tconst shapePartial: TLShapePartial = {\n\t\tid,\n\t\ttype: 'embed',\n\t\tx: newPoint.x,\n\t\ty: newPoint.y,\n\t\tprops: {\n\t\t\tw: width,\n\t\t\th: height,\n\t\t\turl,\n\t\t},\n\t}\n\n\tif (editor.canCreateShape(shapePartial)) {\n\t\teditor.createShape(shapePartial).select(id)\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalFileContent(\n\teditor: Editor,\n\t{ point, files }: { point?: VecLike; files: File[] },\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst { acceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES, toasts, msg } = options\n\tif (files.length > editor.options.maxFilesAtOnce) {\n\t\ttoasts.addToast({ title: msg('assets.files.amount-too-many'), severity: 'error' })\n\t\treturn\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst pagePoint = new Vec(position.x, position.y)\n\tconst assetPartials: TLAsset[] = []\n\tconst assetsToUpdate: {\n\t\tasset: TLAsset\n\t\tfile: File\n\t}[] = []\n\tfor (const file of files) {\n\t\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\t\tif (!isSuccess) continue\n\n\t\tconst assetInfo = await getAssetInfo(file, options)\n\t\tif (acceptedImageMimeTypes.includes(file.type)) {\n\t\t\teditor.createTemporaryAssetPreview(assetInfo.id, file)\n\t\t}\n\t\tassetPartials.push(assetInfo)\n\t\tassetsToUpdate.push({ asset: assetInfo, file })\n\t}\n\n\tPromise.allSettled(\n\t\tassetsToUpdate.map(async (assetAndFile) => {\n\t\t\ttry {\n\t\t\t\tconst newAsset = await editor.getAssetForExternalContent({\n\t\t\t\t\ttype: 'file',\n\t\t\t\t\tfile: assetAndFile.file,\n\t\t\t\t})\n\n\t\t\t\tif (!newAsset) {\n\t\t\t\t\tthrow Error('Could not create an asset')\n\t\t\t\t}\n\n\t\t\t\t// Save the new asset under the old asset's id\n\t\t\t\teditor.updateAssets([{ ...newAsset, id: assetAndFile.asset.id }])\n\t\t\t} catch (error) {\n\t\t\t\ttoasts.addToast({\n\t\t\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t})\n\t\t\t\tconsole.error(error)\n\t\t\t\teditor.deleteAssets([assetAndFile.asset.id])\n\t\t\t\treturn\n\t\t\t}\n\t\t})\n\t)\n\n\tcreateShapesForAssets(editor, assetPartials, pagePoint)\n}\n\n/** @public */\nexport async function defaultHandleExternalTextContent(\n\teditor: Editor,\n\t{ point, text, html }: { point?: VecLike; text: string; html?: string }\n) {\n\tconst p =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()\n\n\tconst cleanedUpPlaintext = cleanupText(text)\n\tconst richTextToPaste = html\n\t\t? renderRichTextFromHTML(editor, html)\n\t\t: toRichText(cleanedUpPlaintext)\n\n\t// todo: discuss\n\t// If we have one shape with rich text selected, update the shape's text.\n\t// const onlySelectedShape = editor.getOnlySelectedShape()\n\t// if (onlySelectedShape && 'richText' in onlySelectedShape.props) {\n\t// \teditor.updateShapes([\n\t// \t\t{\n\t// \t\t\tid: onlySelectedShape.id,\n\t// \t\t\ttype: onlySelectedShape.type,\n\t// \t\t\tprops: {\n\t// \t\t\t\trichText: richTextToPaste,\n\t// \t\t\t},\n\t// \t\t},\n\t// \t])\n\n\t// \treturn\n\t// }\n\n\t// Measure the text with default values\n\tlet w: number\n\tlet h: number\n\tlet autoSize: boolean\n\tlet align = 'middle' as TLTextShapeProps['textAlign']\n\n\tconst htmlToMeasure = html ?? cleanedUpPlaintext.replace(/\\n/g, '<br>')\n\tconst isMultiLine = html\n\t\t? richTextToPaste.content.length > 1\n\t\t: cleanedUpPlaintext.split('\\n').length > 1\n\n\t// check whether the text contains the most common characters in RTL languages\n\tconst isRtl = isRightToLeftLanguage(cleanedUpPlaintext)\n\n\tif (isMultiLine) {\n\t\talign = isMultiLine ? (isRtl ? 'end' : 'start') : 'middle'\n\t}\n\n\tconst rawSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t...TEXT_PROPS,\n\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\tmaxWidth: null,\n\t})\n\n\tconst minWidth = Math.min(\n\t\tisMultiLine ? editor.getViewportPageBounds().width * 0.9 : 920,\n\t\tMath.max(200, editor.getViewportPageBounds().width * 0.9)\n\t)\n\n\tif (rawSize.w > minWidth) {\n\t\tconst shrunkSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\t\tmaxWidth: minWidth,\n\t\t})\n\t\tw = shrunkSize.w\n\t\th = shrunkSize.h\n\t\tautoSize = false\n\t\talign = isRtl ? 'end' : 'start'\n\t} else {\n\t\t// autosize is fine\n\t\tw = Math.max(rawSize.w, 10)\n\t\th = Math.max(rawSize.h, 10)\n\t\tautoSize = true\n\t}\n\n\tif (p.y - h / 2 < editor.getViewportPageBounds().minY + 40) {\n\t\tp.y = editor.getViewportPageBounds().minY + 40 + h / 2\n\t}\n\n\tconst newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)\n\tconst shapeId = createShapeId()\n\n\t// Allow this to trigger the max shapes reached alert\n\teditor.createShapes([\n\t\t{\n\t\t\tid: shapeId,\n\t\t\ttype: 'text',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\trichText: richTextToPaste,\n\t\t\t\t// if the text has more than one line, align it to the left\n\t\t\t\ttextAlign: align,\n\t\t\t\tautoSize,\n\t\t\t\tw,\n\t\t\t},\n\t\t},\n\t])\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlContent(\n\teditor: Editor,\n\t{ point, url }: { point?: VecLike; url: string },\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n) {\n\t// try to paste as an embed first\n\tconst embedUtil = editor.getShapeUtil('embed') as EmbedShapeUtil | undefined\n\tconst embedInfo = embedUtil?.getEmbedDefinition(url)\n\n\tif (embedInfo && embedInfo.definition.embedOnPaste !== false) {\n\t\treturn editor.putExternalContent({\n\t\t\ttype: 'embed',\n\t\t\turl: embedInfo.url,\n\t\t\tpoint,\n\t\t\tembed: embedInfo.definition,\n\t\t})\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\t// Use the new function to create the bookmark\n\tconst result = await createBookmarkFromUrl(editor, { url, center: position })\n\n\tif (!result.ok) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalTldrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: TLContent }\n) {\n\teditor.run(() => {\n\t\tconst selectionBoundsBefore = editor.getSelectionPageBounds()\n\t\teditor.markHistoryStoppingPoint('paste')\n\n\t\t// Unlock any locked root shapes on paste\n\t\tfor (const shape of content.shapes) {\n\t\t\tif (content.rootShapeIds.includes(shape.id)) {\n\t\t\t\tshape.isLocked = false\n\t\t\t}\n\t\t}\n\n\t\teditor.putContentOntoCurrentPage(content, {\n\t\t\tpoint: point,\n\t\t\tselect: true,\n\t\t})\n\t\tconst selectedBoundsAfter = editor.getSelectionPageBounds()\n\t\tif (\n\t\t\tselectionBoundsBefore &&\n\t\t\tselectedBoundsAfter &&\n\t\t\tselectionBoundsBefore?.collides(selectedBoundsAfter)\n\t\t) {\n\t\t\t// Creates a 'puff' to show content has been pasted\n\t\t\teditor.updateInstanceState({ isChangingStyle: true })\n\t\t\teditor.timers.setTimeout(() => {\n\t\t\t\teditor.updateInstanceState({ isChangingStyle: false })\n\t\t\t}, 150)\n\t\t}\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalExcalidrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: any }\n) {\n\teditor.run(() => {\n\t\tputExcalidrawContent(editor, content, point)\n\t})\n}\n\n/** @public */\nexport async function getMediaAssetInfoPartial(\n\tfile: File,\n\tassetId: TLAssetId,\n\tisImageType: boolean,\n\tisVideoType: boolean,\n\tmaxImageDimension?: number\n) {\n\tlet fileType = file.type\n\n\tif (file.type === 'video/quicktime') {\n\t\t// hack to make .mov videos work\n\t\tfileType = 'video/mp4'\n\t}\n\n\tconst size = isImageType\n\t\t? await MediaHelpers.getImageSize(file)\n\t\t: await MediaHelpers.getVideoSize(file)\n\n\tconst isAnimated = (await MediaHelpers.isAnimated(file)) || isVideoType\n\n\tconst assetInfo = {\n\t\tid: assetId,\n\t\ttype: isImageType ? 'image' : 'video',\n\t\ttypeName: 'asset',\n\t\tprops: {\n\t\t\tname: file.name,\n\t\t\tsrc: '',\n\t\t\tw: size.w,\n\t\t\th: size.h,\n\t\t\tfileSize: file.size,\n\t\t\tmimeType: fileType,\n\t\t\tisAnimated,\n\t\t},\n\t\tmeta: {},\n\t} as TLImageAsset | TLVideoAsset\n\n\tif (maxImageDimension && isFinite(maxImageDimension)) {\n\t\tconst size = { w: assetInfo.props.w, h: assetInfo.props.h }\n\t\tconst resizedSize = containBoxSize(size, { w: maxImageDimension, h: maxImageDimension })\n\t\tif (size !== resizedSize && MediaHelpers.isStaticImageType(file.type)) {\n\t\t\tassetInfo.props.w = resizedSize.w\n\t\t\tassetInfo.props.h = resizedSize.h\n\t\t}\n\t}\n\n\treturn assetInfo\n}\n\n/**\n * A helper function for an external content handler. It creates bookmarks,\n * images or video shapes corresponding to the type of assets provided.\n *\n * @param editor - The editor instance\n *\n * @param assets - An array of asset Ids\n *\n * @param position - the position at which to create the shapes\n *\n * @public\n */\nexport async function createShapesForAssets(\n\teditor: Editor,\n\tassets: TLAsset[],\n\tposition: VecLike\n): Promise<TLShapeId[]> {\n\tif (!assets.length) return []\n\n\tconst currentPoint = Vec.From(position)\n\tconst partials: TLShapePartial[] = []\n\n\tfor (let i = 0; i < assets.length; i++) {\n\t\tconst asset = assets[i]\n\t\tswitch (asset.type) {\n\t\t\tcase 'image': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'video': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'video',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\t// Create any assets\n\t\tconst assetsToCreate = assets.filter((asset) => !editor.getAsset(asset.id))\n\n\t\teditor.store.atomic(() => {\n\t\t\tif (editor.canCreateShapes(partials)) {\n\t\t\t\tif (assetsToCreate.length) {\n\t\t\t\t\teditor.createAssets(assetsToCreate)\n\t\t\t\t}\n\n\t\t\t\t// Create the shapes\n\t\t\t\teditor.createShapes(partials).select(...partials.map((p) => p.id))\n\n\t\t\t\t// Re-position shapes so that the center of the group is at the provided point\n\t\t\t\tcenterSelectionAroundPoint(editor, position)\n\t\t\t}\n\t\t})\n\t})\n\n\treturn partials.map((p) => p.id)\n}\n\n/**\n * Repositions selected shapes do that the center of the group is\n * at the provided position\n *\n * @param editor - The editor instance\n *\n * @param position - the point to center the shapes around\n *\n * @public\n */\nexport function centerSelectionAroundPoint(editor: Editor, position: VecLike) {\n\t// Re-position shapes so that the center of the group is at the provided point\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tlet selectionPageBounds = editor.getSelectionPageBounds()\n\n\tif (selectionPageBounds) {\n\t\tconst offset = selectionPageBounds!.center.sub(position)\n\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst localRotation = editor.getShapeParentTransform(shape).decompose().rotation\n\t\t\t\tconst localDelta = Vec.Rot(offset, -localRotation)\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: shape.x! - localDelta.x,\n\t\t\t\t\ty: shape.y! - localDelta.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\t// align selection with the grid if necessary\n\tif (selectionPageBounds && editor.getInstanceState().isGridMode) {\n\t\tconst gridSize = editor.getDocumentSettings().gridSize\n\t\tconst topLeft = new Vec(selectionPageBounds.minX, selectionPageBounds.minY)\n\t\tconst gridSnappedPoint = topLeft.clone().snapToGrid(gridSize)\n\t\tconst delta = Vec.Sub(topLeft, gridSnappedPoint)\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst newPoint = { x: shape.x! - delta.x, y: shape.y! - delta.y }\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\t// Zoom out to fit the shapes, if necessary\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\tif (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) {\n\t\teditor.zoomToSelection({ animation: { duration: editor.options.animationMediumMs } })\n\t}\n}\n\n/** @public */\nexport function createEmptyBookmarkShape(\n\teditor: Editor,\n\turl: string,\n\tposition: VecLike\n): TLBookmarkShape {\n\tconst partial: TLShapePartial = {\n\t\tid: createShapeId(),\n\t\ttype: 'bookmark',\n\t\tx: position.x - 150,\n\t\ty: position.y - 160,\n\t\topacity: 1,\n\t\tprops: {\n\t\t\tassetId: null,\n\t\t\turl,\n\t\t},\n\t}\n\n\teditor.run(() => {\n\t\t// Allow this to trigger the max shapes reached alert\n\t\teditor.createShape(partial)\n\t\tif (!editor.getShape(partial.id)) return\n\t\teditor.select(partial.id)\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn editor.getShape(partial.id) as TLBookmarkShape\n}\n\n/**\n * Checks if a file is allowed to be uploaded. If it is not, it will show a toast explaining why to the user.\n *\n * @param file - The file to check\n * @param options - The options for the external content handler\n * @returns True if the file is allowed, false otherwise\n * @public\n */\nexport function notifyIfFileNotAllowed(file: File, options: TLDefaultExternalContentHandlerOpts) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxAssetSize = DEFAULT_MAX_ASSET_SIZE,\n\t\ttoasts,\n\t\tmsg,\n\t} = options\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\n\tif (!isImageType && !isVideoType) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.type-not-allowed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\tif (file.size > maxAssetSize) {\n\t\tconst formatBytes = (bytes: number): string => {\n\t\t\tif (bytes === 0) return '0 bytes'\n\n\t\t\tconst units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']\n\t\t\tconst base = 1024\n\t\t\tconst unitIndex = Math.floor(Math.log(bytes) / Math.log(base))\n\n\t\t\tconst value = bytes / Math.pow(base, unitIndex)\n\t\t\tconst formatted = value % 1 === 0 ? value.toString() : value.toFixed(1)\n\n\t\t\treturn `${formatted} ${units[unitIndex]}`\n\t\t}\n\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.size-too-big'),\n\t\t\tdescription: msg('assets.files.maximum-size').replace('{size}', formatBytes(maxAssetSize)),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\t// Use mime type instead of file ext, this is because\n\t// window.navigator.clipboard does not preserve file names\n\t// of copied files.\n\tif (!file.type) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tconsole.error('No mime type')\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/** @public */\nexport async function getAssetInfo(\n\tfile: File,\n\toptions: TLDefaultExternalContentHandlerOpts,\n\tassetId?: TLAssetId\n) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxImageDimension = DEFAULT_MAX_IMAGE_DIMENSION,\n\t} = options\n\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tassetId ??= AssetRecordType.createId(hash)\n\tconst assetInfo = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImageType,\n\t\tisVideoType,\n\t\tmaxImageDimension\n\t)\n\treturn assetInfo\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAgBA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,6BAA6B;AAEtC,SAAS,2CAA2C;AACpD,SAAS,eAAe,YAAY,kBAAkB;AAGtD,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,aAAa,6BAA6B;AAM5C,MAAM,8BAA8B;AAKpC,MAAM,yBAAyB,KAAK,OAAO;AAiC3C,SAAS,uCACf,QACA,SACC;AAED,SAAO,6BAA6B,QAAQ,OAAO,kBAAkB;AACpE,WAAO,+BAA+B,QAAQ,eAAe,OAA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AK,IAAI,MAAM,SAAS;AAC9C,YAAM,YAAY,QAAQ,MAAM,IAAI,MAAM,SAAS,IAAI,MAAM,QAAQ,CAAC;AAEtE,aAAO,GAAG,SAAS,IAAI,MAAM,SAAS,CAAC;AAAA,IACxC;AAEA,WAAO,SAAS;AAAA,MACf,OAAO,IAAI,2BAA2B;AAAA,MACtC,aAAa,IAAI,2BAA2B,EAAE,QAAQ,UAAU,YAAY,YAAY,CAAC;AAAA,MACzF,UAAU;AAAA,IACX,CAAC;AACD,WAAO;AAAA,EACR;AAKA,MAAI,CAAC,KAAK,MAAM;AACf,WAAO,SAAS;AAAA,MACf,OAAO,IAAI,4BAA4B;AAAA,MACvC,UAAU;AAAA,IACX,CAAC;AACD,YAAQ,MAAM,cAAc;AAC5B,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAGA,eAAsB,aACrB,MACA,SACA,SACC;AACD,QAAM;AAAA,IACL,yBAAyB;AAAA,IACzB,yBAAyB;AAAA,IACzB,oBAAoB;AAAA,EACrB,IAAI;AAEJ,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,OAAO,iBAAiB,MAAM,KAAK,YAAY,CAAC;AACtD,cAAY,gBAAgB,SAAS,IAAI;AACzC,QAAM,YAAY,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;",
6
6
  "names": ["size"]
7
7
  }
@@ -20,10 +20,15 @@ function registerDefaultSideEffects(editor) {
20
20
  const shape = editor.getEditingShape();
21
21
  if (shape && shape.type === "text" && editor.isInAny("text.pointing", "select.resizing") && editor.getInstanceState().isToolLocked) {
22
22
  editor.setCurrentTool("select.editing_shape", {
23
+ target: "shape",
24
+ shape,
23
25
  isCreatingTextWhileToolLocked: true
24
26
  });
25
27
  } else {
26
- editor.setCurrentTool("select.editing_shape");
28
+ editor.setCurrentTool("select.editing_shape", {
29
+ target: "shape",
30
+ shape
31
+ });
27
32
  }
28
33
  }
29
34
  } else if (prev.editingShapeId && !next.editingShapeId) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/defaultSideEffects.ts"],
4
- "sourcesContent": ["import { Editor } from '@tldraw/editor'\n\n/** @public */\nexport function registerDefaultSideEffects(editor: Editor) {\n\treturn editor.sideEffects.register({\n\t\tinstance_page_state: {\n\t\t\tafterChange: (prev, next) => {\n\t\t\t\tif (prev.croppingShapeId !== next.croppingShapeId) {\n\t\t\t\t\tconst isInCroppingState = editor.isIn('select.crop')\n\t\t\t\t\tif (!prev.croppingShapeId && next.croppingShapeId) {\n\t\t\t\t\t\tif (!isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (prev.croppingShapeId && !next.croppingShapeId) {\n\t\t\t\t\t\tif (isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (prev.editingShapeId !== next.editingShapeId) {\n\t\t\t\t\tif (!prev.editingShapeId && next.editingShapeId) {\n\t\t\t\t\t\tif (!editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\t// Here's where we handle the special tool locking case for text\n\t\t\t\t\t\t\t// If tool lock is enabled, and we just finished editing a text\n\t\t\t\t\t\t\t// shape and are setting that shape as the new editing shape,\n\t\t\t\t\t\t\t// then create the shape with a flag that will let it know to\n\t\t\t\t\t\t\t// go back to the text tool once the edit is complete.\n\t\t\t\t\t\t\tconst shape = editor.getEditingShape()\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tshape &&\n\t\t\t\t\t\t\t\tshape.type === 'text' &&\n\t\t\t\t\t\t\t\teditor.isInAny('text.pointing', 'select.resizing') &&\n\t\t\t\t\t\t\t\teditor.getInstanceState().isToolLocked\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape', {\n\t\t\t\t\t\t\t\t\tisCreatingTextWhileToolLocked: true,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (prev.editingShapeId && !next.editingShapeId) {\n\t\t\t\t\t\tif (editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t})\n}\n"],
5
- "mappings": "AAGO,SAAS,2BAA2B,QAAgB;AAC1D,SAAO,OAAO,YAAY,SAAS;AAAA,IAClC,qBAAqB;AAAA,MACpB,aAAa,CAAC,MAAM,SAAS;AAC5B,YAAI,KAAK,oBAAoB,KAAK,iBAAiB;AAClD,gBAAM,oBAAoB,OAAO,KAAK,aAAa;AACnD,cAAI,CAAC,KAAK,mBAAmB,KAAK,iBAAiB;AAClD,gBAAI,CAAC,mBAAmB;AACvB,qBAAO,eAAe,kBAAkB;AAAA,YACzC;AAAA,UACD,WAAW,KAAK,mBAAmB,CAAC,KAAK,iBAAiB;AACzD,gBAAI,mBAAmB;AACtB,qBAAO,eAAe,aAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAEA,YAAI,KAAK,mBAAmB,KAAK,gBAAgB;AAChD,cAAI,CAAC,KAAK,kBAAkB,KAAK,gBAAgB;AAChD,gBAAI,CAAC,OAAO,KAAK,sBAAsB,GAAG;AAMzC,oBAAM,QAAQ,OAAO,gBAAgB;AACrC,kBACC,SACA,MAAM,SAAS,UACf,OAAO,QAAQ,iBAAiB,iBAAiB,KACjD,OAAO,iBAAiB,EAAE,cACzB;AACD,uBAAO,eAAe,wBAAwB;AAAA,kBAC7C,+BAA+B;AAAA,gBAChC,CAAC;AAAA,cACF,OAAO;AACN,uBAAO,eAAe,sBAAsB;AAAA,cAC7C;AAAA,YACD;AAAA,UACD,WAAW,KAAK,kBAAkB,CAAC,KAAK,gBAAgB;AACvD,gBAAI,OAAO,KAAK,sBAAsB,GAAG;AACxC,qBAAO,eAAe,aAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AACF;",
4
+ "sourcesContent": ["import { Editor } from '@tldraw/editor'\n\n/** @public */\nexport function registerDefaultSideEffects(editor: Editor) {\n\treturn editor.sideEffects.register({\n\t\tinstance_page_state: {\n\t\t\tafterChange: (prev, next) => {\n\t\t\t\tif (prev.croppingShapeId !== next.croppingShapeId) {\n\t\t\t\t\tconst isInCroppingState = editor.isIn('select.crop')\n\t\t\t\t\tif (!prev.croppingShapeId && next.croppingShapeId) {\n\t\t\t\t\t\tif (!isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (prev.croppingShapeId && !next.croppingShapeId) {\n\t\t\t\t\t\tif (isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (prev.editingShapeId !== next.editingShapeId) {\n\t\t\t\t\tif (!prev.editingShapeId && next.editingShapeId) {\n\t\t\t\t\t\tif (!editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\t// Here's where we handle the special tool locking case for text\n\t\t\t\t\t\t\t// If tool lock is enabled, and we just finished editing a text\n\t\t\t\t\t\t\t// shape and are setting that shape as the new editing shape,\n\t\t\t\t\t\t\t// then create the shape with a flag that will let it know to\n\t\t\t\t\t\t\t// go back to the text tool once the edit is complete.\n\t\t\t\t\t\t\tconst shape = editor.getEditingShape()\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tshape &&\n\t\t\t\t\t\t\t\tshape.type === 'text' &&\n\t\t\t\t\t\t\t\teditor.isInAny('text.pointing', 'select.resizing') &&\n\t\t\t\t\t\t\t\teditor.getInstanceState().isToolLocked\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape', {\n\t\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t\t\tshape: shape,\n\t\t\t\t\t\t\t\t\tisCreatingTextWhileToolLocked: true,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape', {\n\t\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t\t\tshape: shape,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (prev.editingShapeId && !next.editingShapeId) {\n\t\t\t\t\t\tif (editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t})\n}\n"],
5
+ "mappings": "AAGO,SAAS,2BAA2B,QAAgB;AAC1D,SAAO,OAAO,YAAY,SAAS;AAAA,IAClC,qBAAqB;AAAA,MACpB,aAAa,CAAC,MAAM,SAAS;AAC5B,YAAI,KAAK,oBAAoB,KAAK,iBAAiB;AAClD,gBAAM,oBAAoB,OAAO,KAAK,aAAa;AACnD,cAAI,CAAC,KAAK,mBAAmB,KAAK,iBAAiB;AAClD,gBAAI,CAAC,mBAAmB;AACvB,qBAAO,eAAe,kBAAkB;AAAA,YACzC;AAAA,UACD,WAAW,KAAK,mBAAmB,CAAC,KAAK,iBAAiB;AACzD,gBAAI,mBAAmB;AACtB,qBAAO,eAAe,aAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAEA,YAAI,KAAK,mBAAmB,KAAK,gBAAgB;AAChD,cAAI,CAAC,KAAK,kBAAkB,KAAK,gBAAgB;AAChD,gBAAI,CAAC,OAAO,KAAK,sBAAsB,GAAG;AAMzC,oBAAM,QAAQ,OAAO,gBAAgB;AACrC,kBACC,SACA,MAAM,SAAS,UACf,OAAO,QAAQ,iBAAiB,iBAAiB,KACjD,OAAO,iBAAiB,EAAE,cACzB;AACD,uBAAO,eAAe,wBAAwB;AAAA,kBAC7C,QAAQ;AAAA,kBACR;AAAA,kBACA,+BAA+B;AAAA,gBAChC,CAAC;AAAA,cACF,OAAO;AACN,uBAAO,eAAe,wBAAwB;AAAA,kBAC7C,QAAQ;AAAA,kBACR;AAAA,gBACD,CAAC;AAAA,cACF;AAAA,YACD;AAAA,UACD,WAAW,KAAK,kBAAkB,CAAC,KAAK,gBAAgB;AACvD,gBAAI,OAAO,KAAK,sBAAsB,GAAG;AACxC,qBAAO,eAAe,aAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AACF;",
6
6
  "names": []
7
7
  }
@@ -30,8 +30,7 @@ import {
30
30
  track,
31
31
  useEditor,
32
32
  useIsEditing,
33
- useSharedSafeId,
34
- useValue
33
+ useSharedSafeId
35
34
  } from "@tldraw/editor";
36
35
  import { useMemo } from "react";
37
36
  import { updateArrowTerminal } from "../../bindings/arrow/ArrowBindingUtil.mjs";
@@ -42,6 +41,7 @@ import { ShapeFill } from "../shared/ShapeFill.mjs";
42
41
  import { ARROW_LABEL_PADDING, STROKE_SIZES, TEXT_PROPS } from "../shared/default-shape-constants.mjs";
43
42
  import { getFillDefForCanvas, getFillDefForExport } from "../shared/defaultStyleDefs.mjs";
44
43
  import { useDefaultColorTheme } from "../shared/useDefaultColorTheme.mjs";
44
+ import { useEfficientZoomThreshold } from "../shared/useEfficientZoomThreshold.mjs";
45
45
  import { getArrowBodyPath, getArrowHandlePath } from "./ArrowPath.mjs";
46
46
  import {
47
47
  getArrowLabelDefaultPosition,
@@ -94,8 +94,13 @@ class ArrowShapeUtil extends ShapeUtil {
94
94
  elbowMinSegmentLengthToShowMidpointHandle: 20,
95
95
  hoverPreciseTimeout: 600,
96
96
  pointingPreciseTimeout: 320,
97
- shouldBeExact: (editor) => editor.inputs.altKey,
98
- shouldIgnoreTargets: (editor) => editor.inputs.ctrlKey
97
+ shouldBeExact(editor) {
98
+ return editor.inputs.getAltKey();
99
+ },
100
+ shouldIgnoreTargets(editor) {
101
+ return editor.inputs.getCtrlKey();
102
+ },
103
+ showTextOutline: true
99
104
  };
100
105
  canEdit() {
101
106
  return true;
@@ -223,7 +228,7 @@ class ArrowShapeUtil extends ShapeUtil {
223
228
  const shapePageTransform = this.editor.getShapePageTransform(shape.id);
224
229
  const segmentStart = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentStart);
225
230
  const segmentEnd = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentEnd);
226
- const segmentLength = Vec.Dist(segmentStart, segmentEnd) * this.editor.getZoomLevel();
231
+ const segmentLength = Vec.Dist(segmentStart, segmentEnd) * this.editor.getEfficientZoomLevel();
227
232
  if (segmentLength > this.options.elbowMinSegmentLengthToShowMidpointHandle) {
228
233
  handles.push({
229
234
  id: "middle" /* Middle */,
@@ -295,7 +300,7 @@ class ArrowShapeUtil extends ShapeUtil {
295
300
  shapeToPageTransform.applyToPoint(axis.v(midRange.hi, 0)),
296
301
  angle
297
302
  );
298
- const maxSnapDistance = this.options.elbowMidpointSnapDistance / this.editor.getZoomLevel();
303
+ const maxSnapDistance = this.options.elbowMidpointSnapDistance / this.editor.getEfficientZoomLevel();
299
304
  const midPoint = perpDistanceToLineAngle(
300
305
  shapeToPageTransform.applyToPoint(axis.v(lerp(midRange.lo, midRange.hi, 0.5), 0)),
301
306
  angle
@@ -620,6 +625,7 @@ class ArrowShapeUtil extends ShapeUtil {
620
625
  textWidth: labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale,
621
626
  isSelected,
622
627
  padding: 0,
628
+ showTextOutline: this.options.showTextOutline,
623
629
  style: {
624
630
  transform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)`
625
631
  }
@@ -746,7 +752,7 @@ class ArrowShapeUtil extends ShapeUtil {
746
752
  richText: shape.props.richText,
747
753
  bounds: getArrowLabelPosition(this.editor, shape).box.clone().expandBy(-ARROW_LABEL_PADDING * shape.props.scale),
748
754
  padding: 0,
749
- showTextOutline: true
755
+ showTextOutline: this.options.showTextOutline
750
756
  }
751
757
  )
752
758
  ] });
@@ -792,13 +798,7 @@ const ArrowSvg = track(function ArrowSvg2({
792
798
  const editor = useEditor();
793
799
  const theme = useDefaultColorTheme();
794
800
  const info = getArrowInfo(editor, shape);
795
- const isForceSolid = useValue(
796
- "force solid",
797
- () => {
798
- return editor.getZoomLevel() < 0.2;
799
- },
800
- [editor]
801
- );
801
+ const isForceSolid = useEfficientZoomThreshold(shape.props.scale * 0.25);
802
802
  const clipPathId = useSharedSafeId(shape.id + "_clip");
803
803
  const arrowheadDotId = useSharedSafeId("arrowhead-dot");
804
804
  const arrowheadCrossId = useSharedSafeId("arrowhead-cross");
@@ -819,7 +819,7 @@ const ArrowSvg = track(function ArrowSvg2({
819
819
  start: "skip",
820
820
  end: "skip",
821
821
  lengthRatio: 2.5,
822
- strokeWidth: 2 / editor.getZoomLevel(),
822
+ strokeWidth: 2 / editor.getEfficientZoomLevel(),
823
823
  props: {
824
824
  className: "tl-arrow-hint",
825
825
  markerStart: bindings.start ? bindings.start.props.isExact ? "" : bindings.start.props.isPrecise ? `url(#${arrowheadCrossId})` : `url(#${arrowheadDotId})` : "",