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

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 (215) hide show
  1. package/dist-cjs/index.d.ts +75 -70
  2. package/dist-cjs/index.js +10 -8
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/editor/Editor.js +44 -73
  5. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  6. package/dist-cjs/lib/editor/derivations/bindingsIndex.js +22 -22
  7. package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
  8. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +16 -20
  9. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +3 -3
  10. package/dist-cjs/lib/editor/derivations/parentsToChildren.js +16 -16
  11. package/dist-cjs/lib/editor/derivations/parentsToChildren.js.map +2 -2
  12. package/dist-cjs/lib/editor/managers/{ClickManager.js → ClickManager/ClickManager.js} +1 -1
  13. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +7 -0
  14. package/dist-cjs/lib/editor/managers/{EdgeScrollManager.js → EdgeScrollManager/EdgeScrollManager.js} +2 -2
  15. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +7 -0
  16. package/dist-cjs/lib/editor/managers/{FocusManager.js → FocusManager/FocusManager.js} +2 -0
  17. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +7 -0
  18. package/dist-cjs/lib/editor/managers/{FontManager.js → FontManager/FontManager.js} +5 -1
  19. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +7 -0
  20. package/dist-cjs/lib/editor/managers/{HistoryManager.js → HistoryManager/HistoryManager.js} +64 -6
  21. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +7 -0
  22. package/dist-cjs/lib/editor/managers/{ScribbleManager.js → ScribbleManager/ScribbleManager.js} +1 -1
  23. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +7 -0
  24. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +7 -0
  25. package/dist-cjs/lib/editor/managers/{TickManager.js → TickManager/TickManager.js} +1 -1
  26. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +7 -0
  27. package/dist-cjs/lib/editor/managers/{UserPreferencesManager.js → UserPreferencesManager/UserPreferencesManager.js} +1 -1
  28. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +7 -0
  29. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +8 -0
  30. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  31. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +6 -0
  32. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  33. package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
  34. package/dist-cjs/lib/exports/getSvgJsx.js.map +1 -1
  35. package/dist-cjs/lib/primitives/Box.js +39 -33
  36. package/dist-cjs/lib/primitives/Box.js.map +2 -2
  37. package/dist-cjs/lib/primitives/Vec.js +18 -13
  38. package/dist-cjs/lib/primitives/Vec.js.map +3 -3
  39. package/dist-cjs/lib/primitives/geometry/Arc2d.js +41 -21
  40. package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
  41. package/dist-cjs/lib/primitives/geometry/Circle2d.js +11 -11
  42. package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
  43. package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js +13 -16
  44. package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js.map +2 -2
  45. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +4 -4
  46. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +2 -2
  47. package/dist-cjs/lib/primitives/geometry/Edge2d.js +14 -21
  48. package/dist-cjs/lib/primitives/geometry/Edge2d.js.map +2 -2
  49. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +10 -10
  50. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
  51. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +5 -0
  52. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  53. package/dist-cjs/lib/primitives/geometry/Point2d.js +6 -6
  54. package/dist-cjs/lib/primitives/geometry/Point2d.js.map +2 -2
  55. package/dist-cjs/lib/primitives/geometry/Polygon2d.js +3 -0
  56. package/dist-cjs/lib/primitives/geometry/Polygon2d.js.map +2 -2
  57. package/dist-cjs/lib/primitives/geometry/Polyline2d.js +8 -5
  58. package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
  59. package/dist-cjs/lib/primitives/geometry/Rectangle2d.js +22 -11
  60. package/dist-cjs/lib/primitives/geometry/Rectangle2d.js.map +2 -2
  61. package/dist-cjs/lib/primitives/geometry/Stadium2d.js +22 -22
  62. package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
  63. package/dist-cjs/lib/utils/areShapesContentEqual.js +1 -1
  64. package/dist-cjs/lib/utils/areShapesContentEqual.js.map +2 -2
  65. package/dist-cjs/lib/utils/reorderShapes.js +11 -10
  66. package/dist-cjs/lib/utils/reorderShapes.js.map +2 -2
  67. package/dist-cjs/lib/utils/richText.js.map +1 -1
  68. package/dist-cjs/version.js +3 -3
  69. package/dist-cjs/version.js.map +1 -1
  70. package/dist-esm/index.d.mts +75 -70
  71. package/dist-esm/index.mjs +17 -9
  72. package/dist-esm/index.mjs.map +2 -2
  73. package/dist-esm/lib/editor/Editor.mjs +44 -73
  74. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  75. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs +22 -22
  76. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
  77. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +16 -20
  78. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +3 -3
  79. package/dist-esm/lib/editor/derivations/parentsToChildren.mjs +16 -16
  80. package/dist-esm/lib/editor/derivations/parentsToChildren.mjs.map +2 -2
  81. package/dist-esm/lib/editor/managers/{ClickManager.mjs → ClickManager/ClickManager.mjs} +1 -1
  82. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +7 -0
  83. package/dist-esm/lib/editor/managers/{EdgeScrollManager.mjs → EdgeScrollManager/EdgeScrollManager.mjs} +2 -2
  84. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +7 -0
  85. package/dist-esm/lib/editor/managers/{FocusManager.mjs → FocusManager/FocusManager.mjs} +2 -0
  86. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +7 -0
  87. package/dist-esm/lib/editor/managers/{FontManager.mjs → FontManager/FontManager.mjs} +5 -1
  88. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +7 -0
  89. package/dist-esm/lib/editor/managers/{HistoryManager.mjs → HistoryManager/HistoryManager.mjs} +60 -2
  90. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +7 -0
  91. package/dist-esm/lib/editor/managers/{ScribbleManager.mjs → ScribbleManager/ScribbleManager.mjs} +1 -1
  92. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +7 -0
  93. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +7 -0
  94. package/dist-esm/lib/editor/managers/{TickManager.mjs → TickManager/TickManager.mjs} +1 -1
  95. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +7 -0
  96. package/dist-esm/lib/editor/managers/{UserPreferencesManager.mjs → UserPreferencesManager/UserPreferencesManager.mjs} +1 -1
  97. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +7 -0
  98. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +8 -0
  99. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  100. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +6 -0
  101. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  102. package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
  103. package/dist-esm/lib/exports/getSvgJsx.mjs.map +1 -1
  104. package/dist-esm/lib/primitives/Box.mjs +39 -33
  105. package/dist-esm/lib/primitives/Box.mjs.map +2 -2
  106. package/dist-esm/lib/primitives/Vec.mjs +19 -14
  107. package/dist-esm/lib/primitives/Vec.mjs.map +3 -3
  108. package/dist-esm/lib/primitives/geometry/Arc2d.mjs +41 -21
  109. package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
  110. package/dist-esm/lib/primitives/geometry/Circle2d.mjs +11 -11
  111. package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
  112. package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs +13 -16
  113. package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs.map +2 -2
  114. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +4 -4
  115. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +2 -2
  116. package/dist-esm/lib/primitives/geometry/Edge2d.mjs +14 -21
  117. package/dist-esm/lib/primitives/geometry/Edge2d.mjs.map +2 -2
  118. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +11 -11
  119. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
  120. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +7 -1
  121. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  122. package/dist-esm/lib/primitives/geometry/Point2d.mjs +6 -6
  123. package/dist-esm/lib/primitives/geometry/Point2d.mjs.map +2 -2
  124. package/dist-esm/lib/primitives/geometry/Polygon2d.mjs +3 -0
  125. package/dist-esm/lib/primitives/geometry/Polygon2d.mjs.map +2 -2
  126. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +8 -5
  127. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
  128. package/dist-esm/lib/primitives/geometry/Rectangle2d.mjs +22 -11
  129. package/dist-esm/lib/primitives/geometry/Rectangle2d.mjs.map +2 -2
  130. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +22 -22
  131. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
  132. package/dist-esm/lib/utils/areShapesContentEqual.mjs +1 -1
  133. package/dist-esm/lib/utils/areShapesContentEqual.mjs.map +2 -2
  134. package/dist-esm/lib/utils/reorderShapes.mjs +11 -10
  135. package/dist-esm/lib/utils/reorderShapes.mjs.map +2 -2
  136. package/dist-esm/lib/utils/richText.mjs.map +1 -1
  137. package/dist-esm/version.mjs +3 -3
  138. package/dist-esm/version.mjs.map +1 -1
  139. package/package.json +7 -7
  140. package/src/index.ts +18 -8
  141. package/src/lib/editor/Editor.test.ts +252 -3
  142. package/src/lib/editor/Editor.ts +47 -75
  143. package/src/lib/editor/derivations/bindingsIndex.ts +27 -26
  144. package/src/lib/editor/derivations/notVisibleShapes.ts +24 -25
  145. package/src/lib/editor/derivations/parentsToChildren.ts +28 -25
  146. package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +442 -0
  147. package/src/lib/editor/managers/{ClickManager.ts → ClickManager/ClickManager.ts} +3 -3
  148. package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +374 -0
  149. package/src/lib/editor/managers/{EdgeScrollManager.ts → EdgeScrollManager/EdgeScrollManager.ts} +3 -3
  150. package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +455 -0
  151. package/src/lib/editor/managers/{FocusManager.ts → FocusManager/FocusManager.ts} +3 -1
  152. package/src/lib/editor/managers/FontManager/FontManager.test.ts +263 -0
  153. package/src/lib/editor/managers/{FontManager.ts → FontManager/FontManager.ts} +6 -2
  154. package/src/lib/editor/managers/{HistoryManager.test.ts → HistoryManager/HistoryManager.test.ts} +388 -1
  155. package/src/lib/editor/managers/{HistoryManager.ts → HistoryManager/HistoryManager.ts} +73 -2
  156. package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +624 -0
  157. package/src/lib/editor/managers/{ScribbleManager.ts → ScribbleManager/ScribbleManager.ts} +2 -2
  158. package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +485 -0
  159. package/src/lib/editor/managers/TextManager/TextManager.test.ts +411 -0
  160. package/src/lib/editor/managers/{TextManager.ts → TextManager/TextManager.ts} +1 -1
  161. package/src/lib/editor/managers/TickManager/TickManager.test.ts +314 -0
  162. package/src/lib/editor/managers/{TickManager.ts → TickManager/TickManager.ts} +2 -2
  163. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +591 -0
  164. package/src/lib/editor/managers/{UserPreferencesManager.ts → UserPreferencesManager/UserPreferencesManager.ts} +2 -2
  165. package/src/lib/editor/shapes/ShapeUtil.ts +10 -1
  166. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +8 -0
  167. package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +5 -2
  168. package/src/lib/exports/getSvgJsx.tsx +1 -1
  169. package/src/lib/primitives/Box.test.ts +588 -7
  170. package/src/lib/primitives/Box.ts +41 -33
  171. package/src/lib/primitives/Vec.test.ts +2 -2
  172. package/src/lib/primitives/Vec.ts +15 -10
  173. package/src/lib/primitives/geometry/Arc2d.ts +42 -23
  174. package/src/lib/primitives/geometry/Circle2d.ts +12 -12
  175. package/src/lib/primitives/geometry/CubicBezier2d.test.ts +5 -0
  176. package/src/lib/primitives/geometry/CubicBezier2d.ts +13 -17
  177. package/src/lib/primitives/geometry/CubicSpline2d.ts +5 -5
  178. package/src/lib/primitives/geometry/Edge2d.ts +14 -25
  179. package/src/lib/primitives/geometry/Ellipse2d.ts +12 -13
  180. package/src/lib/primitives/geometry/Geometry2d.ts +6 -0
  181. package/src/lib/primitives/geometry/Point2d.ts +6 -6
  182. package/src/lib/primitives/geometry/Polygon2d.ts +4 -0
  183. package/src/lib/primitives/geometry/Polyline2d.ts +10 -7
  184. package/src/lib/primitives/geometry/Rectangle2d.ts +24 -11
  185. package/src/lib/primitives/geometry/Stadium2d.ts +22 -23
  186. package/src/lib/utils/areShapesContentEqual.ts +2 -1
  187. package/src/lib/utils/reorderShapes.ts +10 -13
  188. package/src/lib/utils/richText.ts +1 -1
  189. package/src/version.ts +3 -3
  190. package/dist-cjs/lib/editor/managers/ClickManager.js.map +0 -7
  191. package/dist-cjs/lib/editor/managers/EdgeScrollManager.js.map +0 -7
  192. package/dist-cjs/lib/editor/managers/FocusManager.js.map +0 -7
  193. package/dist-cjs/lib/editor/managers/FontManager.js.map +0 -7
  194. package/dist-cjs/lib/editor/managers/HistoryManager.js.map +0 -7
  195. package/dist-cjs/lib/editor/managers/ScribbleManager.js.map +0 -7
  196. package/dist-cjs/lib/editor/managers/Stack.js +0 -82
  197. package/dist-cjs/lib/editor/managers/Stack.js.map +0 -7
  198. package/dist-cjs/lib/editor/managers/TextManager.js.map +0 -7
  199. package/dist-cjs/lib/editor/managers/TickManager.js.map +0 -7
  200. package/dist-cjs/lib/editor/managers/UserPreferencesManager.js.map +0 -7
  201. package/dist-esm/lib/editor/managers/ClickManager.mjs.map +0 -7
  202. package/dist-esm/lib/editor/managers/EdgeScrollManager.mjs.map +0 -7
  203. package/dist-esm/lib/editor/managers/FocusManager.mjs.map +0 -7
  204. package/dist-esm/lib/editor/managers/FontManager.mjs.map +0 -7
  205. package/dist-esm/lib/editor/managers/HistoryManager.mjs.map +0 -7
  206. package/dist-esm/lib/editor/managers/ScribbleManager.mjs.map +0 -7
  207. package/dist-esm/lib/editor/managers/Stack.mjs +0 -62
  208. package/dist-esm/lib/editor/managers/Stack.mjs.map +0 -7
  209. package/dist-esm/lib/editor/managers/TextManager.mjs.map +0 -7
  210. package/dist-esm/lib/editor/managers/TickManager.mjs.map +0 -7
  211. package/dist-esm/lib/editor/managers/UserPreferencesManager.mjs.map +0 -7
  212. package/src/lib/editor/managers/ScribbleManager.test.ts +0 -32
  213. package/src/lib/editor/managers/Stack.ts +0 -71
  214. /package/dist-cjs/lib/editor/managers/{TextManager.js → TextManager/TextManager.js} +0 -0
  215. /package/dist-esm/lib/editor/managers/{TextManager.mjs → TextManager/TextManager.mjs} +0 -0
