@tldraw/editor 3.14.0-canary.e0ab6f4c80f9 → 3.14.0-canary.e2a8e4a03aff

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 (235) hide show
  1. package/dist-cjs/index.d.ts +133 -107
  2. package/dist-cjs/index.js +8 -8
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/config/TLSessionStateSnapshot.js +1 -12
  5. package/dist-cjs/lib/config/TLSessionStateSnapshot.js.map +3 -3
  6. package/dist-cjs/lib/editor/Editor.js +82 -78
  7. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  8. package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +2 -2
  9. package/dist-cjs/lib/editor/derivations/bindingsIndex.js +22 -22
  10. package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
  11. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +16 -20
  12. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +3 -3
  13. package/dist-cjs/lib/editor/derivations/parentsToChildren.js +16 -16
  14. package/dist-cjs/lib/editor/derivations/parentsToChildren.js.map +2 -2
  15. package/dist-cjs/lib/editor/managers/{ClickManager.js → ClickManager/ClickManager.js} +1 -1
  16. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +7 -0
  17. package/dist-cjs/lib/editor/managers/{EdgeScrollManager.js → EdgeScrollManager/EdgeScrollManager.js} +2 -2
  18. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +7 -0
  19. package/dist-cjs/lib/editor/managers/{FocusManager.js → FocusManager/FocusManager.js} +2 -0
  20. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +7 -0
  21. package/dist-cjs/lib/editor/managers/{FontManager.js → FontManager/FontManager.js} +4 -1
  22. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +7 -0
  23. package/dist-cjs/lib/editor/managers/{HistoryManager.js → HistoryManager/HistoryManager.js} +64 -6
  24. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +7 -0
  25. package/dist-cjs/lib/editor/managers/{ScribbleManager.js → ScribbleManager/ScribbleManager.js} +1 -1
  26. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +7 -0
  27. package/dist-cjs/lib/editor/managers/{TextManager.js → TextManager/TextManager.js} +73 -42
  28. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +7 -0
  29. package/dist-cjs/lib/editor/managers/{TickManager.js → TickManager/TickManager.js} +1 -1
  30. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +7 -0
  31. package/dist-cjs/lib/editor/managers/{UserPreferencesManager.js → UserPreferencesManager/UserPreferencesManager.js} +1 -1
  32. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +7 -0
  33. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +8 -0
  34. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  35. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +6 -0
  36. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  37. package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
  38. package/dist-cjs/lib/editor/tools/StateNode.js +3 -3
  39. package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
  40. package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
  41. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  42. package/dist-cjs/lib/exports/getSvgJsx.js.map +1 -1
  43. package/dist-cjs/lib/hooks/useCanvasEvents.js +1 -2
  44. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  45. package/dist-cjs/lib/primitives/Box.js +33 -33
  46. package/dist-cjs/lib/primitives/Box.js.map +2 -2
  47. package/dist-cjs/lib/primitives/Vec.js +18 -13
  48. package/dist-cjs/lib/primitives/Vec.js.map +3 -3
  49. package/dist-cjs/lib/primitives/geometry/Arc2d.js +41 -21
  50. package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
  51. package/dist-cjs/lib/primitives/geometry/Circle2d.js +11 -11
  52. package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
  53. package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js +13 -16
  54. package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js.map +2 -2
  55. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +4 -4
  56. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +2 -2
  57. package/dist-cjs/lib/primitives/geometry/Edge2d.js +14 -21
  58. package/dist-cjs/lib/primitives/geometry/Edge2d.js.map +2 -2
  59. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +10 -10
  60. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
  61. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +5 -0
  62. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  63. package/dist-cjs/lib/primitives/geometry/Point2d.js +6 -6
  64. package/dist-cjs/lib/primitives/geometry/Point2d.js.map +2 -2
  65. package/dist-cjs/lib/primitives/geometry/Polygon2d.js +3 -0
  66. package/dist-cjs/lib/primitives/geometry/Polygon2d.js.map +2 -2
  67. package/dist-cjs/lib/primitives/geometry/Polyline2d.js +8 -5
  68. package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
  69. package/dist-cjs/lib/primitives/geometry/Rectangle2d.js +22 -11
  70. package/dist-cjs/lib/primitives/geometry/Rectangle2d.js.map +2 -2
  71. package/dist-cjs/lib/primitives/geometry/Stadium2d.js +22 -22
  72. package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
  73. package/dist-cjs/lib/utils/reorderShapes.js +11 -10
  74. package/dist-cjs/lib/utils/reorderShapes.js.map +2 -2
  75. package/dist-cjs/lib/utils/richText.js +7 -2
  76. package/dist-cjs/lib/utils/richText.js.map +2 -2
  77. package/dist-cjs/version.js +3 -3
  78. package/dist-cjs/version.js.map +1 -1
  79. package/dist-esm/index.d.mts +133 -107
  80. package/dist-esm/index.mjs +15 -9
  81. package/dist-esm/index.mjs.map +2 -2
  82. package/dist-esm/lib/config/TLSessionStateSnapshot.mjs +1 -1
  83. package/dist-esm/lib/config/TLSessionStateSnapshot.mjs.map +2 -2
  84. package/dist-esm/lib/editor/Editor.mjs +82 -78
  85. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  86. package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +2 -2
  87. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs +22 -22
  88. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
  89. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +16 -20
  90. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +3 -3
  91. package/dist-esm/lib/editor/derivations/parentsToChildren.mjs +16 -16
  92. package/dist-esm/lib/editor/derivations/parentsToChildren.mjs.map +2 -2
  93. package/dist-esm/lib/editor/managers/{ClickManager.mjs → ClickManager/ClickManager.mjs} +1 -1
  94. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +7 -0
  95. package/dist-esm/lib/editor/managers/{EdgeScrollManager.mjs → EdgeScrollManager/EdgeScrollManager.mjs} +2 -2
  96. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +7 -0
  97. package/dist-esm/lib/editor/managers/{FocusManager.mjs → FocusManager/FocusManager.mjs} +2 -0
  98. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +7 -0
  99. package/dist-esm/lib/editor/managers/{FontManager.mjs → FontManager/FontManager.mjs} +4 -1
  100. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +7 -0
  101. package/dist-esm/lib/editor/managers/{HistoryManager.mjs → HistoryManager/HistoryManager.mjs} +60 -2
  102. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +7 -0
  103. package/dist-esm/lib/editor/managers/{ScribbleManager.mjs → ScribbleManager/ScribbleManager.mjs} +1 -1
  104. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +7 -0
  105. package/dist-esm/lib/editor/managers/{TextManager.mjs → TextManager/TextManager.mjs} +73 -42
  106. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +7 -0
  107. package/dist-esm/lib/editor/managers/{TickManager.mjs → TickManager/TickManager.mjs} +1 -1
  108. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +7 -0
  109. package/dist-esm/lib/editor/managers/{UserPreferencesManager.mjs → UserPreferencesManager/UserPreferencesManager.mjs} +1 -1
  110. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +7 -0
  111. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +8 -0
  112. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  113. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +6 -0
  114. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  115. package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
  116. package/dist-esm/lib/editor/tools/StateNode.mjs +3 -3
  117. package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
  118. package/dist-esm/lib/exports/getSvgJsx.mjs.map +1 -1
  119. package/dist-esm/lib/hooks/useCanvasEvents.mjs +1 -2
  120. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  121. package/dist-esm/lib/primitives/Box.mjs +33 -33
  122. package/dist-esm/lib/primitives/Box.mjs.map +2 -2
  123. package/dist-esm/lib/primitives/Vec.mjs +19 -14
  124. package/dist-esm/lib/primitives/Vec.mjs.map +3 -3
  125. package/dist-esm/lib/primitives/geometry/Arc2d.mjs +41 -21
  126. package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
  127. package/dist-esm/lib/primitives/geometry/Circle2d.mjs +11 -11
  128. package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
  129. package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs +13 -16
  130. package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs.map +2 -2
  131. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +4 -4
  132. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +2 -2
  133. package/dist-esm/lib/primitives/geometry/Edge2d.mjs +14 -21
  134. package/dist-esm/lib/primitives/geometry/Edge2d.mjs.map +2 -2
  135. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +11 -11
  136. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
  137. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +7 -1
  138. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  139. package/dist-esm/lib/primitives/geometry/Point2d.mjs +6 -6
  140. package/dist-esm/lib/primitives/geometry/Point2d.mjs.map +2 -2
  141. package/dist-esm/lib/primitives/geometry/Polygon2d.mjs +3 -0
  142. package/dist-esm/lib/primitives/geometry/Polygon2d.mjs.map +2 -2
  143. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +8 -5
  144. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
  145. package/dist-esm/lib/primitives/geometry/Rectangle2d.mjs +22 -11
  146. package/dist-esm/lib/primitives/geometry/Rectangle2d.mjs.map +2 -2
  147. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +22 -22
  148. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
  149. package/dist-esm/lib/utils/reorderShapes.mjs +11 -10
  150. package/dist-esm/lib/utils/reorderShapes.mjs.map +2 -2
  151. package/dist-esm/lib/utils/richText.mjs +8 -3
  152. package/dist-esm/lib/utils/richText.mjs.map +2 -2
  153. package/dist-esm/version.mjs +3 -3
  154. package/dist-esm/version.mjs.map +1 -1
  155. package/editor.css +433 -482
  156. package/package.json +8 -9
  157. package/src/index.ts +19 -8
  158. package/src/lib/config/TLSessionStateSnapshot.ts +1 -1
  159. package/src/lib/editor/Editor.test.ts +252 -3
  160. package/src/lib/editor/Editor.ts +83 -76
  161. package/src/lib/editor/bindings/BindingUtil.ts +6 -0
  162. package/src/lib/editor/derivations/bindingsIndex.ts +27 -26
  163. package/src/lib/editor/derivations/notVisibleShapes.ts +24 -25
  164. package/src/lib/editor/derivations/parentsToChildren.ts +28 -25
  165. package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +442 -0
  166. package/src/lib/editor/managers/{ClickManager.ts → ClickManager/ClickManager.ts} +3 -3
  167. package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +374 -0
  168. package/src/lib/editor/managers/{EdgeScrollManager.ts → EdgeScrollManager/EdgeScrollManager.ts} +3 -3
  169. package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +455 -0
  170. package/src/lib/editor/managers/{FocusManager.ts → FocusManager/FocusManager.ts} +3 -1
  171. package/src/lib/editor/managers/FontManager/FontManager.test.ts +263 -0
  172. package/src/lib/editor/managers/{FontManager.ts → FontManager/FontManager.ts} +5 -2
  173. package/src/lib/editor/managers/{HistoryManager.test.ts → HistoryManager/HistoryManager.test.ts} +388 -1
  174. package/src/lib/editor/managers/{HistoryManager.ts → HistoryManager/HistoryManager.ts} +73 -2
  175. package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +624 -0
  176. package/src/lib/editor/managers/{ScribbleManager.ts → ScribbleManager/ScribbleManager.ts} +2 -2
  177. package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +485 -0
  178. package/src/lib/editor/managers/TextManager/TextManager.test.ts +407 -0
  179. package/src/lib/editor/managers/{TextManager.ts → TextManager/TextManager.ts} +119 -87
  180. package/src/lib/editor/managers/TickManager/TickManager.test.ts +314 -0
  181. package/src/lib/editor/managers/{TickManager.ts → TickManager/TickManager.ts} +2 -2
  182. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +591 -0
  183. package/src/lib/editor/managers/{UserPreferencesManager.ts → UserPreferencesManager/UserPreferencesManager.ts} +2 -2
  184. package/src/lib/editor/shapes/ShapeUtil.ts +11 -1
  185. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +8 -0
  186. package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +5 -2
  187. package/src/lib/editor/tools/StateNode.ts +3 -3
  188. package/src/lib/editor/types/emit-types.ts +4 -0
  189. package/src/lib/editor/types/external-content.ts +11 -2
  190. package/src/lib/exports/getSvgJsx.tsx +1 -1
  191. package/src/lib/hooks/useCanvasEvents.ts +0 -1
  192. package/src/lib/primitives/Box.test.ts +588 -7
  193. package/src/lib/primitives/Box.ts +33 -33
  194. package/src/lib/primitives/Vec.test.ts +2 -2
  195. package/src/lib/primitives/Vec.ts +15 -10
  196. package/src/lib/primitives/geometry/Arc2d.ts +42 -23
  197. package/src/lib/primitives/geometry/Circle2d.ts +12 -12
  198. package/src/lib/primitives/geometry/CubicBezier2d.test.ts +5 -0
  199. package/src/lib/primitives/geometry/CubicBezier2d.ts +13 -17
  200. package/src/lib/primitives/geometry/CubicSpline2d.ts +5 -5
  201. package/src/lib/primitives/geometry/Edge2d.ts +14 -25
  202. package/src/lib/primitives/geometry/Ellipse2d.ts +12 -13
  203. package/src/lib/primitives/geometry/Geometry2d.ts +6 -0
  204. package/src/lib/primitives/geometry/Point2d.ts +6 -6
  205. package/src/lib/primitives/geometry/Polygon2d.ts +4 -0
  206. package/src/lib/primitives/geometry/Polyline2d.ts +10 -7
  207. package/src/lib/primitives/geometry/Rectangle2d.ts +24 -11
  208. package/src/lib/primitives/geometry/Stadium2d.ts +22 -23
  209. package/src/lib/utils/reorderShapes.ts +10 -13
  210. package/src/lib/utils/richText.ts +10 -4
  211. package/src/version.ts +3 -3
  212. package/dist-cjs/lib/editor/managers/ClickManager.js.map +0 -7
  213. package/dist-cjs/lib/editor/managers/EdgeScrollManager.js.map +0 -7
  214. package/dist-cjs/lib/editor/managers/FocusManager.js.map +0 -7
  215. package/dist-cjs/lib/editor/managers/FontManager.js.map +0 -7
  216. package/dist-cjs/lib/editor/managers/HistoryManager.js.map +0 -7
  217. package/dist-cjs/lib/editor/managers/ScribbleManager.js.map +0 -7
  218. package/dist-cjs/lib/editor/managers/Stack.js +0 -82
  219. package/dist-cjs/lib/editor/managers/Stack.js.map +0 -7
  220. package/dist-cjs/lib/editor/managers/TextManager.js.map +0 -7
  221. package/dist-cjs/lib/editor/managers/TickManager.js.map +0 -7
  222. package/dist-cjs/lib/editor/managers/UserPreferencesManager.js.map +0 -7
  223. package/dist-esm/lib/editor/managers/ClickManager.mjs.map +0 -7
  224. package/dist-esm/lib/editor/managers/EdgeScrollManager.mjs.map +0 -7
  225. package/dist-esm/lib/editor/managers/FocusManager.mjs.map +0 -7
  226. package/dist-esm/lib/editor/managers/FontManager.mjs.map +0 -7
  227. package/dist-esm/lib/editor/managers/HistoryManager.mjs.map +0 -7
  228. package/dist-esm/lib/editor/managers/ScribbleManager.mjs.map +0 -7
  229. package/dist-esm/lib/editor/managers/Stack.mjs +0 -62
  230. package/dist-esm/lib/editor/managers/Stack.mjs.map +0 -7
  231. package/dist-esm/lib/editor/managers/TextManager.mjs.map +0 -7
  232. package/dist-esm/lib/editor/managers/TickManager.mjs.map +0 -7
  233. package/dist-esm/lib/editor/managers/UserPreferencesManager.mjs.map +0 -7
  234. package/src/lib/editor/managers/ScribbleManager.test.ts +0 -32
  235. package/src/lib/editor/managers/Stack.ts +0 -71
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/reorderShapes.ts"],
4
- "sourcesContent": ["import { TLParentId, TLShape, TLShapeId, TLShapePartial } from '@tldraw/tlschema'\nimport { IndexKey, compact, getIndicesBetween, sortByIndex } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\nimport { Vec } from '../primitives/Vec'\nimport { polygonsIntersect } from '../primitives/intersect'\n\nexport function getReorderingShapesChanges(\n\teditor: Editor,\n\toperation: 'toBack' | 'toFront' | 'forward' | 'backward',\n\tids: TLShapeId[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tif (ids.length === 0) return []\n\n\t// From the ids that are moving, collect the parents, their children, and which of those children are moving\n\tconst parents = new Map<TLParentId, { moving: Set<TLShape>; children: TLShape[] }>()\n\n\tfor (const shape of compact(ids.map((id) => editor.getShape(id)))) {\n\t\tconst { parentId } = shape\n\t\tif (!parents.has(parentId)) {\n\t\t\tparents.set(parentId, {\n\t\t\t\tchildren: compact(\n\t\t\t\t\teditor.getSortedChildIdsForParent(parentId).map((id) => editor.getShape(id))\n\t\t\t\t),\n\t\t\t\tmoving: new Set(),\n\t\t\t})\n\t\t}\n\t\tparents.get(parentId)!.moving.add(shape)\n\t}\n\n\tconst changes: TLShapePartial[] = []\n\n\tswitch (operation) {\n\t\tcase 'toBack': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToBack(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'toFront': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToFront(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'forward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderForward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t\tcase 'backward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderBackward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn changes\n}\n\n/**\n * Reorders the moving shapes to the back of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToBack(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the back; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be below the moved shapes.\n\t\t\tbelow = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be above our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as below (if any).\n\t\t\tabove = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the back of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\n/**\n * Reorders the moving shapes to the front of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToFront(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the front; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be above the moved shapes.\n\t\t\tabove = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be below our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as above (if any).\n\t\t\tbelow = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the front of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\nfunction getOverlapChecker(editor: Editor, moving: Set<TLShape>) {\n\tconst movingVertices = Array.from(moving)\n\t\t.map((shape) => {\n\t\t\tconst vertices = editor.getShapePageGeometry(shape).vertices\n\t\t\tif (!vertices) return null\n\t\t\treturn { shape, vertices }\n\t\t})\n\t\t.filter(Boolean) as { shape: TLShape; vertices: Vec[] }[]\n\n\tconst isOverlapping = (child: TLShape) => {\n\t\tconst vertices = editor.getShapePageGeometry(child).vertices\n\t\tif (!vertices) return false\n\t\treturn movingVertices.some((other) => {\n\t\t\treturn polygonsIntersect(other.vertices, vertices)\n\t\t})\n\t}\n\n\treturn isOverlapping\n}\n\n/**\n * Reorders the moving shapes forward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderForward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in front of the not moving shape; and start skipping\n\t\t\t\tconst { selectIndex } = state\n\t\t\t\tgetIndicesBetween(children[i].index, children[i + 1]?.index, i - selectIndex).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[selectIndex + k]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Reorders the moving shapes backward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderBackward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in behind of the not moving shape; and start skipping\n\t\t\t\tgetIndicesBetween(children[i - 1]?.index, children[i].index, state.selectIndex - i).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[i + k + 1]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkE;AAGlE,uBAAkC;AAE3B,SAAS,2BACf,QACA,WACA,KACA,MACC;AACD,MAAI,IAAI,WAAW,EAAG,QAAO,CAAC;AAG9B,QAAM,UAAU,oBAAI,IAA+D;AAEnF,aAAW,aAAS,sBAAQ,IAAI,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC,CAAC,GAAG;AAClE,UAAM,EAAE,SAAS,IAAI;AACrB,QAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG;AAC3B,cAAQ,IAAI,UAAU;AAAA,QACrB,cAAU;AAAA,UACT,OAAO,2BAA2B,QAAQ,EAAE,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC;AAAA,QAC5E;AAAA,QACA,QAAQ,oBAAI,IAAI;AAAA,MACjB,CAAC;AAAA,IACF;AACA,YAAQ,IAAI,QAAQ,EAAG,OAAO,IAAI,KAAK;AAAA,EACxC;AAEA,QAAM,UAA4B,CAAC;AAEnC,UAAQ,WAAW;AAAA,IAClB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CAAC,EAAG;AAG7D,4CAAkB,SAAS,IAAI,CAAC,GAAG,OAAO,SAAS,CAAC,EAAE,OAAO,MAAM,cAAc,CAAC,EAAE;AAAA,UACnF,CAAC,OAAO,MAAM;AACb,kBAAM,QAAQ,SAAS,IAAI,IAAI,CAAC;AAEhC,gBAAI,CAAC,OAAO,IAAI,KAAK,EAAG;AACxB,oBAAQ,KAAK,EAAE,GAAG,OAAO,MAAM,CAAC;AAAA,UACjC;AAAA,QACD;AACA,gBAAQ,EAAE,MAAM,WAAW;AAC3B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["import { TLParentId, TLShape, TLShapeId, TLShapePartial } from '@tldraw/tlschema'\nimport { IndexKey, compact, getIndicesBetween, sortByIndex } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\n\nexport function getReorderingShapesChanges(\n\teditor: Editor,\n\toperation: 'toBack' | 'toFront' | 'forward' | 'backward',\n\tids: TLShapeId[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tif (ids.length === 0) return []\n\n\t// From the ids that are moving, collect the parents, their children, and which of those children are moving\n\tconst parents = new Map<TLParentId, { moving: Set<TLShape>; children: TLShape[] }>()\n\n\tfor (const shape of compact(ids.map((id) => editor.getShape(id)))) {\n\t\tconst { parentId } = shape\n\t\tif (!parents.has(parentId)) {\n\t\t\tparents.set(parentId, {\n\t\t\t\tchildren: compact(\n\t\t\t\t\teditor.getSortedChildIdsForParent(parentId).map((id) => editor.getShape(id))\n\t\t\t\t),\n\t\t\t\tmoving: new Set(),\n\t\t\t})\n\t\t}\n\t\tparents.get(parentId)!.moving.add(shape)\n\t}\n\n\tconst changes: TLShapePartial[] = []\n\n\tswitch (operation) {\n\t\tcase 'toBack': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToBack(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'toFront': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToFront(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'forward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderForward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t\tcase 'backward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderBackward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn changes\n}\n\n/**\n * Reorders the moving shapes to the back of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToBack(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the back; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be below the moved shapes.\n\t\t\tbelow = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be above our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as below (if any).\n\t\t\tabove = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the back of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\n/**\n * Reorders the moving shapes to the front of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToFront(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the front; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be above the moved shapes.\n\t\t\tabove = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be below our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as above (if any).\n\t\t\tbelow = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the front of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\nfunction getOverlapChecker(editor: Editor, moving: Set<TLShape>) {\n\tconst movingBounds = compact(\n\t\tArray.from(moving).map((shape) => {\n\t\t\tconst bounds = editor.getShapePageBounds(shape)\n\t\t\tif (!bounds) return null\n\t\t\treturn { shape, bounds }\n\t\t})\n\t)\n\tconst isOverlapping = (child: TLShape) => {\n\t\tconst bounds = editor.getShapePageBounds(child)\n\t\tif (!bounds) return false\n\t\treturn movingBounds.some((other) => {\n\t\t\treturn other.bounds.includes(bounds)\n\t\t})\n\t}\n\n\treturn isOverlapping\n}\n\n/**\n * Reorders the moving shapes forward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderForward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in front of the not moving shape; and start skipping\n\t\t\t\tconst { selectIndex } = state\n\t\t\t\tgetIndicesBetween(children[i].index, children[i + 1]?.index, i - selectIndex).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[selectIndex + k]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Reorders the moving shapes backward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderBackward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in behind of the not moving shape; and start skipping\n\t\t\t\tgetIndicesBetween(children[i - 1]?.index, children[i].index, state.selectIndex - i).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[i + k + 1]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkE;AAG3D,SAAS,2BACf,QACA,WACA,KACA,MACC;AACD,MAAI,IAAI,WAAW,EAAG,QAAO,CAAC;AAG9B,QAAM,UAAU,oBAAI,IAA+D;AAEnF,aAAW,aAAS,sBAAQ,IAAI,IA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,MAAM;AAEtD,QAAM,MAAM,SAAS;AAErB,MAAI,OAAO,SAAS,IAAK;AAEzB,MAAI,QAAQ,EAAE,MAAM,WAAW;AAK/B,WAAS,IAAI,MAAM,GAAG,IAAI,IAAI,KAAK;AAClC,UAAM,WAAW,OAAO,IAAI,SAAS,CAAC,CAAC;AAEvC,YAAQ,MAAM,MAAM;AAAA,MACnB,KAAK,YAAY;AAChB,YAAI,CAAC,SAAU;AAEf,gBAAQ,EAAE,MAAM,aAAa,aAAa,EAAE;AAC5C;AAAA,MACD;AAAA,MACA,KAAK,aAAa;AACjB,YAAI,SAAU;AACd,YAAI,CAAC,MAAM,qBAAqB,CAAC,cAAc,SAAS,CAAC,CAAC,EAAG;AAG7D,4CAAkB,SAAS,IAAI,CAAC,GAAG,OAAO,SAAS,CAAC,EAAE,OAAO,MAAM,cAAc,CAAC,EAAE;AAAA,UACnF,CAAC,OAAO,MAAM;AACb,kBAAM,QAAQ,SAAS,IAAI,IAAI,CAAC;AAEhC,gBAAI,CAAC,OAAO,IAAI,KAAK,EAAG;AACxB,oBAAQ,KAAK,EAAE,GAAG,OAAO,MAAM,CAAC;AAAA,UACjC;AAAA,QACD;AACA,gBAAQ,EAAE,MAAM,WAAW;AAC3B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -18,17 +18,22 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var richText_exports = {};
20
20
  __export(richText_exports, {
21
- getFontsFromRichText: () => getFontsFromRichText
21
+ getFontsFromRichText: () => getFontsFromRichText,
22
+ getTipTapSchema: () => getTipTapSchema
22
23
  });
23
24
  module.exports = __toCommonJS(richText_exports);
24
25
  var import_core = require("@tiptap/core");
25
26
  var import_model = require("@tiptap/pm/model");
26
27
  var import_utils = require("@tldraw/utils");
28
+ const schemaCache = new import_utils.WeakCache();
29
+ function getTipTapSchema(tipTapConfig) {
30
+ return schemaCache.get(tipTapConfig, () => (0, import_core.getSchema)(tipTapConfig.extensions ?? []));
31
+ }
27
32
  function getFontsFromRichText(editor, richText, initialState) {
28
33
  const { tipTapConfig, addFontsFromNode } = editor.getTextOptions();
29
34
  (0, import_utils.assert)(tipTapConfig, "textOptions.tipTapConfig must be set to use rich text");
30
35
  (0, import_utils.assert)(addFontsFromNode, "textOptions.addFontsFromNode must be set to use rich text");
31
- const schema = (0, import_core.getSchema)(tipTapConfig.extensions ?? []);
36
+ const schema = getTipTapSchema(tipTapConfig);
32
37
  const rootNode = import_model.Node.fromJSON(schema, richText);
33
38
  const fonts = /* @__PURE__ */ new Set();
34
39
  function addFont(font) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/richText.ts"],
4
- "sourcesContent": ["import { getSchema, JSONContent, Editor as TTEditor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { EditorProviderProps } from '@tiptap/react'\nimport { TLRichText } from '@tldraw/tlschema'\nimport { assert } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\nimport { TLFontFace } from '../editor/managers/FontManager'\n\n/**\n * This is the TipTap editor! Docs are {@link https://tiptap.dev/docs}.\n *\n * @public\n */\nexport type TiptapEditor = TTEditor\n\n/**\n * A TipTap node. See {@link https://tiptap.dev/docs}.\n * @public\n */\nexport type TiptapNode = Node\n\n/** @public */\nexport interface TLTextOptions {\n\ttipTapConfig?: EditorProviderProps\n\taddFontsFromNode?: RichTextFontVisitor\n}\n\n/** @public */\nexport interface RichTextFontVisitorState {\n\treadonly family: string\n\treadonly weight: string\n\treadonly style: string\n}\n\n/** @public */\nexport type RichTextFontVisitor = (\n\tnode: TiptapNode,\n\tstate: RichTextFontVisitorState,\n\taddFont: (font: TLFontFace) => void\n) => RichTextFontVisitorState\n\n/** @public */\nexport function getFontsFromRichText(\n\teditor: Editor,\n\trichText: TLRichText,\n\tinitialState: RichTextFontVisitorState\n) {\n\tconst { tipTapConfig, addFontsFromNode } = editor.getTextOptions()\n\tassert(tipTapConfig, 'textOptions.tipTapConfig must be set to use rich text')\n\tassert(addFontsFromNode, 'textOptions.addFontsFromNode must be set to use rich text')\n\n\tconst schema = getSchema(tipTapConfig.extensions ?? [])\n\tconst rootNode = Node.fromJSON(schema, richText as JSONContent)\n\n\tconst fonts = new Set<TLFontFace>()\n\n\tfunction addFont(font: TLFontFace) {\n\t\tfonts.add(font)\n\t}\n\n\tfunction visit(node: TiptapNode, state: RichTextFontVisitorState) {\n\t\tstate = addFontsFromNode!(node, state, addFont)\n\n\t\tfor (const child of node.children) {\n\t\t\tvisit(child, state)\n\t\t}\n\t}\n\n\tvisit(rootNode, initialState)\n\n\treturn Array.from(fonts)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2D;AAC3D,mBAAqB;AAGrB,mBAAuB;AAsChB,SAAS,qBACf,QACA,UACA,cACC;AACD,QAAM,EAAE,cAAc,iBAAiB,IAAI,OAAO,eAAe;AACjE,2BAAO,cAAc,uDAAuD;AAC5E,2BAAO,kBAAkB,2DAA2D;AAEpF,QAAM,aAAS,uBAAU,aAAa,cAAc,CAAC,CAAC;AACtD,QAAM,WAAW,kBAAK,SAAS,QAAQ,QAAuB;AAE9D,QAAM,QAAQ,oBAAI,IAAgB;AAElC,WAAS,QAAQ,MAAkB;AAClC,UAAM,IAAI,IAAI;AAAA,EACf;AAEA,WAAS,MAAM,MAAkB,OAAiC;AACjE,YAAQ,iBAAkB,MAAM,OAAO,OAAO;AAE9C,eAAW,SAAS,KAAK,UAAU;AAClC,YAAM,OAAO,KAAK;AAAA,IACnB;AAAA,EACD;AAEA,QAAM,UAAU,YAAY;AAE5B,SAAO,MAAM,KAAK,KAAK;AACxB;",
4
+ "sourcesContent": ["import { getSchema, JSONContent, Editor as TTEditor } from '@tiptap/core'\nimport { Node, Schema } from '@tiptap/pm/model'\nimport { EditorProviderProps } from '@tiptap/react'\nimport { TLRichText } from '@tldraw/tlschema'\nimport { assert, WeakCache } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\nimport { TLFontFace } from '../editor/managers/FontManager/FontManager'\n\n/**\n * This is the TipTap editor! Docs are {@link https://tiptap.dev/docs}.\n *\n * @public\n */\nexport type TiptapEditor = TTEditor\n\n/**\n * A TipTap node. See {@link https://tiptap.dev/docs}.\n * @public\n */\nexport type TiptapNode = Node\n\n/** @public */\nexport interface TLTextOptions {\n\ttipTapConfig?: EditorProviderProps\n\taddFontsFromNode?: RichTextFontVisitor\n}\n\n/** @public */\nexport interface RichTextFontVisitorState {\n\treadonly family: string\n\treadonly weight: string\n\treadonly style: string\n}\n\n/** @public */\nexport type RichTextFontVisitor = (\n\tnode: TiptapNode,\n\tstate: RichTextFontVisitorState,\n\taddFont: (font: TLFontFace) => void\n) => RichTextFontVisitorState\n\nconst schemaCache = new WeakCache<EditorProviderProps, Schema>()\nexport function getTipTapSchema(tipTapConfig: EditorProviderProps) {\n\treturn schemaCache.get(tipTapConfig, () => getSchema(tipTapConfig.extensions ?? []))\n}\n\n/** @public */\nexport function getFontsFromRichText(\n\teditor: Editor,\n\trichText: TLRichText,\n\tinitialState: RichTextFontVisitorState\n) {\n\tconst { tipTapConfig, addFontsFromNode } = editor.getTextOptions()\n\tassert(tipTapConfig, 'textOptions.tipTapConfig must be set to use rich text')\n\tassert(addFontsFromNode, 'textOptions.addFontsFromNode must be set to use rich text')\n\n\tconst schema = getTipTapSchema(tipTapConfig)\n\n\tconst rootNode = Node.fromJSON(schema, richText as JSONContent)\n\n\tconst fonts = new Set<TLFontFace>()\n\n\tfunction addFont(font: TLFontFace) {\n\t\tfonts.add(font)\n\t}\n\n\tfunction visit(node: TiptapNode, state: RichTextFontVisitorState) {\n\t\tstate = addFontsFromNode!(node, state, addFont)\n\n\t\tfor (const child of node.children) {\n\t\t\tvisit(child, state)\n\t\t}\n\t}\n\n\tvisit(rootNode, initialState)\n\n\treturn Array.from(fonts)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2D;AAC3D,mBAA6B;AAG7B,mBAAkC;AAqClC,MAAM,cAAc,IAAI,uBAAuC;AACxD,SAAS,gBAAgB,cAAmC;AAClE,SAAO,YAAY,IAAI,cAAc,UAAM,uBAAU,aAAa,cAAc,CAAC,CAAC,CAAC;AACpF;AAGO,SAAS,qBACf,QACA,UACA,cACC;AACD,QAAM,EAAE,cAAc,iBAAiB,IAAI,OAAO,eAAe;AACjE,2BAAO,cAAc,uDAAuD;AAC5E,2BAAO,kBAAkB,2DAA2D;AAEpF,QAAM,SAAS,gBAAgB,YAAY;AAE3C,QAAM,WAAW,kBAAK,SAAS,QAAQ,QAAuB;AAE9D,QAAM,QAAQ,oBAAI,IAAgB;AAElC,WAAS,QAAQ,MAAkB;AAClC,UAAM,IAAI,IAAI;AAAA,EACf;AAEA,WAAS,MAAM,MAAkB,OAAiC;AACjE,YAAQ,iBAAkB,MAAM,OAAO,OAAO;AAE9C,eAAW,SAAS,KAAK,UAAU;AAClC,YAAM,OAAO,KAAK;AAAA,IACnB;AAAA,EACD;AAEA,QAAM,UAAU,YAAY;AAE5B,SAAO,MAAM,KAAK,KAAK;AACxB;",
6
6
  "names": []
7
7
  }
@@ -22,10 +22,10 @@ __export(version_exports, {
22
22
  version: () => version
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- const version = "3.14.0-canary.e0ab6f4c80f9";
25
+ const version = "3.14.0-canary.e2a8e4a03aff";
26
26
  const publishDates = {
27
27
  major: "2024-09-13T14:36:29.063Z",
28
- minor: "2025-05-23T10:08:18.976Z",
29
- patch: "2025-05-23T10:08:18.976Z"
28
+ minor: "2025-06-24T14:05:35.474Z",
29
+ patch: "2025-06-24T14:05:35.474Z"
30
30
  };
31
31
  //# sourceMappingURL=version.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/version.ts"],
4
- "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.14.0-canary.e0ab6f4c80f9'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-05-23T10:08:18.976Z',\n\tpatch: '2025-05-23T10:08:18.976Z',\n}\n"],
4
+ "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.14.0-canary.e2a8e4a03aff'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-06-24T14:05:35.474Z',\n\tpatch: '2025-06-24T14:05:35.474Z',\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -105,15 +105,15 @@ export declare function approximately(a: number, b: number, precision?: number):
105
105
 
106
106
  /** @public */
107
107
  export declare class Arc2d extends Geometry2d {
108
- _center: Vec;
109
- radius: number;
110
- start: Vec;
111
- end: Vec;
112
- largeArcFlag: number;
113
- sweepFlag: number;
114
- measure: number;
115
- angleStart: number;
116
- angleEnd: number;
108
+ private _center;
109
+ private _radius;
110
+ private _start;
111
+ private _end;
112
+ private _largeArcFlag;
113
+ private _sweepFlag;
114
+ private _measure;
115
+ private _angleStart;
116
+ private _angleEnd;
117
117
  constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
118
118
  center: Vec;
119
119
  end: Vec;
@@ -206,6 +206,12 @@ export declare interface BindingOnShapeChangeOptions<Binding extends TLUnknownBi
206
206
  shapeBefore: TLShape;
207
207
  /** The shape record after the change is made. */
208
208
  shapeAfter: TLShape;
209
+ /**
210
+ * Why did this shape change?
211
+ * - 'self': the shape itself changed
212
+ * - 'ancestry': the ancestry of the shape changed, but the shape itself may not have done
213
+ */
214
+ reason: 'ancestry' | 'self';
209
215
  }
210
216
 
211
217
  /**
@@ -551,10 +557,10 @@ export declare class Circle2d extends Geometry2d {
551
557
  x?: number;
552
558
  y?: number;
553
559
  };
554
- _center: Vec;
555
- radius: number;
556
- x: number;
557
- y: number;
560
+ private _center;
561
+ private _radius;
562
+ private _x;
563
+ private _y;
558
564
  constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
559
565
  isFilled: boolean;
560
566
  radius: number;
@@ -716,10 +722,10 @@ export declare function createTLUser(opts?: {
716
722
 
717
723
  /** @public */
718
724
  export declare class CubicBezier2d extends Polyline2d {
719
- a: Vec;
720
- b: Vec;
721
- c: Vec;
722
- d: Vec;
725
+ private _a;
726
+ private _b;
727
+ private _c;
728
+ private _d;
723
729
  constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
724
730
  cp1: Vec;
725
731
  cp2: Vec;
@@ -727,20 +733,19 @@ export declare class CubicBezier2d extends Polyline2d {
727
733
  start: Vec;
728
734
  });
729
735
  getVertices(): Vec[];
730
- midPoint(): Vec;
731
736
  nearestPoint(A: VecLike): Vec;
732
737
  getSvgPathData(first?: boolean): string;
733
738
  static GetAtT(segment: CubicBezier2d, t: number): Vec;
734
- getLength(filters?: Geometry2dFilters, precision?: number): number;
739
+ getLength(_filters?: Geometry2dFilters, precision?: number): number;
735
740
  }
736
741
 
737
742
  /** @public */
738
743
  export declare class CubicSpline2d extends Geometry2d {
739
- points: Vec[];
744
+ private _points;
740
745
  constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
741
746
  points: Vec[];
742
747
  });
743
- _segments?: CubicBezier2d[];
748
+ private _segments?;
744
749
  get segments(): CubicBezier2d[];
745
750
  getLength(): number;
746
751
  getVertices(): Vec[];
@@ -927,20 +932,18 @@ export declare const EASINGS: {
927
932
 
928
933
  /** @public */
929
934
  export declare class Edge2d extends Geometry2d {
930
- start: Vec;
931
- end: Vec;
932
- d: Vec;
933
- u: Vec;
934
- ul: number;
935
+ private _start;
936
+ private _end;
937
+ private _d;
938
+ private _u;
939
+ private _ul;
935
940
  constructor(config: {
936
941
  end: Vec;
937
942
  start: Vec;
938
943
  });
939
944
  getLength(): number;
940
- midPoint(): Vec;
941
945
  getVertices(): Vec[];
942
946
  nearestPoint(point: VecLike): Vec;
943
- hitTestLineSegment(A: VecLike, B: VecLike, distance?: number): boolean;
944
947
  getSvgPathData(first?: boolean): string;
945
948
  }
946
949
 
@@ -1628,6 +1631,13 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1628
1631
  * @public
1629
1632
  */
1630
1633
  getSelectionPageBounds(): Box | null;
1634
+ /**
1635
+ * The bounds of the selection bounding box in the current page space.
1636
+ *
1637
+ * @readonly
1638
+ * @public
1639
+ */
1640
+ getSelectionScreenBounds(): Box | undefined;
1631
1641
  /* Excluded from this release type: getShapesSharedRotation */
1632
1642
  /**
1633
1643
  * The rotation of the selection bounding box in the current page space.
@@ -2458,23 +2468,6 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2458
2468
  * @public
2459
2469
  */
2460
2470
  getShapeGeometry<T extends Geometry2d>(shape: TLShape | TLShapeId, opts?: TLGeometryOpts): T;
2461
- private _shapePageGeometryCaches;
2462
- /**
2463
- * Get the geometry of a shape in page-space.
2464
- *
2465
- * @example
2466
- * ```ts
2467
- * editor.getShapePageGeometry(myShape)
2468
- * editor.getShapePageGeometry(myShapeId)
2469
- * editor.getShapePageGeometry(myShapeId, { context: "arrow" })
2470
- * ```
2471
- *
2472
- * @param shape - The shape (or shape id) to get the geometry for.
2473
- * @param opts - Additional options about the request for geometry. Passed to {@link ShapeUtil.getGeometry}.
2474
- *
2475
- * @public
2476
- */
2477
- getShapePageGeometry<T extends Geometry2d>(shape: TLShape | TLShapeId, opts?: TLGeometryOpts): T;
2478
2471
  /* Excluded from this release type: _getShapeHandlesCache */
2479
2472
  /**
2480
2473
  * Get the handles (if any) for a shape.
@@ -2652,11 +2645,16 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2652
2645
  *
2653
2646
  * @public
2654
2647
  */
2655
- isShapeOrAncestorLocked(shape?: TLShape): boolean;
2656
- isShapeOrAncestorLocked(id?: TLShapeId): boolean;
2648
+ isShapeOrAncestorLocked(shape?: TLShape | TLShapeId): boolean;
2649
+ /**
2650
+ * Get shapes that are outside of the viewport.
2651
+ *
2652
+ * @public
2653
+ */
2654
+ getNotVisibleShapes(): Set<TLShapeId>;
2657
2655
  private _notVisibleShapes;
2658
2656
  /**
2659
- * Get culled shapes.
2657
+ * Get culled shapes (those that should not render), taking into account which shapes are selected or editing.
2660
2658
  *
2661
2659
  * @public
2662
2660
  */
@@ -2698,12 +2696,14 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2698
2696
  * @example
2699
2697
  * ```ts
2700
2698
  * editor.getShapesAtPoint({ x: 100, y: 100 })
2701
- * editor.getShapesAtPoint({ x: 100, y: 100 }, { hitInside: true, exact: true })
2699
+ * editor.getShapesAtPoint({ x: 100, y: 100 }, { hitInside: true, margin: 8 })
2702
2700
  * ```
2703
2701
  *
2704
2702
  * @param point - The page point to test.
2705
2703
  * @param opts - The options for the hit point testing.
2706
2704
  *
2705
+ * @returns An array of shapes at the given point, sorted in reverse order of their absolute z-index (top-most shape first).
2706
+ *
2707
2707
  * @public
2708
2708
  */
2709
2709
  getShapesAtPoint(point: VecLike, opts?: {
@@ -3608,6 +3608,12 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3608
3608
  * @param info - Info about the external content.
3609
3609
  */
3610
3610
  putExternalContent<E>(info: TLExternalContent<E>): Promise<void>;
3611
+ /**
3612
+ * Handle replacing external content.
3613
+ *
3614
+ * @param info - Info about the external content.
3615
+ */
3616
+ replaceExternalContent<E>(info: TLExternalContent<E>): Promise<void>;
3611
3617
  /**
3612
3618
  * Get content that can be exported for the given shape ids.
3613
3619
  *
@@ -3997,13 +4003,13 @@ export declare class Ellipse2d extends Geometry2d {
3997
4003
  height: number;
3998
4004
  width: number;
3999
4005
  };
4000
- w: number;
4001
- h: number;
4006
+ private _w;
4007
+ private _h;
4008
+ private _edges?;
4002
4009
  constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
4003
4010
  height: number;
4004
4011
  width: number;
4005
4012
  });
4006
- _edges?: Edge2d[];
4007
4013
  get edges(): Edge2d[];
4008
4014
  getVertices(): any[];
4009
4015
  nearestPoint(A: VecLike): Vec;
@@ -4184,11 +4190,11 @@ export declare function getIncrementedName(name: string, others: string[]): stri
4184
4190
  /** @public */
4185
4191
  export declare function getPerfectDashProps(totalLength: number, strokeWidth: number, opts?: {
4186
4192
  closed?: boolean;
4187
- end?: 'none' | 'outset' | 'skip';
4193
+ end?: PerfectDashTerminal;
4188
4194
  forceSolid?: boolean;
4189
4195
  lengthRatio?: number;
4190
4196
  snap?: number;
4191
- start?: 'none' | 'outset' | 'skip';
4197
+ start?: PerfectDashTerminal;
4192
4198
  style?: TLDefaultDashStyle;
4193
4199
  }): {
4194
4200
  strokeDasharray: string;
@@ -4301,6 +4307,8 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
4301
4307
  static migrations: TLPropsMigrations;
4302
4308
  hideSelectionBoundsFg(): boolean;
4303
4309
  canBind(): boolean;
4310
+ canResize(): boolean;
4311
+ canResizeChildren(): boolean;
4304
4312
  getDefaultProps(): TLGroupShape['props'];
4305
4313
  getGeometry(shape: TLGroupShape): Geometry2d;
4306
4314
  component(shape: TLGroupShape): JSX_2.Element | null;
@@ -4666,6 +4674,9 @@ export declare type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pi
4666
4674
  */
4667
4675
  export declare function parseDeepLinkString(deepLinkString: string): TLDeepLink;
4668
4676
 
4677
+ /** @public */
4678
+ export declare type PerfectDashTerminal = 'none' | 'outset' | 'skip';
4679
+
4669
4680
  /**
4670
4681
  * Find the approximate perimeter of an ellipse.
4671
4682
  *
@@ -4683,7 +4694,7 @@ export declare const PI2: number;
4683
4694
 
4684
4695
  /** @public */
4685
4696
  export declare class Point2d extends Geometry2d {
4686
- point: Vec;
4697
+ private _point;
4687
4698
  constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
4688
4699
  margin: number;
4689
4700
  point: Vec;
@@ -4727,12 +4738,12 @@ export declare function polygonsIntersect(a: VecLike[], b: VecLike[]): boolean;
4727
4738
 
4728
4739
  /** @public */
4729
4740
  export declare class Polyline2d extends Geometry2d {
4730
- points: Vec[];
4741
+ private _points;
4742
+ private _segments?;
4731
4743
  constructor(config: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {
4732
4744
  points: Vec[];
4733
4745
  });
4734
- _segments?: Edge2d[];
4735
- get segments(): Edge2d[];
4746
+ protected get segments(): Edge2d[];
4736
4747
  getLength(): number;
4737
4748
  getVertices(): Vec[];
4738
4749
  nearestPoint(A: VecLike): Vec;
@@ -4798,10 +4809,10 @@ export declare class ReadonlySharedStyleMap {
4798
4809
 
4799
4810
  /** @public */
4800
4811
  export declare class Rectangle2d extends Polygon2d {
4801
- x: number;
4802
- y: number;
4803
- w: number;
4804
- h: number;
4812
+ private _x;
4813
+ private _y;
4814
+ private _w;
4815
+ private _h;
4805
4816
  constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
4806
4817
  height: number;
4807
4818
  width: number;
@@ -4810,6 +4821,7 @@ export declare class Rectangle2d extends Polygon2d {
4810
4821
  });
4811
4822
  getBounds(): Box;
4812
4823
  getSvgPathData(): string;
4824
+ private negativeZeroFix;
4813
4825
  }
4814
4826
 
4815
4827
  /** @public */
@@ -5095,6 +5107,12 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
5095
5107
  * @public
5096
5108
  */
5097
5109
  canResize(_shape: Shape): boolean;
5110
+ /**
5111
+ * When the shape is resized, whether the shape's children should also be resized.
5112
+ *
5113
+ * @public
5114
+ */
5115
+ canResizeChildren(_shape: Shape): boolean;
5098
5116
  /**
5099
5117
  * Whether the shape can be edited in read-only mode.
5100
5118
  *
@@ -5538,12 +5556,12 @@ export declare class Stadium2d extends Geometry2d {
5538
5556
  height: number;
5539
5557
  width: number;
5540
5558
  };
5541
- w: number;
5542
- h: number;
5543
- a: Arc2d;
5544
- b: Edge2d;
5545
- c: Arc2d;
5546
- d: Edge2d;
5559
+ private _w;
5560
+ private _h;
5561
+ private _a;
5562
+ private _b;
5563
+ private _c;
5564
+ private _d;
5547
5565
  constructor(config: Omit<Geometry2dOptions, 'isClosed'> & {
5548
5566
  height: number;
5549
5567
  width: number;
@@ -5612,7 +5630,7 @@ export declare abstract class StateNode implements Partial<TLEventHandlers> {
5612
5630
  transition(id: string, info?: any): this;
5613
5631
  handleEvent(info: Exclude<TLEventInfo, TLPinchEventInfo>): void;
5614
5632
  enter(info: any, from: string): void;
5615
- exit(info: any, from: string): void;
5633
+ exit(info: any, to: string): void;
5616
5634
  /**
5617
5635
  * This is a hack / escape hatch that will tell the editor to
5618
5636
  * report a different state as active (in `getCurrentToolId()`) when
@@ -5719,43 +5737,15 @@ export declare const TAB_ID: string;
5719
5737
  /** @public */
5720
5738
  export declare class TextManager {
5721
5739
  editor: Editor;
5722
- private baseElem;
5740
+ private elm;
5741
+ private defaultStyles;
5723
5742
  constructor(editor: Editor);
5724
- measureText(textToMeasure: string, opts: {
5725
- /**
5726
- * When maxWidth is a number, the text will be wrapped to that maxWidth. When maxWidth
5727
- * is null, the text will be measured without wrapping, but explicit line breaks and
5728
- * space are preserved.
5729
- */
5730
- maxWidth: null | number;
5731
- disableOverflowWrapBreaking?: boolean;
5732
- fontFamily: string;
5733
- fontSize: number;
5734
- fontStyle: string;
5735
- fontWeight: string;
5736
- lineHeight: number;
5737
- minWidth?: null | number;
5738
- padding: string;
5739
- }): BoxModel & {
5743
+ dispose(): void;
5744
+ private resetElmStyles;
5745
+ measureText(textToMeasure: string, opts: TLMeasureTextOpts): BoxModel & {
5740
5746
  scrollWidth: number;
5741
5747
  };
5742
- measureHtml(html: string, opts: {
5743
- /**
5744
- * When maxWidth is a number, the text will be wrapped to that maxWidth. When maxWidth
5745
- * is null, the text will be measured without wrapping, but explicit line breaks and
5746
- * space are preserved.
5747
- */
5748
- maxWidth: null | number;
5749
- disableOverflowWrapBreaking?: boolean;
5750
- fontFamily: string;
5751
- fontSize: number;
5752
- fontStyle: string;
5753
- fontWeight: string;
5754
- lineHeight: number;
5755
- minWidth?: null | number;
5756
- otherStyles?: Record<string, string>;
5757
- padding: string;
5758
- }): BoxModel & {
5748
+ measureHtml(html: string, opts: TLMeasureTextOpts): BoxModel & {
5759
5749
  scrollWidth: number;
5760
5750
  };
5761
5751
  /**
@@ -6012,6 +6002,7 @@ export declare interface TLCropInfo<T extends TLShape> {
6012
6002
  w: number;
6013
6003
  };
6014
6004
  initialShape: T;
6005
+ aspectRatioLocked?: boolean;
6015
6006
  }
6016
6007
 
6017
6008
  /** @public */
@@ -6539,6 +6530,10 @@ export declare interface TLEventMap {
6539
6530
  };
6540
6531
  shapeId: TLShapeId;
6541
6532
  }];
6533
+ 'created-shapes': [TLRecord[]];
6534
+ 'edited-shapes': [TLRecord[]];
6535
+ 'deleted-shapes': [TLShapeId[]];
6536
+ edit: [];
6542
6537
  }
6543
6538
 
6544
6539
  /** @public */
@@ -6569,7 +6564,7 @@ export declare type TLExportType = 'jpeg' | 'png' | 'svg' | 'webp';
6569
6564
  export declare type TLExternalAsset = TLFileExternalAsset | TLUrlExternalAsset;
6570
6565
 
6571
6566
  /** @public */
6572
- export declare type TLExternalContent<EmbedDefinition> = TLEmbedExternalContent<EmbedDefinition> | TLExcalidrawExternalContent | TLFilesExternalContent | TLSvgTextExternalContent | TLTextExternalContent | TLTldrawExternalContent | TLUrlExternalContent;
6567
+ export declare type TLExternalContent<EmbedDefinition> = TLEmbedExternalContent<EmbedDefinition> | TLExcalidrawExternalContent | TLFileReplaceExternalContent | TLFilesExternalContent | TLSvgTextExternalContent | TLTextExternalContent | TLTldrawExternalContent | TLUrlExternalContent;
6573
6568
 
6574
6569
  /** @public */
6575
6570
  export declare type TLExternalContentSource = TLErrorExternalContentSource | TLExcalidrawExternalContentSource | TLTextExternalContentSource | TLTldrawExternalContentSource;
@@ -6581,11 +6576,19 @@ export declare interface TLFileExternalAsset {
6581
6576
  assetId?: TLAssetId;
6582
6577
  }
6583
6578
 
6579
+ /** @public */
6580
+ export declare interface TLFileReplaceExternalContent extends TLBaseExternalContent {
6581
+ type: 'file-replace';
6582
+ file: File;
6583
+ shapeId: TLShapeId;
6584
+ isImage: boolean;
6585
+ }
6586
+
6584
6587
  /** @public */
6585
6588
  export declare interface TLFilesExternalContent extends TLBaseExternalContent {
6586
6589
  type: 'files';
6587
6590
  files: File[];
6588
- ignoreParent: boolean;
6591
+ ignoreParent?: boolean;
6589
6592
  }
6590
6593
 
6591
6594
  /**
@@ -6780,6 +6783,27 @@ export declare interface TLLoadSnapshotOptions {
6780
6783
  forceOverwriteSessionState?: boolean;
6781
6784
  }
6782
6785
 
6786
+ /** @public */
6787
+ export declare interface TLMeasureTextOpts {
6788
+ fontStyle: string;
6789
+ fontWeight: string;
6790
+ fontFamily: string;
6791
+ fontSize: number;
6792
+ /** This must be a number, e.g. 1.35, not a pixel value. */
6793
+ lineHeight: number;
6794
+ /**
6795
+ * When maxWidth is a number, the text will be wrapped to that maxWidth. When maxWidth
6796
+ * is null, the text will be measured without wrapping, but explicit line breaks and
6797
+ * space are preserved.
6798
+ */
6799
+ maxWidth: null | number;
6800
+ minWidth?: null | number;
6801
+ padding: string;
6802
+ otherStyles?: Record<string, string>;
6803
+ disableOverflowWrapBreaking?: boolean;
6804
+ measureScrollWidth?: boolean;
6805
+ }
6806
+
6783
6807
  /** @public */
6784
6808
  export declare interface TLMeasureTextSpanOpts {
6785
6809
  overflow: 'truncate-clip' | 'truncate-ellipsis' | 'wrap';
@@ -6793,6 +6817,7 @@ export declare interface TLMeasureTextSpanOpts {
6793
6817
  lineHeight: number;
6794
6818
  textAlign: TLDefaultHorizontalAlignStyle;
6795
6819
  otherStyles?: Record<string, string>;
6820
+ measureScrollWidth?: boolean;
6796
6821
  }
6797
6822
 
6798
6823
  /** @public */
@@ -7676,7 +7701,7 @@ export declare class Vec {
7676
7701
  len(): number;
7677
7702
  pry(V: VecLike): number;
7678
7703
  per(): this;
7679
- uni(): Vec;
7704
+ uni(): this;
7680
7705
  tan(V: VecLike): Vec;
7681
7706
  dist(V: VecLike): number;
7682
7707
  distanceToLineSegment(A: VecLike, B: VecLike): number;
@@ -7687,8 +7712,9 @@ export declare class Vec {
7687
7712
  lrp(B: VecLike, t: number): Vec;
7688
7713
  equals(B: VecLike): boolean;
7689
7714
  equalsXY(x: number, y: number): boolean;
7715
+ /** @deprecated use `uni` instead */
7690
7716
  norm(): this;
7691
- toFixed(): Vec;
7717
+ toFixed(): this;
7692
7718
  toString(): string;
7693
7719
  toJson(): VecModel;
7694
7720
  toArray(): number[];