@openmaic/renderer 0.0.1 → 0.0.3

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 (175) hide show
  1. package/DESIGN.md +7 -1
  2. package/README.md +11 -3
  3. package/dist/SlideCanvas.d.ts +12 -1
  4. package/dist/SlideCanvas.js +105 -0
  5. package/dist/SlideCanvas.js.map +1 -0
  6. package/dist/SlideElement.d.ts +3 -2
  7. package/dist/SlideElement.js +60 -0
  8. package/dist/SlideElement.js.map +1 -0
  9. package/dist/context.d.ts +2 -1
  10. package/dist/context.js +27 -0
  11. package/dist/context.js.map +1 -0
  12. package/dist/editing/EditableSlideCanvas.d.ts +26 -0
  13. package/dist/editing/EditableSlideCanvas.js +352 -0
  14. package/dist/editing/EditableSlideCanvas.js.map +1 -0
  15. package/dist/editing/core/drag.d.ts +108 -0
  16. package/dist/editing/core/drag.js +119 -0
  17. package/dist/editing/core/drag.js.map +1 -0
  18. package/dist/editing/core/geometry.d.ts +48 -0
  19. package/dist/editing/core/geometry.js +186 -0
  20. package/dist/editing/core/geometry.js.map +1 -0
  21. package/dist/editing/core/intent.d.ts +39 -0
  22. package/dist/editing/core/intent.js +35 -0
  23. package/dist/editing/core/intent.js.map +1 -0
  24. package/dist/editing/core/line-drag.d.ts +19 -0
  25. package/dist/editing/core/line-drag.js +163 -0
  26. package/dist/editing/core/line-drag.js.map +1 -0
  27. package/dist/editing/core/marquee.d.ts +56 -0
  28. package/dist/editing/core/marquee.js +74 -0
  29. package/dist/editing/core/marquee.js.map +1 -0
  30. package/dist/editing/core/resize.d.ts +121 -0
  31. package/dist/editing/core/resize.js +392 -0
  32. package/dist/editing/core/resize.js.map +1 -0
  33. package/dist/editing/core/rotate.d.ts +37 -0
  34. package/dist/editing/core/rotate.js +74 -0
  35. package/dist/editing/core/rotate.js.map +1 -0
  36. package/dist/editing/core/selection.d.ts +68 -0
  37. package/dist/editing/core/selection.js +108 -0
  38. package/dist/editing/core/selection.js.map +1 -0
  39. package/dist/editing/core/snapping.d.ts +54 -0
  40. package/dist/editing/core/snapping.js +96 -0
  41. package/dist/editing/core/snapping.js.map +1 -0
  42. package/dist/editing/handles/BorderLine.d.ts +15 -0
  43. package/dist/editing/handles/BorderLine.js +17 -0
  44. package/dist/editing/handles/BorderLine.js.map +1 -0
  45. package/dist/editing/handles/LineHandles.d.ts +28 -0
  46. package/dist/editing/handles/LineHandles.js +51 -0
  47. package/dist/editing/handles/LineHandles.js.map +1 -0
  48. package/dist/editing/handles/MarqueeBox.d.ts +19 -0
  49. package/dist/editing/handles/MarqueeBox.js +26 -0
  50. package/dist/editing/handles/MarqueeBox.js.map +1 -0
  51. package/dist/editing/handles/ResizeHandles.d.ts +31 -0
  52. package/dist/editing/handles/ResizeHandles.js +44 -0
  53. package/dist/editing/handles/ResizeHandles.js.map +1 -0
  54. package/dist/editing/handles/RotateHandle.d.ts +26 -0
  55. package/dist/editing/handles/RotateHandle.js +52 -0
  56. package/dist/editing/handles/RotateHandle.js.map +1 -0
  57. package/dist/editing/handles/SelectionOverlay.d.ts +18 -0
  58. package/dist/editing/handles/SelectionOverlay.js +35 -0
  59. package/dist/editing/handles/SelectionOverlay.js.map +1 -0
  60. package/dist/editing/index.d.ts +3 -0
  61. package/dist/editing/index.js +4 -0
  62. package/dist/editing/index.js.map +1 -0
  63. package/dist/editing/types.d.ts +107 -0
  64. package/dist/editing/types.js +7 -0
  65. package/dist/editing/types.js.map +1 -0
  66. package/dist/editing/useEditGesture.d.ts +46 -0
  67. package/dist/editing/useEditGesture.js +217 -0
  68. package/dist/editing/useEditGesture.js.map +1 -0
  69. package/dist/editing/useLineHandleGesture.d.ts +35 -0
  70. package/dist/editing/useLineHandleGesture.js +112 -0
  71. package/dist/editing/useLineHandleGesture.js.map +1 -0
  72. package/dist/editing/useMarqueeGesture.d.ts +43 -0
  73. package/dist/editing/useMarqueeGesture.js +157 -0
  74. package/dist/editing/useMarqueeGesture.js.map +1 -0
  75. package/dist/editing/useResizeGesture.d.ts +43 -0
  76. package/dist/editing/useResizeGesture.js +137 -0
  77. package/dist/editing/useResizeGesture.js.map +1 -0
  78. package/dist/editing/useRotateGesture.d.ts +47 -0
  79. package/dist/editing/useRotateGesture.js +128 -0
  80. package/dist/editing/useRotateGesture.js.map +1 -0
  81. package/dist/effects/HighlightOverlay.js +44 -0
  82. package/dist/effects/HighlightOverlay.js.map +1 -0
  83. package/dist/effects/LaserOverlay.js +40 -0
  84. package/dist/effects/LaserOverlay.js.map +1 -0
  85. package/dist/effects/SpotlightOverlay.d.ts +3 -1
  86. package/dist/effects/SpotlightOverlay.js +99 -0
  87. package/dist/effects/SpotlightOverlay.js.map +1 -0
  88. package/dist/effects/ZoomWrapper.js +19 -0
  89. package/dist/effects/ZoomWrapper.js.map +1 -0
  90. package/dist/elements/chart/BaseChartElement.js +22 -0
  91. package/dist/elements/chart/BaseChartElement.js.map +1 -0
  92. package/dist/elements/chart/Chart.js +83 -0
  93. package/dist/elements/chart/Chart.js.map +1 -0
  94. package/dist/elements/chart/chartOption.js +178 -0
  95. package/dist/elements/chart/chartOption.js.map +1 -0
  96. package/dist/elements/code/BaseCodeElement.js +525 -0
  97. package/dist/elements/code/BaseCodeElement.js.map +1 -0
  98. package/dist/elements/image/BaseImageElement.d.ts +4 -4
  99. package/dist/elements/image/BaseImageElement.js +76 -0
  100. package/dist/elements/image/BaseImageElement.js.map +1 -0
  101. package/dist/elements/image/ImageOutline.js +30 -0
  102. package/dist/elements/image/ImageOutline.js.map +1 -0
  103. package/dist/elements/image/clipPaths.js +130 -0
  104. package/dist/elements/image/clipPaths.js.map +1 -0
  105. package/dist/elements/image/useClipImage.js +40 -0
  106. package/dist/elements/image/useClipImage.js.map +1 -0
  107. package/dist/elements/image/useFilter.d.ts +1 -0
  108. package/dist/elements/image/useFilter.js +35 -0
  109. package/dist/elements/image/useFilter.js.map +1 -0
  110. package/dist/elements/index.js +14 -9
  111. package/dist/elements/index.js.map +1 -1
  112. package/dist/elements/latex/BaseLatexElement.js +94 -0
  113. package/dist/elements/latex/BaseLatexElement.js.map +1 -0
  114. package/dist/elements/line/BaseLineElement.js +72 -0
  115. package/dist/elements/line/BaseLineElement.js.map +1 -0
  116. package/dist/elements/line/LinePointMarker.js +19 -0
  117. package/dist/elements/line/LinePointMarker.js.map +1 -0
  118. package/dist/elements/shape/BaseShapeElement.js +174 -0
  119. package/dist/elements/shape/BaseShapeElement.js.map +1 -0
  120. package/dist/elements/shape/GradientDefs.js +11 -0
  121. package/dist/elements/shape/GradientDefs.js.map +1 -0
  122. package/dist/elements/shape/PatternDefs.js +8 -0
  123. package/dist/elements/shape/PatternDefs.js.map +1 -0
  124. package/dist/elements/shared/ElementOutline.js +13 -0
  125. package/dist/elements/shared/ElementOutline.js.map +1 -0
  126. package/dist/elements/shared/useElementFill.js +15 -0
  127. package/dist/elements/shared/useElementFill.js.map +1 -0
  128. package/dist/elements/shared/useElementFlip.js +18 -0
  129. package/dist/elements/shared/useElementFlip.js.map +1 -0
  130. package/dist/elements/shared/useElementOutline.js +19 -0
  131. package/dist/elements/shared/useElementOutline.js.map +1 -0
  132. package/dist/elements/shared/useElementShadow.js +15 -0
  133. package/dist/elements/shared/useElementShadow.js.map +1 -0
  134. package/dist/elements/table/BaseTableElement.js +21 -0
  135. package/dist/elements/table/BaseTableElement.js.map +1 -0
  136. package/dist/elements/table/StaticTable.js +117 -0
  137. package/dist/elements/table/StaticTable.js.map +1 -0
  138. package/dist/elements/table/tableUtils.js +28 -0
  139. package/dist/elements/table/tableUtils.js.map +1 -0
  140. package/dist/elements/text/BaseTextElement.js +46 -0
  141. package/dist/elements/text/BaseTextElement.js.map +1 -0
  142. package/dist/elements/video/BaseVideoElement.d.ts +3 -1
  143. package/dist/elements/video/BaseVideoElement.js +36 -0
  144. package/dist/elements/video/BaseVideoElement.js.map +1 -0
  145. package/dist/hooks/useSlideBackgroundStyle.js +43 -0
  146. package/dist/hooks/useSlideBackgroundStyle.js.map +1 -0
  147. package/dist/hooks/useViewportSize.d.ts +2 -0
  148. package/dist/hooks/useViewportSize.js +71 -0
  149. package/dist/hooks/useViewportSize.js.map +1 -0
  150. package/dist/index.js +11 -31
  151. package/dist/index.js.map +1 -1
  152. package/dist/snapshot/index.d.ts +1 -0
  153. package/dist/snapshot/index.js +93 -28
  154. package/dist/snapshot/index.js.map +1 -1
  155. package/dist/snapshot/katex-fonts-embed.d.ts +10 -0
  156. package/dist/snapshot/katex-fonts-embed.js +13 -0
  157. package/dist/snapshot/katex-fonts-embed.js.map +1 -0
  158. package/dist/snapshot/measure.d.ts +32 -0
  159. package/dist/snapshot/measure.js +129 -0
  160. package/dist/snapshot/measure.js.map +1 -0
  161. package/dist/styles.js +50 -0
  162. package/dist/styles.js.map +1 -0
  163. package/dist/types/effects.d.ts +2 -0
  164. package/dist/utils/cn.js +9 -0
  165. package/dist/utils/cn.js.map +1 -0
  166. package/dist/utils/element.js +85 -0
  167. package/dist/utils/element.js.map +1 -0
  168. package/dist/utils/geometry.d.ts +2 -2
  169. package/dist/utils/geometry.js +44 -0
  170. package/dist/utils/geometry.js.map +1 -0
  171. package/package.json +19 -4
  172. package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js +0 -1742
  173. package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js.map +0 -1
  174. package/dist/chunks/SlideCanvas-BwlcjqMl.js +0 -469
  175. package/dist/chunks/SlideCanvas-BwlcjqMl.js.map +0 -1
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Pure click-selection resolution for the editing surface, shared by every
3
+ * pointer-down entry point (box hit targets and line stroke blockers) so all
4
+ * element kinds resolve modifiers and groups identically. No React, no store,
5
+ * no `@/` imports — plain data in, plain data out.
6
+ */
7
+ /** True when a click/drag selection modifier (Ctrl/Shift/Meta) is held. Meta is
8
+ * included for mac parity with the resize aspect modifier — a deliberate
9
+ * superset of the app's Ctrl/Shift. */
10
+ function isSelectionModifier(e) {
11
+ return e.ctrlKey || e.shiftKey || e.metaKey;
12
+ }
13
+ /** Dedup ids preserving first-seen order (no lodash dep in this package). */
14
+ function uniqIds(ids) {
15
+ return Array.from(new Set(ids));
16
+ }
17
+ /** Exact ordered id-list equality for no-op emit guards. */
18
+ function sameIds(a, b) {
19
+ return a.length === b.length && a.every((id, index) => id === b[index]);
20
+ }
21
+ /**
22
+ * The clicked element's cohesion unit: every member of its group (in element
23
+ * order), or just the element itself when ungrouped. Group cohesion is
24
+ * all-or-nothing at the click entry point too (app parity): selecting,
25
+ * adding, or removing a grouped element always applies to the whole group,
26
+ * so a group can never be half-selected by clicking. Locked members are
27
+ * included — they may sit in the selection for feedback; the drag layer is
28
+ * responsible for never translating them.
29
+ */
30
+ function groupMemberIds(el, elements) {
31
+ if (!el.groupId)
32
+ return [el.id];
33
+ const members = elements.filter((o) => o.groupId === el.groupId).map((o) => o.id);
34
+ return members.length > 0 ? members : [el.id];
35
+ }
36
+ /**
37
+ * Group-close a host-provided selection: every known selected element expands
38
+ * to its full group unit, while unknown ids are preserved in-place. This keeps
39
+ * externally controlled selection state from leaking a split group into click
40
+ * resolution or into the drag set it returns.
41
+ */
42
+ function closeSelectionGroupIds(ids, elements) {
43
+ const byId = new Map(elements.map((el) => [el.id, el]));
44
+ const closed = [];
45
+ for (const id of ids) {
46
+ const el = byId.get(id);
47
+ closed.push(...(el ? groupMemberIds(el, elements) : [id]));
48
+ }
49
+ return uniqIds(closed);
50
+ }
51
+ /**
52
+ * Resolve a pointer-down on element `el` against the current `selection` per
53
+ * the modifier table (group-cohesive — `el` expands to its whole group unit):
54
+ * - not selected, no modifier → select only the unit (primary = clicked);
55
+ * arm a drag on it.
56
+ * - not selected, modifier → ADD the unit to the selection (uniq,
57
+ * primary = clicked); no drag.
58
+ * - selected, modifier → REMOVE the unit; no-op if that would empty
59
+ * the selection; the current primary is preserved when it survives the
60
+ * removal, else the last remaining id becomes primary. No drag.
61
+ * - selected, no modifier → KEEP the whole selection, make the clicked
62
+ * element the primary (no emit when it already is), and arm a drag that
63
+ * translates every selected element.
64
+ *
65
+ * Invariant: this resolver never returns a selection or armed drag set that
66
+ * splits a group, even when the incoming controlled selection already does.
67
+ */
68
+ function resolveClickSelection(input) {
69
+ const { element: el, elements, selection, modifier } = input;
70
+ const rawIds = selection.elementIds;
71
+ const ids = closeSelectionGroupIds(rawIds, elements);
72
+ const inSelection = ids.includes(el.id);
73
+ const unit = groupMemberIds(el, elements);
74
+ if (!inSelection && !modifier) {
75
+ return { next: { elementIds: unit, primaryId: el.id }, armDrag: true, dragIds: unit };
76
+ }
77
+ if (!inSelection && modifier) {
78
+ return {
79
+ next: { elementIds: uniqIds([...ids, ...unit]), primaryId: el.id },
80
+ armDrag: false,
81
+ dragIds: unit,
82
+ };
83
+ }
84
+ if (inSelection && modifier) {
85
+ const removed = new Set(unit);
86
+ const remaining = ids.filter((id) => !removed.has(id));
87
+ // A modifier click must never clear the selection to empty.
88
+ if (remaining.length === 0)
89
+ return { next: null, armDrag: false, dragIds: unit };
90
+ const primaryId = selection.primaryId !== undefined && remaining.includes(selection.primaryId)
91
+ ? selection.primaryId
92
+ : remaining[remaining.length - 1];
93
+ return { next: { elementIds: remaining, primaryId }, armDrag: false, dragIds: unit };
94
+ }
95
+ // Already selected, no modifier: keep the whole selection, re-point the
96
+ // primary at the clicked element. Skip the emit only when the incoming
97
+ // selection was already group-closed and already points at the clicked
98
+ // primary, so a cohesive plain click doesn't double-emit.
99
+ const unchanged = selection.primaryId === el.id && sameIds(ids, rawIds);
100
+ return {
101
+ next: unchanged ? null : { elementIds: ids, primaryId: el.id },
102
+ armDrag: true,
103
+ dragIds: ids,
104
+ };
105
+ }
106
+
107
+ export { groupMemberIds, isSelectionModifier, resolveClickSelection, uniqIds };
108
+ //# sourceMappingURL=selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.js","sources":["../../../src/editing/core/selection.ts"],"sourcesContent":["import type { PPTElement } from '@openmaic/dsl';\nimport type { Selection } from '../types';\n\n/**\n * Pure click-selection resolution for the editing surface, shared by every\n * pointer-down entry point (box hit targets and line stroke blockers) so all\n * element kinds resolve modifiers and groups identically. No React, no store,\n * no `@/` imports — plain data in, plain data out.\n */\n\n/** True when a click/drag selection modifier (Ctrl/Shift/Meta) is held. Meta is\n * included for mac parity with the resize aspect modifier — a deliberate\n * superset of the app's Ctrl/Shift. */\nexport function isSelectionModifier(e: {\n ctrlKey: boolean;\n shiftKey: boolean;\n metaKey: boolean;\n}): boolean {\n return e.ctrlKey || e.shiftKey || e.metaKey;\n}\n\n/** Dedup ids preserving first-seen order (no lodash dep in this package). */\nexport function uniqIds(ids: readonly string[]): string[] {\n return Array.from(new Set(ids));\n}\n\n/** Exact ordered id-list equality for no-op emit guards. */\nfunction sameIds(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((id, index) => id === b[index]);\n}\n\n/**\n * The clicked element's cohesion unit: every member of its group (in element\n * order), or just the element itself when ungrouped. Group cohesion is\n * all-or-nothing at the click entry point too (app parity): selecting,\n * adding, or removing a grouped element always applies to the whole group,\n * so a group can never be half-selected by clicking. Locked members are\n * included — they may sit in the selection for feedback; the drag layer is\n * responsible for never translating them.\n */\nexport function groupMemberIds(el: PPTElement, elements: readonly PPTElement[]): string[] {\n if (!el.groupId) return [el.id];\n const members = elements.filter((o) => o.groupId === el.groupId).map((o) => o.id);\n return members.length > 0 ? members : [el.id];\n}\n\n/**\n * Group-close a host-provided selection: every known selected element expands\n * to its full group unit, while unknown ids are preserved in-place. This keeps\n * externally controlled selection state from leaking a split group into click\n * resolution or into the drag set it returns.\n */\nfunction closeSelectionGroupIds(ids: readonly string[], elements: readonly PPTElement[]): string[] {\n const byId = new Map(elements.map((el) => [el.id, el]));\n const closed: string[] = [];\n for (const id of ids) {\n const el = byId.get(id);\n closed.push(...(el ? groupMemberIds(el, elements) : [id]));\n }\n return uniqIds(closed);\n}\n\nexport interface ClickSelectionInput {\n /** The element under the pointer. */\n element: PPTElement;\n /** The slide's elements (group-membership lookup). */\n elements: readonly PPTElement[];\n /** The current controlled selection. */\n selection: Selection;\n /** Whether a selection modifier (Ctrl/Shift/Meta) was held at pointer-down. */\n modifier: boolean;\n}\n\nexport interface ClickSelectionResult {\n /** The selection to publish, or `null` when nothing changes (no emit). */\n next: Selection | null;\n /** Whether this pointer-down arms a move gesture (plain clicks only). */\n armDrag: boolean;\n /**\n * The ids an armed drag translates: the clicked element's group unit for a\n * fresh plain click, or the group-closed current selection for a plain click\n * on an already-selected element. Meaningless when `armDrag` is false.\n */\n dragIds: readonly string[];\n}\n\n/**\n * Resolve a pointer-down on element `el` against the current `selection` per\n * the modifier table (group-cohesive — `el` expands to its whole group unit):\n * - not selected, no modifier → select only the unit (primary = clicked);\n * arm a drag on it.\n * - not selected, modifier → ADD the unit to the selection (uniq,\n * primary = clicked); no drag.\n * - selected, modifier → REMOVE the unit; no-op if that would empty\n * the selection; the current primary is preserved when it survives the\n * removal, else the last remaining id becomes primary. No drag.\n * - selected, no modifier → KEEP the whole selection, make the clicked\n * element the primary (no emit when it already is), and arm a drag that\n * translates every selected element.\n *\n * Invariant: this resolver never returns a selection or armed drag set that\n * splits a group, even when the incoming controlled selection already does.\n */\nexport function resolveClickSelection(input: ClickSelectionInput): ClickSelectionResult {\n const { element: el, elements, selection, modifier } = input;\n const rawIds = selection.elementIds;\n const ids = closeSelectionGroupIds(rawIds, elements);\n const inSelection = ids.includes(el.id);\n const unit = groupMemberIds(el, elements);\n\n if (!inSelection && !modifier) {\n return { next: { elementIds: unit, primaryId: el.id }, armDrag: true, dragIds: unit };\n }\n\n if (!inSelection && modifier) {\n return {\n next: { elementIds: uniqIds([...ids, ...unit]), primaryId: el.id },\n armDrag: false,\n dragIds: unit,\n };\n }\n\n if (inSelection && modifier) {\n const removed = new Set(unit);\n const remaining = ids.filter((id) => !removed.has(id));\n // A modifier click must never clear the selection to empty.\n if (remaining.length === 0) return { next: null, armDrag: false, dragIds: unit };\n const primaryId =\n selection.primaryId !== undefined && remaining.includes(selection.primaryId)\n ? selection.primaryId\n : remaining[remaining.length - 1];\n return { next: { elementIds: remaining, primaryId }, armDrag: false, dragIds: unit };\n }\n\n // Already selected, no modifier: keep the whole selection, re-point the\n // primary at the clicked element. Skip the emit only when the incoming\n // selection was already group-closed and already points at the clicked\n // primary, so a cohesive plain click doesn't double-emit.\n const unchanged = selection.primaryId === el.id && sameIds(ids, rawIds);\n return {\n next: unchanged ? null : { elementIds: ids, primaryId: el.id },\n armDrag: true,\n dragIds: ids,\n };\n}\n"],"names":[],"mappings":"AAGA;;;;;AAKG;AAEH;;AAEuC;AACjC,SAAU,mBAAmB,CAAC,CAInC,EAAA;IACC,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,OAAO;AAC7C;AAEA;AACM,SAAU,OAAO,CAAC,GAAsB,EAAA;IAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AACjC;AAEA;AACA,SAAS,OAAO,CAAC,CAAoB,EAAE,CAAoB,EAAA;IACzD,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,KAAK,KAAK,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;AACzE;AAEA;;;;;;;;AAQG;AACG,SAAU,cAAc,CAAC,EAAc,EAAE,QAA+B,EAAA;IAC5E,IAAI,CAAC,EAAE,CAAC,OAAO;AAAE,QAAA,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/B,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACjF,IAAA,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/C;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PPTElement } from '@openmaic/dsl';
2
+ import type { SnappingOptions } from '../types';
3
+ import { type AlignLine, type ElementRange } from './geometry';
4
+ /**
5
+ * Pure alignment-snapping math for the editing surface. Consumes geometry
6
+ * primitives (`getVisualElementRange`, `uniqAlignLines`, `AlignLine`,
7
+ * `ElementRange`) and the DSL element shape. No React, no store, no `@/` imports
8
+ * — ported (decoupled) from the app's `useDragElement` drag-snap math and
9
+ * `AlignmentLine` guide shape so it can be exercised with plain unit tests and
10
+ * reused by any host.
11
+ */
12
+ /** A single alignment guide line to render during a drag/resize gesture. */
13
+ export interface Guide {
14
+ type: 'vertical' | 'horizontal';
15
+ /** Top-left render position, in canvas units (matches the app's AlignmentLine div). */
16
+ axis: {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ /** Rendered length: height for a vertical guide, width for a horizontal one. */
21
+ length: number;
22
+ }
23
+ /**
24
+ * Build the candidate snap lines for a drag/resize gesture: other elements'
25
+ * edges + centers (`toElements`) and the viewport's left/centerX/right and
26
+ * top/centerY/bottom lines (`toCanvas`). Each axis list is deduplicated by
27
+ * value via `uniqAlignLines`. Element candidates use visual ranges: the
28
+ * conservative editing hull answers "could this be here?" for selection and
29
+ * multi-drag unions, while guides answer "what visibly aligns?" and must not
30
+ * point at Bezier control-hull geometry the user never sees. Does not mutate
31
+ * `others`.
32
+ */
33
+ export declare function buildAlignLines(others: PPTElement[], viewport: {
34
+ width: number;
35
+ height: number;
36
+ }, opts?: SnappingOptions): {
37
+ vertical: AlignLine[];
38
+ horizontal: AlignLine[];
39
+ };
40
+ /**
41
+ * Snap a target bounding range against candidate alignment lines: for each
42
+ * axis independently, probe the target's min/center/max edges and pick the
43
+ * nearest in-range line. Returns the winning correction (`dx`/`dy`, 0 when
44
+ * no line is within `range`) plus the guide(s) to display. Does not mutate
45
+ * `target` or `lines`.
46
+ */
47
+ export declare function snapRange(target: ElementRange, lines: {
48
+ vertical: AlignLine[];
49
+ horizontal: AlignLine[];
50
+ }, range: number): {
51
+ dx: number;
52
+ dy: number;
53
+ guides: Guide[];
54
+ };
@@ -0,0 +1,96 @@
1
+ import { getVisualElementRange, uniqAlignLines } from './geometry.js';
2
+
3
+ /** Guides are drawn 100 canvas units longer than the strict overlap span (50 past each end). */
4
+ const GUIDE_OVERHANG = 50;
5
+ /**
6
+ * Build the candidate snap lines for a drag/resize gesture: other elements'
7
+ * edges + centers (`toElements`) and the viewport's left/centerX/right and
8
+ * top/centerY/bottom lines (`toCanvas`). Each axis list is deduplicated by
9
+ * value via `uniqAlignLines`. Element candidates use visual ranges: the
10
+ * conservative editing hull answers "could this be here?" for selection and
11
+ * multi-drag unions, while guides answer "what visibly aligns?" and must not
12
+ * point at Bezier control-hull geometry the user never sees. Does not mutate
13
+ * `others`.
14
+ */
15
+ function buildAlignLines(others, viewport, opts = {}) {
16
+ const vertical = [];
17
+ const horizontal = [];
18
+ if (opts.toElements) {
19
+ for (const el of others) {
20
+ const { minX, maxX, minY, maxY } = getVisualElementRange(el);
21
+ const centerX = minX + (maxX - minX) / 2;
22
+ const centerY = minY + (maxY - minY) / 2;
23
+ vertical.push({ value: minX, range: [minY, maxY] }, { value: maxX, range: [minY, maxY] }, { value: centerX, range: [minY, maxY] });
24
+ horizontal.push({ value: minY, range: [minX, maxX] }, { value: maxY, range: [minX, maxX] }, { value: centerY, range: [minX, maxX] });
25
+ }
26
+ }
27
+ if (opts.toCanvas) {
28
+ const { width, height } = viewport;
29
+ vertical.push({ value: 0, range: [0, height] }, { value: width / 2, range: [0, height] }, { value: width, range: [0, height] });
30
+ horizontal.push({ value: 0, range: [0, width] }, { value: height / 2, range: [0, width] }, { value: height, range: [0, width] });
31
+ }
32
+ return {
33
+ vertical: uniqAlignLines(vertical),
34
+ horizontal: uniqAlignLines(horizontal),
35
+ };
36
+ }
37
+ /**
38
+ * Scan `lines` against `probes` (a target's min/center/max on one axis) and
39
+ * return the smallest in-range correction, or `null` if none of the probes
40
+ * land within `range` of any line.
41
+ */
42
+ function findBestMatch(lines, probes, range) {
43
+ let best = null;
44
+ for (const line of lines) {
45
+ for (const probe of probes) {
46
+ const delta = line.value - probe;
47
+ if (Math.abs(delta) < range && (!best || Math.abs(delta) < Math.abs(best.delta))) {
48
+ best = { delta, line };
49
+ }
50
+ }
51
+ }
52
+ return best;
53
+ }
54
+ /**
55
+ * Snap a target bounding range against candidate alignment lines: for each
56
+ * axis independently, probe the target's min/center/max edges and pick the
57
+ * nearest in-range line. Returns the winning correction (`dx`/`dy`, 0 when
58
+ * no line is within `range`) plus the guide(s) to display. Does not mutate
59
+ * `target` or `lines`.
60
+ */
61
+ function snapRange(target, lines, range) {
62
+ const { minX, maxX, minY, maxY } = target;
63
+ const centerX = minX + (maxX - minX) / 2;
64
+ const centerY = minY + (maxY - minY) / 2;
65
+ const guides = [];
66
+ let dx = 0;
67
+ let dy = 0;
68
+ const bestVertical = findBestMatch(lines.vertical, [minX, centerX, maxX], range);
69
+ if (bestVertical) {
70
+ dx = bestVertical.delta;
71
+ const { line } = bestVertical;
72
+ const spanMin = Math.min(line.range[0], minY, maxY);
73
+ const spanMax = Math.max(line.range[1], minY, maxY);
74
+ guides.push({
75
+ type: 'vertical',
76
+ axis: { x: line.value, y: spanMin - GUIDE_OVERHANG },
77
+ length: spanMax - spanMin + GUIDE_OVERHANG * 2,
78
+ });
79
+ }
80
+ const bestHorizontal = findBestMatch(lines.horizontal, [minY, centerY, maxY], range);
81
+ if (bestHorizontal) {
82
+ dy = bestHorizontal.delta;
83
+ const { line } = bestHorizontal;
84
+ const spanMin = Math.min(line.range[0], minX, maxX);
85
+ const spanMax = Math.max(line.range[1], minX, maxX);
86
+ guides.push({
87
+ type: 'horizontal',
88
+ axis: { x: spanMin - GUIDE_OVERHANG, y: line.value },
89
+ length: spanMax - spanMin + GUIDE_OVERHANG * 2,
90
+ });
91
+ }
92
+ return { dx, dy, guides };
93
+ }
94
+
95
+ export { buildAlignLines, snapRange };
96
+ //# sourceMappingURL=snapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapping.js","sources":["../../../src/editing/core/snapping.ts"],"sourcesContent":["import type { PPTElement } from '@openmaic/dsl';\nimport type { SnappingOptions } from '../types';\nimport {\n getVisualElementRange,\n uniqAlignLines,\n type AlignLine,\n type ElementRange,\n} from './geometry';\n\n/**\n * Pure alignment-snapping math for the editing surface. Consumes geometry\n * primitives (`getVisualElementRange`, `uniqAlignLines`, `AlignLine`,\n * `ElementRange`) and the DSL element shape. No React, no store, no `@/` imports\n * — ported (decoupled) from the app's `useDragElement` drag-snap math and\n * `AlignmentLine` guide shape so it can be exercised with plain unit tests and\n * reused by any host.\n */\n\n/** A single alignment guide line to render during a drag/resize gesture. */\nexport interface Guide {\n type: 'vertical' | 'horizontal';\n /** Top-left render position, in canvas units (matches the app's AlignmentLine div). */\n axis: { x: number; y: number };\n /** Rendered length: height for a vertical guide, width for a horizontal one. */\n length: number;\n}\n\n/** Guides are drawn 100 canvas units longer than the strict overlap span (50 past each end). */\nconst GUIDE_OVERHANG = 50;\n\n/**\n * Build the candidate snap lines for a drag/resize gesture: other elements'\n * edges + centers (`toElements`) and the viewport's left/centerX/right and\n * top/centerY/bottom lines (`toCanvas`). Each axis list is deduplicated by\n * value via `uniqAlignLines`. Element candidates use visual ranges: the\n * conservative editing hull answers \"could this be here?\" for selection and\n * multi-drag unions, while guides answer \"what visibly aligns?\" and must not\n * point at Bezier control-hull geometry the user never sees. Does not mutate\n * `others`.\n */\nexport function buildAlignLines(\n others: PPTElement[],\n viewport: { width: number; height: number },\n opts: SnappingOptions = {},\n): { vertical: AlignLine[]; horizontal: AlignLine[] } {\n const vertical: AlignLine[] = [];\n const horizontal: AlignLine[] = [];\n\n if (opts.toElements) {\n for (const el of others) {\n const { minX, maxX, minY, maxY } = getVisualElementRange(el);\n const centerX = minX + (maxX - minX) / 2;\n const centerY = minY + (maxY - minY) / 2;\n\n vertical.push(\n { value: minX, range: [minY, maxY] },\n { value: maxX, range: [minY, maxY] },\n { value: centerX, range: [minY, maxY] },\n );\n horizontal.push(\n { value: minY, range: [minX, maxX] },\n { value: maxY, range: [minX, maxX] },\n { value: centerY, range: [minX, maxX] },\n );\n }\n }\n\n if (opts.toCanvas) {\n const { width, height } = viewport;\n\n vertical.push(\n { value: 0, range: [0, height] },\n { value: width / 2, range: [0, height] },\n { value: width, range: [0, height] },\n );\n horizontal.push(\n { value: 0, range: [0, width] },\n { value: height / 2, range: [0, width] },\n { value: height, range: [0, width] },\n );\n }\n\n return {\n vertical: uniqAlignLines(vertical),\n horizontal: uniqAlignLines(horizontal),\n };\n}\n\ninterface BestMatch {\n delta: number;\n line: AlignLine;\n}\n\n/**\n * Scan `lines` against `probes` (a target's min/center/max on one axis) and\n * return the smallest in-range correction, or `null` if none of the probes\n * land within `range` of any line.\n */\nfunction findBestMatch(lines: AlignLine[], probes: number[], range: number): BestMatch | null {\n let best: BestMatch | null = null;\n for (const line of lines) {\n for (const probe of probes) {\n const delta = line.value - probe;\n if (Math.abs(delta) < range && (!best || Math.abs(delta) < Math.abs(best.delta))) {\n best = { delta, line };\n }\n }\n }\n return best;\n}\n\n/**\n * Snap a target bounding range against candidate alignment lines: for each\n * axis independently, probe the target's min/center/max edges and pick the\n * nearest in-range line. Returns the winning correction (`dx`/`dy`, 0 when\n * no line is within `range`) plus the guide(s) to display. Does not mutate\n * `target` or `lines`.\n */\nexport function snapRange(\n target: ElementRange,\n lines: { vertical: AlignLine[]; horizontal: AlignLine[] },\n range: number,\n): { dx: number; dy: number; guides: Guide[] } {\n const { minX, maxX, minY, maxY } = target;\n const centerX = minX + (maxX - minX) / 2;\n const centerY = minY + (maxY - minY) / 2;\n\n const guides: Guide[] = [];\n let dx = 0;\n let dy = 0;\n\n const bestVertical = findBestMatch(lines.vertical, [minX, centerX, maxX], range);\n if (bestVertical) {\n dx = bestVertical.delta;\n const { line } = bestVertical;\n const spanMin = Math.min(line.range[0], minY, maxY);\n const spanMax = Math.max(line.range[1], minY, maxY);\n guides.push({\n type: 'vertical',\n axis: { x: line.value, y: spanMin - GUIDE_OVERHANG },\n length: spanMax - spanMin + GUIDE_OVERHANG * 2,\n });\n }\n\n const bestHorizontal = findBestMatch(lines.horizontal, [minY, centerY, maxY], range);\n if (bestHorizontal) {\n dy = bestHorizontal.delta;\n const { line } = bestHorizontal;\n const spanMin = Math.min(line.range[0], minX, maxX);\n const spanMax = Math.max(line.range[1], minX, maxX);\n guides.push({\n type: 'horizontal',\n axis: { x: spanMin - GUIDE_OVERHANG, y: line.value },\n length: spanMax - spanMin + GUIDE_OVERHANG * 2,\n });\n }\n\n return { dx, dy, guides };\n}\n"],"names":[],"mappings":";;AA2BA;AACA,MAAM,cAAc,GAAG,EAAE;AAEzB;;;;;;;;;AASG;AACG,SAAU,eAAe,CAC7B,MAAoB,EACpB,QAA2C,EAC3C,OAAwB,EAAE,EAAA;IAE1B,MAAM,QAAQ,GAAgB,EAAE;IAChC,MAAM,UAAU,GAAgB,EAAE;AAElC,IAAA,IAAI,IAAI,CAAC,UAAU,EAAE;AACnB,QAAA,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE;AACvB,YAAA,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,qBAAqB,CAAC,EAAE,CAAC;YAC5D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC;YACxC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC;YAExC,QAAQ,CAAC,IAAI,CACX,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EACpC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EACpC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CACxC;YACD,UAAU,CAAC,IAAI,CACb,EAAE,KAAK,EAA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AE,IAAI,EAAE,IAAI,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,IAAI,EAAE,UAAU;AAChB,YAAA,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,GAAG,cAAc,EAAE;AACpD,YAAA,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,cAAc,GAAG,CAAC;AAC/C,SAAA,CAAC;IACJ;AAEA,IAAA,MAAM,cAAc,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC;IACpF,IAAI,cAAc,EAAE;AAClB,QAAA,EAAE,GAAG,cAAc,CAAC,KAAK;AACzB,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc;AAC/B,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;AACnD,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,IAAI,EAAE,YAAY;AAClB,YAAA,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,GAAG,cAAc,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE;AACpD,YAAA,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,cAAc,GAAG,CAAC;AAC/C,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;AAC3B;;;;"}
@@ -0,0 +1,15 @@
1
+ import type { CSSProperties } from 'react';
2
+ /**
3
+ * Presentational selection border rect. Pure props-driven: no store, no
4
+ * document knowledge. `width`/`height` are already resolved to px (the
5
+ * caller applies canvas scale before passing them in). `style` lets a caller
6
+ * (e.g. `SelectionOverlay`) layer on positioning without this component
7
+ * needing to know about elements or scale.
8
+ */
9
+ export interface BorderLineProps {
10
+ width: number;
11
+ height: number;
12
+ className?: string;
13
+ style?: CSSProperties;
14
+ }
15
+ export declare function BorderLine({ width, height, className, style }: BorderLineProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ function BorderLine({ width, height, className, style }) {
4
+ return (jsx("div", { "data-selection-border": "", className: className, style: {
5
+ position: 'absolute',
6
+ width: `${width}px`,
7
+ height: `${height}px`,
8
+ outline: '1px solid #3b82f6',
9
+ outlineOffset: '-1px',
10
+ boxSizing: 'border-box',
11
+ pointerEvents: 'none',
12
+ ...style,
13
+ } }));
14
+ }
15
+
16
+ export { BorderLine };
17
+ //# sourceMappingURL=BorderLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BorderLine.js","sources":["../../../src/editing/handles/BorderLine.tsx"],"sourcesContent":["import type { CSSProperties } from 'react';\n\n/**\n * Presentational selection border rect. Pure props-driven: no store, no\n * document knowledge. `width`/`height` are already resolved to px (the\n * caller applies canvas scale before passing them in). `style` lets a caller\n * (e.g. `SelectionOverlay`) layer on positioning without this component\n * needing to know about elements or scale.\n */\nexport interface BorderLineProps {\n width: number;\n height: number;\n className?: string;\n style?: CSSProperties;\n}\n\nexport function BorderLine({ width, height, className, style }: BorderLineProps) {\n return (\n <div\n data-selection-border=\"\"\n className={className}\n style={{\n position: 'absolute',\n width: `${width}px`,\n height: `${height}px`,\n outline: '1px solid #3b82f6',\n outlineOffset: '-1px',\n boxSizing: 'border-box',\n pointerEvents: 'none',\n ...style,\n }}\n />\n );\n}\n"],"names":["_jsx"],"mappings":";;AAgBM,SAAU,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAmB,EAAA;IAC7E,QACEA,sCACwB,EAAE,EACxB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE;AACL,YAAA,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,CAAA,EAAG,KAAK,CAAA,EAAA,CAAI;YACnB,MAAM,EAAE,CAAA,EAAG,MAAM,CAAA,EAAA,CAAI;AACrB,YAAA,OAAO,EAAE,mBAAmB;AAC5B,YAAA,aAAa,EAAE,MAAM;AACrB,YAAA,SAAS,EAAE,YAAY;AACvB,YAAA,aAAa,EAAE,MAAM;AACrB,YAAA,GAAG,KAAK;AACT,SAAA,EAAA,CACD;AAEN;;;;"}
@@ -0,0 +1,28 @@
1
+ import type { PointerEvent as ReactPointerEvent } from 'react';
2
+ import type { PPTLineElement } from '@openmaic/dsl';
3
+ import type { ViewportStyles } from '../../hooks/useViewportSize';
4
+ import type { LineHandle } from '../types';
5
+ export interface LineHandlesProps {
6
+ /** The line whose endpoint/control handles are drawn. */
7
+ element: PPTLineElement;
8
+ /** SlideCanvas centering offset — handles share the element container's origin. */
9
+ viewportStyles: ViewportStyles;
10
+ /** Canvas → screen scale (`props.scale ?? fitScale`). */
11
+ canvasScale: number;
12
+ /** Arm a handle-reshape gesture from a pointer-down on a handle box. */
13
+ onHandlePointerDown: (handle: LineHandle, e: ReactPointerEvent) => void;
14
+ }
15
+ /**
16
+ * Presentational endpoint/control handles for a selected line. Props-driven
17
+ * only: resolves the line's `start`/`end` (always) plus the single quadratic
18
+ * control point (`ctrl` ← `broken`/`broken2`/`curve`) or the two cubic control
19
+ * points (`ctrl1`/`ctrl2` ← `cubic`) when present, and draws a small draggable
20
+ * box centered on each in screen space.
21
+ *
22
+ * Screen position mirrors the v1 line hit layer / element container:
23
+ * `left = viewportStyles.left + (el.left + point[0]) * canvasScale` (same for
24
+ * `top`), so a handle sits exactly on the rendered endpoint even when the
25
+ * container is letterboxed. Each box carries `data-line-handle={handle}` and
26
+ * arms the reshape gesture via `onHandlePointerDown`. No `@/` imports.
27
+ */
28
+ export declare function LineHandles({ element, viewportStyles, canvasScale, onHandlePointerDown, }: LineHandlesProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+
3
+ /** Half the handle box size, so `translate(-HALF, -HALF)` centers it on its point. */
4
+ const HANDLE_HALF = 5;
5
+ /**
6
+ * Presentational endpoint/control handles for a selected line. Props-driven
7
+ * only: resolves the line's `start`/`end` (always) plus the single quadratic
8
+ * control point (`ctrl` ← `broken`/`broken2`/`curve`) or the two cubic control
9
+ * points (`ctrl1`/`ctrl2` ← `cubic`) when present, and draws a small draggable
10
+ * box centered on each in screen space.
11
+ *
12
+ * Screen position mirrors the v1 line hit layer / element container:
13
+ * `left = viewportStyles.left + (el.left + point[0]) * canvasScale` (same for
14
+ * `top`), so a handle sits exactly on the rendered endpoint even when the
15
+ * container is letterboxed. Each box carries `data-line-handle={handle}` and
16
+ * arms the reshape gesture via `onHandlePointerDown`. No `@/` imports.
17
+ */
18
+ function LineHandles({ element, viewportStyles, canvasScale, onHandlePointerDown, }) {
19
+ const points = [
20
+ { handle: 'start', point: element.start },
21
+ { handle: 'end', point: element.end },
22
+ ];
23
+ // Field precedence MUST match `computeLineDrag` (core/line-drag.ts), which
24
+ // resolves the single control point as `broken || broken2 || curve`, so the
25
+ // rendered handle sits exactly where the drag math reads/writes it.
26
+ const ctrl = element.broken || element.broken2 || element.curve;
27
+ if (ctrl) {
28
+ points.push({ handle: 'ctrl', point: ctrl });
29
+ }
30
+ else if (element.cubic) {
31
+ points.push({ handle: 'ctrl1', point: element.cubic[0] });
32
+ points.push({ handle: 'ctrl2', point: element.cubic[1] });
33
+ }
34
+ return (jsx(Fragment, { children: points.map(({ handle, point }) => (jsx("div", { "data-line-handle": handle, onPointerDown: (e) => onHandlePointerDown(handle, e), style: {
35
+ position: 'absolute',
36
+ left: `${viewportStyles.left + (element.left + point[0]) * canvasScale}px`,
37
+ top: `${viewportStyles.top + (element.top + point[1]) * canvasScale}px`,
38
+ width: '10px',
39
+ height: '10px',
40
+ transform: `translate(-${HANDLE_HALF}px, -${HANDLE_HALF}px)`,
41
+ border: '1px solid #3b82f6',
42
+ backgroundColor: '#fff',
43
+ boxSizing: 'border-box',
44
+ pointerEvents: 'auto',
45
+ cursor: 'pointer',
46
+ touchAction: 'none',
47
+ } }, handle))) }));
48
+ }
49
+
50
+ export { LineHandles };
51
+ //# sourceMappingURL=LineHandles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineHandles.js","sources":["../../../src/editing/handles/LineHandles.tsx"],"sourcesContent":["import type { PointerEvent as ReactPointerEvent } from 'react';\nimport type { PPTLineElement } from '@openmaic/dsl';\n\nimport type { ViewportStyles } from '../../hooks/useViewportSize';\nimport type { LineHandle } from '../types';\n\nexport interface LineHandlesProps {\n /** The line whose endpoint/control handles are drawn. */\n element: PPTLineElement;\n /** SlideCanvas centering offset — handles share the element container's origin. */\n viewportStyles: ViewportStyles;\n /** Canvas → screen scale (`props.scale ?? fitScale`). */\n canvasScale: number;\n /** Arm a handle-reshape gesture from a pointer-down on a handle box. */\n onHandlePointerDown: (handle: LineHandle, e: ReactPointerEvent) => void;\n}\n\n/** Half the handle box size, so `translate(-HALF, -HALF)` centers it on its point. */\nconst HANDLE_HALF = 5;\n\n/**\n * Presentational endpoint/control handles for a selected line. Props-driven\n * only: resolves the line's `start`/`end` (always) plus the single quadratic\n * control point (`ctrl` ← `broken`/`broken2`/`curve`) or the two cubic control\n * points (`ctrl1`/`ctrl2` ← `cubic`) when present, and draws a small draggable\n * box centered on each in screen space.\n *\n * Screen position mirrors the v1 line hit layer / element container:\n * `left = viewportStyles.left + (el.left + point[0]) * canvasScale` (same for\n * `top`), so a handle sits exactly on the rendered endpoint even when the\n * container is letterboxed. Each box carries `data-line-handle={handle}` and\n * arms the reshape gesture via `onHandlePointerDown`. No `@/` imports.\n */\nexport function LineHandles({\n element,\n viewportStyles,\n canvasScale,\n onHandlePointerDown,\n}: LineHandlesProps) {\n const points: Array<{ handle: LineHandle; point: [number, number] }> = [\n { handle: 'start', point: element.start },\n { handle: 'end', point: element.end },\n ];\n\n // Field precedence MUST match `computeLineDrag` (core/line-drag.ts), which\n // resolves the single control point as `broken || broken2 || curve`, so the\n // rendered handle sits exactly where the drag math reads/writes it.\n const ctrl = element.broken || element.broken2 || element.curve;\n if (ctrl) {\n points.push({ handle: 'ctrl', point: ctrl });\n } else if (element.cubic) {\n points.push({ handle: 'ctrl1', point: element.cubic[0] });\n points.push({ handle: 'ctrl2', point: element.cubic[1] });\n }\n\n return (\n <>\n {points.map(({ handle, point }) => (\n <div\n key={handle}\n data-line-handle={handle}\n onPointerDown={(e) => onHandlePointerDown(handle, e)}\n style={{\n position: 'absolute',\n left: `${viewportStyles.left + (element.left + point[0]) * canvasScale}px`,\n top: `${viewportStyles.top + (element.top + point[1]) * canvasScale}px`,\n width: '10px',\n height: '10px',\n transform: `translate(-${HANDLE_HALF}px, -${HANDLE_HALF}px)`,\n border: '1px solid #3b82f6',\n backgroundColor: '#fff',\n boxSizing: 'border-box',\n pointerEvents: 'auto',\n cursor: 'pointer',\n touchAction: 'none',\n }}\n />\n ))}\n </>\n );\n}\n"],"names":["_jsx","_Fragment"],"mappings":";;AAiBA;AACA,MAAM,WAAW,GAAG,CAAC;AAErB;;;;;;;;;;;;AAYG;AACG,SAAU,WAAW,CAAC,EAC1B,OAAO,EACP,cAAc,EACd,WAAW,EACX,mBAAmB,GACF,EAAA;AACjB,IAAA,MAAM,MAAM,GAA2D;QACrE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE;QACzC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE;KACtC;;;;AAKD,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK;IAC/D,IAAI,IAAI,EAAE;AACR,QAAA,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,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AAM,EAAE,SAAS;AACjB,gBAAA,WAAW,EAAE,MAAM;AACpB,aAAA,EAAA,EAhBI,MAAM,CAiBX,CACH,CAAC,EAAA,CACD;AAEP;;;;"}
@@ -0,0 +1,19 @@
1
+ import type { ViewportStyles } from '../../hooks/useViewportSize';
2
+ import type { MarqueeRect } from '../core/marquee';
3
+ export interface MarqueeBoxProps {
4
+ /** The live marquee rectangle, normalized in canvas units. */
5
+ rect: MarqueeRect;
6
+ /** SlideCanvas centering offset — the box shares the element container's origin. */
7
+ viewportStyles: ViewportStyles;
8
+ /** Canvas → screen scale (`props.scale ?? fitScale`). */
9
+ canvasScale: number;
10
+ }
11
+ /**
12
+ * Presentational marquee (rubber-band) rectangle: a dashed border drawn over the
13
+ * canvas while a blank-canvas drag-select is in flight. Props-driven only — the
14
+ * normalized canvas-unit {@link MarqueeRect} is scaled by `canvasScale` and
15
+ * offset by `viewportStyles.left/top` so it lines up with the rendered elements
16
+ * even when the container is letterboxed. Purely visual (`pointerEvents: none`);
17
+ * it never hit-tests. No `@/` imports.
18
+ */
19
+ export declare function MarqueeBox({ rect, viewportStyles, canvasScale }: MarqueeBoxProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Presentational marquee (rubber-band) rectangle: a dashed border drawn over the
5
+ * canvas while a blank-canvas drag-select is in flight. Props-driven only — the
6
+ * normalized canvas-unit {@link MarqueeRect} is scaled by `canvasScale` and
7
+ * offset by `viewportStyles.left/top` so it lines up with the rendered elements
8
+ * even when the container is letterboxed. Purely visual (`pointerEvents: none`);
9
+ * it never hit-tests. No `@/` imports.
10
+ */
11
+ function MarqueeBox({ rect, viewportStyles, canvasScale }) {
12
+ return (jsx("div", { "data-marquee-box": "", style: {
13
+ position: 'absolute',
14
+ left: `${viewportStyles.left + rect.minX * canvasScale}px`,
15
+ top: `${viewportStyles.top + rect.minY * canvasScale}px`,
16
+ width: `${(rect.maxX - rect.minX) * canvasScale}px`,
17
+ height: `${(rect.maxY - rect.minY) * canvasScale}px`,
18
+ border: '1px dashed #3b82f6',
19
+ backgroundColor: 'rgba(59, 130, 246, 0.1)',
20
+ boxSizing: 'border-box',
21
+ pointerEvents: 'none',
22
+ } }));
23
+ }
24
+
25
+ export { MarqueeBox };
26
+ //# sourceMappingURL=MarqueeBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarqueeBox.js","sources":["../../../src/editing/handles/MarqueeBox.tsx"],"sourcesContent":["import type { ViewportStyles } from '../../hooks/useViewportSize';\nimport type { MarqueeRect } from '../core/marquee';\n\nexport interface MarqueeBoxProps {\n /** The live marquee rectangle, normalized in canvas units. */\n rect: MarqueeRect;\n /** SlideCanvas centering offset — the box shares the element container's origin. */\n viewportStyles: ViewportStyles;\n /** Canvas → screen scale (`props.scale ?? fitScale`). */\n canvasScale: number;\n}\n\n/**\n * Presentational marquee (rubber-band) rectangle: a dashed border drawn over the\n * canvas while a blank-canvas drag-select is in flight. Props-driven only — the\n * normalized canvas-unit {@link MarqueeRect} is scaled by `canvasScale` and\n * offset by `viewportStyles.left/top` so it lines up with the rendered elements\n * even when the container is letterboxed. Purely visual (`pointerEvents: none`);\n * it never hit-tests. No `@/` imports.\n */\nexport function MarqueeBox({ rect, viewportStyles, canvasScale }: MarqueeBoxProps) {\n return (\n <div\n data-marquee-box=\"\"\n style={{\n position: 'absolute',\n left: `${viewportStyles.left + rect.minX * canvasScale}px`,\n top: `${viewportStyles.top + rect.minY * canvasScale}px`,\n width: `${(rect.maxX - rect.minX) * canvasScale}px`,\n height: `${(rect.maxY - rect.minY) * canvasScale}px`,\n border: '1px dashed #3b82f6',\n backgroundColor: 'rgba(59, 130, 246, 0.1)',\n boxSizing: 'border-box',\n pointerEvents: 'none',\n }}\n />\n );\n}\n"],"names":["_jsx"],"mappings":";;AAYA;;;;;;;AAOG;AACG,SAAU,UAAU,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAmB,EAAA;AAC/E,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAA,kBAAA,EACmB,EAAE,EACnB,KAAK,EAAE;AACL,YAAA,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,CAAA,EAAG,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA,EAAA,CAAI;YAC1D,GAAG,EAAE,CAAA,EAAG,cAAc,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA,EAAA,CAAI;AACxD,YAAA,KAAK,EAAE,CAAA,EAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,WAAW,CAAA,EAAA,CAAI;AACnD,YAAA,MAAM,EAAE,CAAA,EAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,WAAW,CAAA,EAAA,CAAI;AACpD,YAAA,MAAM,EAAE,oBAAoB;AAC5B,YAAA,eAAe,EAAE,yBAAyB;AAC1C,YAAA,SAAS,EAAE,YAAY;AACvB,YAAA,aAAa,EAAE,MAAM;AACtB,SAAA,EAAA,CACD;AAEN;;;;"}
@@ -0,0 +1,31 @@
1
+ import type { PointerEvent as ReactPointerEvent } from 'react';
2
+ import type { ViewportStyles } from '../../hooks/useViewportSize';
3
+ import { type PPTBoxElement, type ResizeHandle } from '../core/resize';
4
+ export interface ResizeHandlesProps {
5
+ /** The box element whose resize points are drawn. */
6
+ element: PPTBoxElement;
7
+ /** Which of the eight points to draw (per-kind gate, e.g. text gets two). */
8
+ handles: readonly ResizeHandle[];
9
+ /** SlideCanvas centering offset — handles share the element container's origin. */
10
+ viewportStyles: ViewportStyles;
11
+ /** Canvas → screen scale (`props.scale ?? fitScale`). */
12
+ canvasScale: number;
13
+ /** Arm a resize gesture from a pointer-down on a handle box. */
14
+ onHandlePointerDown: (handle: ResizeHandle, e: ReactPointerEvent) => void;
15
+ }
16
+ /**
17
+ * Presentational 8-point resize handles for a selected box element.
18
+ * Props-driven only: draws a small draggable box centered on each requested
19
+ * point, with a rotation-aware directional cursor.
20
+ *
21
+ * Positions are computed ANALYTICALLY in canvas space via
22
+ * {@link getRotateElementPoints} — the exact rotated location of each frame
23
+ * point — rather than nesting the handles inside a rotated CSS frame. That
24
+ * keeps every handle in plain overlay screen coordinates (like `LineHandles`),
25
+ * so hit-testing, the drag math, and the un-rotated 10px handle boxes all
26
+ * agree: `left = viewportStyles.left + point.left * canvasScale` (same for
27
+ * `top`), matching the element container's origin even when letterboxed.
28
+ * Each box carries `data-resize-handle={handle}` and arms the resize gesture
29
+ * via `onHandlePointerDown`. No `@/` imports.
30
+ */
31
+ export declare function ResizeHandles({ element, handles, viewportStyles, canvasScale, onHandlePointerDown, }: ResizeHandlesProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,44 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+ import { getRotateElementPoints, getResizeCursor } from '../core/resize.js';
3
+
4
+ /** Half the handle box size, so `translate(-HALF, -HALF)` centers it on its point. */
5
+ const HANDLE_HALF = 5;
6
+ /**
7
+ * Presentational 8-point resize handles for a selected box element.
8
+ * Props-driven only: draws a small draggable box centered on each requested
9
+ * point, with a rotation-aware directional cursor.
10
+ *
11
+ * Positions are computed ANALYTICALLY in canvas space via
12
+ * {@link getRotateElementPoints} — the exact rotated location of each frame
13
+ * point — rather than nesting the handles inside a rotated CSS frame. That
14
+ * keeps every handle in plain overlay screen coordinates (like `LineHandles`),
15
+ * so hit-testing, the drag math, and the un-rotated 10px handle boxes all
16
+ * agree: `left = viewportStyles.left + point.left * canvasScale` (same for
17
+ * `top`), matching the element container's origin even when letterboxed.
18
+ * Each box carries `data-resize-handle={handle}` and arms the resize gesture
19
+ * via `onHandlePointerDown`. No `@/` imports.
20
+ */
21
+ function ResizeHandles({ element, handles, viewportStyles, canvasScale, onHandlePointerDown, }) {
22
+ const rotate = element.rotate || 0;
23
+ const points = getRotateElementPoints({ left: element.left, top: element.top, width: element.width, height: element.height }, rotate);
24
+ return (jsx(Fragment, { children: handles.map((handle) => {
25
+ const point = points[handle];
26
+ return (jsx("div", { "data-resize-handle": handle, onPointerDown: (e) => onHandlePointerDown(handle, e), style: {
27
+ position: 'absolute',
28
+ left: `${viewportStyles.left + point.left * canvasScale}px`,
29
+ top: `${viewportStyles.top + point.top * canvasScale}px`,
30
+ width: '10px',
31
+ height: '10px',
32
+ transform: `translate(-${HANDLE_HALF}px, -${HANDLE_HALF}px)`,
33
+ border: '1px solid #3b82f6',
34
+ backgroundColor: '#fff',
35
+ boxSizing: 'border-box',
36
+ pointerEvents: 'auto',
37
+ cursor: getResizeCursor(handle, rotate),
38
+ touchAction: 'none',
39
+ } }, handle));
40
+ }) }));
41
+ }
42
+
43
+ export { ResizeHandles };
44
+ //# sourceMappingURL=ResizeHandles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResizeHandles.js","sources":["../../../src/editing/handles/ResizeHandles.tsx"],"sourcesContent":["import type { PointerEvent as ReactPointerEvent } from 'react';\n\nimport type { ViewportStyles } from '../../hooks/useViewportSize';\nimport {\n getRotateElementPoints,\n getResizeCursor,\n type PPTBoxElement,\n type ResizeHandle,\n} from '../core/resize';\n\nexport interface ResizeHandlesProps {\n /** The box element whose resize points are drawn. */\n element: PPTBoxElement;\n /** Which of the eight points to draw (per-kind gate, e.g. text gets two). */\n handles: readonly ResizeHandle[];\n /** SlideCanvas centering offset — handles share the element container's origin. */\n viewportStyles: ViewportStyles;\n /** Canvas → screen scale (`props.scale ?? fitScale`). */\n canvasScale: number;\n /** Arm a resize gesture from a pointer-down on a handle box. */\n onHandlePointerDown: (handle: ResizeHandle, e: ReactPointerEvent) => void;\n}\n\n/** Half the handle box size, so `translate(-HALF, -HALF)` centers it on its point. */\nconst HANDLE_HALF = 5;\n\n/**\n * Presentational 8-point resize handles for a selected box element.\n * Props-driven only: draws a small draggable box centered on each requested\n * point, with a rotation-aware directional cursor.\n *\n * Positions are computed ANALYTICALLY in canvas space via\n * {@link getRotateElementPoints} — the exact rotated location of each frame\n * point — rather than nesting the handles inside a rotated CSS frame. That\n * keeps every handle in plain overlay screen coordinates (like `LineHandles`),\n * so hit-testing, the drag math, and the un-rotated 10px handle boxes all\n * agree: `left = viewportStyles.left + point.left * canvasScale` (same for\n * `top`), matching the element container's origin even when letterboxed.\n * Each box carries `data-resize-handle={handle}` and arms the resize gesture\n * via `onHandlePointerDown`. No `@/` imports.\n */\nexport function ResizeHandles({\n element,\n handles,\n viewportStyles,\n canvasScale,\n onHandlePointerDown,\n}: ResizeHandlesProps) {\n const rotate = element.rotate || 0;\n const points = getRotateElementPoints(\n { left: element.left, top: element.top, width: element.width, height: element.height },\n rotate,\n );\n\n return (\n <>\n {handles.map((handle) => {\n const point = points[handle];\n return (\n <div\n key={handle}\n data-resize-handle={handle}\n onPointerDown={(e) => onHandlePointerDown(handle, e)}\n style={{\n position: 'absolute',\n left: `${viewportStyles.left + point.left * canvasScale}px`,\n top: `${viewportStyles.top + point.top * canvasScale}px`,\n width: '10px',\n height: '10px',\n transform: `translate(-${HANDLE_HALF}px, -${HANDLE_HALF}px)`,\n border: '1px solid #3b82f6',\n backgroundColor: '#fff',\n boxSizing: 'border-box',\n pointerEvents: 'auto',\n cursor: getResizeCursor(handle, rotate),\n touchAction: 'none',\n }}\n />\n );\n })}\n </>\n );\n}\n"],"names":["_jsx"],"mappings":";;;AAuBA;AACA,MAAM,WAAW,GAAG,CAAC;AAErB;;;;;;;;;;;;;;AAcG;AACG,SAAU,aAAa,CAAC,EAC5B,OAAO,EACP,OAAO,EACP,cAAc,EACd,WAAW,EACX,mBAAmB,GACA,EAAA;AACnB,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;AAClC,IAAA,MAAM,MAAM,GAAG,sBAAsB,CACnC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EACtF,MAAM,CACP;IAED,QACEA,0BACG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,KAAI;AACtB,YAAA,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;AAC5B,YAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAA,oBAAA,EAEsB,MAAM,EAC1B,aAAa,EAAE,CAAC,CAAC,KAAK,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,EACpD,KAAK,EAAE;AACL,oBAAA,QAAQ,EAAE,UAAU;oBACpB,IAAI,EAAE,CAAA,EAAG,cAAc,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,WAAW,CAAA,EAAA,CAAI;oBAC3D,GAAG,EAAE,CAAA,EAAG,cAAc,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,GAAG,WAAW,CAAA,EAAA,CAAI;AACxD,oBAAA,KAAK,EAAE,MAAM;AACb,oBAAA,MAAM,EAAE,MAAM;AACd,oBAAA,SAAS,EAAE,CAAA,WAAA,EAAc,WAAW,CAAA,KAAA,EAAQ,WAAW,CAAA,GAAA,CAAK;AAC5D,oBAAA,MAAM,EAAE,mBAAmB;AAC3B,oBAAA,eAAe,EAAE,MAAM;AACvB,oBAAA,SAAS,EAAE,YAAY;AACvB,oBAAA,aAAa,EAAE,MAAM;AACrB,oBAAA,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC;AACvC,oBAAA,WAAW,EAAE,MAAM;iBACpB,EAAA,EAhBI,MAAM,CAiBX;QAEN,CAAC,CAAC,EAAA,CACD;AAEP;;;;"}
@@ -0,0 +1,26 @@
1
+ import type { PointerEvent as ReactPointerEvent } from 'react';
2
+ import type { ViewportStyles } from '../../hooks/useViewportSize';
3
+ import { type PPTBoxElement } from '../core/resize';
4
+ export interface RotateHandleProps {
5
+ /** The box element whose rotate handle is drawn. */
6
+ element: PPTBoxElement;
7
+ /** SlideCanvas centering offset — the handle shares the element container's origin. */
8
+ viewportStyles: ViewportStyles;
9
+ /** Canvas → screen scale (`props.scale ?? fitScale`). */
10
+ canvasScale: number;
11
+ /** Arm a rotate gesture from a pointer-down on the handle box. */
12
+ onPointerDown: (e: ReactPointerEvent) => void;
13
+ }
14
+ /**
15
+ * Presentational rotate handle for a selected box element: a small grab-cursor
16
+ * box floating above the element's rotated top-center point.
17
+ *
18
+ * Position is computed ANALYTICALLY (like `ResizeHandles`): the rotated
19
+ * top-center point comes from {@link getRotateElementPoints}, then the handle
20
+ * is pushed {@link ROTATE_HANDLE_OFFSET_PX} screen px further along the rotated
21
+ * up vector `(sin θ, -cos θ)` — the un-rotated `(0, -1)` turned by the
22
+ * element's angle — so the handle orbits the element as it rotates. The box
23
+ * carries `data-rotate-handle` and arms the rotate gesture via
24
+ * `onPointerDown`. No `@/` imports.
25
+ */
26
+ export declare function RotateHandle({ element, viewportStyles, canvasScale, onPointerDown, }: RotateHandleProps): import("react/jsx-runtime").JSX.Element;