tldraw 4.3.0-canary.da35795ba8e2 → 4.3.0-canary.e1766dd4eab3

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 (310) hide show
  1. package/dist-cjs/index.d.ts +26 -5
  2. package/dist-cjs/index.js +2 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.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/defaultExternalContentHandlers.js.map +2 -2
  8. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +9 -12
  9. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  10. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  11. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  12. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  13. package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
  14. package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
  15. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  16. package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
  17. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
  18. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  19. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
  20. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  21. package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
  22. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +1 -1
  23. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  24. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +10 -6
  25. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  26. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  27. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +1 -1
  28. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  29. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  30. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +5 -5
  31. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  32. package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
  33. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +2 -1
  34. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  35. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
  36. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
  37. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +11 -3
  38. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
  39. package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
  40. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  41. package/dist-cjs/lib/shapes/shared/crop.js +1 -0
  42. package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
  43. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  44. package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
  45. package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
  46. package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
  47. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
  48. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  49. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
  50. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  51. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  52. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
  53. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  54. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  55. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  56. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +1 -4
  57. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  58. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  59. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  60. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -1
  61. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  62. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +30 -10
  63. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  64. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  65. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  66. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  67. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  68. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  69. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  70. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  71. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
  72. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
  73. package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
  74. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  75. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  76. package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js +1 -1
  77. package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js.map +2 -2
  78. package/dist-cjs/lib/ui/components/menu-items.js +3 -1
  79. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  80. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
  81. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  82. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +143 -88
  83. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  84. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -1
  85. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  86. package/dist-cjs/lib/ui/context/actions.js +1 -2
  87. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  88. package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
  89. package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
  90. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  91. package/dist-cjs/lib/ui/version.js +3 -3
  92. package/dist-cjs/lib/ui/version.js.map +1 -1
  93. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -0
  94. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  95. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  96. package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
  97. package/dist-cjs/lib/utils/text/richText.js +7 -17
  98. package/dist-cjs/lib/utils/text/richText.js.map +3 -3
  99. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  100. package/dist-esm/index.d.mts +26 -5
  101. package/dist-esm/index.mjs +3 -1
  102. package/dist-esm/index.mjs.map +2 -2
  103. package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
  104. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
  105. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  106. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  107. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +10 -14
  108. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  109. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  110. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  111. package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
  112. package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
  113. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  114. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
  115. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +3 -3
  116. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  117. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
  118. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  119. package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
  120. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +1 -1
  121. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  122. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +10 -6
  123. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  124. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  125. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +1 -1
  126. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  127. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  128. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -5
  129. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  130. package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
  131. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +3 -2
  132. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  133. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
  134. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  135. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +11 -3
  136. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  137. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
  138. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  139. package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
  140. package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
  141. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  142. package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
  143. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
  144. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
  145. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
  146. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  147. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
  148. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  149. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  150. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
  151. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  152. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  153. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +1 -4
  154. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  155. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +1 -4
  156. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  157. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  158. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  159. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -1
  160. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  161. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +30 -10
  162. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  163. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  164. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  165. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +1 -4
  166. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  167. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  168. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  169. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  170. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  171. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
  172. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
  173. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
  174. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  175. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  176. package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs +1 -1
  177. package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs.map +2 -2
  178. package/dist-esm/lib/ui/components/menu-items.mjs +4 -5
  179. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  180. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
  181. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  182. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +151 -90
  183. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  184. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -2
  185. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  186. package/dist-esm/lib/ui/context/actions.mjs +1 -2
  187. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  188. package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
  189. package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
  190. package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
  191. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  192. package/dist-esm/lib/ui/version.mjs +3 -3
  193. package/dist-esm/lib/ui/version.mjs.map +1 -1
  194. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +8 -0
  195. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  196. package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
  197. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  198. package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
  199. package/dist-esm/lib/utils/text/richText.mjs +3 -3
  200. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  201. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  202. package/package.json +10 -10
  203. package/src/index.ts +1 -0
  204. package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
  205. package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
  206. package/src/lib/defaultExternalContentHandlers.ts +3 -4
  207. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
  208. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +11 -13
  209. package/src/lib/shapes/arrow/arrow-types.ts +2 -0
  210. package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
  211. package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
  212. package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
  213. package/src/lib/shapes/arrow/shared.ts +4 -4
  214. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
  215. package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
  216. package/src/lib/shapes/draw/DrawShapeUtil.tsx +3 -3
  217. package/src/lib/shapes/draw/toolStates/Drawing.ts +4 -4
  218. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  219. package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
  220. package/src/lib/shapes/frame/FrameShapeUtil.tsx +1 -1
  221. package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
  222. package/src/lib/shapes/geo/GeoShapeUtil.tsx +9 -4
  223. package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
  224. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +1 -1
  225. package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
  226. package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
  227. package/src/lib/shapes/line/toolStates/Pointing.ts +1 -1
  228. package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
  229. package/src/lib/shapes/note/NoteShapeUtil.tsx +7 -8
  230. package/src/lib/shapes/note/noteHelpers.ts +2 -2
  231. package/src/lib/shapes/shared/HyperlinkButton.tsx +3 -2
  232. package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
  233. package/src/lib/shapes/shared/RichTextLabel.tsx +13 -3
  234. package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
  235. package/src/lib/shapes/shared/crop.ts +1 -0
  236. package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
  237. package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
  238. package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
  239. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
  240. package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
  241. package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
  242. package/src/lib/shapes/text/toolStates/Pointing.ts +1 -1
  243. package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
  244. package/src/lib/tools/EraserTool/childStates/Erasing.ts +3 -5
  245. package/src/lib/tools/EraserTool/childStates/Pointing.ts +3 -16
  246. package/src/lib/tools/SelectTool/DragAndDropManager.ts +2 -4
  247. package/src/lib/tools/SelectTool/childStates/Brushing.ts +2 -6
  248. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +2 -3
  249. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +4 -7
  250. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +46 -15
  251. package/src/lib/tools/SelectTool/childStates/Idle.ts +6 -10
  252. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
  253. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +4 -12
  254. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
  255. package/src/lib/tools/SelectTool/childStates/Resizing.ts +2 -4
  256. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +2 -4
  257. package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -3
  258. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
  259. package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
  260. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
  261. package/src/lib/ui/components/ZoomMenu/DefaultZoomMenu.tsx +1 -1
  262. package/src/lib/ui/components/menu-items.tsx +9 -15
  263. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
  264. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +196 -108
  265. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
  266. package/src/lib/ui/context/actions.tsx +9 -13
  267. package/src/lib/ui/hooks/menu-hooks.ts +9 -19
  268. package/src/lib/ui/hooks/useFlatten.ts +1 -2
  269. package/src/lib/ui/hooks/useTools.tsx +1 -2
  270. package/src/lib/ui/version.ts +3 -3
  271. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +8 -0
  272. package/src/lib/utils/export/exportAs.ts +2 -9
  273. package/src/lib/utils/frames/frames.ts +1 -1
  274. package/src/lib/utils/text/richText.ts +3 -3
  275. package/src/lib/utils/tldr/buildFromV1Document.ts +12 -17
  276. package/src/test/Editor.test.tsx +38 -12
  277. package/src/test/SelectTool.test.ts +11 -19
  278. package/src/test/TestEditor.ts +1 -4
  279. package/src/test/TldrawEditor.test.tsx +21 -18
  280. package/src/test/bindings.test.tsx +29 -25
  281. package/src/test/bindingsIndex.test.tsx +4 -4
  282. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +2 -2
  283. package/src/test/commands/cameraState.test.ts +299 -0
  284. package/src/test/commands/createShape.test.ts +64 -0
  285. package/src/test/commands/createShapes.test.ts +15 -1
  286. package/src/test/commands/getSvgString.test.ts +2 -2
  287. package/src/test/commands/isShapeOfType.test.ts +44 -0
  288. package/src/test/commands/putContent.test.ts +80 -1
  289. package/src/test/commands/updateShape.test.ts +67 -0
  290. package/src/test/commands/updateShapes.test.ts +21 -5
  291. package/src/test/custom-clipping.test.ts +36 -35
  292. package/src/test/customSnapping.test.tsx +77 -62
  293. package/src/test/duplicate.test.ts +1 -1
  294. package/src/test/frames.test.ts +2 -2
  295. package/src/test/getCulledShapes.test.tsx +11 -3
  296. package/src/test/getShapeAtPoint.test.ts +2 -2
  297. package/src/test/groups.test.tsx +6 -3
  298. package/src/test/resizing.test.ts +9 -13
  299. package/src/test/selection-omnibus.test.ts +11 -11
  300. package/src/test/shapeutils.test.ts +1 -1
  301. package/src/test/styles2.test.tsx +1 -1
  302. package/src/test/styles3.test.ts +5 -5
  303. package/src/test/test-jsx.tsx +69 -57
  304. package/src/test/text.test.ts +15 -17
  305. package/src/test/translating.test.ts +6 -8
  306. package/tldraw.css +8 -4
  307. package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
  308. package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
  309. package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
  310. package/src/lib/shapes/shared/useForceSolid.ts +0 -6
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/utils/tldr/buildFromV1Document.ts"],
4
- "sourcesContent": ["import {\n\tAssetRecordType,\n\tEditor,\n\tPageRecordType,\n\tTLArrowShape,\n\tTLArrowShapeArrowheadStyle,\n\tTLAsset,\n\tTLAssetId,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLDrawShape,\n\tTLGeoShape,\n\tTLImageShape,\n\tTLNoteShape,\n\tTLPageId,\n\tTLShapeId,\n\tTLTextShape,\n\tTLVideoShape,\n\tVec,\n\tVecModel,\n\tclamp,\n\tcreateShapeId,\n\tfetch,\n\tstructuredClone,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { getArrowBindings } from '../../shapes/arrow/shared'\n\nconst TLDRAW_V1_VERSION = 15.5\n\n/** @internal */\nexport function buildFromV1Document(editor: Editor, _document: unknown) {\n\tlet document = _document as TLV1Document\n\teditor.run(() => {\n\t\tdocument = migrate(document, TLDRAW_V1_VERSION)\n\t\t// Cancel any interactions / states\n\t\teditor.cancel().cancel().cancel().cancel()\n\n\t\tconst firstPageId = editor.getPages()[0].id\n\n\t\t// Set the current page to the first page\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\t// Delete all pages except first page\n\t\tfor (const page of editor.getPages().slice(1)) {\n\t\t\teditor.deletePage(page.id)\n\t\t}\n\n\t\t// Delete all of the shapes on the current page\n\t\teditor.selectAll()\n\t\teditor.deleteShapes(editor.getSelectedShapeIds())\n\n\t\t// Create assets\n\t\tconst v1AssetIdsToV2AssetIds = new Map<string, TLAssetId>()\n\n\t\tObject.values(document.assets ?? {}).forEach((v1Asset) => {\n\t\t\tswitch (v1Asset.type) {\n\t\t\t\tcase TLV1AssetType.Image: {\n\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\tconst placeholderAsset: TLAsset = {\n\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t}\n\t\t\t\t\teditor.createAssets([placeholderAsset])\n\t\t\t\t\ttryMigrateAsset(editor, placeholderAsset)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase TLV1AssetType.Video:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\t\teditor.createAssets([\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\t\t\tisAnimated: true,\n\t\t\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t})\n\n\t\t// Create pages\n\n\t\tconst v1PageIdsToV2PageIds = new Map<string, TLPageId>()\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page, i) => {\n\t\t\t\tif (i === 0) {\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, editor.getCurrentPageId())\n\t\t\t\t} else {\n\t\t\t\t\tconst pageId = PageRecordType.createId()\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, pageId)\n\t\t\t\t\teditor.createPage({ name: v1Page.name ?? 'Page', id: pageId })\n\t\t\t\t}\n\t\t\t})\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page) => {\n\t\t\t\t// Set the current page id to the current page\n\t\t\t\teditor.setCurrentPage(v1PageIdsToV2PageIds.get(v1Page.id)!)\n\n\t\t\t\tconst v1ShapeIdsToV2ShapeIds = new Map<string, TLShapeId>()\n\t\t\t\tconst v1GroupShapeIdsToV1ChildIds = new Map<string, string[]>()\n\n\t\t\t\tconst v1Shapes = Object.values(v1Page.shapes ?? {})\n\t\t\t\t\t.sort((a, b) => (a.childIndex < b.childIndex ? -1 : 1))\n\t\t\t\t\t.slice(0, editor.options.maxShapesPerPage)\n\n\t\t\t\t// Groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Group) return\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.id, [])\n\t\t\t\t})\n\n\t\t\t\tfunction decideNotToCreateShape(v1Shape: TLV1Shape) {\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.delete(v1Shape.id)\n\t\t\t\t\tconst v1GroupParent = v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)\n\t\t\t\t\tif (v1GroupParent) {\n\t\t\t\t\t\tconst ids = v1GroupShapeIdsToV1ChildIds\n\t\t\t\t\t\t\t.get(v1Shape.parentId)!\n\t\t\t\t\t\t\t.filter((id) => id !== v1Shape.id)\n\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.parentId, ids)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Non-groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\t// Skip groups for now, we'll create groups via the app's API\n\t\t\t\t\tif (v1Shape.type === TLV1ShapeType.Group) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\n\t\t\t\t\tif (v1Shape.parentId !== v1Page.id) {\n\t\t\t\t\t\t// If the parent is a group, then add the shape to the group's children\n\t\t\t\t\t\tif (v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)) {\n\t\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.get(v1Shape.parentId)!.push(v1Shape.id)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.warn('parent does not exist', v1Shape)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// First, try to find the shape's parent among the existing groups\n\t\t\t\t\tconst parentId = v1PageIdsToV2PageIds.get(v1Page.id)!\n\n\t\t\t\t\tconst inCommon = {\n\t\t\t\t\t\tid: shapeId,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\tx: coerceNumber(v1Shape.point[0]),\n\t\t\t\t\t\ty: coerceNumber(v1Shape.point[1]),\n\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\tisLocked: !!v1Shape.isLocked,\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch (v1Shape.type) {\n\t\t\t\t\t\tcase TLV1ShapeType.Sticky: {\n\t\t\t\t\t\t\teditor.createShapes<TLNoteShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'note',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\talign: getV2Align(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Rectangle: {\n\t\t\t\t\t\t\teditor.createShapes<TLGeoShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'rectangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes<TLGeoShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Triangle: {\n\t\t\t\t\t\t\teditor.createShapes<TLGeoShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'triangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes<TLGeoShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Ellipse: {\n\t\t\t\t\t\t\teditor.createShapes<TLGeoShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'ellipse',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.radius[0]) * 2,\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.radius[1]) * 2,\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes<TLGeoShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Draw: {\n\t\t\t\t\t\t\tif (v1Shape.points.length === 0) {\n\t\t\t\t\t\t\t\tdecideNotToCreateShape(v1Shape)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes<TLDrawShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'draw',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tisPen: false,\n\t\t\t\t\t\t\t\t\t\tisComplete: v1Shape.isComplete,\n\t\t\t\t\t\t\t\t\t\tsegments: [{ type: 'free', points: v1Shape.points.map(getV2Point) }],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Arrow: {\n\t\t\t\t\t\t\tconst v1Bend = coerceNumber(v1Shape.bend)\n\t\t\t\t\t\t\tconst v1Start = getV2Point(v1Shape.handles.start.point)\n\t\t\t\t\t\t\tconst v1End = getV2Point(v1Shape.handles.end.point)\n\t\t\t\t\t\t\tconst dist = Vec.Dist(v1Start, v1End)\n\t\t\t\t\t\t\tconst v2Bend = (dist * -v1Bend) / 2\n\n\t\t\t\t\t\t\t// Could also be a line... but we'll use it as an arrow anyway\n\t\t\t\t\t\t\teditor.createShapes<TLArrowShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tarrowheadStart: getV2Arrowhead(v1Shape.decorations?.start),\n\t\t\t\t\t\t\t\t\t\tarrowheadEnd: getV2Arrowhead(v1Shape.decorations?.end),\n\t\t\t\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.start.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.start.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.end.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.end.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tbend: v2Bend,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Text: {\n\t\t\t\t\t\t\teditor.createShapes<TLTextShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ' '),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2TextSize(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\ttextAlign: getV2TextAlign(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t\tscale: v1Shape.style.scale ?? 1,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Image: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes<TLImageShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Video: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes<TLVideoShape>([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rotation = coerceNumber(v1Shape.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(shapeId)\n\t\t\t\t\t\teditor.rotateShapesBy([shapeId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Create groups\n\t\t\t\tv1GroupShapeIdsToV1ChildIds.forEach((v1ChildIds, v1GroupId) => {\n\t\t\t\t\tconst v2ChildShapeIds = v1ChildIds.map((id) => v1ShapeIdsToV2ShapeIds.get(id)!)\n\t\t\t\t\tconst v2GroupId = v1ShapeIdsToV2ShapeIds.get(v1GroupId)!\n\t\t\t\t\teditor.groupShapes(v2ChildShapeIds, { groupId: v2GroupId })\n\n\t\t\t\t\tconst v1Group = v1Page.shapes[v1GroupId]\n\t\t\t\t\tconst rotation = coerceNumber(v1Group.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(v2GroupId)\n\t\t\t\t\t\teditor.rotateShapesBy([v2GroupId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Bind arrows to shapes\n\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Arrow) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst v2ShapeId = v1ShapeIdsToV2ShapeIds.get(v1Shape.id)!\n\t\t\t\t\tconst util = editor.getShapeUtil<TLArrowShape>('arrow')\n\n\t\t\t\t\t// dumb but necessary\n\t\t\t\t\teditor.inputs.ctrlKey = false\n\n\t\t\t\t\tfor (const handleId of ['start', 'end'] as const) {\n\t\t\t\t\t\tconst bindingId = v1Shape.handles[handleId].bindingId\n\t\t\t\t\t\tif (bindingId) {\n\t\t\t\t\t\t\tconst binding = v1Page.bindings[bindingId]\n\t\t\t\t\t\t\tif (!binding) {\n\t\t\t\t\t\t\t\t// arrow has a reference to a binding that no longer exists\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst targetId = v1ShapeIdsToV2ShapeIds.get(binding.toId)!\n\n\t\t\t\t\t\t\tconst targetShape = editor.getShape(targetId)!\n\n\t\t\t\t\t\t\t// (unexpected) We didn't create the target shape\n\t\t\t\t\t\t\tif (!targetShape) continue\n\n\t\t\t\t\t\t\tif (targetId) {\n\t\t\t\t\t\t\t\tconst bounds = editor.getShapePageBounds(targetId)!\n\n\t\t\t\t\t\t\t\tconst v2ShapeFresh = editor.getShape<TLArrowShape>(v2ShapeId)!\n\n\t\t\t\t\t\t\t\tconst nx = clamp((coerceNumber(binding.point[0]) + 0.5) / 2, 0.2, 0.8)\n\t\t\t\t\t\t\t\tconst ny = clamp((coerceNumber(binding.point[1]) + 0.5) / 2, 0.2, 0.8)\n\n\t\t\t\t\t\t\t\tconst point = editor.getPointInShapeSpace(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\tx: bounds.minX + bounds.width * nx,\n\t\t\t\t\t\t\t\t\ty: bounds.minY + bounds.height * ny,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tconst handles = editor.getShapeHandles(v2ShapeFresh)!\n\t\t\t\t\t\t\t\tconst change = util.onHandleDrag!(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\thandle: {\n\t\t\t\t\t\t\t\t\t\t...handles.find((h) => h.id === handleId)!,\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tisPrecise: point.x !== 0.5 || point.y !== 0.5,\n\t\t\t\t\t\t\t\t\tisCreatingShape: true,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\t\t\teditor.updateShape(change)\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst freshBinding = getArrowBindings(\n\t\t\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\t\t\teditor.getShape<TLArrowShape>(v2ShapeId)!\n\t\t\t\t\t\t\t\t)[handleId]\n\t\t\t\t\t\t\t\tif (freshBinding) {\n\t\t\t\t\t\t\t\t\tconst updatedFreshBinding = structuredClone(freshBinding)\n\t\t\t\t\t\t\t\t\tif (binding.distance === 0) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.isExact = true\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (updatedFreshBinding.toId !== targetId) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.toId = targetId\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.normalizedAnchor = { x: nx, y: ny }\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\teditor.updateBinding(updatedFreshBinding)\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}\n\t\t\t\t})\n\t\t\t})\n\n\t\t// Set the current page to the first page again\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\teditor.clearHistory()\n\t\teditor.selectNone()\n\n\t\tconst bounds = editor.getCurrentPageBounds()\n\t\tif (bounds) {\n\t\t\teditor.zoomToBounds(bounds, { targetZoom: 1 })\n\t\t}\n\t})\n}\n\nfunction coerceNumber(n: unknown): number {\n\tif (typeof n !== 'number') return 0\n\tif (Number.isNaN(n)) return 0\n\tif (!Number.isFinite(n)) return 0\n\treturn n\n}\n\nfunction coerceDimension(d: unknown): number {\n\tconst n = coerceNumber(d)\n\tif (n <= 0) return 1\n\treturn n\n}\n\n/**\n * We want to move assets over to our new S3 bucket & extract any relevant metadata. That process is\n * async though, where the rest of our migration is synchronous.\n *\n * We'll write placeholder assets to the app using the old asset URLs, then kick off a process async\n * to try and download the real assets, extract the metadata, and upload them to our new bucket.\n * It's not a big deal if this fails though.\n */\nasync function tryMigrateAsset(editor: Editor, placeholderAsset: TLAsset) {\n\ttry {\n\t\tif (placeholderAsset.type === 'bookmark' || !placeholderAsset.props.src) return\n\n\t\tconst response = await fetch(placeholderAsset.props.src)\n\t\tif (!response.ok) return\n\n\t\tconst file = new File([await response.blob()], placeholderAsset.props.name, {\n\t\t\ttype: response.headers.get('content-type') ?? placeholderAsset.props.mimeType ?? undefined,\n\t\t})\n\n\t\tconst newAsset = await editor.getAssetForExternalContent({ type: 'file', file })\n\t\tif (!newAsset) throw new Error('Could not get asset for external content')\n\t\tif (newAsset.type === 'bookmark') return\n\n\t\teditor.updateAssets([\n\t\t\t{\n\t\t\t\tid: placeholderAsset.id,\n\t\t\t\ttype: placeholderAsset.type,\n\t\t\t\tprops: {\n\t\t\t\t\t...newAsset.props,\n\t\t\t\t\tname: placeholderAsset.props.name,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t} catch {\n\t\t// not a big deal, we'll just keep the placeholder asset\n\t}\n}\n\nfunction migrate(document: TLV1Document, newVersion: number): TLV1Document {\n\tconst { version = 0 } = document\n\n\tif (!document.assets) {\n\t\tdocument.assets = {}\n\t}\n\n\t// Remove unused assets when loading a document\n\tconst assetIdsInUse = new Set<string>()\n\n\tObject.values(document.pages).forEach((page) =>\n\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\tconst { parentId, children, assetId } = shape\n\n\t\t\tif (assetId) {\n\t\t\t\tassetIdsInUse.add(assetId)\n\t\t\t}\n\n\t\t\t// Fix missing parent bug\n\t\t\tif (parentId !== page.id && !page.shapes[parentId]) {\n\t\t\t\tconsole.warn('Encountered a shape with a missing parent!')\n\t\t\t\tshape.parentId = page.id\n\t\t\t}\n\n\t\t\tif (shape.type === TLV1ShapeType.Group && children) {\n\t\t\t\tchildren.forEach((childId) => {\n\t\t\t\t\tif (!page.shapes[childId]) {\n\t\t\t\t\t\tconsole.warn('Encountered a parent with a missing child!', shape.id, childId)\n\t\t\t\t\t\tchildren?.splice(children.indexOf(childId), 1)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// TODO: Remove the shape if it has no children\n\t\t\t}\n\t\t})\n\t)\n\n\tObject.keys(document.assets).forEach((assetId) => {\n\t\tif (!assetIdsInUse.has(assetId)) {\n\t\t\tdelete document.assets[assetId]\n\t\t}\n\t})\n\n\tif (version !== newVersion) {\n\t\tif (version < 14) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.shapes)\n\t\t\t\t\t.filter((shape) => shape.type === TLV1ShapeType.Text)\n\t\t\t\t\t.forEach((shape) => {\n\t\t\t\t\t\tif ((shape as TLV1TextShape).style.font === undefined) {\n\t\t\t\t\t\t\t;(shape as TLV1TextShape).style.font = TLV1FontStyle.Script\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Lowercase styles, move binding meta to binding\n\t\tif (version <= 13) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.bindings).forEach((binding) => {\n\t\t\t\t\tObject.assign(binding, (binding as any).meta)\n\t\t\t\t})\n\n\t\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\t\tObject.entries(shape.style).forEach(([id, style]) => {\n\t\t\t\t\t\tif (typeof style === 'string') {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tshape.style[id] = style.toLowerCase()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\n\t\t\t\t\tif (shape.type === TLV1ShapeType.Arrow) {\n\t\t\t\t\t\tif (shape.decorations) {\n\t\t\t\t\t\t\tObject.entries(shape.decorations).forEach(([id, decoration]) => {\n\t\t\t\t\t\t\t\tif ((decoration as unknown) === 'Arrow') {\n\t\t\t\t\t\t\t\t\tshape.decorations = {\n\t\t\t\t\t\t\t\t\t\t...shape.decorations,\n\t\t\t\t\t\t\t\t\t\t[id]: TLV1Decoration.Arrow,\n\t\t\t\t\t\t\t\t\t}\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}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Add document name and file system handle\n\t\tif (version <= 13.1 && document.name == null) {\n\t\t\tdocument.name = 'New Document'\n\t\t}\n\n\t\tif (version < 15 && document.assets == null) {\n\t\t\tdocument.assets = {}\n\t\t}\n\n\t\tObject.values(document.pages).forEach((page) => {\n\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\tif (version < 15.2) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t(shape.type === TLV1ShapeType.Image || shape.type === TLV1ShapeType.Video) &&\n\t\t\t\t\t\tshape.style.isFilled == null\n\t\t\t\t\t) {\n\t\t\t\t\t\tshape.style.isFilled = true\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (version < 15.3) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Rectangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Triangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Ellipse ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Arrow\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ('text' in shape && typeof shape.text === 'string') {\n\t\t\t\t\t\t\tshape.label = shape.text\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.label) {\n\t\t\t\t\t\t\tshape.label = ''\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.labelPoint) {\n\t\t\t\t\t\t\tshape.labelPoint = [0.5, 0.5]\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\t// Cleanup\n\tObject.values(document.pageStates).forEach((pageState) => {\n\t\tpageState.selectedIds = pageState.selectedIds.filter((id) => {\n\t\t\treturn document.pages[pageState.id].shapes[id] !== undefined\n\t\t})\n\t\tpageState.bindingId = undefined\n\t\tpageState.editingId = undefined\n\t\tpageState.hoveredId = undefined\n\t\tpageState.pointedId = undefined\n\t})\n\n\tdocument.version = newVersion\n\n\treturn document\n}\n\n/* -------------------- TLV1 Types -------------------- */\n\n/** @internal */\nexport interface TLV1Handle {\n\tid: string\n\tindex: number\n\tpoint: number[]\n\tcanBind?: boolean\n\tbindingId?: string\n}\n\n/** @internal */\nexport interface TLV1BaseBinding {\n\tid: string\n\ttoId: string\n\tfromId: string\n}\n\n/** @internal */\nexport enum TLV1ShapeType {\n\tSticky = 'sticky',\n\tEllipse = 'ellipse',\n\tRectangle = 'rectangle',\n\tTriangle = 'triangle',\n\tDraw = 'draw',\n\tArrow = 'arrow',\n\tText = 'text',\n\tGroup = 'group',\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport enum TLV1ColorStyle {\n\tWhite = 'white',\n\tLightGray = 'lightGray',\n\tGray = 'gray',\n\tBlack = 'black',\n\tGreen = 'green',\n\tCyan = 'cyan',\n\tBlue = 'blue',\n\tIndigo = 'indigo',\n\tViolet = 'violet',\n\tRed = 'red',\n\tOrange = 'orange',\n\tYellow = 'yellow',\n}\n\n/** @internal */\nexport enum TLV1SizeStyle {\n\tSmall = 'small',\n\tMedium = 'medium',\n\tLarge = 'large',\n}\n\n/** @internal */\nexport enum TLV1DashStyle {\n\tDraw = 'draw',\n\tSolid = 'solid',\n\tDashed = 'dashed',\n\tDotted = 'dotted',\n}\n\n/** @internal */\nexport enum TLV1AlignStyle {\n\tStart = 'start',\n\tMiddle = 'middle',\n\tEnd = 'end',\n\tJustify = 'justify',\n}\n\n/** @internal */\nexport enum TLV1FontStyle {\n\tScript = 'script',\n\tSans = 'sans',\n\tSerif = 'serif',\n\tMono = 'mono',\n}\n\n/** @internal */\nexport interface TLV1ShapeStyles {\n\tcolor: TLV1ColorStyle\n\tsize: TLV1SizeStyle\n\tdash: TLV1DashStyle\n\tfont?: TLV1FontStyle\n\ttextAlign?: TLV1AlignStyle\n\tisFilled?: boolean\n\tscale?: number\n}\n\n/** @internal */\nexport interface TLV1BaseShape {\n\tid: string\n\tparentId: string\n\tchildIndex: number\n\tname: string\n\tpoint: number[]\n\tassetId?: string\n\trotation?: number\n\tchildren?: string[]\n\tisGhost?: boolean\n\tisHidden?: boolean\n\tisLocked?: boolean\n\tisGenerated?: boolean\n\tisAspectRatioLocked?: boolean\n\tstyle: TLV1ShapeStyles\n\ttype: TLV1ShapeType\n\tlabel?: string\n\thandles?: Record<string, TLV1Handle>\n}\n\n/** @internal */\nexport interface TLV1DrawShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Draw\n\tpoints: number[][]\n\tisComplete: boolean\n}\n\n/** @internal */\nexport interface TLV1RectangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Rectangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1EllipseShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Ellipse\n\tradius: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1TriangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Triangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport enum TLV1Decoration {\n\tArrow = 'arrow',\n}\n\n// The shape created with the arrow tool\n/** @internal */\nexport interface TLV1ArrowShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Arrow\n\tbend: number\n\thandles: {\n\t\tstart: TLV1Handle\n\t\tbend: TLV1Handle\n\t\tend: TLV1Handle\n\t}\n\tdecorations?: {\n\t\tstart?: TLV1Decoration\n\t\tend?: TLV1Decoration\n\t\tmiddle?: TLV1Decoration\n\t}\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1ArrowBinding extends TLV1BaseBinding {\n\thandleId: keyof TLV1ArrowShape['handles']\n\tdistance: number\n\tpoint: number[]\n}\n\n/** @internal */\nexport type TLV1Binding = TLV1ArrowBinding\n\n/** @internal */\nexport interface TLV1ImageShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Image\n\tsize: number[]\n\tassetId: string\n}\n\n/** @internal */\nexport interface TLV1VideoShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Video\n\tsize: number[]\n\tassetId: string\n\tisPlaying: boolean\n\tcurrentTime: number\n}\n\n// The shape created by the text tool\n/** @internal */\nexport interface TLV1TextShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Text\n\ttext: string\n}\n\n// The shape created by the sticky tool\n/** @internal */\nexport interface TLV1StickyShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Sticky\n\tsize: number[]\n\ttext: string\n}\n\n// The shape created when multiple shapes are grouped\n/** @internal */\nexport interface TLV1GroupShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Group\n\tsize: number[]\n\tchildren: string[]\n}\n\n/** @internal */\nexport type TLV1Shape =\n\t| TLV1RectangleShape\n\t| TLV1EllipseShape\n\t| TLV1TriangleShape\n\t| TLV1DrawShape\n\t| TLV1ArrowShape\n\t| TLV1TextShape\n\t| TLV1GroupShape\n\t| TLV1StickyShape\n\t| TLV1ImageShape\n\t| TLV1VideoShape\n\n/** @internal */\nexport interface TLV1Page {\n\tid: string\n\tname?: string\n\tchildIndex?: number\n\tshapes: Record<string, TLV1Shape>\n\tbindings: Record<string, TLV1Binding>\n}\n\n/** @internal */\nexport interface TLV1Bounds {\n\tminX: number\n\tminY: number\n\tmaxX: number\n\tmaxY: number\n\twidth: number\n\theight: number\n\trotation?: number\n}\n\n/** @internal */\nexport interface TLV1PageState {\n\tid: string\n\tselectedIds: string[]\n\tcamera: {\n\t\tpoint: number[]\n\t\tzoom: number\n\t}\n\tbrush?: TLV1Bounds | null\n\tpointedId?: string | null\n\thoveredId?: string | null\n\teditingId?: string | null\n\tbindingId?: string | null\n}\n\n/** @internal */\nexport enum TLV1AssetType {\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport interface TLV1ImageAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Image\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1VideoAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Video\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1BaseAsset {\n\tid: string\n\ttype: string\n}\n\n/** @internal */\nexport type TLV1Asset = TLV1ImageAsset | TLV1VideoAsset\n\n/** @internal */\nexport interface TLV1Document {\n\tid: string\n\tname: string\n\tversion: number\n\tpages: Record<string, TLV1Page>\n\tpageStates: Record<string, TLV1PageState>\n\tassets: Record<string, TLV1Asset>\n}\n\n/* ------------------ Translations ------------------ */\n\nconst v1ColorsToV2Colors: Record<TLV1ColorStyle, TLDefaultColorStyle> = {\n\t[TLV1ColorStyle.White]: 'black',\n\t[TLV1ColorStyle.Black]: 'black',\n\t[TLV1ColorStyle.LightGray]: 'grey',\n\t[TLV1ColorStyle.Gray]: 'grey',\n\t[TLV1ColorStyle.Green]: 'light-green',\n\t[TLV1ColorStyle.Cyan]: 'green',\n\t[TLV1ColorStyle.Blue]: 'light-blue',\n\t[TLV1ColorStyle.Indigo]: 'blue',\n\t[TLV1ColorStyle.Orange]: 'orange',\n\t[TLV1ColorStyle.Yellow]: 'yellow',\n\t[TLV1ColorStyle.Red]: 'red',\n\t[TLV1ColorStyle.Violet]: 'light-violet',\n}\n\nconst v1FontsToV2Fonts: Record<TLV1FontStyle, TLDefaultFontStyle> = {\n\t[TLV1FontStyle.Mono]: 'mono',\n\t[TLV1FontStyle.Sans]: 'sans',\n\t[TLV1FontStyle.Script]: 'draw',\n\t[TLV1FontStyle.Serif]: 'serif',\n}\n\nconst v1AlignsToV2Aligns: Record<TLV1AlignStyle, TLDefaultHorizontalAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextAlignsToV2TextAligns: Record<TLV1AlignStyle, TLDefaultTextAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextSizesToV2TextSizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 's',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1SizesToV2Sizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 'm',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1DashesToV2Dashes: Record<TLV1DashStyle, TLDefaultDashStyle> = {\n\t[TLV1DashStyle.Solid]: 'solid',\n\t[TLV1DashStyle.Dashed]: 'dashed',\n\t[TLV1DashStyle.Dotted]: 'dotted',\n\t[TLV1DashStyle.Draw]: 'draw',\n}\n\nfunction getV2Color(color: TLV1ColorStyle | undefined): TLDefaultColorStyle {\n\treturn color ? (v1ColorsToV2Colors[color] ?? 'black') : 'black'\n}\n\nfunction getV2Font(font: TLV1FontStyle | undefined): TLDefaultFontStyle {\n\treturn font ? (v1FontsToV2Fonts[font] ?? 'draw') : 'draw'\n}\n\nfunction getV2Align(align: TLV1AlignStyle | undefined): TLDefaultHorizontalAlignStyle {\n\treturn align ? (v1AlignsToV2Aligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextAlign(align: TLV1AlignStyle | undefined): TLDefaultTextAlignStyle {\n\treturn align ? (v1TextAlignsToV2TextAligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextSize(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1TextSizesToV2TextSizes[size] ?? 'm') : 'm'\n}\n\nfunction getV2Size(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1SizesToV2Sizes[size] ?? 'l') : 'l'\n}\n\nfunction getV2Dash(dash: TLV1DashStyle | undefined): TLDefaultDashStyle {\n\treturn dash ? (v1DashesToV2Dashes[dash] ?? 'draw') : 'draw'\n}\n\nfunction getV2Point(point: number[]): VecModel {\n\treturn {\n\t\tx: coerceNumber(point[0]),\n\t\ty: coerceNumber(point[1]),\n\t\tz: point[2] == null ? 0.5 : coerceNumber(point[2]),\n\t}\n}\n\nfunction getV2Arrowhead(decoration: TLV1Decoration | undefined): TLArrowShapeArrowheadStyle {\n\treturn decoration === TLV1Decoration.Arrow ? 'arrow' : 'none'\n}\n\nfunction getV2Fill(isFilled: boolean | undefined, color: TLV1ColorStyle) {\n\treturn isFilled\n\t\t? color === TLV1ColorStyle.Black || color === TLV1ColorStyle.White\n\t\t\t? 'semi'\n\t\t\t: 'solid'\n\t\t: 'none'\n}\n"],
5
- "mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EAmBA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AAEjC,MAAM,oBAAoB;AAGnB,SAAS,oBAAoB,QAAgB,WAAoB;AACvE,MAAI,WAAW;AACf,SAAO,IAAI,MAAM;AAChB,eAAW,QAAQ,UAAU,iBAAiB;AAE9C,WAAO,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;AAEzC,UAAM,cAAc,OAAO,SAAS,EAAE,CAAC,EAAE;AAGzC,WAAO,eAAe,WAAW;AAGjC,eAAW,QAAQ,OAAO,SAAS,EAAE,MAAM,CAAC,GAAG;AAC9C,aAAO,WAAW,KAAK,EAAE;AAAA,IAC1B;AAGA,WAAO,UAAU;AACjB,WAAO,aAAa,OAAO,oBAAoB,CAAC;AAGhD,UAAM,yBAAyB,oBAAI,IAAuB;AAE1D,WAAO,OAAO,SAAS,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,YAAY;AACzD,cAAQ,QAAQ,MAAM;AAAA,QACrB,KAAK,qBAAqB;AACzB,gBAAM,UAAqB,gBAAgB,SAAS;AACpD,iCAAuB,IAAI,QAAQ,IAAI,OAAO;AAC9C,gBAAM,mBAA4B;AAAA,YACjC,IAAI;AAAA,YACJ,UAAU;AAAA,YACV,MAAM;A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rowShapeArrowheadStyle,\n\tTLAsset,\n\tTLAssetId,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLGeoShape,\n\tTLPageId,\n\tTLShapeId,\n\tVec,\n\tVecModel,\n\tclamp,\n\tcreateShapeId,\n\tfetch,\n\tstructuredClone,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { getArrowBindings } from '../../shapes/arrow/shared'\n\nconst TLDRAW_V1_VERSION = 15.5\n\n/** @internal */\nexport function buildFromV1Document(editor: Editor, _document: unknown) {\n\tlet document = _document as TLV1Document\n\teditor.run(() => {\n\t\tdocument = migrate(document, TLDRAW_V1_VERSION)\n\t\t// Cancel any interactions / states\n\t\teditor.cancel().cancel().cancel().cancel()\n\n\t\tconst firstPageId = editor.getPages()[0].id\n\n\t\t// Set the current page to the first page\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\t// Delete all pages except first page\n\t\tfor (const page of editor.getPages().slice(1)) {\n\t\t\teditor.deletePage(page.id)\n\t\t}\n\n\t\t// Delete all of the shapes on the current page\n\t\teditor.selectAll()\n\t\teditor.deleteShapes(editor.getSelectedShapeIds())\n\n\t\t// Create assets\n\t\tconst v1AssetIdsToV2AssetIds = new Map<string, TLAssetId>()\n\n\t\tObject.values(document.assets ?? {}).forEach((v1Asset) => {\n\t\t\tswitch (v1Asset.type) {\n\t\t\t\tcase TLV1AssetType.Image: {\n\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\tconst placeholderAsset: TLAsset = {\n\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t}\n\t\t\t\t\teditor.createAssets([placeholderAsset])\n\t\t\t\t\ttryMigrateAsset(editor, placeholderAsset)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase TLV1AssetType.Video:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\t\teditor.createAssets([\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\t\t\tisAnimated: true,\n\t\t\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t})\n\n\t\t// Create pages\n\n\t\tconst v1PageIdsToV2PageIds = new Map<string, TLPageId>()\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page, i) => {\n\t\t\t\tif (i === 0) {\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, editor.getCurrentPageId())\n\t\t\t\t} else {\n\t\t\t\t\tconst pageId = PageRecordType.createId()\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, pageId)\n\t\t\t\t\teditor.createPage({ name: v1Page.name ?? 'Page', id: pageId })\n\t\t\t\t}\n\t\t\t})\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page) => {\n\t\t\t\t// Set the current page id to the current page\n\t\t\t\teditor.setCurrentPage(v1PageIdsToV2PageIds.get(v1Page.id)!)\n\n\t\t\t\tconst v1ShapeIdsToV2ShapeIds = new Map<string, TLShapeId>()\n\t\t\t\tconst v1GroupShapeIdsToV1ChildIds = new Map<string, string[]>()\n\n\t\t\t\tconst v1Shapes = Object.values(v1Page.shapes ?? {})\n\t\t\t\t\t.sort((a, b) => (a.childIndex < b.childIndex ? -1 : 1))\n\t\t\t\t\t.slice(0, editor.options.maxShapesPerPage)\n\n\t\t\t\t// Groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Group) return\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.id, [])\n\t\t\t\t})\n\n\t\t\t\tfunction decideNotToCreateShape(v1Shape: TLV1Shape) {\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.delete(v1Shape.id)\n\t\t\t\t\tconst v1GroupParent = v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)\n\t\t\t\t\tif (v1GroupParent) {\n\t\t\t\t\t\tconst ids = v1GroupShapeIdsToV1ChildIds\n\t\t\t\t\t\t\t.get(v1Shape.parentId)!\n\t\t\t\t\t\t\t.filter((id) => id !== v1Shape.id)\n\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.parentId, ids)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Non-groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\t// Skip groups for now, we'll create groups via the app's API\n\t\t\t\t\tif (v1Shape.type === TLV1ShapeType.Group) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\n\t\t\t\t\tif (v1Shape.parentId !== v1Page.id) {\n\t\t\t\t\t\t// If the parent is a group, then add the shape to the group's children\n\t\t\t\t\t\tif (v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)) {\n\t\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.get(v1Shape.parentId)!.push(v1Shape.id)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.warn('parent does not exist', v1Shape)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// First, try to find the shape's parent among the existing groups\n\t\t\t\t\tconst parentId = v1PageIdsToV2PageIds.get(v1Page.id)!\n\n\t\t\t\t\tconst inCommon = {\n\t\t\t\t\t\tid: shapeId,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\tx: coerceNumber(v1Shape.point[0]),\n\t\t\t\t\t\ty: coerceNumber(v1Shape.point[1]),\n\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\tisLocked: !!v1Shape.isLocked,\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch (v1Shape.type) {\n\t\t\t\t\t\tcase TLV1ShapeType.Sticky: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'note',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\talign: getV2Align(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Rectangle: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'rectangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Triangle: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'triangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Ellipse: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'ellipse',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.radius[0]) * 2,\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.radius[1]) * 2,\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Draw: {\n\t\t\t\t\t\t\tif (v1Shape.points.length === 0) {\n\t\t\t\t\t\t\t\tdecideNotToCreateShape(v1Shape)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'draw',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tisPen: false,\n\t\t\t\t\t\t\t\t\t\tisComplete: v1Shape.isComplete,\n\t\t\t\t\t\t\t\t\t\tsegments: [{ type: 'free', points: v1Shape.points.map(getV2Point) }],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Arrow: {\n\t\t\t\t\t\t\tconst v1Bend = coerceNumber(v1Shape.bend)\n\t\t\t\t\t\t\tconst v1Start = getV2Point(v1Shape.handles.start.point)\n\t\t\t\t\t\t\tconst v1End = getV2Point(v1Shape.handles.end.point)\n\t\t\t\t\t\t\tconst dist = Vec.Dist(v1Start, v1End)\n\t\t\t\t\t\t\tconst v2Bend = (dist * -v1Bend) / 2\n\n\t\t\t\t\t\t\t// Could also be a line... but we'll use it as an arrow anyway\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tarrowheadStart: getV2Arrowhead(v1Shape.decorations?.start),\n\t\t\t\t\t\t\t\t\t\tarrowheadEnd: getV2Arrowhead(v1Shape.decorations?.end),\n\t\t\t\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.start.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.start.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.end.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.end.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tbend: v2Bend,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Text: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ' '),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2TextSize(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\ttextAlign: getV2TextAlign(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t\tscale: v1Shape.style.scale ?? 1,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Image: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Video: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rotation = coerceNumber(v1Shape.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(shapeId)\n\t\t\t\t\t\teditor.rotateShapesBy([shapeId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Create groups\n\t\t\t\tv1GroupShapeIdsToV1ChildIds.forEach((v1ChildIds, v1GroupId) => {\n\t\t\t\t\tconst v2ChildShapeIds = v1ChildIds.map((id) => v1ShapeIdsToV2ShapeIds.get(id)!)\n\t\t\t\t\tconst v2GroupId = v1ShapeIdsToV2ShapeIds.get(v1GroupId)!\n\t\t\t\t\teditor.groupShapes(v2ChildShapeIds, { groupId: v2GroupId })\n\n\t\t\t\t\tconst v1Group = v1Page.shapes[v1GroupId]\n\t\t\t\t\tconst rotation = coerceNumber(v1Group.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(v2GroupId)\n\t\t\t\t\t\teditor.rotateShapesBy([v2GroupId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Bind arrows to shapes\n\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Arrow) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst v2ShapeId = v1ShapeIdsToV2ShapeIds.get(v1Shape.id)!\n\t\t\t\t\tconst util = editor.getShapeUtil<TLArrowShape>('arrow')\n\n\t\t\t\t\t// dumb but necessary\n\t\t\t\t\teditor.inputs.ctrlKey = false\n\n\t\t\t\t\tfor (const handleId of ['start', 'end'] as const) {\n\t\t\t\t\t\tconst bindingId = v1Shape.handles[handleId].bindingId\n\t\t\t\t\t\tif (bindingId) {\n\t\t\t\t\t\t\tconst binding = v1Page.bindings[bindingId]\n\t\t\t\t\t\t\tif (!binding) {\n\t\t\t\t\t\t\t\t// arrow has a reference to a binding that no longer exists\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst targetId = v1ShapeIdsToV2ShapeIds.get(binding.toId)!\n\n\t\t\t\t\t\t\tconst targetShape = editor.getShape(targetId)!\n\n\t\t\t\t\t\t\t// (unexpected) We didn't create the target shape\n\t\t\t\t\t\t\tif (!targetShape) continue\n\n\t\t\t\t\t\t\tif (targetId) {\n\t\t\t\t\t\t\t\tconst bounds = editor.getShapePageBounds(targetId)!\n\n\t\t\t\t\t\t\t\tconst v2ShapeFresh = editor.getShape<TLArrowShape>(v2ShapeId)!\n\n\t\t\t\t\t\t\t\tconst nx = clamp((coerceNumber(binding.point[0]) + 0.5) / 2, 0.2, 0.8)\n\t\t\t\t\t\t\t\tconst ny = clamp((coerceNumber(binding.point[1]) + 0.5) / 2, 0.2, 0.8)\n\n\t\t\t\t\t\t\t\tconst point = editor.getPointInShapeSpace(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\tx: bounds.minX + bounds.width * nx,\n\t\t\t\t\t\t\t\t\ty: bounds.minY + bounds.height * ny,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tconst handles = editor.getShapeHandles(v2ShapeFresh)!\n\t\t\t\t\t\t\t\tconst change = util.onHandleDrag!(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\thandle: {\n\t\t\t\t\t\t\t\t\t\t...handles.find((h) => h.id === handleId)!,\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tisPrecise: point.x !== 0.5 || point.y !== 0.5,\n\t\t\t\t\t\t\t\t\tisCreatingShape: true,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\t\t\teditor.updateShape(change)\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst freshBinding = getArrowBindings(\n\t\t\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\t\t\teditor.getShape<TLArrowShape>(v2ShapeId)!\n\t\t\t\t\t\t\t\t)[handleId]\n\t\t\t\t\t\t\t\tif (freshBinding) {\n\t\t\t\t\t\t\t\t\tconst updatedFreshBinding = structuredClone(freshBinding)\n\t\t\t\t\t\t\t\t\tif (binding.distance === 0) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.isExact = true\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (updatedFreshBinding.toId !== targetId) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.toId = targetId\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.normalizedAnchor = { x: nx, y: ny }\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\teditor.updateBinding(updatedFreshBinding)\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}\n\t\t\t\t})\n\t\t\t})\n\n\t\t// Set the current page to the first page again\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\teditor.clearHistory()\n\t\teditor.selectNone()\n\n\t\tconst bounds = editor.getCurrentPageBounds()\n\t\tif (bounds) {\n\t\t\teditor.zoomToBounds(bounds, { targetZoom: 1 })\n\t\t}\n\t})\n}\n\nfunction coerceNumber(n: unknown): number {\n\tif (typeof n !== 'number') return 0\n\tif (Number.isNaN(n)) return 0\n\tif (!Number.isFinite(n)) return 0\n\treturn n\n}\n\nfunction coerceDimension(d: unknown): number {\n\tconst n = coerceNumber(d)\n\tif (n <= 0) return 1\n\treturn n\n}\n\n/**\n * We want to move assets over to our new S3 bucket & extract any relevant metadata. That process is\n * async though, where the rest of our migration is synchronous.\n *\n * We'll write placeholder assets to the app using the old asset URLs, then kick off a process async\n * to try and download the real assets, extract the metadata, and upload them to our new bucket.\n * It's not a big deal if this fails though.\n */\nasync function tryMigrateAsset(editor: Editor, placeholderAsset: TLAsset) {\n\ttry {\n\t\tif (placeholderAsset.type === 'bookmark' || !placeholderAsset.props.src) return\n\n\t\tconst response = await fetch(placeholderAsset.props.src)\n\t\tif (!response.ok) return\n\n\t\tconst file = new File([await response.blob()], placeholderAsset.props.name, {\n\t\t\ttype: response.headers.get('content-type') ?? placeholderAsset.props.mimeType ?? undefined,\n\t\t})\n\n\t\tconst newAsset = await editor.getAssetForExternalContent({ type: 'file', file })\n\t\tif (!newAsset) throw new Error('Could not get asset for external content')\n\t\tif (newAsset.type === 'bookmark') return\n\n\t\teditor.updateAssets([\n\t\t\t{\n\t\t\t\tid: placeholderAsset.id,\n\t\t\t\ttype: placeholderAsset.type,\n\t\t\t\tprops: {\n\t\t\t\t\t...newAsset.props,\n\t\t\t\t\tname: placeholderAsset.props.name,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t} catch {\n\t\t// not a big deal, we'll just keep the placeholder asset\n\t}\n}\n\nfunction migrate(document: TLV1Document, newVersion: number): TLV1Document {\n\tconst { version = 0 } = document\n\n\tif (!document.assets) {\n\t\tdocument.assets = {}\n\t}\n\n\t// Remove unused assets when loading a document\n\tconst assetIdsInUse = new Set<string>()\n\n\tObject.values(document.pages).forEach((page) =>\n\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\tconst { parentId, children, assetId } = shape\n\n\t\t\tif (assetId) {\n\t\t\t\tassetIdsInUse.add(assetId)\n\t\t\t}\n\n\t\t\t// Fix missing parent bug\n\t\t\tif (parentId !== page.id && !page.shapes[parentId]) {\n\t\t\t\tconsole.warn('Encountered a shape with a missing parent!')\n\t\t\t\tshape.parentId = page.id\n\t\t\t}\n\n\t\t\tif (shape.type === TLV1ShapeType.Group && children) {\n\t\t\t\tchildren.forEach((childId) => {\n\t\t\t\t\tif (!page.shapes[childId]) {\n\t\t\t\t\t\tconsole.warn('Encountered a parent with a missing child!', shape.id, childId)\n\t\t\t\t\t\tchildren?.splice(children.indexOf(childId), 1)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// TODO: Remove the shape if it has no children\n\t\t\t}\n\t\t})\n\t)\n\n\tObject.keys(document.assets).forEach((assetId) => {\n\t\tif (!assetIdsInUse.has(assetId)) {\n\t\t\tdelete document.assets[assetId]\n\t\t}\n\t})\n\n\tif (version !== newVersion) {\n\t\tif (version < 14) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.shapes)\n\t\t\t\t\t.filter((shape) => shape.type === TLV1ShapeType.Text)\n\t\t\t\t\t.forEach((shape) => {\n\t\t\t\t\t\tif ((shape as TLV1TextShape).style.font === undefined) {\n\t\t\t\t\t\t\t;(shape as TLV1TextShape).style.font = TLV1FontStyle.Script\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Lowercase styles, move binding meta to binding\n\t\tif (version <= 13) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.bindings).forEach((binding) => {\n\t\t\t\t\tObject.assign(binding, (binding as any).meta)\n\t\t\t\t})\n\n\t\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\t\tObject.entries(shape.style).forEach(([id, style]) => {\n\t\t\t\t\t\tif (typeof style === 'string') {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tshape.style[id] = style.toLowerCase()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\n\t\t\t\t\tif (shape.type === TLV1ShapeType.Arrow) {\n\t\t\t\t\t\tif (shape.decorations) {\n\t\t\t\t\t\t\tObject.entries(shape.decorations).forEach(([id, decoration]) => {\n\t\t\t\t\t\t\t\tif ((decoration as unknown) === 'Arrow') {\n\t\t\t\t\t\t\t\t\tshape.decorations = {\n\t\t\t\t\t\t\t\t\t\t...shape.decorations,\n\t\t\t\t\t\t\t\t\t\t[id]: TLV1Decoration.Arrow,\n\t\t\t\t\t\t\t\t\t}\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}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Add document name and file system handle\n\t\tif (version <= 13.1 && document.name == null) {\n\t\t\tdocument.name = 'New Document'\n\t\t}\n\n\t\tif (version < 15 && document.assets == null) {\n\t\t\tdocument.assets = {}\n\t\t}\n\n\t\tObject.values(document.pages).forEach((page) => {\n\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\tif (version < 15.2) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t(shape.type === TLV1ShapeType.Image || shape.type === TLV1ShapeType.Video) &&\n\t\t\t\t\t\tshape.style.isFilled == null\n\t\t\t\t\t) {\n\t\t\t\t\t\tshape.style.isFilled = true\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (version < 15.3) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Rectangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Triangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Ellipse ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Arrow\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ('text' in shape && typeof shape.text === 'string') {\n\t\t\t\t\t\t\tshape.label = shape.text\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.label) {\n\t\t\t\t\t\t\tshape.label = ''\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.labelPoint) {\n\t\t\t\t\t\t\tshape.labelPoint = [0.5, 0.5]\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\t// Cleanup\n\tObject.values(document.pageStates).forEach((pageState) => {\n\t\tpageState.selectedIds = pageState.selectedIds.filter((id) => {\n\t\t\treturn document.pages[pageState.id].shapes[id] !== undefined\n\t\t})\n\t\tpageState.bindingId = undefined\n\t\tpageState.editingId = undefined\n\t\tpageState.hoveredId = undefined\n\t\tpageState.pointedId = undefined\n\t})\n\n\tdocument.version = newVersion\n\n\treturn document\n}\n\n/* -------------------- TLV1 Types -------------------- */\n\n/** @internal */\nexport interface TLV1Handle {\n\tid: string\n\tindex: number\n\tpoint: number[]\n\tcanBind?: boolean\n\tbindingId?: string\n}\n\n/** @internal */\nexport interface TLV1BaseBinding {\n\tid: string\n\ttoId: string\n\tfromId: string\n}\n\n/** @internal */\nexport enum TLV1ShapeType {\n\tSticky = 'sticky',\n\tEllipse = 'ellipse',\n\tRectangle = 'rectangle',\n\tTriangle = 'triangle',\n\tDraw = 'draw',\n\tArrow = 'arrow',\n\tText = 'text',\n\tGroup = 'group',\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport enum TLV1ColorStyle {\n\tWhite = 'white',\n\tLightGray = 'lightGray',\n\tGray = 'gray',\n\tBlack = 'black',\n\tGreen = 'green',\n\tCyan = 'cyan',\n\tBlue = 'blue',\n\tIndigo = 'indigo',\n\tViolet = 'violet',\n\tRed = 'red',\n\tOrange = 'orange',\n\tYellow = 'yellow',\n}\n\n/** @internal */\nexport enum TLV1SizeStyle {\n\tSmall = 'small',\n\tMedium = 'medium',\n\tLarge = 'large',\n}\n\n/** @internal */\nexport enum TLV1DashStyle {\n\tDraw = 'draw',\n\tSolid = 'solid',\n\tDashed = 'dashed',\n\tDotted = 'dotted',\n}\n\n/** @internal */\nexport enum TLV1AlignStyle {\n\tStart = 'start',\n\tMiddle = 'middle',\n\tEnd = 'end',\n\tJustify = 'justify',\n}\n\n/** @internal */\nexport enum TLV1FontStyle {\n\tScript = 'script',\n\tSans = 'sans',\n\tSerif = 'serif',\n\tMono = 'mono',\n}\n\n/** @internal */\nexport interface TLV1ShapeStyles {\n\tcolor: TLV1ColorStyle\n\tsize: TLV1SizeStyle\n\tdash: TLV1DashStyle\n\tfont?: TLV1FontStyle\n\ttextAlign?: TLV1AlignStyle\n\tisFilled?: boolean\n\tscale?: number\n}\n\n/** @internal */\nexport interface TLV1BaseShape {\n\tid: string\n\tparentId: string\n\tchildIndex: number\n\tname: string\n\tpoint: number[]\n\tassetId?: string\n\trotation?: number\n\tchildren?: string[]\n\tisGhost?: boolean\n\tisHidden?: boolean\n\tisLocked?: boolean\n\tisGenerated?: boolean\n\tisAspectRatioLocked?: boolean\n\tstyle: TLV1ShapeStyles\n\ttype: TLV1ShapeType\n\tlabel?: string\n\thandles?: Record<string, TLV1Handle>\n}\n\n/** @internal */\nexport interface TLV1DrawShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Draw\n\tpoints: number[][]\n\tisComplete: boolean\n}\n\n/** @internal */\nexport interface TLV1RectangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Rectangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1EllipseShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Ellipse\n\tradius: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1TriangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Triangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport enum TLV1Decoration {\n\tArrow = 'arrow',\n}\n\n// The shape created with the arrow tool\n/** @internal */\nexport interface TLV1ArrowShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Arrow\n\tbend: number\n\thandles: {\n\t\tstart: TLV1Handle\n\t\tbend: TLV1Handle\n\t\tend: TLV1Handle\n\t}\n\tdecorations?: {\n\t\tstart?: TLV1Decoration\n\t\tend?: TLV1Decoration\n\t\tmiddle?: TLV1Decoration\n\t}\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1ArrowBinding extends TLV1BaseBinding {\n\thandleId: keyof TLV1ArrowShape['handles']\n\tdistance: number\n\tpoint: number[]\n}\n\n/** @internal */\nexport type TLV1Binding = TLV1ArrowBinding\n\n/** @internal */\nexport interface TLV1ImageShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Image\n\tsize: number[]\n\tassetId: string\n}\n\n/** @internal */\nexport interface TLV1VideoShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Video\n\tsize: number[]\n\tassetId: string\n\tisPlaying: boolean\n\tcurrentTime: number\n}\n\n// The shape created by the text tool\n/** @internal */\nexport interface TLV1TextShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Text\n\ttext: string\n}\n\n// The shape created by the sticky tool\n/** @internal */\nexport interface TLV1StickyShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Sticky\n\tsize: number[]\n\ttext: string\n}\n\n// The shape created when multiple shapes are grouped\n/** @internal */\nexport interface TLV1GroupShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Group\n\tsize: number[]\n\tchildren: string[]\n}\n\n/** @internal */\nexport type TLV1Shape =\n\t| TLV1RectangleShape\n\t| TLV1EllipseShape\n\t| TLV1TriangleShape\n\t| TLV1DrawShape\n\t| TLV1ArrowShape\n\t| TLV1TextShape\n\t| TLV1GroupShape\n\t| TLV1StickyShape\n\t| TLV1ImageShape\n\t| TLV1VideoShape\n\n/** @internal */\nexport interface TLV1Page {\n\tid: string\n\tname?: string\n\tchildIndex?: number\n\tshapes: Record<string, TLV1Shape>\n\tbindings: Record<string, TLV1Binding>\n}\n\n/** @internal */\nexport interface TLV1Bounds {\n\tminX: number\n\tminY: number\n\tmaxX: number\n\tmaxY: number\n\twidth: number\n\theight: number\n\trotation?: number\n}\n\n/** @internal */\nexport interface TLV1PageState {\n\tid: string\n\tselectedIds: string[]\n\tcamera: {\n\t\tpoint: number[]\n\t\tzoom: number\n\t}\n\tbrush?: TLV1Bounds | null\n\tpointedId?: string | null\n\thoveredId?: string | null\n\teditingId?: string | null\n\tbindingId?: string | null\n}\n\n/** @internal */\nexport enum TLV1AssetType {\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport interface TLV1ImageAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Image\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1VideoAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Video\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1BaseAsset {\n\tid: string\n\ttype: string\n}\n\n/** @internal */\nexport type TLV1Asset = TLV1ImageAsset | TLV1VideoAsset\n\n/** @internal */\nexport interface TLV1Document {\n\tid: string\n\tname: string\n\tversion: number\n\tpages: Record<string, TLV1Page>\n\tpageStates: Record<string, TLV1PageState>\n\tassets: Record<string, TLV1Asset>\n}\n\n/* ------------------ Translations ------------------ */\n\nconst v1ColorsToV2Colors: Record<TLV1ColorStyle, TLDefaultColorStyle> = {\n\t[TLV1ColorStyle.White]: 'black',\n\t[TLV1ColorStyle.Black]: 'black',\n\t[TLV1ColorStyle.LightGray]: 'grey',\n\t[TLV1ColorStyle.Gray]: 'grey',\n\t[TLV1ColorStyle.Green]: 'light-green',\n\t[TLV1ColorStyle.Cyan]: 'green',\n\t[TLV1ColorStyle.Blue]: 'light-blue',\n\t[TLV1ColorStyle.Indigo]: 'blue',\n\t[TLV1ColorStyle.Orange]: 'orange',\n\t[TLV1ColorStyle.Yellow]: 'yellow',\n\t[TLV1ColorStyle.Red]: 'red',\n\t[TLV1ColorStyle.Violet]: 'light-violet',\n}\n\nconst v1FontsToV2Fonts: Record<TLV1FontStyle, TLDefaultFontStyle> = {\n\t[TLV1FontStyle.Mono]: 'mono',\n\t[TLV1FontStyle.Sans]: 'sans',\n\t[TLV1FontStyle.Script]: 'draw',\n\t[TLV1FontStyle.Serif]: 'serif',\n}\n\nconst v1AlignsToV2Aligns: Record<TLV1AlignStyle, TLDefaultHorizontalAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextAlignsToV2TextAligns: Record<TLV1AlignStyle, TLDefaultTextAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextSizesToV2TextSizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 's',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1SizesToV2Sizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 'm',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1DashesToV2Dashes: Record<TLV1DashStyle, TLDefaultDashStyle> = {\n\t[TLV1DashStyle.Solid]: 'solid',\n\t[TLV1DashStyle.Dashed]: 'dashed',\n\t[TLV1DashStyle.Dotted]: 'dotted',\n\t[TLV1DashStyle.Draw]: 'draw',\n}\n\nfunction getV2Color(color: TLV1ColorStyle | undefined): TLDefaultColorStyle {\n\treturn color ? (v1ColorsToV2Colors[color] ?? 'black') : 'black'\n}\n\nfunction getV2Font(font: TLV1FontStyle | undefined): TLDefaultFontStyle {\n\treturn font ? (v1FontsToV2Fonts[font] ?? 'draw') : 'draw'\n}\n\nfunction getV2Align(align: TLV1AlignStyle | undefined): TLDefaultHorizontalAlignStyle {\n\treturn align ? (v1AlignsToV2Aligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextAlign(align: TLV1AlignStyle | undefined): TLDefaultTextAlignStyle {\n\treturn align ? (v1TextAlignsToV2TextAligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextSize(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1TextSizesToV2TextSizes[size] ?? 'm') : 'm'\n}\n\nfunction getV2Size(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1SizesToV2Sizes[size] ?? 'l') : 'l'\n}\n\nfunction getV2Dash(dash: TLV1DashStyle | undefined): TLDefaultDashStyle {\n\treturn dash ? (v1DashesToV2Dashes[dash] ?? 'draw') : 'draw'\n}\n\nfunction getV2Point(point: number[]): VecModel {\n\treturn {\n\t\tx: coerceNumber(point[0]),\n\t\ty: coerceNumber(point[1]),\n\t\tz: point[2] == null ? 0.5 : coerceNumber(point[2]),\n\t}\n}\n\nfunction getV2Arrowhead(decoration: TLV1Decoration | undefined): TLArrowShapeArrowheadStyle {\n\treturn decoration === TLV1Decoration.Arrow ? 'arrow' : 'none'\n}\n\nfunction getV2Fill(isFilled: boolean | undefined, color: TLV1ColorStyle) {\n\treturn isFilled\n\t\t? color === TLV1ColorStyle.Black || color === TLV1ColorStyle.White\n\t\t\t? 'semi'\n\t\t\t: 'solid'\n\t\t: 'none'\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EAcA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AAEjC,MAAM,oBAAoB;AAGnB,SAAS,oBAAoB,QAAgB,WAAoB;AACvE,MAAI,WAAW;AACf,SAAO,IAAI,MAAM;AAChB,eAAW,QAAQ,UAAU,iBAAiB;AAE9C,WAAO,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;AAEzC,UAAM,cAAc,OAAO,SAAS,EAAE,CAAC,EAAE;AAGzC,WAAO,eAAe,WAAW;AAGjC,eAAW,QAAQ,OAAO,SAAS,EAAE,MAAM,CAAC,GAAG;AAC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CAAC,CAAC;AAAA,IACxB,GAAG,aAAa,MAAM,CAAC,CAAC;AAAA,IACxB,GAAG,MAAM,CAAC,KAAK,OAAO,MAAM,aAAa,MAAM,CAAC,CAAC;AAAA,EAClD;AACD;AAEA,SAAS,eAAe,YAAoE;AAC3F,SAAO,eAAe,sBAAuB,UAAU;AACxD;AAEA,SAAS,UAAU,UAA+B,OAAuB;AACxE,SAAO,WACJ,UAAU,uBAAwB,UAAU,sBAC3C,SACA,UACD;AACJ;",
6
6
  "names": ["bounds", "TLV1ShapeType", "TLV1ColorStyle", "TLV1SizeStyle", "TLV1DashStyle", "TLV1AlignStyle", "TLV1FontStyle", "TLV1Decoration", "TLV1AssetType"]
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tldraw",
3
3
  "description": "A tiny little drawing editor.",
