@openmaic/renderer 0.0.4 → 0.1.0
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.
- package/README.md +14 -1
- package/dist/SlideCanvas.d.ts +14 -1
- package/dist/SlideCanvas.js +17 -7
- package/dist/SlideCanvas.js.map +1 -1
- package/dist/SlideElement.d.ts +10 -2
- package/dist/SlideElement.js +16 -5
- package/dist/SlideElement.js.map +1 -1
- package/dist/elements/audio/BaseAudioElement.d.ts +10 -0
- package/dist/elements/audio/BaseAudioElement.js +71 -0
- package/dist/elements/audio/BaseAudioElement.js.map +1 -0
- package/dist/elements/image/BaseImageElement.js +1 -1
- package/dist/elements/image/BaseImageElement.js.map +1 -1
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +2 -0
- package/dist/elements/index.js.map +1 -1
- package/dist/elements/line/BaseLineElement.js +5 -4
- package/dist/elements/line/BaseLineElement.js.map +1 -1
- package/dist/elements/shape/BaseShapeElement.d.ts +4 -1
- package/dist/elements/shape/BaseShapeElement.js +19 -18
- package/dist/elements/shape/BaseShapeElement.js.map +1 -1
- package/dist/elements/table/BaseTableElement.d.ts +3 -1
- package/dist/elements/table/BaseTableElement.js +3 -2
- package/dist/elements/table/BaseTableElement.js.map +1 -1
- package/dist/elements/table/StaticTable.js +1 -3
- package/dist/elements/table/StaticTable.js.map +1 -1
- package/dist/elements/text/BaseTextElement.d.ts +3 -1
- package/dist/elements/text/BaseTextElement.js +9 -5
- package/dist/elements/text/BaseTextElement.js.map +1 -1
- package/dist/elements/video/BaseVideoElement.js +1 -1
- package/dist/elements/video/BaseVideoElement.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.d.ts +5 -6
- package/dist/styles.js +21 -5
- package/dist/styles.js.map +1 -1
- package/package.json +2 -6
- package/dist/editing/EditableSlideCanvas.d.ts +0 -26
- package/dist/editing/EditableSlideCanvas.js +0 -352
- package/dist/editing/EditableSlideCanvas.js.map +0 -1
- package/dist/editing/core/drag.d.ts +0 -108
- package/dist/editing/core/drag.js +0 -119
- package/dist/editing/core/drag.js.map +0 -1
- package/dist/editing/core/geometry.d.ts +0 -48
- package/dist/editing/core/geometry.js +0 -186
- package/dist/editing/core/geometry.js.map +0 -1
- package/dist/editing/core/intent.d.ts +0 -39
- package/dist/editing/core/intent.js +0 -35
- package/dist/editing/core/intent.js.map +0 -1
- package/dist/editing/core/line-drag.d.ts +0 -19
- package/dist/editing/core/line-drag.js +0 -163
- package/dist/editing/core/line-drag.js.map +0 -1
- package/dist/editing/core/marquee.d.ts +0 -56
- package/dist/editing/core/marquee.js +0 -74
- package/dist/editing/core/marquee.js.map +0 -1
- package/dist/editing/core/resize.d.ts +0 -121
- package/dist/editing/core/resize.js +0 -392
- package/dist/editing/core/resize.js.map +0 -1
- package/dist/editing/core/rotate.d.ts +0 -37
- package/dist/editing/core/rotate.js +0 -74
- package/dist/editing/core/rotate.js.map +0 -1
- package/dist/editing/core/selection.d.ts +0 -68
- package/dist/editing/core/selection.js +0 -108
- package/dist/editing/core/selection.js.map +0 -1
- package/dist/editing/core/snapping.d.ts +0 -54
- package/dist/editing/core/snapping.js +0 -96
- package/dist/editing/core/snapping.js.map +0 -1
- package/dist/editing/handles/BorderLine.d.ts +0 -15
- package/dist/editing/handles/BorderLine.js +0 -17
- package/dist/editing/handles/BorderLine.js.map +0 -1
- package/dist/editing/handles/LineHandles.d.ts +0 -28
- package/dist/editing/handles/LineHandles.js +0 -51
- package/dist/editing/handles/LineHandles.js.map +0 -1
- package/dist/editing/handles/MarqueeBox.d.ts +0 -19
- package/dist/editing/handles/MarqueeBox.js +0 -26
- package/dist/editing/handles/MarqueeBox.js.map +0 -1
- package/dist/editing/handles/ResizeHandles.d.ts +0 -31
- package/dist/editing/handles/ResizeHandles.js +0 -44
- package/dist/editing/handles/ResizeHandles.js.map +0 -1
- package/dist/editing/handles/RotateHandle.d.ts +0 -26
- package/dist/editing/handles/RotateHandle.js +0 -52
- package/dist/editing/handles/RotateHandle.js.map +0 -1
- package/dist/editing/handles/SelectionOverlay.d.ts +0 -18
- package/dist/editing/handles/SelectionOverlay.js +0 -35
- package/dist/editing/handles/SelectionOverlay.js.map +0 -1
- package/dist/editing/index.d.ts +0 -3
- package/dist/editing/index.js +0 -4
- package/dist/editing/index.js.map +0 -1
- package/dist/editing/types.d.ts +0 -107
- package/dist/editing/types.js +0 -7
- package/dist/editing/types.js.map +0 -1
- package/dist/editing/useEditGesture.d.ts +0 -46
- package/dist/editing/useEditGesture.js +0 -217
- package/dist/editing/useEditGesture.js.map +0 -1
- package/dist/editing/useLineHandleGesture.d.ts +0 -35
- package/dist/editing/useLineHandleGesture.js +0 -112
- package/dist/editing/useLineHandleGesture.js.map +0 -1
- package/dist/editing/useMarqueeGesture.d.ts +0 -43
- package/dist/editing/useMarqueeGesture.js +0 -157
- package/dist/editing/useMarqueeGesture.js.map +0 -1
- package/dist/editing/useResizeGesture.d.ts +0 -43
- package/dist/editing/useResizeGesture.js +0 -137
- package/dist/editing/useResizeGesture.js.map +0 -1
- package/dist/editing/useRotateGesture.d.ts +0 -47
- package/dist/editing/useRotateGesture.js +0 -128
- package/dist/editing/useRotateGesture.js.map +0 -1
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure, store-free core for dragging a line element's handles. Ported from the
|
|
3
|
-
* app's `useDragLineElement` gesture, but with no React/store/DOM: the caller
|
|
4
|
-
* feeds the ORIGINAL element plus a pointer delta already converted to canvas
|
|
5
|
-
* units, and gets back the re-normalized `left/top/start/end` (plus whichever
|
|
6
|
-
* control field the line actually carries). No `@/` imports.
|
|
7
|
-
*
|
|
8
|
-
* All intermediate math runs in ABSOLUTE canvas coordinates derived from the
|
|
9
|
-
* original element; `start`/`end`/control offsets are LOCAL to `left/top`, so
|
|
10
|
-
* we lift them to absolute, apply the delta + snapping, then re-normalize the
|
|
11
|
-
* bbox back down to a fresh local frame.
|
|
12
|
-
*/
|
|
13
|
-
/** Snap threshold in canvas units (not screen px). Mirrors the app's `sorptionRange`. */
|
|
14
|
-
const SNAP_RANGE = 8;
|
|
15
|
-
function computeLineDrag(input) {
|
|
16
|
-
const { element, handle, deltaCanvas } = input;
|
|
17
|
-
const { left, top } = element;
|
|
18
|
-
const dx = deltaCanvas.x;
|
|
19
|
-
const dy = deltaCanvas.y;
|
|
20
|
-
// Lift endpoints + control points into absolute canvas coordinates.
|
|
21
|
-
let startX = left + element.start[0];
|
|
22
|
-
let startY = top + element.start[1];
|
|
23
|
-
let endX = left + element.end[0];
|
|
24
|
-
let endY = top + element.end[1];
|
|
25
|
-
const mid = element.broken || element.broken2 || element.curve || [0, 0];
|
|
26
|
-
let midX = left + mid[0];
|
|
27
|
-
let midY = top + mid[1];
|
|
28
|
-
const [c1, c2] = element.cubic || [
|
|
29
|
-
[0, 0],
|
|
30
|
-
[0, 0],
|
|
31
|
-
];
|
|
32
|
-
let c1X = left + c1[0];
|
|
33
|
-
let c1Y = top + c1[1];
|
|
34
|
-
let c2X = left + c2[0];
|
|
35
|
-
let c2Y = top + c2[1];
|
|
36
|
-
// Apply the delta to the dragged handle in absolute space, with axis snapping.
|
|
37
|
-
// NOTE: external-element adsorption (snapping a handle onto sibling anchor
|
|
38
|
-
// points) is deferred — out of scope for this core.
|
|
39
|
-
if (handle === 'start') {
|
|
40
|
-
startX += dx;
|
|
41
|
-
startY += dy;
|
|
42
|
-
if (Math.abs(startX - endX) < SNAP_RANGE)
|
|
43
|
-
startX = endX;
|
|
44
|
-
if (Math.abs(startY - endY) < SNAP_RANGE)
|
|
45
|
-
startY = endY;
|
|
46
|
-
}
|
|
47
|
-
else if (handle === 'end') {
|
|
48
|
-
endX += dx;
|
|
49
|
-
endY += dy;
|
|
50
|
-
if (Math.abs(startX - endX) < SNAP_RANGE)
|
|
51
|
-
endX = startX;
|
|
52
|
-
if (Math.abs(startY - endY) < SNAP_RANGE)
|
|
53
|
-
endY = startY;
|
|
54
|
-
}
|
|
55
|
-
else if (handle === 'ctrl') {
|
|
56
|
-
midX += dx;
|
|
57
|
-
midY += dy;
|
|
58
|
-
if (Math.abs(midX - startX) < SNAP_RANGE)
|
|
59
|
-
midX = startX;
|
|
60
|
-
if (Math.abs(midY - startY) < SNAP_RANGE)
|
|
61
|
-
midY = startY;
|
|
62
|
-
if (Math.abs(midX - endX) < SNAP_RANGE)
|
|
63
|
-
midX = endX;
|
|
64
|
-
if (Math.abs(midY - endY) < SNAP_RANGE)
|
|
65
|
-
midY = endY;
|
|
66
|
-
if (Math.abs(midX - (startX + endX) / 2) < SNAP_RANGE &&
|
|
67
|
-
Math.abs(midY - (startY + endY) / 2) < SNAP_RANGE) {
|
|
68
|
-
midX = (startX + endX) / 2;
|
|
69
|
-
midY = (startY + endY) / 2;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else if (handle === 'ctrl1') {
|
|
73
|
-
c1X += dx;
|
|
74
|
-
c1Y += dy;
|
|
75
|
-
if (Math.abs(c1X - startX) < SNAP_RANGE)
|
|
76
|
-
c1X = startX;
|
|
77
|
-
if (Math.abs(c1Y - startY) < SNAP_RANGE)
|
|
78
|
-
c1Y = startY;
|
|
79
|
-
if (Math.abs(c1X - endX) < SNAP_RANGE)
|
|
80
|
-
c1X = endX;
|
|
81
|
-
if (Math.abs(c1Y - endY) < SNAP_RANGE)
|
|
82
|
-
c1Y = endY;
|
|
83
|
-
}
|
|
84
|
-
else if (handle === 'ctrl2') {
|
|
85
|
-
c2X += dx;
|
|
86
|
-
c2Y += dy;
|
|
87
|
-
if (Math.abs(c2X - startX) < SNAP_RANGE)
|
|
88
|
-
c2X = startX;
|
|
89
|
-
if (Math.abs(c2Y - startY) < SNAP_RANGE)
|
|
90
|
-
c2Y = startY;
|
|
91
|
-
if (Math.abs(c2X - endX) < SNAP_RANGE)
|
|
92
|
-
c2X = endX;
|
|
93
|
-
if (Math.abs(c2Y - endY) < SNAP_RANGE)
|
|
94
|
-
c2Y = endY;
|
|
95
|
-
}
|
|
96
|
-
// Re-normalize the bbox: new local frame origin = (minX, minY).
|
|
97
|
-
const minX = Math.min(startX, endX);
|
|
98
|
-
const minY = Math.min(startY, endY);
|
|
99
|
-
const maxX = Math.max(startX, endX);
|
|
100
|
-
const maxY = Math.max(startY, endY);
|
|
101
|
-
const start = [0, 0];
|
|
102
|
-
const end = [maxX - minX, maxY - minY];
|
|
103
|
-
if (startX > endX) {
|
|
104
|
-
start[0] = maxX - minX;
|
|
105
|
-
end[0] = 0;
|
|
106
|
-
}
|
|
107
|
-
if (startY > endY) {
|
|
108
|
-
start[1] = maxY - minY;
|
|
109
|
-
end[1] = 0;
|
|
110
|
-
}
|
|
111
|
-
const props = {
|
|
112
|
-
left: minX,
|
|
113
|
-
top: minY,
|
|
114
|
-
start,
|
|
115
|
-
end,
|
|
116
|
-
};
|
|
117
|
-
const localMidpoint = [(start[0] + end[0]) / 2, (start[1] + end[1]) / 2];
|
|
118
|
-
if (handle === 'start' || handle === 'end') {
|
|
119
|
-
// Endpoint moved: reset the present control(s) to the new local midpoint so
|
|
120
|
-
// the curve/broken stays visually centered on the re-normalized segment.
|
|
121
|
-
// deferred: Ctrl/Shift would keep control point in place.
|
|
122
|
-
if (element.broken)
|
|
123
|
-
props.broken = [localMidpoint[0], localMidpoint[1]];
|
|
124
|
-
if (element.curve)
|
|
125
|
-
props.curve = [localMidpoint[0], localMidpoint[1]];
|
|
126
|
-
if (element.cubic)
|
|
127
|
-
props.cubic = [
|
|
128
|
-
[localMidpoint[0], localMidpoint[1]],
|
|
129
|
-
[localMidpoint[0], localMidpoint[1]],
|
|
130
|
-
];
|
|
131
|
-
// broken2 is always reset to the midpoint on an endpoint drag.
|
|
132
|
-
if (element.broken2)
|
|
133
|
-
props.broken2 = [localMidpoint[0], localMidpoint[1]];
|
|
134
|
-
}
|
|
135
|
-
else if (handle === 'ctrl') {
|
|
136
|
-
// Single control point dragged: recompute its local offset from the new origin.
|
|
137
|
-
if (element.broken)
|
|
138
|
-
props.broken = [midX - minX, midY - minY];
|
|
139
|
-
if (element.curve)
|
|
140
|
-
props.curve = [midX - minX, midY - minY];
|
|
141
|
-
if (element.broken2) {
|
|
142
|
-
// broken2 tracks only the dominant axis; the other axis keeps its offset.
|
|
143
|
-
if (maxX - minX >= maxY - minY) {
|
|
144
|
-
props.broken2 = [midX - minX, element.broken2[1]];
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
props.broken2 = [element.broken2[0], midY - minY];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else if (handle === 'ctrl1' || handle === 'ctrl2') {
|
|
152
|
-
if (element.cubic) {
|
|
153
|
-
props.cubic = [
|
|
154
|
-
[c1X - minX, c1Y - minY],
|
|
155
|
-
[c2X - minX, c2Y - minY],
|
|
156
|
-
];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return { props };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export { computeLineDrag };
|
|
163
|
-
//# sourceMappingURL=line-drag.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"line-drag.js","sources":["../../../src/editing/core/line-drag.ts"],"sourcesContent":["import type { PPTLineElement } from '@openmaic/dsl';\nimport type { LineHandle } from '../types';\n\n/**\n * Pure, store-free core for dragging a line element's handles. Ported from the\n * app's `useDragLineElement` gesture, but with no React/store/DOM: the caller\n * feeds the ORIGINAL element plus a pointer delta already converted to canvas\n * units, and gets back the re-normalized `left/top/start/end` (plus whichever\n * control field the line actually carries). No `@/` imports.\n *\n * All intermediate math runs in ABSOLUTE canvas coordinates derived from the\n * original element; `start`/`end`/control offsets are LOCAL to `left/top`, so\n * we lift them to absolute, apply the delta + snapping, then re-normalize the\n * bbox back down to a fresh local frame.\n */\n\n/** Snap threshold in canvas units (not screen px). Mirrors the app's `sorptionRange`. */\nconst SNAP_RANGE = 8;\n\nexport interface LineDragInput {\n element: PPTLineElement;\n handle: LineHandle;\n deltaCanvas: { x: number; y: number };\n}\n\nexport interface LineDragResult {\n props: {\n left: number;\n top: number;\n start: [number, number];\n end: [number, number];\n } & Partial<Pick<PPTLineElement, 'broken' | 'broken2' | 'curve' | 'cubic'>>;\n}\n\nexport function computeLineDrag(input: LineDragInput): LineDragResult {\n const { element, handle, deltaCanvas } = input;\n const { left, top } = element;\n const dx = deltaCanvas.x;\n const dy = deltaCanvas.y;\n\n // Lift endpoints + control points into absolute canvas coordinates.\n let startX = left + element.start[0];\n let startY = top + element.start[1];\n let endX = left + element.end[0];\n let endY = top + element.end[1];\n\n const mid = element.broken || element.broken2 || element.curve || [0, 0];\n let midX = left + mid[0];\n let midY = top + mid[1];\n\n const [c1, c2] = element.cubic || [\n [0, 0],\n [0, 0],\n ];\n let c1X = left + c1[0];\n let c1Y = top + c1[1];\n let c2X = left + c2[0];\n let c2Y = top + c2[1];\n\n // Apply the delta to the dragged handle in absolute space, with axis snapping.\n // NOTE: external-element adsorption (snapping a handle onto sibling anchor\n // points) is deferred — out of scope for this core.\n if (handle === 'start') {\n startX += dx;\n startY += dy;\n if (Math.abs(startX - endX) < SNAP_RANGE) startX = endX;\n if (Math.abs(startY - endY) < SNAP_RANGE) startY = endY;\n } else if (handle === 'end') {\n endX += dx;\n endY += dy;\n if (Math.abs(startX - endX) < SNAP_RANGE) endX = startX;\n if (Math.abs(startY - endY) < SNAP_RANGE) endY = startY;\n } else if (handle === 'ctrl') {\n midX += dx;\n midY += dy;\n if (Math.abs(midX - startX) < SNAP_RANGE) midX = startX;\n if (Math.abs(midY - startY) < SNAP_RANGE) midY = startY;\n if (Math.abs(midX - endX) < SNAP_RANGE) midX = endX;\n if (Math.abs(midY - endY) < SNAP_RANGE) midY = endY;\n if (\n Math.abs(midX - (startX + endX) / 2) < SNAP_RANGE &&\n Math.abs(midY - (startY + endY) / 2) < SNAP_RANGE\n ) {\n midX = (startX + endX) / 2;\n midY = (startY + endY) / 2;\n }\n } else if (handle === 'ctrl1') {\n c1X += dx;\n c1Y += dy;\n if (Math.abs(c1X - startX) < SNAP_RANGE) c1X = startX;\n if (Math.abs(c1Y - startY) < SNAP_RANGE) c1Y = startY;\n if (Math.abs(c1X - endX) < SNAP_RANGE) c1X = endX;\n if (Math.abs(c1Y - endY) < SNAP_RANGE) c1Y = endY;\n } else if (handle === 'ctrl2') {\n c2X += dx;\n c2Y += dy;\n if (Math.abs(c2X - startX) < SNAP_RANGE) c2X = startX;\n if (Math.abs(c2Y - startY) < SNAP_RANGE) c2Y = startY;\n if (Math.abs(c2X - endX) < SNAP_RANGE) c2X = endX;\n if (Math.abs(c2Y - endY) < SNAP_RANGE) c2Y = endY;\n }\n\n // Re-normalize the bbox: new local frame origin = (minX, minY).\n const minX = Math.min(startX, endX);\n const minY = Math.min(startY, endY);\n const maxX = Math.max(startX, endX);\n const maxY = Math.max(startY, endY);\n\n const start: [number, number] = [0, 0];\n const end: [number, number] = [maxX - minX, maxY - minY];\n if (startX > endX) {\n start[0] = maxX - minX;\n end[0] = 0;\n }\n if (startY > endY) {\n start[1] = maxY - minY;\n end[1] = 0;\n }\n\n const props: LineDragResult['props'] = {\n left: minX,\n top: minY,\n start,\n end,\n };\n\n const localMidpoint: [number, number] = [(start[0] + end[0]) / 2, (start[1] + end[1]) / 2];\n\n if (handle === 'start' || handle === 'end') {\n // Endpoint moved: reset the present control(s) to the new local midpoint so\n // the curve/broken stays visually centered on the re-normalized segment.\n // deferred: Ctrl/Shift would keep control point in place.\n if (element.broken) props.broken = [localMidpoint[0], localMidpoint[1]];\n if (element.curve) props.curve = [localMidpoint[0], localMidpoint[1]];\n if (element.cubic)\n props.cubic = [\n [localMidpoint[0], localMidpoint[1]],\n [localMidpoint[0], localMidpoint[1]],\n ];\n // broken2 is always reset to the midpoint on an endpoint drag.\n if (element.broken2) props.broken2 = [localMidpoint[0], localMidpoint[1]];\n } else if (handle === 'ctrl') {\n // Single control point dragged: recompute its local offset from the new origin.\n if (element.broken) props.broken = [midX - minX, midY - minY];\n if (element.curve) props.curve = [midX - minX, midY - minY];\n if (element.broken2) {\n // broken2 tracks only the dominant axis; the other axis keeps its offset.\n if (maxX - minX >= maxY - minY) {\n props.broken2 = [midX - minX, element.broken2[1]];\n } else {\n props.broken2 = [element.broken2[0], midY - minY];\n }\n }\n } else if (handle === 'ctrl1' || handle === 'ctrl2') {\n if (element.cubic) {\n props.cubic = [\n [c1X - minX, c1Y - minY],\n [c2X - minX, c2Y - minY],\n ];\n }\n }\n\n return { props };\n}\n"],"names":[],"mappings":"AAGA;;;;;;;;;;;AAWG;AAEH;AACA,MAAM,UAAU,GAAG,CAAC;AAiBd,SAAU,eAAe,CAAC,KAAoB,EAAA;IAClD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK;AAC9C,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;AAC7B,IAAA,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC;AACxB,IAAA,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC;;IAGxB,IAAI,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,IAAI,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACnC,IAAI,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,IAAI,IAAI,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/B,IAAA,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IACxE,IAAI,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;IACxB,IAAI,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;IAEvB,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,O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;YACnD;iBAAO;AACL,gBAAA,KAAK,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;YACnD;QACF;IACF;SAAO,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,OAAO,EAAE;AACnD,QAAA,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,KAAK,CAAC,KAAK,GAAG;AACZ,gBAAA,CAAC,GAAG,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;AACxB,gBAAA,CAAC,GAAG,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;aACzB;QACH;IACF;IAEA,OAAO,EAAE,KAAK,EAAE;AAClB;;;;"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { PPTElement } from '@openmaic/dsl';
|
|
2
|
-
import { type ElementRange } from './geometry';
|
|
3
|
-
/**
|
|
4
|
-
* Pure marquee (rubber-band / drag-select) math for the editing surface. Ported
|
|
5
|
-
* from the app's `useMouseSelection`, but store-free and normalized: the caller
|
|
6
|
-
* feeds a rectangle already in canvas units plus the slide elements, and gets
|
|
7
|
-
* back the ids the marquee selects. No React, no store, no `@/` imports — this
|
|
8
|
-
* module only consumes the DSL element shape and plain numbers, so it can be
|
|
9
|
-
* exercised with plain unit tests and reused by any host.
|
|
10
|
-
*
|
|
11
|
-
* The app stores the marquee as start + |magnitude| + quadrant and branches the
|
|
12
|
-
* containment test four ways (one per drag direction). Here the rectangle is
|
|
13
|
-
* NORMALIZED to `{minX,minY,maxX,maxY}` at the source ({@link marqueeRect}), so
|
|
14
|
-
* containment/intersection each collapse to a single predicate regardless of
|
|
15
|
-
* drag direction — which also sidesteps the app's stale-closure quadrant bug.
|
|
16
|
-
*/
|
|
17
|
-
/** A pointer position in canvas units (viewportSize space). */
|
|
18
|
-
export interface MarqueePoint {
|
|
19
|
-
x: number;
|
|
20
|
-
y: number;
|
|
21
|
-
}
|
|
22
|
-
/** A normalized marquee rectangle in canvas units (min/max on each axis). */
|
|
23
|
-
export type MarqueeRect = ElementRange;
|
|
24
|
-
/**
|
|
25
|
-
* How an element's bounds must relate to the marquee rectangle to be selected:
|
|
26
|
-
* - `contain`: the element's AABB is wholly inside the rectangle (no modifier).
|
|
27
|
-
* - `intersect`: the element's AABB overlaps the rectangle at all (Ctrl/Shift).
|
|
28
|
-
*/
|
|
29
|
-
export type MarqueeMode = 'contain' | 'intersect';
|
|
30
|
-
export interface MarqueeSelectionOptions {
|
|
31
|
-
mode: MarqueeMode;
|
|
32
|
-
/** Ids the marquee must never select (e.g. host-hidden elements). */
|
|
33
|
-
excludeIds?: readonly string[];
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Normalize a start + current pointer pair (canvas units) into a rectangle with
|
|
37
|
-
* min/max on each axis, so the four drag directions all produce the same
|
|
38
|
-
* `{minX,minY,maxX,maxY}` and containment is a single predicate.
|
|
39
|
-
*/
|
|
40
|
-
export declare function marqueeRect(start: MarqueePoint, current: MarqueePoint): MarqueeRect;
|
|
41
|
-
/**
|
|
42
|
-
* The ids the marquee `rect` selects from `elements`, in element (z-)order.
|
|
43
|
-
*
|
|
44
|
-
* Rules, ported from the app:
|
|
45
|
-
* - Non-line elements are tested by their rotation-aware AABB
|
|
46
|
-
* ({@link getEditingElementRange}), so a rotated element uses its enclosing box.
|
|
47
|
-
* - Line elements are tested by a control-point-aware conservative AABB
|
|
48
|
-
* ({@link getEditingElementRange}), so a bent line's bow is still hit-testable.
|
|
49
|
-
* - Locked elements (and any `excludeIds`) are never selected.
|
|
50
|
-
* - Group cohesion is all-or-nothing: a matched element that carries a
|
|
51
|
-
* `groupId` survives only if EVERY member of that group also matched — so a
|
|
52
|
-
* partial box over a group never splits it.
|
|
53
|
-
*
|
|
54
|
-
* The result REPLACES the selection (the caller decides how to publish it).
|
|
55
|
-
*/
|
|
56
|
-
export declare function computeMarqueeSelection(rect: MarqueeRect, elements: readonly PPTElement[], options: MarqueeSelectionOptions): string[];
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { getEditingElementRange } from './geometry.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Normalize a start + current pointer pair (canvas units) into a rectangle with
|
|
5
|
-
* min/max on each axis, so the four drag directions all produce the same
|
|
6
|
-
* `{minX,minY,maxX,maxY}` and containment is a single predicate.
|
|
7
|
-
*/
|
|
8
|
-
function marqueeRect(start, current) {
|
|
9
|
-
return {
|
|
10
|
-
minX: Math.min(start.x, current.x),
|
|
11
|
-
minY: Math.min(start.y, current.y),
|
|
12
|
-
maxX: Math.max(start.x, current.x),
|
|
13
|
-
maxY: Math.max(start.y, current.y),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Whether an element's bounding range hits the marquee per `mode`. `contain` is
|
|
18
|
-
* inclusive of a boundary-touching edge (`>=`/`<=`); `intersect` requires a
|
|
19
|
-
* strictly-positive overlap (`>`/`<`) so edge-to-edge touching does not count.
|
|
20
|
-
*/
|
|
21
|
-
function hitsMarquee(range, rect, mode) {
|
|
22
|
-
if (mode === 'contain') {
|
|
23
|
-
return (range.minX >= rect.minX &&
|
|
24
|
-
range.maxX <= rect.maxX &&
|
|
25
|
-
range.minY >= rect.minY &&
|
|
26
|
-
range.maxY <= rect.maxY);
|
|
27
|
-
}
|
|
28
|
-
return (range.minX < rect.maxX &&
|
|
29
|
-
range.maxX > rect.minX &&
|
|
30
|
-
range.minY < rect.maxY &&
|
|
31
|
-
range.maxY > rect.minY);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The ids the marquee `rect` selects from `elements`, in element (z-)order.
|
|
35
|
-
*
|
|
36
|
-
* Rules, ported from the app:
|
|
37
|
-
* - Non-line elements are tested by their rotation-aware AABB
|
|
38
|
-
* ({@link getEditingElementRange}), so a rotated element uses its enclosing box.
|
|
39
|
-
* - Line elements are tested by a control-point-aware conservative AABB
|
|
40
|
-
* ({@link getEditingElementRange}), so a bent line's bow is still hit-testable.
|
|
41
|
-
* - Locked elements (and any `excludeIds`) are never selected.
|
|
42
|
-
* - Group cohesion is all-or-nothing: a matched element that carries a
|
|
43
|
-
* `groupId` survives only if EVERY member of that group also matched — so a
|
|
44
|
-
* partial box over a group never splits it.
|
|
45
|
-
*
|
|
46
|
-
* The result REPLACES the selection (the caller decides how to publish it).
|
|
47
|
-
*/
|
|
48
|
-
function computeMarqueeSelection(rect, elements, options) {
|
|
49
|
-
const { mode, excludeIds } = options;
|
|
50
|
-
const excluded = excludeIds && excludeIds.length ? new Set(excludeIds) : null;
|
|
51
|
-
const matched = [];
|
|
52
|
-
for (const el of elements) {
|
|
53
|
-
if (el.lock)
|
|
54
|
-
continue;
|
|
55
|
-
if (excluded?.has(el.id))
|
|
56
|
-
continue;
|
|
57
|
-
const range = getEditingElementRange(el);
|
|
58
|
-
if (hitsMarquee(range, rect, mode))
|
|
59
|
-
matched.push(el);
|
|
60
|
-
}
|
|
61
|
-
const matchedIds = new Set(matched.map((el) => el.id));
|
|
62
|
-
const cohesive = matched.filter((el) => {
|
|
63
|
-
if (!el.groupId)
|
|
64
|
-
return true;
|
|
65
|
-
// A grouped element stays only if every sibling in its group also matched.
|
|
66
|
-
return elements
|
|
67
|
-
.filter((o) => o.groupId === el.groupId)
|
|
68
|
-
.every((member) => matchedIds.has(member.id));
|
|
69
|
-
});
|
|
70
|
-
return cohesive.map((el) => el.id);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { computeMarqueeSelection, marqueeRect };
|
|
74
|
-
//# sourceMappingURL=marquee.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.js","sources":["../../../src/editing/core/marquee.ts"],"sourcesContent":["import type { PPTElement } from '@openmaic/dsl';\nimport { getEditingElementRange, type ElementRange } from './geometry';\n\n/**\n * Pure marquee (rubber-band / drag-select) math for the editing surface. Ported\n * from the app's `useMouseSelection`, but store-free and normalized: the caller\n * feeds a rectangle already in canvas units plus the slide elements, and gets\n * back the ids the marquee selects. No React, no store, no `@/` imports — this\n * module only consumes the DSL element shape and plain numbers, so it can be\n * exercised with plain unit tests and reused by any host.\n *\n * The app stores the marquee as start + |magnitude| + quadrant and branches the\n * containment test four ways (one per drag direction). Here the rectangle is\n * NORMALIZED to `{minX,minY,maxX,maxY}` at the source ({@link marqueeRect}), so\n * containment/intersection each collapse to a single predicate regardless of\n * drag direction — which also sidesteps the app's stale-closure quadrant bug.\n */\n\n/** A pointer position in canvas units (viewportSize space). */\nexport interface MarqueePoint {\n x: number;\n y: number;\n}\n\n/** A normalized marquee rectangle in canvas units (min/max on each axis). */\nexport type MarqueeRect = ElementRange;\n\n/**\n * How an element's bounds must relate to the marquee rectangle to be selected:\n * - `contain`: the element's AABB is wholly inside the rectangle (no modifier).\n * - `intersect`: the element's AABB overlaps the rectangle at all (Ctrl/Shift).\n */\nexport type MarqueeMode = 'contain' | 'intersect';\n\nexport interface MarqueeSelectionOptions {\n mode: MarqueeMode;\n /** Ids the marquee must never select (e.g. host-hidden elements). */\n excludeIds?: readonly string[];\n}\n\n/**\n * Normalize a start + current pointer pair (canvas units) into a rectangle with\n * min/max on each axis, so the four drag directions all produce the same\n * `{minX,minY,maxX,maxY}` and containment is a single predicate.\n */\nexport function marqueeRect(start: MarqueePoint, current: MarqueePoint): MarqueeRect {\n return {\n minX: Math.min(start.x, current.x),\n minY: Math.min(start.y, current.y),\n maxX: Math.max(start.x, current.x),\n maxY: Math.max(start.y, current.y),\n };\n}\n\n/**\n * Whether an element's bounding range hits the marquee per `mode`. `contain` is\n * inclusive of a boundary-touching edge (`>=`/`<=`); `intersect` requires a\n * strictly-positive overlap (`>`/`<`) so edge-to-edge touching does not count.\n */\nfunction hitsMarquee(range: ElementRange, rect: MarqueeRect, mode: MarqueeMode): boolean {\n if (mode === 'contain') {\n return (\n range.minX >= rect.minX &&\n range.maxX <= rect.maxX &&\n range.minY >= rect.minY &&\n range.maxY <= rect.maxY\n );\n }\n return (\n range.minX < rect.maxX &&\n range.maxX > rect.minX &&\n range.minY < rect.maxY &&\n range.maxY > rect.minY\n );\n}\n\n/**\n * The ids the marquee `rect` selects from `elements`, in element (z-)order.\n *\n * Rules, ported from the app:\n * - Non-line elements are tested by their rotation-aware AABB\n * ({@link getEditingElementRange}), so a rotated element uses its enclosing box.\n * - Line elements are tested by a control-point-aware conservative AABB\n * ({@link getEditingElementRange}), so a bent line's bow is still hit-testable.\n * - Locked elements (and any `excludeIds`) are never selected.\n * - Group cohesion is all-or-nothing: a matched element that carries a\n * `groupId` survives only if EVERY member of that group also matched — so a\n * partial box over a group never splits it.\n *\n * The result REPLACES the selection (the caller decides how to publish it).\n */\nexport function computeMarqueeSelection(\n rect: MarqueeRect,\n elements: readonly PPTElement[],\n options: MarqueeSelectionOptions,\n): string[] {\n const { mode, excludeIds } = options;\n const excluded = excludeIds && excludeIds.length ? new Set(excludeIds) : null;\n\n const matched: PPTElement[] = [];\n for (const el of elements) {\n if (el.lock) continue;\n if (excluded?.has(el.id)) continue;\n const range = getEditingElementRange(el);\n if (hitsMarquee(range, rect, mode)) matched.push(el);\n }\n\n const matchedIds = new Set(matched.map((el) => el.id));\n const cohesive = matched.filter((el) => {\n if (!el.groupId) return true;\n // A grouped element stays only if every sibling in its group also matched.\n return elements\n .filter((o) => o.groupId === el.groupId)\n .every((member) => matchedIds.has(member.id));\n });\n\n return cohesive.map((el) => el.id);\n}\n"],"names":[],"mappings":";;AAwCA;;;;AAIG;AACG,SAAU,WAAW,CAAC,KAAmB,EAAE,OAAqB,EAAA;IACpE,OAAO;AACL,QAAA,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAClC,QAAA,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAClC,QAAA,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CA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AAA,IAAI,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC;AAAE,YAAA,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IACtD;AAEA,IAAA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAI;QACrC,IAAI,CAAC,EAAE,CAAC,OAAO;AAAE,YAAA,OAAO,IAAI;;AAE5B,QAAA,OAAO;AACJ,aAAA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC,OAAO;AACtC,aAAA,KAAK,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACjD,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACpC;;;;"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { PPTElement, PPTLineElement } from '@openmaic/dsl';
|
|
2
|
-
import type { SnappingOptions } from '../types';
|
|
3
|
-
import { type Guide } from './snapping';
|
|
4
|
-
/**
|
|
5
|
-
* Pure, store-free core for the 8-point box resize gesture. Ported from the
|
|
6
|
-
* app's scale-element gesture, but with no React/store/DOM: the caller feeds
|
|
7
|
-
* the ORIGINAL element plus a pointer delta already converted to canvas units,
|
|
8
|
-
* and gets back the new `left/top/width/height` box plus any alignment guides.
|
|
9
|
-
* No `@/` imports — this module only consumes the DSL element shape, the
|
|
10
|
-
* sibling snapping/drag cores, and plain numbers.
|
|
11
|
-
*
|
|
12
|
-
* Scope note: `computeResize` emits ONLY the box props. Kind-specific content
|
|
13
|
-
* recomputation that must track the box (a shape's `pathFormula`/`viewBox`
|
|
14
|
-
* path, a table's `cellMinHeight`, an image's clip mode) is a host/app concern
|
|
15
|
-
* or a later slice — the host can post-process in response to the intent.
|
|
16
|
-
*/
|
|
17
|
-
/** A selectable element that carries a box model (`width`/`height`/`rotate`). */
|
|
18
|
-
export type PPTBoxElement = Exclude<PPTElement, PPTLineElement>;
|
|
19
|
-
/** The eight resize points on a box element's selection frame. */
|
|
20
|
-
export type ResizeHandle = 'left-top' | 'top' | 'right-top' | 'left' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom';
|
|
21
|
-
/** All eight handles, in the app's render order (row-major, top to bottom). */
|
|
22
|
-
export declare const RESIZE_HANDLES: readonly ResizeHandle[];
|
|
23
|
-
/** The diagonally/axially opposite handle — the visually fixed point of a resize. */
|
|
24
|
-
export declare const OPPOSITE_HANDLE: Record<ResizeHandle, ResizeHandle>;
|
|
25
|
-
/**
|
|
26
|
-
* Minimum size (canvas units) an element may be resized down to, per type.
|
|
27
|
-
* Mirrors the app's element config so the package clamps identically.
|
|
28
|
-
*/
|
|
29
|
-
export declare const ELEMENT_MIN_SIZE: Record<string, number>;
|
|
30
|
-
interface Box {
|
|
31
|
-
left: number;
|
|
32
|
-
top: number;
|
|
33
|
-
width: number;
|
|
34
|
-
height: number;
|
|
35
|
-
}
|
|
36
|
-
interface Point {
|
|
37
|
-
left: number;
|
|
38
|
-
top: number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Positions (canvas units) of the eight resize points of a ROTATED box: each
|
|
42
|
-
* un-rotated frame point rotated about the box center by `angle` (degrees,
|
|
43
|
-
* CSS-clockwise). At `angle === 0` this degenerates to the plain frame points
|
|
44
|
-
* (e.g. `left-top` = `(left, top)`), so it also serves as the single source of
|
|
45
|
-
* truth for handle placement at any rotation.
|
|
46
|
-
*/
|
|
47
|
-
export declare function getRotateElementPoints(element: Box, angle: number): Record<ResizeHandle, Point>;
|
|
48
|
-
export type ResizeCursor = 'nwse-resize' | 'ns-resize' | 'nesw-resize' | 'ew-resize';
|
|
49
|
-
/**
|
|
50
|
-
* Rotation-aware resize cursor for a handle: bucket `rotate` to the nearest of
|
|
51
|
-
* 0/45/90/135 (mod 180, +-22.5deg thresholds, negatives wrap the same way),
|
|
52
|
-
* then advance the handle's rotation-0 cursor one {@link CURSOR_CYCLE} step per
|
|
53
|
-
* 45deg bucket. Reproduces the app's full handle x bucket cursor table.
|
|
54
|
-
*/
|
|
55
|
-
export declare function getResizeCursor(handle: ResizeHandle, rotate: number): ResizeCursor;
|
|
56
|
-
/**
|
|
57
|
-
* Which resize handles a box element exposes, by kind (app parity):
|
|
58
|
-
* - `code`: none — the app renders no resize points for code blocks.
|
|
59
|
-
* - `text`: only the width axis, since text height follows content — `left`/
|
|
60
|
-
* `right`, or `top`/`bottom` when the text is vertical.
|
|
61
|
-
* - everything else: all eight points.
|
|
62
|
-
* Line elements never reach here (they have endpoint handles, not a box).
|
|
63
|
-
*/
|
|
64
|
-
export declare function getResizeHandles(element: PPTBoxElement): readonly ResizeHandle[];
|
|
65
|
-
/**
|
|
66
|
-
* Single-element resize input for one gesture tick: the ORIGINAL element (as
|
|
67
|
-
* captured at pointer-down — deltas always apply to the origin, never to a
|
|
68
|
-
* previous tick's output), the operated handle, its siblings (`others`, snap
|
|
69
|
-
* candidates), the viewport (canvas bounds for `toCanvas` snapping), the
|
|
70
|
-
* pointer delta already converted to canvas units, whether the aspect-lock
|
|
71
|
-
* modifier (Ctrl/Shift/Meta) is held at THIS tick, and the snapping config.
|
|
72
|
-
*/
|
|
73
|
-
export interface ResizeInput {
|
|
74
|
-
element: PPTBoxElement;
|
|
75
|
-
handle: ResizeHandle;
|
|
76
|
-
others: PPTElement[];
|
|
77
|
-
viewport: {
|
|
78
|
-
width: number;
|
|
79
|
-
height: number;
|
|
80
|
-
};
|
|
81
|
-
deltaCanvas: {
|
|
82
|
-
x: number;
|
|
83
|
-
y: number;
|
|
84
|
-
};
|
|
85
|
-
aspectModifier?: boolean;
|
|
86
|
-
snapping?: boolean | SnappingOptions;
|
|
87
|
-
}
|
|
88
|
-
/** The resized element's new box plus the guides to render, if any. */
|
|
89
|
-
export interface ResizeResult {
|
|
90
|
-
props: {
|
|
91
|
-
left: number;
|
|
92
|
-
top: number;
|
|
93
|
-
width: number;
|
|
94
|
-
height: number;
|
|
95
|
-
};
|
|
96
|
-
guides: Guide[];
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Apply a resize delta to a single box element. Composition, per the app:
|
|
100
|
-
*
|
|
101
|
-
* - **Un-rotated**: the moving edge(s) follow the pointer delta directly; the
|
|
102
|
-
* moving corner/edge position is snapped against `others`/the canvas BEFORE
|
|
103
|
-
* min-size clamping (aspect lock recomputes the other axis from whichever
|
|
104
|
-
* axis snapped); resizing from a left/top edge shifts `left`/`top` so the
|
|
105
|
-
* opposite edge stays put. Rotated siblings and lines are excluded from the
|
|
106
|
-
* snap candidates (their axis-aligned bboxes are not meaningful snap edges).
|
|
107
|
-
* - **Rotated**: the pointer delta is first rotated into the element's local
|
|
108
|
-
* axes; the same per-handle size math applies; then the position is
|
|
109
|
-
* corrected so the point OPPOSITE the operated handle stays visually fixed
|
|
110
|
-
* (resizing changes where the rotated opposite corner lands, so `left`/`top`
|
|
111
|
-
* must compensate). No snapping for rotated elements (app parity).
|
|
112
|
-
*
|
|
113
|
-
* Aspect lock (`aspectModifier` held, or the element's own `fixedRatio`) only
|
|
114
|
-
* affects the four CORNER handles: the vertical delta is recomputed from the
|
|
115
|
-
* horizontal one at the origin's aspect ratio. Edge handles ignore it.
|
|
116
|
-
*
|
|
117
|
-
* Min-size clamping uses the per-type {@link ELEMENT_MIN_SIZE}; under aspect
|
|
118
|
-
* lock the limit is scaled so both axes reach their minimum together.
|
|
119
|
-
*/
|
|
120
|
-
export declare function computeResize(input: ResizeInput): ResizeResult;
|
|
121
|
-
export {};
|