@@ -25,10 +25,10 @@ var import_Box = require("../Box");
25
25
  var import_Vec = require("../Vec");
26
26
  var import_Polygon2d = require("./Polygon2d");
27
27
  class Rectangle2d extends import_Polygon2d.Polygon2d {
28
- x;
29
- y;
30
- w;
31
- h;
28
+ _x;
29
+ _y;
30
+ _w;
31
+ _h;
32
32
  constructor(config) {
33
33
  const { x = 0, y = 0, width, height } = config;
34
34
  super({
@@ -40,17 +40,28 @@ class Rectangle2d extends import_Polygon2d.Polygon2d {
40
40
  new import_Vec.Vec(x, y + height)
41
41
  ]
42
42
  });
43
- this.x = x;
44
- this.y = y;
45
- this.w = width;
46
- this.h = height;
43
+ this._x = x;
44
+ this._y = y;
45
+ this._w = width;
46
+ this._h = height;
47
47
  }
48
48
  getBounds() {
49
- return new import_Box.Box(this.x, this.y, this.w, this.h);
49
+ return new import_Box.Box(this._x, this._y, this._w, this._h);
50
50
  }
51
51
  getSvgPathData() {
52
- const { x, y, w, h } = this;
53
- return `M${x},${y} h${w} v${h} h-${w}z`;
52
+ const { _x: x, _y: y, _w: w, _h: h } = this;
53
+ this.negativeZeroFix();
54
+ return `M${x},${y} h${w} v${h} h${-w}z`;
54
55
  }
56
+ negativeZeroFix() {
57
+ this._x = zeroFix(this._x);
58
+ this._y = zeroFix(this._y);
59
+ this._w = zeroFix(this._w);
60
+ this._h = zeroFix(this._h);
61
+ }
62
+ }
63
+ function zeroFix(value) {
64
+ if (Object.is(value, -0)) return 0;
65
+ return value;
55
66
  }