4
- "version": "4.3.0-canary.da35795ba8e2",
4
+ "version": "4.3.0-canary.e1766dd4eab3",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -55,15 +55,15 @@
55
55
  "src"
56
56
  ],
57
57
  "dependencies": {
58
- "@tiptap/core": "3.6.2",
59
- "@tiptap/extension-code": "3.6.2",
60
- "@tiptap/extension-highlight": "3.6.2",
61
- "@tiptap/extension-list": "3.6.2",
62
- "@tiptap/pm": "3.6.2",
63
- "@tiptap/react": "3.6.2",
64
- "@tiptap/starter-kit": "3.6.2",
65
- "@tldraw/editor": "4.3.0-canary.da35795ba8e2",
66
- "@tldraw/store": "4.3.0-canary.da35795ba8e2",
58
+ "@tiptap/core": "^3.6.2",
59
+ "@tiptap/extension-code": "^3.6.2",
60
+ "@tiptap/extension-highlight": "^3.6.2",
61
+ "@tiptap/extension-list": "^3.6.2",
62
+ "@tiptap/pm": "^3.6.2",
63
+ "@tiptap/react": "^3.6.2",
64
+ "@tiptap/starter-kit": "^3.6.2",
65
+ "@tldraw/editor": "4.3.0-canary.e1766dd4eab3",
66
+ "@tldraw/store": "4.3.0-canary.e1766dd4eab3",
67
67
  "classnames": "^2.5.1",
68
68
  "hotkeys-js": "^3.13.9",
69
69
  "idb": "^7.1.1",
package/src/index.ts CHANGED
@@ -432,6 +432,7 @@ export {
432
432
  type TLUiToolbarToggleItemProps,
433
433
  } from './lib/ui/components/primitives/TldrawUiToolbar'
434
434
  export {
435
+ hideAllTooltips,
435
436
  TldrawUiTooltip,
436
437
  TldrawUiTooltipProvider,
437
438
  type TldrawUiTooltipProps,
@@ -180,7 +180,7 @@ function reparentArrow(editor: Editor, arrowId: TLShapeId) {
180
180
  }
181
181
 
182
182
  if (finalIndex !== reparentedArrow.index) {
183
- editor.updateShapes<TLArrowShape>([{ id: arrowId, type: 'arrow', index: finalIndex }])
183
+ editor.updateShapes([{ id: arrowId, type: 'arrow', index: finalIndex }])
184
184
  }
185
185
  }
186
186
 
@@ -2,11 +2,7 @@ import {
2
2
  Box,
3
3
  HALF_PI,
4
4
  RotateCorner,
5
- TLEmbedShape,
6
- TLImageShape,
7
5
  TLSelectionForegroundProps,
8
- TLTextShape,
9
- TLVideoShape,
10
6
  getCursor,
11
7
  tlenv,
12
8
  toDomPrecision,
@@ -67,7 +63,7 @@ export const TldrawSelectionForeground = track(function TldrawSelectionForegroun
67
63
 
68
64
  if (onlyShape && editor.isShapeHidden(onlyShape)) return null
69
65
 
70
- const zoom = editor.getZoomLevel()
66
+ const zoom = editor.getEfficientZoomLevel()
71
67
  const isChangingStyle = editor.getInstanceState().isChangingStyle
72
68
 
73
69
  const width = expandedBounds.width
@@ -109,10 +105,10 @@ export const TldrawSelectionForeground = track(function TldrawSelectionForegroun
109
105
  (showSelectionBounds &&
110
106
  editor.isIn('select.resizing') &&
111
107
  onlyShape &&
112
- editor.isShapeOfType<TLTextShape>(onlyShape, 'text'))
108
+ editor.isShapeOfType(onlyShape, 'text'))
113
109
 
114
110
  if (onlyShape && shouldDisplayBox) {
115
- if (tlenv.isFirefox && editor.isShapeOfType<TLEmbedShape>(onlyShape, 'embed')) {
111
+ if (tlenv.isFirefox && editor.isShapeOfType(onlyShape, 'embed')) {
116
112
  shouldDisplayBox = false
117
113
  }
118
114
  }
@@ -194,12 +190,11 @@ export const TldrawSelectionForeground = track(function TldrawSelectionForegroun
194
190
  shouldDisplayControls &&
195
191
  isCoarsePointer &&
196
192
  onlyShape &&
197
- editor.isShapeOfType<TLTextShape>(onlyShape, 'text') &&
193
+ editor.isShapeOfType(onlyShape, 'text') &&
198
194
  textHandleHeight * zoom >= 4
199
195
  const isMediaShape =
200
196
  onlyShape &&
201
- (editor.isShapeOfType<TLImageShape>(onlyShape, 'image') ||
202
- editor.isShapeOfType<TLVideoShape>(onlyShape, 'video'))
197
+ (editor.isShapeOfType(onlyShape, 'image') || editor.isShapeOfType(onlyShape, 'video'))
203
198
 
204
199
  return (
205
200
  <svg
@@ -537,7 +532,7 @@ export const MobileRotateHandle = function RotateHandle({
537
532
  const events = useSelectionEvents('mobile_rotate')
538
533
 
539
534
  const editor = useEditor()
540
- const zoom = useValue('zoom level', () => editor.getZoomLevel(), [editor])
535
+ const zoom = useValue('zoom level', () => editor.getEfficientZoomLevel(), [editor])
541
536
  const bgRadius = Math.max(14 * (1 / zoom), 20 / Math.max(1, zoom))
542
537
  const msg = useTranslation()
543
538
  return (
@@ -19,7 +19,6 @@ import {
19
19
  TLTextShapeProps,
20
20
  TLUrlExternalAsset,
21
21
  TLVideoAsset,
22
- TLVideoShape,
23
22
  Vec,
24
23
  VecLike,
25
24
  assert,
@@ -206,7 +205,7 @@ export async function defaultHandleExternalFileReplaceContent(
206
205
  newY = result.y
207
206
  }
208
207
 
209
- editor.updateShapes<TLImageShape>([
208
+ editor.updateShapes([
210
209
  {
211
210
  id: imageShape.id,
212
211
  type: imageShape.type,
@@ -221,7 +220,7 @@ export async function defaultHandleExternalFileReplaceContent(
221
220
  },
222
221
  ])
223
222
  } else if (shape.type === 'video') {
224
- editor.updateShapes<TLVideoShape>([
223
+ editor.updateShapes([
225
224
  {
226
225
  id: shape.id,
227
226
  type: shape.type,
@@ -531,7 +530,7 @@ export async function defaultHandleExternalTextContent(
531
530
  const shapeId = createShapeId()
532
531
 
533
532
  // Allow this to trigger the max shapes reached alert
534
- editor.createShapes<TLTextShape>([
533
+ editor.createShapes([
535
534
  {
536
535
  id: shapeId,
537
536
  type: 'text',
@@ -333,7 +333,7 @@ describe('Arrow labels', () => {
333
333
  // Create an arrow with a label
334
334
  editor.setCurrentTool('arrow').pointerDown(10, 10).pointerMove(100, 100).pointerUp()
335
335
  const arrowId = editor.getOnlySelectedShape()!.id
336
- editor.updateShapes<TLArrowShape>([
336
+ editor.updateShapes([
337
337
  { id: arrowId, type: 'arrow', props: { richText: toRichText('Test Label') } },
338
338
  ])
339
339
  })
@@ -349,7 +349,7 @@ describe('Arrow labels', () => {
349
349
 
350
350
  it('should update the label of an arrow', () => {
351
351
  const arrowId = editor.getOnlySelectedShape()!.id
352
- editor.updateShapes<TLArrowShape>([
352
+ editor.updateShapes([
353
353
  { id: arrowId, type: 'arrow', props: { richText: toRichText('New Label') } },
354
354
  ])
355
355
  expect(arrow(arrowId)).toMatchObject({
@@ -45,7 +45,6 @@ import {
45
45
  useEditor,
46
46
  useIsEditing,
47
47
  useSharedSafeId,
48
- useValue,
49
48
  } from '@tldraw/editor'
50
49
  import React, { useMemo } from 'react'
51
50
  import { updateArrowTerminal } from '../../bindings/arrow/ArrowBindingUtil'
@@ -56,6 +55,7 @@ import { ShapeFill } from '../shared/ShapeFill'
56
55
  import { ARROW_LABEL_PADDING, STROKE_SIZES, TEXT_PROPS } from '../shared/default-shape-constants'
57
56
  import { getFillDefForCanvas, getFillDefForExport } from '../shared/defaultStyleDefs'
58
57
  import { useDefaultColorTheme } from '../shared/useDefaultColorTheme'
58
+ import { useEfficientZoomThreshold } from '../shared/useEfficientZoomThreshold'
59
59
  import { getArrowBodyPath, getArrowHandlePath } from './ArrowPath'
60
60
  import { ArrowShapeOptions } from './arrow-types'
61
61
  import {
@@ -120,6 +120,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
120
120
 
121
121
  shouldBeExact: (editor: Editor) => editor.inputs.altKey,
122
122
  shouldIgnoreTargets: (editor: Editor) => editor.inputs.ctrlKey,
123
+
124
+ showTextOutline: true,
123
125
  }
124
126
 
125
127
  override canEdit() {
@@ -269,7 +271,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
269
271
 
270
272
  const segmentStart = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentStart)
271
273
  const segmentEnd = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentEnd)
272
- const segmentLength = Vec.Dist(segmentStart, segmentEnd) * this.editor.getZoomLevel()
274
+ const segmentLength = Vec.Dist(segmentStart, segmentEnd) * this.editor.getEfficientZoomLevel()
273
275
 
274
276
  if (segmentLength > this.options.elbowMinSegmentLengthToShowMidpointHandle) {
275
277
  handles.push({
@@ -369,7 +371,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
369
371
 
370
372
  // we want to snap to certain points. the maximum distance at which a snap will occur is
371
373
  // relative to the zoom level:
372
- const maxSnapDistance = this.options.elbowMidpointSnapDistance / this.editor.getZoomLevel()
374
+ const maxSnapDistance =
375
+ this.options.elbowMidpointSnapDistance / this.editor.getEfficientZoomLevel()
373
376
 
374
377
  // we snap to the midpoint of the range by default
375
378
  const midPoint = perpDistanceToLineAngle(
@@ -794,6 +797,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
794
797
  textWidth={labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale}
795
798
  isSelected={isSelected}
796
799
  padding={0}
800
+ showTextOutline={this.options.showTextOutline}
797
801
  style={{
798
802
  transform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)`,
799
803
  }}
@@ -917,7 +921,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
917
921
  if (isEmptyRichText(shape.props.richText)) {
918
922
  // editing text for the first time, so set the position to the default:
919
923
  const labelPosition = getArrowLabelDefaultPosition(this.editor, shape)
920
- this.editor.updateShape<TLArrowShape>({
924
+ this.editor.updateShape({
921
925
  id: shape.id,
922
926
  type: shape.type,
923
927
  props: { labelPosition },
@@ -944,7 +948,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
944
948
  .box.clone()
945
949
  .expandBy(-ARROW_LABEL_PADDING * shape.props.scale)}
946
950
  padding={0}
947
- showTextOutline={true}
951
+ showTextOutline={this.options.showTextOutline}
948
952
  />
949
953
  </g>
950
954
  )
@@ -1005,13 +1009,7 @@ const ArrowSvg = track(function ArrowSvg({
1005
1009
  const editor = useEditor()
1006
1010
  const theme = useDefaultColorTheme()
1007
1011
  const info = getArrowInfo(editor, shape)
1008
- const isForceSolid = useValue(
1009
- 'force solid',
1010
- () => {
1011
- return editor.getZoomLevel() < 0.2
1012
- },
1013
- [editor]
1014
- )
1012
+ const isForceSolid = useEfficientZoomThreshold(shape.props.scale * 0.25)
1015
1013
  const clipPathId = useSharedSafeId(shape.id + '_clip')
1016
1014
  const arrowheadDotId = useSharedSafeId('arrowhead-dot')
1017
1015
  const arrowheadCrossId = useSharedSafeId('arrowhead-cross')
@@ -1037,7 +1035,7 @@ const ArrowSvg = track(function ArrowSvg({
1037
1035
  start: 'skip',
1038
1036
  end: 'skip',
1039
1037
  lengthRatio: 2.5,
1040
- strokeWidth: 2 / editor.getZoomLevel(),
1038
+ strokeWidth: 2 / editor.getEfficientZoomLevel(),
1041
1039
  props: {
1042
1040
  className: 'tl-arrow-hint',
1043
1041
  markerStart: bindings.start
@@ -95,6 +95,8 @@ export interface ArrowShapeOptions {
95
95
  * When creating an arrow, should it bind to the target shape.
96
96
  */
97
97
  shouldIgnoreTargets(editor: Editor): boolean
98
+ /** Whether to show the outline of the arrow shape's label (using the same color as the canvas). This helps with overlapping shapes. It does not show up on Safari, where text outline is a performance issues. */
99
+ readonly showTextOutline: boolean
98
100
  }
99
101
 
100
102
  /** @public */
@@ -311,7 +311,7 @@ export function getArrowLabelDefaultPosition(editor: Editor, shape: TLArrowShape
311
311
 
312
312
  /** @internal */
313
313
  export function isOverArrowLabel(editor: Editor, shape: TLShape) {
314
- if (!editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) return false
314
+ if (!editor.isShapeOfType(shape, 'arrow')) return false
315
315
 
316
316
  const pointInShapeSpace = editor.getPointInShapeSpace(shape, editor.inputs.currentPagePoint)
317
317
  // How should we handle multiple labels? Do shapes ever have multiple labels?
@@ -377,7 +377,7 @@ export function updateArrowTargetState({
377
377
  return result
378
378
  }
379
379
 
380
- const targetFilterFallback = { type: 'arrow' }
380
+ const targetFilterFallback = { type: 'arrow' as const }
381
381
 
382
382
  /**
383
383
  * Funky math but we want the snap distance to be 4 at the minimum and either 16 or 15% of the
@@ -39,17 +39,17 @@ export function getElbowArrowSnapLines(editor: Editor) {
39
39
  .get(editor, (editor) => {
40
40
  const currentSelectedArrowShape = computed('current selected arrow shape', () => {
41
41
  const shape = editor.getOnlySelectedShape()
42
- if (!shape || !editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) return null
42
+ if (!shape || !editor.isShapeOfType(shape, 'arrow')) return null
43
43
  return shape.id
44
44
  })
45
45
 
46
46
  const unselectedArrowShapeIds = editor.store.query.ids('shape', () => {
47
47
  const activeArrowShapeId = currentSelectedArrowShape.get()
48
- if (!activeArrowShapeId) return { type: { eq: 'arrow' } }
48
+ if (!activeArrowShapeId) return { type: { eq: 'arrow' } } as const
49
49
  return {
50
50
  type: { eq: 'arrow' },
51
51
  id: { neq: activeArrowShapeId },
52
- }
52
+ } as const
53
53
  })
54
54
 
55
55
  return computed('elbow arrow snap lines', () => {
@@ -38,7 +38,7 @@ export function getBoundShapeInfoForTerminal(
38
38
  terminalName: 'start' | 'end'
39
39
  ): BoundShapeInfo | undefined {
40
40
  const binding = editor
41
- .getBindingsFromShape<TLArrowBinding>(arrow, 'arrow')
41
+ .getBindingsFromShape(arrow, 'arrow')
42
42
  .find((b) => b.props.terminal === terminalName)
43
43
  if (!binding) return
44
44
 
@@ -105,7 +105,7 @@ export interface TLArrowBindings {
105
105
  const arrowBindingsCache = createComputedCache(
106
106
  'arrow bindings',
107
107
  (editor: Editor, arrow: TLArrowShape) => {
108
- const bindings = editor.getBindingsFromShape<TLArrowBinding>(arrow.id, 'arrow')
108
+ const bindings = editor.getBindingsFromShape(arrow.id, 'arrow')
109
109
  return {
110
110
  start: bindings.find((b) => b.props.terminal === 'start'),
111
111
  end: bindings.find((b) => b.props.terminal === 'end'),
@@ -223,7 +223,7 @@ export function createOrUpdateArrowBinding(
223
223
  const targetId = typeof target === 'string' ? target : target.id
224
224
 
225
225
  const existingMany = editor
226
- .getBindingsFromShape<TLArrowBinding>(arrowId, 'arrow')
226
+ .getBindingsFromShape(arrowId, 'arrow')
227
227
  .filter((b) => b.props.terminal === props.terminal)
228
228
 
229
229
  // if we've somehow ended up with too many bindings, delete the extras
@@ -254,7 +254,7 @@ export function createOrUpdateArrowBinding(
254
254
  */
255
255
  export function removeArrowBinding(editor: Editor, arrow: TLArrowShape, terminal: 'start' | 'end') {
256
256
  const existing = editor
257
- .getBindingsFromShape<TLArrowBinding>(arrow, 'arrow')
257
+ .getBindingsFromShape(arrow, 'arrow')
258
258
  .filter((b) => b.props.terminal === terminal)
259
259
 
260
260
  editor.deleteBindings(existing)
@@ -96,7 +96,7 @@ export class Pointing extends StateNode {
96
96
 
97
97
  this.markId = this.editor.markHistoryStoppingPoint(`creating_arrow:${id}`)
98
98
  const newPoint = maybeSnapToGrid(originPagePoint, this.editor)
99
- this.editor.createShape<TLArrowShape>({
99
+ this.editor.createShape({
100
100
  id,
101
101
  type: 'arrow',
102
102
  x: newPoint.x,