tldraw 4.2.0 → 4.3.0-canary.3811ec6b3dcd

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 (211) hide show
  1. package/dist-cjs/index.d.ts +14 -5
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
  4. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +5 -2
  5. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  6. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  7. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  8. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  9. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  10. package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
  11. package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
  12. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  13. package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
  14. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
  15. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  16. package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
  17. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  18. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  19. package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
  20. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  21. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
  22. package/dist-cjs/lib/shapes/shared/crop.js +1 -0
  23. package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
  24. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  25. package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
  26. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  27. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  28. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  29. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +1 -4
  30. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  31. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  32. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  33. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -1
  34. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  35. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  36. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  37. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  38. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  39. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  40. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  41. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  42. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  43. package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
  44. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  45. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  46. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  47. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +2 -1
  48. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  49. package/dist-cjs/lib/ui/context/actions.js +1 -2
  50. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  51. package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
  52. package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
  53. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  54. package/dist-cjs/lib/ui/version.js +3 -3
  55. package/dist-cjs/lib/ui/version.js.map +1 -1
  56. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -0
  57. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  58. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  59. package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
  60. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  61. package/dist-esm/index.d.mts +14 -5
  62. package/dist-esm/index.mjs +1 -1
  63. package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
  64. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +6 -2
  65. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  66. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  67. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  68. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  69. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  70. package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
  71. package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
  72. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  73. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
  74. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
  75. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  76. package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
  77. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  78. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  79. package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
  80. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  81. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  82. package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
  83. package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
  84. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  85. package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
  86. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  87. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  88. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +1 -4
  89. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  90. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +1 -4
  91. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  92. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  93. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  94. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -1
  95. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  96. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  97. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  98. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  99. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +1 -4
  100. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  101. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  102. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  103. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  104. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  105. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
  106. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  107. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  108. package/dist-esm/lib/ui/components/menu-items.mjs +1 -4
  109. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  110. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -1
  111. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  112. package/dist-esm/lib/ui/context/actions.mjs +1 -2
  113. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  114. package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
  115. package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
  116. package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
  117. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  118. package/dist-esm/lib/ui/version.mjs +3 -3
  119. package/dist-esm/lib/ui/version.mjs.map +1 -1
  120. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +8 -0
  121. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  122. package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
  123. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  124. package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
  125. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  126. package/package.json +10 -10
  127. package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
  128. package/src/lib/canvas/TldrawSelectionForeground.tsx +18 -7
  129. package/src/lib/defaultExternalContentHandlers.ts +3 -4
  130. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
  131. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +1 -1
  132. package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
  133. package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
  134. package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
  135. package/src/lib/shapes/arrow/shared.ts +4 -4
  136. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
  137. package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
  138. package/src/lib/shapes/draw/toolStates/Drawing.ts +4 -4
  139. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  140. package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
  141. package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
  142. package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
  143. package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
  144. package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
  145. package/src/lib/shapes/line/toolStates/Pointing.ts +1 -1
  146. package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
  147. package/src/lib/shapes/note/noteHelpers.ts +2 -2
  148. package/src/lib/shapes/shared/PlainTextLabel.tsx +2 -1
  149. package/src/lib/shapes/shared/RichTextLabel.tsx +2 -1
  150. package/src/lib/shapes/shared/crop.ts +1 -0
  151. package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
  152. package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
  153. package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
  154. package/src/lib/shapes/text/toolStates/Pointing.ts +1 -1
  155. package/src/lib/tools/EraserTool/childStates/Erasing.ts +3 -5
  156. package/src/lib/tools/EraserTool/childStates/Pointing.ts +3 -16
  157. package/src/lib/tools/SelectTool/DragAndDropManager.ts +2 -4
  158. package/src/lib/tools/SelectTool/childStates/Brushing.ts +2 -6
  159. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +2 -3
  160. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +4 -7
  161. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +2 -4
  162. package/src/lib/tools/SelectTool/childStates/Idle.ts +6 -10
  163. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
  164. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +4 -12
  165. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
  166. package/src/lib/tools/SelectTool/childStates/Resizing.ts +2 -4
  167. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +2 -4
  168. package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -3
  169. package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
  170. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
  171. package/src/lib/ui/components/menu-items.tsx +6 -14
  172. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +1 -0
  173. package/src/lib/ui/context/actions.tsx +9 -13
  174. package/src/lib/ui/hooks/menu-hooks.ts +9 -19
  175. package/src/lib/ui/hooks/useFlatten.ts +1 -2
  176. package/src/lib/ui/hooks/useTools.tsx +1 -2
  177. package/src/lib/ui/version.ts +3 -3
  178. package/src/lib/ui.css +4 -6
  179. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +8 -0
  180. package/src/lib/utils/export/exportAs.ts +2 -9
  181. package/src/lib/utils/frames/frames.ts +1 -1
  182. package/src/lib/utils/tldr/buildFromV1Document.ts +12 -17
  183. package/src/test/Editor.test.tsx +38 -12
  184. package/src/test/SelectTool.test.ts +11 -19
  185. package/src/test/TestEditor.ts +1 -4
  186. package/src/test/TldrawEditor.test.tsx +18 -16
  187. package/src/test/bindings.test.tsx +29 -25
  188. package/src/test/bindingsIndex.test.tsx +4 -4
  189. package/src/test/commands/createShape.test.ts +64 -0
  190. package/src/test/commands/createShapes.test.ts +15 -1
  191. package/src/test/commands/getSvgString.test.ts +2 -2
  192. package/src/test/commands/isShapeOfType.test.ts +44 -0
  193. package/src/test/commands/putContent.test.ts +1 -0
  194. package/src/test/commands/updateShape.test.ts +67 -0
  195. package/src/test/commands/updateShapes.test.ts +21 -5
  196. package/src/test/custom-clipping.test.ts +36 -35
  197. package/src/test/customSnapping.test.tsx +77 -62
  198. package/src/test/duplicate.test.ts +1 -1
  199. package/src/test/frames.test.ts +2 -2
  200. package/src/test/getCulledShapes.test.tsx +11 -3
  201. package/src/test/getShapeAtPoint.test.ts +2 -2
  202. package/src/test/groups.test.tsx +6 -3
  203. package/src/test/resizing.test.ts +9 -13
  204. package/src/test/selection-omnibus.test.ts +11 -11
  205. package/src/test/shapeutils.test.ts +1 -1
  206. package/src/test/styles2.test.tsx +1 -1
  207. package/src/test/styles3.test.ts +5 -5
  208. package/src/test/test-jsx.tsx +69 -57
  209. package/src/test/text.test.ts +15 -17
  210. package/src/test/translating.test.ts +6 -8
  211. package/tldraw.css +4 -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBA6BO;AACP,oBAAiC;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,C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AS,eAAe,YAAoE;AAC3F,SAAO,eAAe,sBAAuB,UAAU;AACxD;AAEA,SAAS,UAAU,UAA+B,OAAuB;AACxE,SAAO,WACJ,UAAU,uBAAwB,UAAU,sBAC3C,SACA,UACD;AACJ;",
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\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAwBO;AACP,oBAAiC;AAEjC,MAAM,oBAAoB;AAGnB,SAAS,oBAAoB,QAAgB,WAAoB;AACvE,MAAI,WAAW;AACf,SAAO,I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BAAyB,IAAI,KAAK,MAAO;AACzD;AAEA,SAAS,UAAU,MAAqD;AACvE,SAAO,OAAQ,iBAAiB,IAAI,KAAK,MAAO;AACjD;AAEA,SAAS,UAAU,MAAqD;AACvE,SAAO,OAAQ,mBAAmB,IAAI,KAAK,SAAU;AACtD;AAEA,SAAS,WAAW,OAA2B;AAC9C,SAAO;AAAA,IACN,GAAG,aAAa,MAAM,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
  }