56
67
  //# sourceMappingURL=Rectangle2d.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/primitives/geometry/Rectangle2d.ts"],
4
- "sourcesContent": ["import { Box } from '../Box'\nimport { Vec } from '../Vec'\nimport { Geometry2dOptions } from './Geometry2d'\nimport { Polygon2d } from './Polygon2d'\n\n/** @public */\nexport class Rectangle2d extends Polygon2d {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n\n\tconstructor(\n\t\tconfig: Omit<Geometry2dOptions, 'isClosed'> & {\n\t\t\tx?: number\n\t\t\ty?: number\n\t\t\twidth: number\n\t\t\theight: number\n\t\t}\n\t) {\n\t\tconst { x = 0, y = 0, width, height } = config\n\t\tsuper({\n\t\t\t...config,\n\t\t\tpoints: [\n\t\t\t\tnew Vec(x, y),\n\t\t\t\tnew Vec(x + width, y),\n\t\t\t\tnew Vec(x + width, y + height),\n\t\t\t\tnew Vec(x, y + height),\n\t\t\t],\n\t\t})\n\t\tthis.x = x\n\t\tthis.y = y\n\t\tthis.w = width\n\t\tthis.h = height\n\t}\n\n\tgetBounds() {\n\t\treturn new Box(this.x, this.y, this.w, this.h)\n\t}\n\n\tgetSvgPathData(): string {\n\t\tconst { x, y, w, h } = this\n\t\treturn `M${x},${y} h${w} v${h} h-${w}z`\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,iBAAoB;AAEpB,uBAA0B;AAGnB,MAAM,oBAAoB,2BAAU;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YACC,QAMC;AACD,UAAM,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,OAAO,IAAI;AACxC,UAAM;AAAA,MACL,GAAG;AAAA,MACH,QAAQ;AAAA,QACP,IAAI,eAAI,GAAG,CAAC;AAAA,QACZ,IAAI,eAAI,IAAI,OAAO,CAAC;AAAA,QACpB,IAAI,eAAI,IAAI,OAAO,IAAI,MAAM;AAAA,QAC7B,IAAI,eAAI,GAAG,IAAI,MAAM;AAAA,MACtB;AAAA,IACD,CAAC;AACD,SAAK,IAAI;AACT,SAAK,IAAI;AACT,SAAK,IAAI;AACT,SAAK,IAAI;AAAA,EACV;AAAA,EAEA,YAAY;AACX,WAAO,IAAI,eAAI,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAAA,EAC9C;AAAA,EAEA,iBAAyB;AACxB,UAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI;AACvB,WAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;AAAA,EACrC;AACD;",
4
+ "sourcesContent": ["import { Box } from '../Box'\nimport { Vec } from '../Vec'\nimport { Geometry2dOptions } from './Geometry2d'\nimport { Polygon2d } from './Polygon2d'\n\n/** @public */\nexport class Rectangle2d extends Polygon2d {\n\tprivate _x: number\n\tprivate _y: number\n\tprivate _w: number\n\tprivate _h: number\n\n\tconstructor(\n\t\tconfig: Omit<Geometry2dOptions, 'isClosed'> & {\n\t\t\tx?: number\n\t\t\ty?: number\n\t\t\twidth: number\n\t\t\theight: number\n\t\t}\n\t) {\n\t\tconst { x = 0, y = 0, width, height } = config\n\t\tsuper({\n\t\t\t...config,\n\t\t\tpoints: [\n\t\t\t\tnew Vec(x, y),\n\t\t\t\tnew Vec(x + width, y),\n\t\t\t\tnew Vec(x + width, y + height),\n\t\t\t\tnew Vec(x, y + height),\n\t\t\t],\n\t\t})\n\t\tthis._x = x\n\t\tthis._y = y\n\t\tthis._w = width\n\t\tthis._h = height\n\t}\n\n\tgetBounds() {\n\t\treturn new Box(this._x, this._y, this._w, this._h)\n\t}\n\n\tgetSvgPathData(): string {\n\t\tconst { _x: x, _y: y, _w: w, _h: h } = this\n\t\tthis.negativeZeroFix()\n\t\treturn `M${x},${y} h${w} v${h} h${-w}z`\n\t}\n\n\tprivate negativeZeroFix() {\n\t\tthis._x = zeroFix(this._x)\n\t\tthis._y = zeroFix(this._y)\n\t\tthis._w = zeroFix(this._w)\n\t\tthis._h = zeroFix(this._h)\n\t}\n}\n\nfunction zeroFix(value: number) {\n\tif (Object.is(value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,58 @@ class Stadium2d extends import_Geometry2d.Geometry2d {
32
32
  super({ ...config, isClosed: true });
33
33
  this.config = config;
34
34
  const { width: w, height: h } = config;
35
- this.w = w;
36
- this.h = h;
35
+ this._w = w;
36
+ this._h = h;
37
37
  if (h > w) {
38
38
  const r = w / 2;
39
- this.a = new import_Arc2d.Arc2d({
39
+ this._a = new import_Arc2d.Arc2d({
40
40
  start: new import_Vec.Vec(0, r),
41
41
  end: new import_Vec.Vec(w, r),
42
42
  center: new import_Vec.Vec(w / 2, r),
43
43
  sweepFlag: 1,
44
44
  largeArcFlag: 1
45
45
  });
46
- this.b = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(w, r), end: new import_Vec.Vec(w, h - r) });
47
- this.c = new import_Arc2d.Arc2d({
46
+ this._b = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(w, r), end: new import_Vec.Vec(w, h - r) });
47
+ this._c = new import_Arc2d.Arc2d({
48
48
  start: new import_Vec.Vec(w, h - r),
49
49
  end: new import_Vec.Vec(0, h - r),
50
50
  center: new import_Vec.Vec(w / 2, h - r),
51
51
  sweepFlag: 1,
52
52
  largeArcFlag: 1
53
53
  });
54
- this.d = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(0, h - r), end: new import_Vec.Vec(0, r) });
54
+ this._d = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(0, h - r), end: new import_Vec.Vec(0, r) });
55
55
  } else {
56
56
  const r = h / 2;
57
- this.a = new import_Arc2d.Arc2d({
57
+ this._a = new import_Arc2d.Arc2d({
58
58
  start: new import_Vec.Vec(r, h),
59
59
  end: new import_Vec.Vec(r, 0),
60
60
  center: new import_Vec.Vec(r, r),
61
61
  sweepFlag: 1,
62
62
  largeArcFlag: 1
63
63
  });
64
- this.b = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(r, 0), end: new import_Vec.Vec(w - r, 0) });
65
- this.c = new import_Arc2d.Arc2d({
64
+ this._b = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(r, 0), end: new import_Vec.Vec(w - r, 0) });
65
+ this._c = new import_Arc2d.Arc2d({
66
66
  start: new import_Vec.Vec(w - r, 0),
67
67
  end: new import_Vec.Vec(w - r, h),
68
68
  center: new import_Vec.Vec(w - r, r),
69
69
  sweepFlag: 1,
70
70
  largeArcFlag: 1
71
71
  });
72
- this.d = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(w - r, h), end: new import_Vec.Vec(r, h) });
72
+ this._d = new import_Edge2d.Edge2d({ start: new import_Vec.Vec(w - r, h), end: new import_Vec.Vec(r, h) });
73
73
  }
74
74
  }
75
- w;
76
- h;
77
- a;
78
- b;
79
- c;
80
- d;
75
+ _w;
76
+ _h;
77
+ _a;
78
+ _b;
79
+ _c;
80
+ _d;
81
81
  nearestPoint(A) {
82
82
  let nearest;
83
83
  let dist = Infinity;
84
84
  let _d;
85
85
  let p;
86
- const { a, b, c, d } = this;
86
+ const { _a: a, _b: b, _c: c, _d: d } = this;
87
87
  for (const part of [a, b, c, d]) {
88
88
  p = part.nearestPoint(A);
89
89
  _d = import_Vec.Vec.Dist2(p, A);
@@ -96,26 +96,26 @@ class Stadium2d extends import_Geometry2d.Geometry2d {
96
96
  return nearest;
97
97
  }
98
98
  hitTestLineSegment(A, B) {
99
- const { a, b, c, d } = this;
99
+ const { _a: a, _b: b, _c: c, _d: d } = this;
100
100
  return [a, b, c, d].some((edge) => edge.hitTestLineSegment(A, B));
101
101
  }
102
102
  getVertices() {
103
- const { a, b, c, d } = this;
103
+ const { _a: a, _b: b, _c: c, _d: d } = this;
104
104
  return [a, b, c, d].reduce((a2, p) => {
105
105
  a2.push(...p.vertices);
106
106
  return a2;
107
107
  }, []);
108
108
  }
109
109
  getBounds() {
110
- return new import_Box.Box(0, 0, this.w, this.h);
110
+ return new import_Box.Box(0, 0, this._w, this._h);
111
111
  }
112
112
  getLength() {
113
- const { h, w } = this;
113
+ const { _h: h, _w: w } = this;
114
114
  if (h > w) return (import_utils.PI * (w / 2) + (h - w)) * 2;
115
115
  else return (import_utils.PI * (h / 2) + (w - h)) * 2;
116
116
  }
117
117
  getSvgPathData() {
118
- const { a, b, c, d } = this;
118
+ const { _a: a, _b: b, _c: c, _d: d } = this;
119
119
  return [a, b, c, d].map((p, i) => p.getSvgPathData(i === 0)).join(" ") + " Z";
120
120
  }
121
121
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/primitives/geometry/Stadium2d.ts"],
4
- "sourcesContent": ["import { Box } from '../Box'\nimport { Vec, VecLike } from '../Vec'\nimport { PI } from '../utils'\nimport { Arc2d } from './Arc2d'\nimport { Edge2d } from './Edge2d'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Stadium2d extends Geometry2d {\n\tw: number\n\th: number\n\n\ta: Arc2d\n\tb: Edge2d\n\tc: Arc2d\n\td: Edge2d\n\n\tconstructor(\n\t\tpublic config: Omit<Geometry2dOptions, 'isClosed'> & {\n\t\t\twidth: number\n\t\t\theight: number\n\t\t}\n\t) {\n\t\tsuper({ ...config, isClosed: true })\n\t\tconst { width: w, height: h } = config\n\t\tthis.w = w\n\t\tthis.h = h\n\n\t\tif (h > w) {\n\t\t\tconst r = w / 2\n\t\t\tthis.a = new Arc2d({\n\t\t\t\tstart: new Vec(0, r),\n\t\t\t\tend: new Vec(w, r),\n\t\t\t\tcenter: new Vec(w / 2, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis.b = new Edge2d({ start: new Vec(w, r), end: new Vec(w, h - r) })\n\t\t\tthis.c = new Arc2d({\n\t\t\t\tstart: new Vec(w, h - r),\n\t\t\t\tend: new Vec(0, h - r),\n\t\t\t\tcenter: new Vec(w / 2, h - r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis.d = new Edge2d({ start: new Vec(0, h - r), end: new Vec(0, r) })\n\t\t} else {\n\t\t\tconst r = h / 2\n\t\t\tthis.a = new Arc2d({\n\t\t\t\tstart: new Vec(r, h),\n\t\t\t\tend: new Vec(r, 0),\n\t\t\t\tcenter: new Vec(r, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis.b = new Edge2d({ start: new Vec(r, 0), end: new Vec(w - r, 0) })\n\t\t\tthis.c = new Arc2d({\n\t\t\t\tstart: new Vec(w - r, 0),\n\t\t\t\tend: new Vec(w - r, h),\n\t\t\t\tcenter: new Vec(w - r, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis.d = new Edge2d({ start: new Vec(w - r, h), end: new Vec(r, h) })\n\t\t}\n\t}\n\n\tnearestPoint(A: VecLike): Vec {\n\t\tlet nearest: Vec | undefined\n\t\tlet dist = Infinity\n\t\tlet _d: number\n\t\tlet p: Vec\n\n\t\tconst { a, b, c, d } = this\n\t\tfor (const part of [a, b, c, d]) {\n\t\t\tp = part.nearestPoint(A)\n\t\t\t_d = Vec.Dist2(p, A)\n\t\t\tif (_d < dist) {\n\t\t\t\tnearest = p\n\t\t\t\tdist = _d\n\t\t\t}\n\t\t}\n\t\tif (!nearest) throw Error('nearest point not found')\n\t\treturn nearest\n\t}\n\n\thitTestLineSegment(A: VecLike, B: VecLike): boolean {\n\t\tconst { a, b, c, d } = this\n\t\treturn [a, b, c, d].some((edge) => edge.hitTestLineSegment(A, B))\n\t}\n\n\tgetVertices() {\n\t\tconst { a, b, c, d } = this\n\t\treturn [a, b, c, d].reduce<Vec[]>((a, p) => {\n\t\t\ta.push(...p.vertices)\n\t\t\treturn a\n\t\t}, [])\n\t}\n\n\tgetBounds() {\n\t\treturn new Box(0, 0, this.w, this.h)\n\t}\n\n\tgetLength() {\n\t\tconst { h, w } = this\n\t\tif (h > w) return (PI * (w / 2) + (h - w)) * 2\n\t\telse return (PI * (h / 2) + (w - h)) * 2\n\t}\n\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AAE,IAAI;AACvB,WAAO,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,KAAK,mBAAmB,GAAG,CAAC,CAAC;AAAA,EACjE;AAAA,EAEA,cAAc;AACb,UAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI;AACvB,WAAO,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,OAAc,CAACA,IAAG,MAAM;AAC3C,MAAAA,GAAE,KAAK,GAAG,EAAE,QAAQ;AACpB,aAAOA;AAAA,IACR,GAAG,CAAC,CAAC;AAAA,EACN;AAAA,EAEA,YAAY;AACX,WAAO,IAAI,eAAI,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC;AAAA,EACpC;AAAA,EAEA,YAAY;AACX,UAAM,EAAE,GAAG,EAAE,IAAI;AACjB,QAAI,IAAI,EAAG,SAAQ,mBAAM,IAAI,MAAM,IAAI,MAAM;AAAA,QACxC,SAAQ,mBAAM,IAAI,MAAM,IAAI,MAAM;AAAA,EACxC;AAAA,EAEA,iBAAiB;AAChB,UAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI;AACvB,WAAO,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,EAAE,eAAe,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;AAAA,EAC1E;AACD;",
4
+ "sourcesContent": ["import { Box } from '../Box'\nimport { Vec, VecLike } from '../Vec'\nimport { PI } from '../utils'\nimport { Arc2d } from './Arc2d'\nimport { Edge2d } from './Edge2d'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Stadium2d extends Geometry2d {\n\tprivate _w: number\n\tprivate _h: number\n\tprivate _a: Arc2d\n\tprivate _b: Edge2d\n\tprivate _c: Arc2d\n\tprivate _d: Edge2d\n\n\tconstructor(\n\t\tpublic config: Omit<Geometry2dOptions, 'isClosed'> & {\n\t\t\twidth: number\n\t\t\theight: number\n\t\t}\n\t) {\n\t\tsuper({ ...config, isClosed: true })\n\t\tconst { width: w, height: h } = config\n\t\tthis._w = w\n\t\tthis._h = h\n\n\t\tif (h > w) {\n\t\t\tconst r = w / 2\n\t\t\tthis._a = new Arc2d({\n\t\t\t\tstart: new Vec(0, r),\n\t\t\t\tend: new Vec(w, r),\n\t\t\t\tcenter: new Vec(w / 2, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._b = new Edge2d({ start: new Vec(w, r), end: new Vec(w, h - r) })\n\t\t\tthis._c = new Arc2d({\n\t\t\t\tstart: new Vec(w, h - r),\n\t\t\t\tend: new Vec(0, h - r),\n\t\t\t\tcenter: new Vec(w / 2, h - r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._d = new Edge2d({ start: new Vec(0, h - r), end: new Vec(0, r) })\n\t\t} else {\n\t\t\tconst r = h / 2\n\t\t\tthis._a = new Arc2d({\n\t\t\t\tstart: new Vec(r, h),\n\t\t\t\tend: new Vec(r, 0),\n\t\t\t\tcenter: new Vec(r, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._b = new Edge2d({ start: new Vec(r, 0), end: new Vec(w - r, 0) })\n\t\t\tthis._c = new Arc2d({\n\t\t\t\tstart: new Vec(w - r, 0),\n\t\t\t\tend: new Vec(w - r, h),\n\t\t\t\tcenter: new Vec(w - r, r),\n\t\t\t\tsweepFlag: 1,\n\t\t\t\tlargeArcFlag: 1,\n\t\t\t})\n\t\t\tthis._d = new Edge2d({ start: new Vec(w - r, h), end: new Vec(r, h) })\n\t\t}\n\t}\n\n\tnearestPoint(A: VecLike): Vec {\n\t\tlet nearest: Vec | undefined\n\t\tlet dist = Infinity\n\t\tlet _d: number\n\t\tlet p: Vec\n\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\tfor (const part of [a, b, c, d]) {\n\t\t\tp = part.nearestPoint(A)\n\t\t\t_d = Vec.Dist2(p, A)\n\t\t\tif (_d < dist) {\n\t\t\t\tnearest = p\n\t\t\t\tdist = _d\n\t\t\t}\n\t\t}\n\t\tif (!nearest) throw Error('nearest point not found')\n\t\treturn nearest\n\t}\n\n\thitTestLineSegment(A: VecLike, B: VecLike): boolean {\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\treturn [a, b, c, d].some((edge) => edge.hitTestLineSegment(A, B))\n\t}\n\n\tgetVertices() {\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\treturn [a, b, c, d].reduce<Vec[]>((a, p) => {\n\t\t\ta.push(...p.vertices)\n\t\t\treturn a\n\t\t}, [])\n\t}\n\n\tgetBounds() {\n\t\treturn new Box(0, 0, this._w, this._h)\n\t}\n\n\tgetLength() {\n\t\tconst { _h: h, _w: w } = this\n\t\tif (h > w) return (PI * (w / 2) + (h - w)) * 2\n\t\telse return (PI * (h / 2) + (w - h)) * 2\n\t}\n\n\tgetSvgPathData() {\n\t\tconst { _a: a, _b: b, _c: c, _d: d } = this\n\t\treturn [a, b, c, d].map((p, i) => p.getSvgPathData(i === 0)).join(' ') + ' Z'\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;AACpB,iBAA6B;AAC7B,mBAAmB;AACnB,mBAAsB;AACtB,oBAAuB;AACvB,wBAA8C;AAGvC,MAAM,kBAAkB,6BAAW;AAAA,EAQzC,YACQ,QAIN;AACD,UAAM,EAAE,GAAG,QAAQ,UAAU,KAAK,CAAC;AAL5B;AAMP,UAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,IAAI;AAChC,SAAK,KAAK;AACV,SAAK,KAAK;AAEV,QAAI,IAAI,GAAG;AACV,YAAM,IAAI,IAAI;AACd,WAAK,KAAK,IAAI,mBAAM;AAAA,QACnB,OAAO,IAAI,eAAI,GAAG,CAAC;AAAA,Q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AACzB,QAAI,IAAI,EAAG,SAAQ,mBAAM,IAAI,MAAM,IAAI,MAAM;AAAA,QACxC,SAAQ,mBAAM,IAAI,MAAM,IAAI,MAAM;AAAA,EACxC;AAAA,EAEA,iBAAiB;AAChB,UAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,IAAI;AACvC,WAAO,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,EAAE,eAAe,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;AAAA,EAC1E;AACD;",
6
6
  "names": ["a"]
7
7
  }
@@ -21,5 +21,5 @@ __export(areShapesContentEqual_exports, {
21
21
  areShapesContentEqual: () => areShapesContentEqual
22
22
  });
23
23
  module.exports = __toCommonJS(areShapesContentEqual_exports);
24
- const areShapesContentEqual = (a, b) => a.props === b.props && a.meta === b.meta;
24
+ const areShapesContentEqual = (a, b) => a.parentId === b.parentId && a.props === b.props && a.meta === b.meta;
25
25
  //# sourceMappingURL=areShapesContentEqual.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/areShapesContentEqual.ts"],
4
- "sourcesContent": ["import { TLShape } from '@tldraw/tlschema'\n\nexport const areShapesContentEqual = (a: TLShape, b: TLShape) =>\n\ta.props === b.props && a.meta === b.meta\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,wBAAwB,CAAC,GAAY,MACjD,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE;",
4
+ "sourcesContent": ["import { TLShape } from '@tldraw/tlschema'\n\n/** @public */\nexport const areShapesContentEqual = (a: TLShape, b: TLShape) =>\n\ta.parentId === b.parentId && a.props === b.props && a.meta === b.meta\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,wBAAwB,CAAC,GAAY,MACjD,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE;",
6
6
  "names": []
7
7
  }
@@ -22,7 +22,6 @@ __export(reorderShapes_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(reorderShapes_exports);
24
24
  var import_utils = require("@tldraw/utils");
25
- var import_intersect = require("../primitives/intersect");
26
25
  function getReorderingShapesChanges(editor, operation, ids, opts) {
27
26
  if (ids.length === 0) return [];
28
27
  const parents = /* @__PURE__ */ new Map();
@@ -112,16 +111,18 @@ function reorderToFront(moving, children, changes) {
112
111
  }
113
112
  }
114
113
  function getOverlapChecker(editor, moving) {
115
- const movingVertices = Array.from(moving).map((shape) => {
116
- const vertices = editor.getShapePageGeometry(shape).vertices;
117
- if (!vertices) return null;
118
- return { shape, vertices };
119
- }).filter(Boolean);
114
+ const movingBounds = (0, import_utils.compact)(
115
+ Array.from(moving).map((shape) => {
116
+ const bounds = editor.getShapePageBounds(shape);
117
+ if (!bounds) return null;
118
+ return { shape, bounds };
119
+ })
120
+ );
120
121
  const isOverlapping = (child) => {
121
- const vertices = editor.getShapePageGeometry(child).vertices;
122
- if (!vertices) return false;
123
- return movingVertices.some((other) => {
124
- return (0, import_intersect.polygonsIntersect)(other.vertices, vertices);
122
+ const bounds = editor.getShapePageBounds(child);
123
+ if (!bounds) return false;
124
+ return movingBounds.some((other) => {
125
+ return other.bounds.includes(bounds);
125
126
  });
126
127
  };
127
128
  return isOverlapping;
@@ -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,KAAK,UAAU;AACd,cAAQ,QAAQ,CAAC,EAAE,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,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,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC,CAAC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,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
  }
@@ -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"],
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/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
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;",
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.e7ebd007cb8c";
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-08T22:30:14.059Z",
29
+ patch: "2025-06-08T22:30:14.059Z"
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.e7ebd007cb8c'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-06-08T22:30:14.059Z',\n\tpatch: '2025-06-08T22:30:14.059Z',\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
  }