@@ -15,6 +15,7 @@ import { Editor } from '@tldraw/editor';
15
15
  import { ElbowArrowSnap } from '@tldraw/editor';
16
16
  import { Extension } from '@tiptap/core';
17
17
  import { Extensions } from '@tiptap/core';
18
+ import { ExtractShapeByProps } from '@tldraw/editor';
18
19
  import { ForwardRefExoticComponent } from 'react';
19
20
  import { Geometry2d } from '@tldraw/editor';
20
21
  import { Geometry2dFilters } from '@tldraw/editor';
@@ -1615,7 +1616,7 @@ export declare interface FrameShapeOptions {
1615
1616
  export declare class FrameShapeTool extends BaseBoxShapeTool {
1616
1617
  static id: string;
1617
1618
  static initial: string;
1618
- shapeType: string;
1619
+ shapeType: "frame";
1619
1620
  onCreate(shape: null | TLShape): void;
1620
1621
  }
1621
1622
 
@@ -2414,7 +2415,9 @@ export declare const PlainTextLabel: React_3.NamedExoticComponent<PlainTextLabel
2414
2415
  /** @public */
2415
2416
  export declare interface PlainTextLabelProps {
2416
2417
  shapeId: TLShapeId;
2417
- type: string;
2418
+ type: ExtractShapeByProps<{
2419
+ text: string;
2420
+ }>['type'];
2418
2421
  font: TLDefaultFontStyle;
2419
2422
  fontSize: number;
2420
2423
  lineHeight: number;
@@ -2556,7 +2559,9 @@ export declare const RichTextLabel: React_3.NamedExoticComponent<RichTextLabelPr
2556
2559
  /** @public */
2557
2560
  export declare interface RichTextLabelProps {
2558
2561
  shapeId: TLShapeId;
2559
- type: string;
2562
+ type: ExtractShapeByProps<{
2563
+ richText: TLRichText;
2564
+ }>['type'];
2560
2565
  font: TLDefaultFontStyle;
2561
2566
  fontSize: number;
2562
2567
  lineHeight: number;
@@ -4614,7 +4619,9 @@ export declare function useDefaultHelpers(): {
4614
4619
  export declare function useDialogs(): TLUiDialogsContextType;
4615
4620
 
4616
4621
  /** @public */
4617
- export declare function useEditablePlainText(shapeId: TLShapeId, type: string, text?: string): {
4622
+ export declare function useEditablePlainText(shapeId: TLShapeId, type: ExtractShapeByProps<{
4623
+ text: string;
4624
+ }>['type'], text?: string): {
4618
4625
  handleBlur: () => void;
4619
4626
  handleChange: ({ plaintext }: {
4620
4627
  plaintext: string;
@@ -4633,7 +4640,9 @@ export declare function useEditablePlainText(shapeId: TLShapeId, type: string, t
4633
4640
  };
4634
4641
 
4635
4642
  /** @public */
4636
- export declare function useEditableRichText(shapeId: TLShapeId, type: string, richText?: TLRichText): {
4643
+ export declare function useEditableRichText(shapeId: TLShapeId, type: ExtractShapeByProps<{
4644
+ richText: TLRichText;
4645
+ }>['type'], richText?: TLRichText): {
4637
4646
  handleBlur: () => void;
4638
4647
  handleChange: ({ richText }: {
4639
4648
  richText: TLRichText;
@@ -533,7 +533,7 @@ import {
533
533
  } from "./lib/utils/tldr/file.mjs";
534
534
  registerTldrawLibraryVersion(
535
535
  "tldraw",
536
- "4.2.0",
536
+ "4.3.0-canary.3811ec6b3dcd",
537
537
  "esm"
538
538
  );
539
539
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/bindings/arrow/ArrowBindingUtil.ts"],
4
- "sourcesContent": ["import {\n\tBindingOnChangeOptions,\n\tBindingOnCreateOptions,\n\tBindingOnShapeChangeOptions,\n\tBindingOnShapeIsolateOptions,\n\tBindingUtil,\n\tEditor,\n\tIndexKey,\n\tTLArrowBinding,\n\tTLArrowBindingProps,\n\tTLArrowShape,\n\tTLParentId,\n\tTLShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tapproximately,\n\tarrowBindingMigrations,\n\tarrowBindingProps,\n\tassert,\n\tgetIndexAbove,\n\tgetIndexBetween,\n\tintersectLineSegmentCircle,\n} from '@tldraw/editor'\nimport { getArrowBindings, getArrowInfo, removeArrowBinding } from '../../shapes/arrow/shared'\n\n/**\n * @public\n */\nexport class ArrowBindingUtil extends BindingUtil<TLArrowBinding> {\n\tstatic override type = 'arrow'\n\n\tstatic override props = arrowBindingProps\n\tstatic override migrations = arrowBindingMigrations\n\n\toverride getDefaultProps(): Partial<TLArrowBindingProps> {\n\t\treturn {\n\t\t\tisPrecise: false,\n\t\t\tisExact: false,\n\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\tsnap: 'none',\n\t\t}\n\t}\n\n\t// when the binding itself changes\n\toverride onAfterCreate({ binding }: BindingOnCreateOptions<TLArrowBinding>): void {\n\t\tconst arrow = this.editor.getShape(binding.fromId) as TLArrowShape | undefined\n\t\tif (!arrow) return\n\t\tarrowDidUpdate(this.editor, arrow)\n\t}\n\n\t// when the binding itself changes\n\toverride onAfterChange({ bindingAfter }: BindingOnChangeOptions<TLArrowBinding>): void {\n\t\tconst arrow = this.editor.getShape(bindingAfter.fromId) as TLArrowShape | undefined\n\t\tif (!arrow) return\n\t\tarrowDidUpdate(this.editor, arrow)\n\t}\n\n\t// when the arrow itself changes\n\toverride onAfterChangeFromShape({\n\t\tshapeAfter,\n\t}: BindingOnShapeChangeOptions<TLArrowBinding>): void {\n\t\tarrowDidUpdate(this.editor, shapeAfter as TLArrowShape)\n\t}\n\n\t// when the shape an arrow is bound to changes\n\toverride onAfterChangeToShape({\n\t\tbinding,\n\t\tshapeBefore,\n\t\tshapeAfter,\n\t\treason,\n\t}: BindingOnShapeChangeOptions<TLArrowBinding>): void {\n\t\tif (\n\t\t\treason !== 'ancestry' &&\n\t\t\tshapeBefore.parentId === shapeAfter.parentId &&\n\t\t\tshapeBefore.index === shapeAfter.index\n\t\t) {\n\t\t\treturn\n\t\t}\n\t\treparentArrow(this.editor, binding.fromId)\n\t}\n\n\t// when the arrow is isolated we need to update it's x,y positions\n\toverride onBeforeIsolateFromShape({\n\t\tbinding,\n\t}: BindingOnShapeIsolateOptions<TLArrowBinding>): void {\n\t\tconst arrow = this.editor.getShape<TLArrowShape>(binding.fromId)\n\t\tif (!arrow) return\n\t\tupdateArrowTerminal({\n\t\t\teditor: this.editor,\n\t\t\tarrow,\n\t\t\tterminal: binding.props.terminal,\n\t\t})\n\t}\n}\n\nfunction reparentArrow(editor: Editor, arrowId: TLShapeId) {\n\tconst arrow = editor.getShape<TLArrowShape>(arrowId)\n\tif (!arrow) return\n\tconst bindings = getArrowBindings(editor, arrow)\n\tconst { start, end } = bindings\n\tconst startShape = start ? editor.getShape(start.toId) : undefined\n\tconst endShape = end ? editor.getShape(end.toId) : undefined\n\n\tconst parentPageId = editor.getAncestorPageId(arrow)\n\tif (!parentPageId) return\n\n\tlet nextParentId: TLParentId\n\tif (startShape && endShape) {\n\t\t// if arrow has two bindings, always parent arrow to closest common ancestor of the bindings\n\t\tnextParentId = editor.findCommonAncestor([startShape, endShape]) ?? parentPageId\n\t} else if (startShape || endShape) {\n\t\tconst bindingParentId = (startShape || endShape)?.parentId\n\t\t// If the arrow and the shape that it is bound to have the same parent, then keep that parent\n\t\tif (bindingParentId && bindingParentId === arrow.parentId) {\n\t\t\tnextParentId = arrow.parentId\n\t\t} else {\n\t\t\t// if arrow has one binding, keep arrow on its own page\n\t\t\tnextParentId = parentPageId\n\t\t}\n\t} else {\n\t\treturn\n\t}\n\n\tif (nextParentId && nextParentId !== arrow.parentId) {\n\t\teditor.reparentShapes([arrowId], nextParentId)\n\t}\n\n\tconst reparentedArrow = editor.getShape<TLArrowShape>(arrowId)\n\tif (!reparentedArrow) throw Error('no reparented arrow')\n\n\tconst startSibling = editor.getShapeNearestSibling(reparentedArrow, startShape)\n\tconst endSibling = editor.getShapeNearestSibling(reparentedArrow, endShape)\n\n\tlet highestSibling: TLShape | undefined\n\n\tif (startSibling && endSibling) {\n\t\thighestSibling = startSibling.index > endSibling.index ? startSibling : endSibling\n\t} else if (startSibling && !endSibling) {\n\t\thighestSibling = startSibling\n\t} else if (endSibling && !startSibling) {\n\t\thighestSibling = endSibling\n\t} else {\n\t\treturn\n\t}\n\n\tlet finalIndex: IndexKey\n\n\tconst higherSiblings = editor\n\t\t.getSortedChildIdsForParent(highestSibling.parentId)\n\t\t.map((id) => editor.getShape(id)!)\n\t\t.filter((sibling) => sibling.index > highestSibling!.index)\n\n\tif (higherSiblings.length) {\n\t\t// there are siblings above the highest bound sibling, we need to\n\t\t// insert between them.\n\n\t\t// if the next sibling is also a bound arrow though, we can end up\n\t\t// all fighting for the same indexes. so lets find the next\n\t\t// non-arrow sibling...\n\t\tconst nextHighestNonArrowSibling = higherSiblings.find((sibling) => sibling.type !== 'arrow')\n\n\t\tif (\n\t\t\t// ...then, if we're above the last shape we want to be above...\n\t\t\treparentedArrow.index > highestSibling.index &&\n\t\t\t// ...but below the next non-arrow sibling...\n\t\t\t(!nextHighestNonArrowSibling || reparentedArrow.index < nextHighestNonArrowSibling.index)\n\t\t) {\n\t\t\t// ...then we're already in the right place. no need to update!\n\t\t\treturn\n\t\t}\n\n\t\t// otherwise, we need to find the index between the highest sibling\n\t\t// we want to be above, and the next highest sibling we want to be\n\t\t// below:\n\t\tfinalIndex = getIndexBetween(highestSibling.index, higherSiblings[0].index)\n\t} else {\n\t\t// if there are no siblings above us, we can just get the next index:\n\t\tfinalIndex = getIndexAbove(highestSibling.index)\n\t}\n\n\tif (finalIndex !== reparentedArrow.index) {\n\t\teditor.updateShapes<TLArrowShape>([{ id: arrowId, type: 'arrow', index: finalIndex }])\n\t}\n}\n\nfunction arrowDidUpdate(editor: Editor, arrow: TLArrowShape) {\n\tconst bindings = getArrowBindings(editor, arrow)\n\t// if the shape is an arrow and its bound shape is on another page\n\t// or was deleted, unbind it\n\tfor (const handle of ['start', 'end'] as const) {\n\t\tconst binding = bindings[handle]\n\t\tif (!binding) continue\n\t\tconst boundShape = editor.getShape(binding.toId)\n\t\tconst isShapeInSamePageAsArrow =\n\t\t\teditor.getAncestorPageId(arrow) === editor.getAncestorPageId(boundShape)\n\t\tif (!boundShape || !isShapeInSamePageAsArrow) {\n\t\t\tupdateArrowTerminal({ editor, arrow, terminal: handle, unbind: true })\n\t\t}\n\t}\n\n\t// always check the arrow parents\n\treparentArrow(editor, arrow.id)\n}\n\n/** @internal */\nexport function updateArrowTerminal({\n\teditor,\n\tarrow,\n\tterminal,\n\tunbind = false,\n\tuseHandle = false,\n}: {\n\teditor: Editor\n\tarrow: TLArrowShape\n\tterminal: 'start' | 'end'\n\tunbind?: boolean\n\tuseHandle?: boolean\n}) {\n\tconst info = getArrowInfo(editor, arrow)\n\tif (!info) {\n\t\tthrow new Error('expected arrow info')\n\t}\n\n\tconst startPoint = useHandle ? info.start.handle : info.start.point\n\tconst endPoint = useHandle ? info.end.handle : info.end.point\n\tconst point = terminal === 'start' ? startPoint : endPoint\n\n\tconst update = {\n\t\tid: arrow.id,\n\t\ttype: 'arrow',\n\t\tprops: {\n\t\t\t[terminal]: { x: point.x, y: point.y },\n\t\t\tbend: arrow.props.bend,\n\t\t},\n\t} satisfies TLShapePartial<TLArrowShape>\n\n\t// fix up the bend:\n\tif (info.type === 'arc') {\n\t\t// find the new start/end points of the resulting arrow\n\t\tconst newStart = terminal === 'start' ? startPoint : info.start.handle\n\t\tconst newEnd = terminal === 'end' ? endPoint : info.end.handle\n\t\tconst newMidPoint = Vec.Med(newStart, newEnd)\n\n\t\t// intersect a line segment perpendicular to the new arrow with the old arrow arc to\n\t\t// find the new mid-point\n\t\tconst lineSegment = Vec.Sub(newStart, newEnd)\n\t\t\t.per()\n\t\t\t.uni()\n\t\t\t.mul(info.handleArc.radius * 2 * Math.sign(arrow.props.bend))\n\n\t\t// find the intersections with the old arrow arc:\n\t\tconst intersections = intersectLineSegmentCircle(\n\t\t\tinfo.handleArc.center,\n\t\t\tVec.Add(newMidPoint, lineSegment),\n\t\t\tinfo.handleArc.center,\n\t\t\tinfo.handleArc.radius\n\t\t)\n\n\t\tassert(intersections?.length === 1)\n\t\tconst bend = Vec.Dist(newMidPoint, intersections[0]) * Math.sign(arrow.props.bend)\n\t\t// use `approximately` to avoid endless update loops\n\t\tif (!approximately(bend, update.props.bend)) {\n\t\t\tupdate.props.bend = bend\n\t\t}\n\t}\n\n\teditor.updateShape(update)\n\tif (unbind) {\n\t\tremoveArrowBinding(editor, arrow, terminal)\n\t}\n}\n"],
5
- "mappings": "AAAA;AAAA,EAKC;AAAA,EAUA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB,cAAc,0BAA0B;AAK5D,MAAM,yBAAyB,YAA4B;AAAA,EACjE,OAAgB,OAAO;AAAA,EAEvB,OAAgB,QAAQ;AAAA,EACxB,OAAgB,aAAa;AAAA,EAEpB,kBAAgD;AACxD,WAAO;AAAA,MACN,WAAW;AAAA,MACX,SAAS;AAAA,MACT,kBAAkB,EAAE,GAAG,KAAK,GAAG,IAAI;AAAA,MACnC,MAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA,EAGS,cAAc,EAAE,QAAQ,GAAiD;AACjF,UAAM,QAAQ,KAAK,OAAO,SAAS,QAAQ,MAAM;AACjD,QAAI,CAAC,MAAO;AACZ,mBAAe,KAAK,QAAQ,KAA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MAAM;AAI5C,UAAM,cAAc,IAAI,IAAI,UAAU,MAAM,EAC1C,IAAI,EACJ,IAAI,EACJ,IAAI,KAAK,UAAU,SAAS,IAAI,KAAK,KAAK,MAAM,MAAM,IAAI,CAAC;AAG7D,UAAM,gBAAgB;AAAA,MACrB,KAAK,UAAU;AAAA,MACf,IAAI,IAAI,aAAa,WAAW;AAAA,MAChC,KAAK,UAAU;AAAA,MACf,KAAK,UAAU;AAAA,IAChB;AAEA,WAAO,eAAe,WAAW,CAAC;AAClC,UAAM,OAAO,IAAI,KAAK,aAAa,cAAc,CAAC,CAAC,IAAI,KAAK,KAAK,MAAM,MAAM,IAAI;AAEjF,QAAI,CAAC,cAAc,MAAM,OAAO,MAAM,IAAI,GAAG;AAC5C,aAAO,MAAM,OAAO;AAAA,IACrB;AAAA,EACD;AAEA,SAAO,YAAY,MAAM;AACzB,MAAI,QAAQ;AACX,uBAAmB,QAAQ,OAAO,QAAQ;AAAA,EAC3C;AACD;",
4
+ "sourcesContent": ["import {\n\tBindingOnChangeOptions,\n\tBindingOnCreateOptions,\n\tBindingOnShapeChangeOptions,\n\tBindingOnShapeIsolateOptions,\n\tBindingUtil,\n\tEditor,\n\tIndexKey,\n\tTLArrowBinding,\n\tTLArrowBindingProps,\n\tTLArrowShape,\n\tTLParentId,\n\tTLShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tapproximately,\n\tarrowBindingMigrations,\n\tarrowBindingProps,\n\tassert,\n\tgetIndexAbove,\n\tgetIndexBetween,\n\tintersectLineSegmentCircle,\n} from '@tldraw/editor'\nimport { getArrowBindings, getArrowInfo, removeArrowBinding } from '../../shapes/arrow/shared'\n\n/**\n * @public\n */\nexport class ArrowBindingUtil extends BindingUtil<TLArrowBinding> {\n\tstatic override type = 'arrow'\n\n\tstatic override props = arrowBindingProps\n\tstatic override migrations = arrowBindingMigrations\n\n\toverride getDefaultProps(): Partial<TLArrowBindingProps> {\n\t\treturn {\n\t\t\tisPrecise: false,\n\t\t\tisExact: false,\n\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\tsnap: 'none',\n\t\t}\n\t}\n\n\t// when the binding itself changes\n\toverride onAfterCreate({ binding }: BindingOnCreateOptions<TLArrowBinding>): void {\n\t\tconst arrow = this.editor.getShape(binding.fromId) as TLArrowShape | undefined\n\t\tif (!arrow) return\n\t\tarrowDidUpdate(this.editor, arrow)\n\t}\n\n\t// when the binding itself changes\n\toverride onAfterChange({ bindingAfter }: BindingOnChangeOptions<TLArrowBinding>): void {\n\t\tconst arrow = this.editor.getShape(bindingAfter.fromId) as TLArrowShape | undefined\n\t\tif (!arrow) return\n\t\tarrowDidUpdate(this.editor, arrow)\n\t}\n\n\t// when the arrow itself changes\n\toverride onAfterChangeFromShape({\n\t\tshapeAfter,\n\t}: BindingOnShapeChangeOptions<TLArrowBinding>): void {\n\t\tarrowDidUpdate(this.editor, shapeAfter as TLArrowShape)\n\t}\n\n\t// when the shape an arrow is bound to changes\n\toverride onAfterChangeToShape({\n\t\tbinding,\n\t\tshapeBefore,\n\t\tshapeAfter,\n\t\treason,\n\t}: BindingOnShapeChangeOptions<TLArrowBinding>): void {\n\t\tif (\n\t\t\treason !== 'ancestry' &&\n\t\t\tshapeBefore.parentId === shapeAfter.parentId &&\n\t\t\tshapeBefore.index === shapeAfter.index\n\t\t) {\n\t\t\treturn\n\t\t}\n\t\treparentArrow(this.editor, binding.fromId)\n\t}\n\n\t// when the arrow is isolated we need to update it's x,y positions\n\toverride onBeforeIsolateFromShape({\n\t\tbinding,\n\t}: BindingOnShapeIsolateOptions<TLArrowBinding>): void {\n\t\tconst arrow = this.editor.getShape<TLArrowShape>(binding.fromId)\n\t\tif (!arrow) return\n\t\tupdateArrowTerminal({\n\t\t\teditor: this.editor,\n\t\t\tarrow,\n\t\t\tterminal: binding.props.terminal,\n\t\t})\n\t}\n}\n\nfunction reparentArrow(editor: Editor, arrowId: TLShapeId) {\n\tconst arrow = editor.getShape<TLArrowShape>(arrowId)\n\tif (!arrow) return\n\tconst bindings = getArrowBindings(editor, arrow)\n\tconst { start, end } = bindings\n\tconst startShape = start ? editor.getShape(start.toId) : undefined\n\tconst endShape = end ? editor.getShape(end.toId) : undefined\n\n\tconst parentPageId = editor.getAncestorPageId(arrow)\n\tif (!parentPageId) return\n\n\tlet nextParentId: TLParentId\n\tif (startShape && endShape) {\n\t\t// if arrow has two bindings, always parent arrow to closest common ancestor of the bindings\n\t\tnextParentId = editor.findCommonAncestor([startShape, endShape]) ?? parentPageId\n\t} else if (startShape || endShape) {\n\t\tconst bindingParentId = (startShape || endShape)?.parentId\n\t\t// If the arrow and the shape that it is bound to have the same parent, then keep that parent\n\t\tif (bindingParentId && bindingParentId === arrow.parentId) {\n\t\t\tnextParentId = arrow.parentId\n\t\t} else {\n\t\t\t// if arrow has one binding, keep arrow on its own page\n\t\t\tnextParentId = parentPageId\n\t\t}\n\t} else {\n\t\treturn\n\t}\n\n\tif (nextParentId && nextParentId !== arrow.parentId) {\n\t\teditor.reparentShapes([arrowId], nextParentId)\n\t}\n\n\tconst reparentedArrow = editor.getShape<TLArrowShape>(arrowId)\n\tif (!reparentedArrow) throw Error('no reparented arrow')\n\n\tconst startSibling = editor.getShapeNearestSibling(reparentedArrow, startShape)\n\tconst endSibling = editor.getShapeNearestSibling(reparentedArrow, endShape)\n\n\tlet highestSibling: TLShape | undefined\n\n\tif (startSibling && endSibling) {\n\t\thighestSibling = startSibling.index > endSibling.index ? startSibling : endSibling\n\t} else if (startSibling && !endSibling) {\n\t\thighestSibling = startSibling\n\t} else if (endSibling && !startSibling) {\n\t\thighestSibling = endSibling\n\t} else {\n\t\treturn\n\t}\n\n\tlet finalIndex: IndexKey\n\n\tconst higherSiblings = editor\n\t\t.getSortedChildIdsForParent(highestSibling.parentId)\n\t\t.map((id) => editor.getShape(id)!)\n\t\t.filter((sibling) => sibling.index > highestSibling!.index)\n\n\tif (higherSiblings.length) {\n\t\t// there are siblings above the highest bound sibling, we need to\n\t\t// insert between them.\n\n\t\t// if the next sibling is also a bound arrow though, we can end up\n\t\t// all fighting for the same indexes. so lets find the next\n\t\t// non-arrow sibling...\n\t\tconst nextHighestNonArrowSibling = higherSiblings.find((sibling) => sibling.type !== 'arrow')\n\n\t\tif (\n\t\t\t// ...then, if we're above the last shape we want to be above...\n\t\t\treparentedArrow.index > highestSibling.index &&\n\t\t\t// ...but below the next non-arrow sibling...\n\t\t\t(!nextHighestNonArrowSibling || reparentedArrow.index < nextHighestNonArrowSibling.index)\n\t\t) {\n\t\t\t// ...then we're already in the right place. no need to update!\n\t\t\treturn\n\t\t}\n\n\t\t// otherwise, we need to find the index between the highest sibling\n\t\t// we want to be above, and the next highest sibling we want to be\n\t\t// below:\n\t\tfinalIndex = getIndexBetween(highestSibling.index, higherSiblings[0].index)\n\t} else {\n\t\t// if there are no siblings above us, we can just get the next index:\n\t\tfinalIndex = getIndexAbove(highestSibling.index)\n\t}\n\n\tif (finalIndex !== reparentedArrow.index) {\n\t\teditor.updateShapes([{ id: arrowId, type: 'arrow', index: finalIndex }])\n\t}\n}\n\nfunction arrowDidUpdate(editor: Editor, arrow: TLArrowShape) {\n\tconst bindings = getArrowBindings(editor, arrow)\n\t// if the shape is an arrow and its bound shape is on another page\n\t// or was deleted, unbind it\n\tfor (const handle of ['start', 'end'] as const) {\n\t\tconst binding = bindings[handle]\n\t\tif (!binding) continue\n\t\tconst boundShape = editor.getShape(binding.toId)\n\t\tconst isShapeInSamePageAsArrow =\n\t\t\teditor.getAncestorPageId(arrow) === editor.getAncestorPageId(boundShape)\n\t\tif (!boundShape || !isShapeInSamePageAsArrow) {\n\t\t\tupdateArrowTerminal({ editor, arrow, terminal: handle, unbind: true })\n\t\t}\n\t}\n\n\t// always check the arrow parents\n\treparentArrow(editor, arrow.id)\n}\n\n/** @internal */\nexport function updateArrowTerminal({\n\teditor,\n\tarrow,\n\tterminal,\n\tunbind = false,\n\tuseHandle = false,\n}: {\n\teditor: Editor\n\tarrow: TLArrowShape\n\tterminal: 'start' | 'end'\n\tunbind?: boolean\n\tuseHandle?: boolean\n}) {\n\tconst info = getArrowInfo(editor, arrow)\n\tif (!info) {\n\t\tthrow new Error('expected arrow info')\n\t}\n\n\tconst startPoint = useHandle ? info.start.handle : info.start.point\n\tconst endPoint = useHandle ? info.end.handle : info.end.point\n\tconst point = terminal === 'start' ? startPoint : endPoint\n\n\tconst update = {\n\t\tid: arrow.id,\n\t\ttype: 'arrow',\n\t\tprops: {\n\t\t\t[terminal]: { x: point.x, y: point.y },\n\t\t\tbend: arrow.props.bend,\n\t\t},\n\t} satisfies TLShapePartial<TLArrowShape>\n\n\t// fix up the bend:\n\tif (info.type === 'arc') {\n\t\t// find the new start/end points of the resulting arrow\n\t\tconst newStart = terminal === 'start' ? startPoint : info.start.handle\n\t\tconst newEnd = terminal === 'end' ? endPoint : info.end.handle\n\t\tconst newMidPoint = Vec.Med(newStart, newEnd)\n\n\t\t// intersect a line segment perpendicular to the new arrow with the old arrow arc to\n\t\t// find the new mid-point\n\t\tconst lineSegment = Vec.Sub(newStart, newEnd)\n\t\t\t.per()\n\t\t\t.uni()\n\t\t\t.mul(info.handleArc.radius * 2 * Math.sign(arrow.props.bend))\n\n\t\t// find the intersections with the old arrow arc:\n\t\tconst intersections = intersectLineSegmentCircle(\n\t\t\tinfo.handleArc.center,\n\t\t\tVec.Add(newMidPoint, lineSegment),\n\t\t\tinfo.handleArc.center,\n\t\t\tinfo.handleArc.radius\n\t\t)\n\n\t\tassert(intersections?.length === 1)\n\t\tconst bend = Vec.Dist(newMidPoint, intersections[0]) * Math.sign(arrow.props.bend)\n\t\t// use `approximately` to avoid endless update loops\n\t\tif (!approximately(bend, update.props.bend)) {\n\t\t\tupdate.props.bend = bend\n\t\t}\n\t}\n\n\teditor.updateShape(update)\n\tif (unbind) {\n\t\tremoveArrowBinding(editor, arrow, terminal)\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAKC;AAAA,EAUA;AAAA,EACA;AAAA,EACA;AAAA,EAC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Cursor,
5
6
  tlenv,
6
7
  toDomPrecision,
@@ -37,7 +38,9 @@ const TldrawSelectionForeground = track(function TldrawSelectionForeground2({
37
38
  const isLockedShape = onlyShape && editor.isShapeOrAncestorLocked(onlyShape);
38
39
  const expandOutlineBy = onlyShape ? editor.getShapeUtil(onlyShape).expandSelectionOutlinePx(onlyShape) : 0;
39
40
  const expandedBounds = expandOutlineBy instanceof Box ? bounds.clone().expand(expandOutlineBy).zeroFix() : bounds.clone().expandBy(expandOutlineBy).zeroFix();
40
- useTransform(rSvg, bounds?.x, bounds?.y, 1, editor.getSelectionRotation(), {
41
+ const selectionRotation = editor.getSelectionRotation();
42
+ const isShapeTooCloseToContextualToolbar = selectionRotation / HALF_PI > 1.6 && selectionRotation / HALF_PI < 2.4;
43
+ useTransform(rSvg, bounds?.x, bounds?.y, 1, selectionRotation, {
41
44
  x: expandedBounds.x - bounds.x,
42
45
  y: expandedBounds.y - bounds.y
43
46
  });
@@ -111,6 +114,7 @@ const TldrawSelectionForeground = track(function TldrawSelectionForeground2({
111
114
  }
112
115
  const textHandleHeight = Math.min(24 / zoom, height - targetSizeY * 3);
113
116
  const showTextResizeHandles = shouldDisplayControls && isCoarsePointer && onlyShape && editor.isShapeOfType(onlyShape, "text") && textHandleHeight * zoom >= 4;
117
+ const isMediaShape = onlyShape && (editor.isShapeOfType(onlyShape, "image") || editor.isShapeOfType(onlyShape, "video"));
114
118
  return /* @__PURE__ */ jsx(
115
119
  "svg",
116
120
  {
@@ -179,7 +183,7 @@ const TldrawSelectionForeground = track(function TldrawSelectionForeground2({
179
183
  {
180
184
  "data-testid": "selection.rotate.mobile",
181
185
  cx: isSmallX ? -targetSize * 1.5 : width / 2,
182
- cy: isSmallX ? height / 2 : -targetSize * 1.5,
186
+ cy: isSmallX ? height / 2 : isMediaShape && !isShapeTooCloseToContextualToolbar ? height + targetSize * 1.5 : -targetSize * 1.5,
183
187
  size,
184
188
  isHidden: hideMobileRotateHandle
185
189
  }