@openmaic/renderer 0.0.5 → 0.1.1
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/shape/BaseShapeElement.d.ts +4 -1
- package/dist/elements/shape/BaseShapeElement.js +21 -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 +11 -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 +24 -5
- package/dist/styles.js.map +1 -1
- package/dist/utils/richText.d.ts +1 -0
- package/dist/utils/richText.js +12 -0
- package/dist/utils/richText.js.map +1 -0
- 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,119 +0,0 @@
|
|
|
1
|
-
import { getEditingElementListRange } from './geometry.js';
|
|
2
|
-
import { buildAlignLines, snapRange } from './snapping.js';
|
|
3
|
-
import { getElementRange } from '../../utils/element.js';
|
|
4
|
-
|
|
5
|
-
const DEFAULT_SNAP_RANGE = 5;
|
|
6
|
-
/**
|
|
7
|
-
* Resolve the `snapping` prop into concrete `buildAlignLines` options plus the
|
|
8
|
-
* snap `range`: `true` enables both element- and canvas-snapping at the
|
|
9
|
-
* default range; `false`/absent disables snapping entirely (`null`); an
|
|
10
|
-
* explicit `SnappingOptions` object is used as-is, with `range` defaulted.
|
|
11
|
-
* Shared by the drag and resize cores so both gestures interpret the
|
|
12
|
-
* `snapping` prop identically.
|
|
13
|
-
*/
|
|
14
|
-
function resolveSnapping(snapping) {
|
|
15
|
-
if (snapping === true) {
|
|
16
|
-
return { opts: { toElements: true, toCanvas: true }, range: DEFAULT_SNAP_RANGE };
|
|
17
|
-
}
|
|
18
|
-
if (!snapping) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return { opts: snapping, range: snapping.range ?? DEFAULT_SNAP_RANGE };
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Apply a drag delta to a single element (respecting an optional axis lock),
|
|
25
|
-
* then snap the moved position against `others`/the canvas per `snapping`.
|
|
26
|
-
* Composition: shift the element's `left/top` by `deltaCanvas` → derive the
|
|
27
|
-
* shifted element's `ElementRange` via `getElementRange` → build candidate
|
|
28
|
-
* align lines via `buildAlignLines` → correct the shift via `snapRange`
|
|
29
|
-
* (`dx`/`dy`) → return the corrected `left/top` plus the guides to render.
|
|
30
|
-
* No React, no store, no `@/` imports.
|
|
31
|
-
*/
|
|
32
|
-
function computeDragMove(input) {
|
|
33
|
-
const { element, others, viewport, deltaCanvas, axisLock, snapping } = input;
|
|
34
|
-
// Lines are filtered from dragging upstream (they carry `start`/`end`, not a
|
|
35
|
-
// `width`/`height` box, so the box-model drag intent can't represent them).
|
|
36
|
-
// If one still reaches here, return its current position unchanged rather than
|
|
37
|
-
// reading `undefined` box fields off the union.
|
|
38
|
-
if (element.type === 'line') {
|
|
39
|
-
return { props: { left: element.left, top: element.top }, guides: [] };
|
|
40
|
-
}
|
|
41
|
-
// `element` is now narrowed to the non-line box variants, so `left/top/width/
|
|
42
|
-
// height/rotate` are directly available without any cast.
|
|
43
|
-
const { left, top, width, height, rotate } = element;
|
|
44
|
-
const dx0 = axisLock === 'y' ? 0 : deltaCanvas.x;
|
|
45
|
-
const dy0 = axisLock === 'x' ? 0 : deltaCanvas.y;
|
|
46
|
-
const shiftedLeft = left + dx0;
|
|
47
|
-
const shiftedTop = top + dy0;
|
|
48
|
-
const resolved = resolveSnapping(snapping);
|
|
49
|
-
if (!resolved) {
|
|
50
|
-
return { props: { left: shiftedLeft, top: shiftedTop }, guides: [] };
|
|
51
|
-
}
|
|
52
|
-
const shiftedElement = {
|
|
53
|
-
...element,
|
|
54
|
-
left: shiftedLeft,
|
|
55
|
-
top: shiftedTop,
|
|
56
|
-
width,
|
|
57
|
-
height,
|
|
58
|
-
rotate,
|
|
59
|
-
};
|
|
60
|
-
const targetRange = getElementRange(shiftedElement);
|
|
61
|
-
const lines = buildAlignLines(others, viewport, resolved.opts);
|
|
62
|
-
const { dx, dy, guides } = snapRange(targetRange, lines, resolved.range);
|
|
63
|
-
return {
|
|
64
|
-
props: { left: shiftedLeft + dx, top: shiftedTop + dy },
|
|
65
|
-
guides,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Apply a drag delta to a MULTI-element selection as one rigid translation.
|
|
70
|
-
* Composition mirrors {@link computeDragMove} but snaps the whole set together:
|
|
71
|
-
* shift every selected element by `deltaCanvas` → take the editing UNION
|
|
72
|
-
* bounding box of the shifted set (`getEditingElementListRange`) → snap that union against
|
|
73
|
-
* `others`/the canvas → apply the SAME corrected delta to every selected
|
|
74
|
-
* element's origin. The snap is computed once on the union (not per element), so
|
|
75
|
-
* the set never deforms — spacing between selected elements is preserved.
|
|
76
|
-
*
|
|
77
|
-
* `handleElement` is declared for the caller's clarity (it identifies the
|
|
78
|
-
* pointer's grab element within `selected`); the correction is identical for
|
|
79
|
-
* every member, so it is applied uniformly rather than relative to the handle.
|
|
80
|
-
* Lines carried inside the selection are translated too (they own `left`/`top`),
|
|
81
|
-
* unlike the single-element {@link computeDragMove} which leaves a lone line put.
|
|
82
|
-
*
|
|
83
|
-
* With a single selected element this reduces EXACTLY to {@link computeDragMove}'s
|
|
84
|
-
* position math (same union == that element's range, same snap correction), so
|
|
85
|
-
* the hook can route N == 1 through either and get identical results.
|
|
86
|
-
* No React, no store, no `@/` imports.
|
|
87
|
-
*/
|
|
88
|
-
function computeMultiDragMove(input) {
|
|
89
|
-
const { selected, others, viewport, deltaCanvas, axisLock, snapping } = input;
|
|
90
|
-
// Exported-API hardening: an empty set has no union bbox (a min/max over
|
|
91
|
-
// nothing degenerates to ±Infinity), so there is nothing to move or snap.
|
|
92
|
-
if (selected.length === 0)
|
|
93
|
-
return { updates: [], guides: [] };
|
|
94
|
-
const dx0 = axisLock === 'y' ? 0 : deltaCanvas.x;
|
|
95
|
-
const dy0 = axisLock === 'x' ? 0 : deltaCanvas.y;
|
|
96
|
-
let dx = 0;
|
|
97
|
-
let dy = 0;
|
|
98
|
-
let guides = [];
|
|
99
|
-
const resolved = resolveSnapping(snapping);
|
|
100
|
-
if (resolved) {
|
|
101
|
-
const shifted = selected.map((el) => ({ ...el, left: el.left + dx0, top: el.top + dy0 }));
|
|
102
|
-
const targetRange = getEditingElementListRange(shifted);
|
|
103
|
-
const lines = buildAlignLines(others, viewport, resolved.opts);
|
|
104
|
-
const snapped = snapRange(targetRange, lines, resolved.range);
|
|
105
|
-
dx = snapped.dx;
|
|
106
|
-
dy = snapped.dy;
|
|
107
|
-
guides = snapped.guides;
|
|
108
|
-
}
|
|
109
|
-
const totalX = dx0 + dx;
|
|
110
|
-
const totalY = dy0 + dy;
|
|
111
|
-
const updates = selected.map((el) => ({
|
|
112
|
-
id: el.id,
|
|
113
|
-
props: { left: el.left + totalX, top: el.top + totalY },
|
|
114
|
-
}));
|
|
115
|
-
return { updates, guides };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export { computeDragMove, computeMultiDragMove, resolveSnapping };
|
|
119
|
-
//# sourceMappingURL=drag.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drag.js","sources":["../../../src/editing/core/drag.ts"],"sourcesContent":["import type { PPTElement } from '@openmaic/dsl';\nimport type { SnappingOptions } from '../types';\nimport { getElementRange, getEditingElementListRange } from './geometry';\nimport { buildAlignLines, snapRange, type Guide } from './snapping';\n\n/**\n * Single-element drag input for one gesture-commit tick: the element being\n * dragged, its siblings (`others`, snap candidates), the viewport (canvas\n * bounds for `toCanvas` snapping), the pointer delta already converted to\n * canvas units, an optional single-axis lock, and the snapping config.\n */\nexport interface DragInput {\n element: PPTElement;\n others: PPTElement[];\n viewport: { width: number; height: number };\n deltaCanvas: { x: number; y: number };\n axisLock?: 'x' | 'y';\n snapping?: boolean | SnappingOptions;\n}\n\n/** The dragged element's new position plus the guides to render, if any. */\nexport interface DragResult {\n props: { left: number; top: number };\n guides: Guide[];\n}\n\nconst DEFAULT_SNAP_RANGE = 5;\n\n/**\n * Resolve the `snapping` prop into concrete `buildAlignLines` options plus the\n * snap `range`: `true` enables both element- and canvas-snapping at the\n * default range; `false`/absent disables snapping entirely (`null`); an\n * explicit `SnappingOptions` object is used as-is, with `range` defaulted.\n * Shared by the drag and resize cores so both gestures interpret the\n * `snapping` prop identically.\n */\nexport function resolveSnapping(\n snapping: boolean | SnappingOptions | undefined,\n): { opts: SnappingOptions; range: number } | null {\n if (snapping === true) {\n return { opts: { toElements: true, toCanvas: true }, range: DEFAULT_SNAP_RANGE };\n }\n if (!snapping) {\n return null;\n }\n return { opts: snapping, range: snapping.range ?? DEFAULT_SNAP_RANGE };\n}\n\n/**\n * Apply a drag delta to a single element (respecting an optional axis lock),\n * then snap the moved position against `others`/the canvas per `snapping`.\n * Composition: shift the element's `left/top` by `deltaCanvas` → derive the\n * shifted element's `ElementRange` via `getElementRange` → build candidate\n * align lines via `buildAlignLines` → correct the shift via `snapRange`\n * (`dx`/`dy`) → return the corrected `left/top` plus the guides to render.\n * No React, no store, no `@/` imports.\n */\nexport function computeDragMove(input: DragInput): DragResult {\n const { element, others, viewport, deltaCanvas, axisLock, snapping } = input;\n\n // Lines are filtered from dragging upstream (they carry `start`/`end`, not a\n // `width`/`height` box, so the box-model drag intent can't represent them).\n // If one still reaches here, return its current position unchanged rather than\n // reading `undefined` box fields off the union.\n if (element.type === 'line') {\n return { props: { left: element.left, top: element.top }, guides: [] };\n }\n\n // `element` is now narrowed to the non-line box variants, so `left/top/width/\n // height/rotate` are directly available without any cast.\n const { left, top, width, height, rotate } = element;\n\n const dx0 = axisLock === 'y' ? 0 : deltaCanvas.x;\n const dy0 = axisLock === 'x' ? 0 : deltaCanvas.y;\n\n const shiftedLeft = left + dx0;\n const shiftedTop = top + dy0;\n\n const resolved = resolveSnapping(snapping);\n if (!resolved) {\n return { props: { left: shiftedLeft, top: shiftedTop }, guides: [] };\n }\n\n const shiftedElement = {\n ...element,\n left: shiftedLeft,\n top: shiftedTop,\n width,\n height,\n rotate,\n } as PPTElement;\n const targetRange = getElementRange(shiftedElement);\n\n const lines = buildAlignLines(others, viewport, resolved.opts);\n const { dx, dy, guides } = snapRange(targetRange, lines, resolved.range);\n\n return {\n props: { left: shiftedLeft + dx, top: shiftedTop + dy },\n guides,\n };\n}\n\n/**\n * Multi-element drag input for one gesture-commit tick: the pointer's grab\n * element (`handleElement`, always a member of `selected`), the whole selected\n * set to translate rigidly (`selected`, INCLUDING the handle), the snap\n * candidates (`others` — the caller has already excluded every selected\n * element), the viewport, the pointer delta already converted to canvas units,\n * an optional single-axis lock, and the snapping config.\n */\nexport interface MultiDragInput {\n handleElement: PPTElement;\n selected: PPTElement[];\n others: PPTElement[];\n viewport: { width: number; height: number };\n deltaCanvas: { x: number; y: number };\n axisLock?: 'x' | 'y';\n snapping?: boolean | SnappingOptions;\n}\n\n/** Every selected element's new position plus the guides to render, if any. */\nexport interface MultiDragResult {\n updates: Array<{ id: string; props: { left: number; top: number } }>;\n guides: Guide[];\n}\n\n/**\n * Apply a drag delta to a MULTI-element selection as one rigid translation.\n * Composition mirrors {@link computeDragMove} but snaps the whole set together:\n * shift every selected element by `deltaCanvas` → take the editing UNION\n * bounding box of the shifted set (`getEditingElementListRange`) → snap that union against\n * `others`/the canvas → apply the SAME corrected delta to every selected\n * element's origin. The snap is computed once on the union (not per element), so\n * the set never deforms — spacing between selected elements is preserved.\n *\n * `handleElement` is declared for the caller's clarity (it identifies the\n * pointer's grab element within `selected`); the correction is identical for\n * every member, so it is applied uniformly rather than relative to the handle.\n * Lines carried inside the selection are translated too (they own `left`/`top`),\n * unlike the single-element {@link computeDragMove} which leaves a lone line put.\n *\n * With a single selected element this reduces EXACTLY to {@link computeDragMove}'s\n * position math (same union == that element's range, same snap correction), so\n * the hook can route N == 1 through either and get identical results.\n * No React, no store, no `@/` imports.\n */\nexport function computeMultiDragMove(input: MultiDragInput): MultiDragResult {\n const { selected, others, viewport, deltaCanvas, axisLock, snapping } = input;\n\n // Exported-API hardening: an empty set has no union bbox (a min/max over\n // nothing degenerates to ±Infinity), so there is nothing to move or snap.\n if (selected.length === 0) return { updates: [], guides: [] };\n\n const dx0 = axisLock === 'y' ? 0 : deltaCanvas.x;\n const dy0 = axisLock === 'x' ? 0 : deltaCanvas.y;\n\n let dx = 0;\n let dy = 0;\n let guides: Guide[] = [];\n\n const resolved = resolveSnapping(snapping);\n if (resolved) {\n const shifted = selected.map(\n (el) => ({ ...el, left: el.left + dx0, top: el.top + dy0 }) as PPTElement,\n );\n const targetRange = getEditingElementListRange(shifted);\n const lines = buildAlignLines(others, viewport, resolved.opts);\n const snapped = snapRange(targetRange, lines, resolved.range);\n dx = snapped.dx;\n dy = snapped.dy;\n guides = snapped.guides;\n }\n\n const totalX = dx0 + dx;\n const totalY = dy0 + dy;\n\n const updates = selected.map((el) => ({\n id: el.id,\n props: { left: el.left + totalX, top: el.top + totalY },\n }));\n\n return { updates, guides };\n}\n"],"names":[],"mappings":";;;;AA0BA,MAAM,kBAAkB,GAAG,CAAC;AAE5B;;;;;;;AAOG;AACG,SAAU,eAAe,CAC7B,QAA+C,EAAA;AAE/C,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,OAAO,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE;IAClF;IACA,IAAI,CAAC,QAA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AG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,EAAE,CAAe,CAC1E;AACD,QAAA,MAAM,WAAW,GAAG,0BAA0B,CAAC,OAAO,CAAC;AACvD,QAAA,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC;AAC9D,QAAA,MAAM,OAAO,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC;AAC7D,QAAA,EAAE,GAAG,OAAO,CAAC,EAAE;AACf,QAAA,EAAE,GAAG,OAAO,CAAC,EAAE;AACf,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM;IACzB;AAEA,IAAA,MAAM,MAAM,GAAG,GAAG,GAAG,EAAE;AACvB,IAAA,MAAM,MAAM,GAAG,GAAG,GAAG,EAAE;IAEvB,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM;QACpC,EAAE,EAAE,EAAE,CAAC,EAAE;AACT,QAAA,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,EAAE;AACxD,KAAA,CAAC,CAAC;AAEH,IAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE;AAC5B;;;;"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { PPTElement } from '@openmaic/dsl';
|
|
2
|
-
import { getElementRange } from '../../utils/element';
|
|
3
|
-
/**
|
|
4
|
-
* Pure geometry/bounds math for the editing surface (gesture engine, snapping,
|
|
5
|
-
* alignment guides). No React, no store, no `@/` imports — this module only
|
|
6
|
-
* consumes the DSL element shape and plain numbers, so it can be exercised with
|
|
7
|
-
* plain unit tests and reused by any host.
|
|
8
|
-
*/
|
|
9
|
-
export { getElementRange };
|
|
10
|
-
/** A single alignment/snap guide line: a fixed axis value plus the span it covers. */
|
|
11
|
-
export type AlignLine = {
|
|
12
|
-
value: number;
|
|
13
|
-
range: [number, number];
|
|
14
|
-
};
|
|
15
|
-
/** Axis-aligned bounding box, in canvas units. */
|
|
16
|
-
export interface ElementRange {
|
|
17
|
-
minX: number;
|
|
18
|
-
maxX: number;
|
|
19
|
-
minY: number;
|
|
20
|
-
maxY: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Editing-side element range. Non-line elements delegate to the renderer's
|
|
24
|
-
* shared range helper; line elements use the control-point-aware path AABB so
|
|
25
|
-
* marquee hit-testing and multi-drag union snapping answer "could this be
|
|
26
|
-
* here?" without false misses.
|
|
27
|
-
*/
|
|
28
|
-
export declare function getEditingElementRange(el: PPTElement): ElementRange;
|
|
29
|
-
/**
|
|
30
|
-
* Visual element range for alignment guides. Non-line elements share their
|
|
31
|
-
* normal range; line elements use the exact rendered path bounds so guides
|
|
32
|
-
* answer "what does the user see aligned?" and never point at invisible
|
|
33
|
-
* Bezier control-hull geometry.
|
|
34
|
-
*/
|
|
35
|
-
export declare function getVisualElementRange(el: PPTElement): ElementRange;
|
|
36
|
-
/** Union bbox of a list of elements, in canvas units. */
|
|
37
|
-
export declare function getElementListRange(els: PPTElement[]): ElementRange;
|
|
38
|
-
/** Union bbox of a list of elements using editing-side ranges. */
|
|
39
|
-
export declare function getEditingElementListRange(els: PPTElement[]): ElementRange;
|
|
40
|
-
/**
|
|
41
|
-
* Dedup a list of alignment guide lines by `value`: for equal `value`, merges
|
|
42
|
-
* `range` by taking the min of range starts and max of range ends.
|
|
43
|
-
*/
|
|
44
|
-
export declare function uniqAlignLines(lines: AlignLine[]): AlignLine[];
|
|
45
|
-
/** Convert a screen-pixel delta to canvas units at the given zoom `scale`. */
|
|
46
|
-
export declare function pxToCanvas(px: number, scale: number): number;
|
|
47
|
-
/** Convert a canvas-unit delta to screen pixels at the given zoom `scale`. */
|
|
48
|
-
export declare function canvasToPx(u: number, scale: number): number;
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { getElementRange } from '../../utils/element.js';
|
|
2
|
-
|
|
3
|
-
// Reuse the renderer's single source of truth for element bounds instead of a
|
|
4
|
-
// local re-implementation. `getElementRange` there is line-aware (derives
|
|
5
|
-
// bounds from `start`/`end` for `PPTLineElement`) and rotation-aware, so
|
|
6
|
-
// alignment guides built over a slide containing a line no longer produce NaN.
|
|
7
|
-
function quadraticAt(p0, c, p2, t) {
|
|
8
|
-
const mt = 1 - t;
|
|
9
|
-
return mt * mt * p0 + 2 * mt * t * c + t * t * p2;
|
|
10
|
-
}
|
|
11
|
-
function cubicAt(p0, c1, c2, p3, t) {
|
|
12
|
-
const mt = 1 - t;
|
|
13
|
-
return mt * mt * mt * p0 + 3 * mt * mt * t * c1 + 3 * mt * t * t * c2 + t * t * t * p3;
|
|
14
|
-
}
|
|
15
|
-
function pushQuadraticExtrema(values, p0, c, p2) {
|
|
16
|
-
const denominator = p0 - 2 * c + p2;
|
|
17
|
-
if (denominator === 0)
|
|
18
|
-
return;
|
|
19
|
-
const t = (p0 - c) / denominator;
|
|
20
|
-
if (t > 0 && t < 1)
|
|
21
|
-
values.push(quadraticAt(p0, c, p2, t));
|
|
22
|
-
}
|
|
23
|
-
function pushCubicRoot(values, p0, c1, c2, p3, t) {
|
|
24
|
-
if (t > 0 && t < 1)
|
|
25
|
-
values.push(cubicAt(p0, c1, c2, p3, t));
|
|
26
|
-
}
|
|
27
|
-
function pushCubicExtrema(values, p0, c1, c2, p3) {
|
|
28
|
-
const a = -p0 + 3 * c1 - 3 * c2 + p3;
|
|
29
|
-
const b = 3 * p0 - 6 * c1 + 3 * c2;
|
|
30
|
-
const c = -3 * p0 + 3 * c1;
|
|
31
|
-
const derivativeA = 3 * a;
|
|
32
|
-
const derivativeB = 2 * b;
|
|
33
|
-
const derivativeC = c;
|
|
34
|
-
if (derivativeA === 0) {
|
|
35
|
-
if (derivativeB !== 0)
|
|
36
|
-
pushCubicRoot(values, p0, c1, c2, p3, -derivativeC / derivativeB);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const discriminant = derivativeB * derivativeB - 4 * derivativeA * derivativeC;
|
|
40
|
-
if (discriminant < 0)
|
|
41
|
-
return;
|
|
42
|
-
const root = Math.sqrt(discriminant);
|
|
43
|
-
pushCubicRoot(values, p0, c1, c2, p3, (-derivativeB - root) / (2 * derivativeA));
|
|
44
|
-
if (root !== 0)
|
|
45
|
-
pushCubicRoot(values, p0, c1, c2, p3, (-derivativeB + root) / (2 * derivativeA));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Conservative editing AABB for a line element's rendered path, in canvas
|
|
49
|
-
* units: the box over `start`, `end`, and every present path control point
|
|
50
|
-
* (`broken`, `broken2`, `curve`, `cubic`), offset by the element origin.
|
|
51
|
-
*
|
|
52
|
-
* Straight/broken/broken2 polylines draw through these vertices directly, and
|
|
53
|
-
* quadratic/cubic Beziers stay inside the convex hull of their control points,
|
|
54
|
-
* so this range never misses a visible bend. It is intentionally conservative:
|
|
55
|
-
* a Bezier rarely reaches the control point itself, but editing hit-testing and
|
|
56
|
-
* snap math prefer extra coverage over a false miss.
|
|
57
|
-
*/
|
|
58
|
-
function getLineEditingRange(el) {
|
|
59
|
-
const xs = [el.start[0], el.end[0]];
|
|
60
|
-
const ys = [el.start[1], el.end[1]];
|
|
61
|
-
if (el.broken) {
|
|
62
|
-
xs.push(el.broken[0]);
|
|
63
|
-
ys.push(el.broken[1]);
|
|
64
|
-
}
|
|
65
|
-
if (el.broken2) {
|
|
66
|
-
xs.push(el.broken2[0]);
|
|
67
|
-
ys.push(el.broken2[1]);
|
|
68
|
-
}
|
|
69
|
-
if (el.curve) {
|
|
70
|
-
xs.push(el.curve[0]);
|
|
71
|
-
ys.push(el.curve[1]);
|
|
72
|
-
}
|
|
73
|
-
if (el.cubic) {
|
|
74
|
-
for (const [cx, cy] of el.cubic) {
|
|
75
|
-
xs.push(cx);
|
|
76
|
-
ys.push(cy);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
minX: el.left + Math.min(...xs),
|
|
81
|
-
maxX: el.left + Math.max(...xs),
|
|
82
|
-
minY: el.top + Math.min(...ys),
|
|
83
|
-
maxY: el.top + Math.max(...ys),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Editing-side element range. Non-line elements delegate to the renderer's
|
|
88
|
-
* shared range helper; line elements use the control-point-aware path AABB so
|
|
89
|
-
* marquee hit-testing and multi-drag union snapping answer "could this be
|
|
90
|
-
* here?" without false misses.
|
|
91
|
-
*/
|
|
92
|
-
function getEditingElementRange(el) {
|
|
93
|
-
return el.type === 'line' ? getLineEditingRange(el) : getElementRange(el);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Visual element range for alignment guides. Non-line elements share their
|
|
97
|
-
* normal range; line elements use the exact rendered path bounds so guides
|
|
98
|
-
* answer "what does the user see aligned?" and never point at invisible
|
|
99
|
-
* Bezier control-hull geometry.
|
|
100
|
-
*/
|
|
101
|
-
function getVisualElementRange(el) {
|
|
102
|
-
if (el.type !== 'line')
|
|
103
|
-
return getElementRange(el);
|
|
104
|
-
const xs = [el.start[0], el.end[0]];
|
|
105
|
-
const ys = [el.start[1], el.end[1]];
|
|
106
|
-
const start = el.start;
|
|
107
|
-
const end = el.end;
|
|
108
|
-
if (el.broken) {
|
|
109
|
-
xs.push(el.broken[0]);
|
|
110
|
-
ys.push(el.broken[1]);
|
|
111
|
-
}
|
|
112
|
-
else if (el.broken2) {
|
|
113
|
-
/**
|
|
114
|
-
* Mirrors `getLineElementPath`: `broken2` selects two orthogonal elbows,
|
|
115
|
-
* not a drawn vertex. Keep this in lockstep so visual snap bounds follow
|
|
116
|
-
* the rendered stroke instead of the control handle.
|
|
117
|
-
*/
|
|
118
|
-
const { minX, maxX, minY, maxY } = getElementRange(el);
|
|
119
|
-
if (maxX - minX >= maxY - minY) {
|
|
120
|
-
xs.push(el.broken2[0], el.broken2[0]);
|
|
121
|
-
ys.push(start[1], end[1]);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
xs.push(start[0], end[0]);
|
|
125
|
-
ys.push(el.broken2[1], el.broken2[1]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else if (el.curve) {
|
|
129
|
-
pushQuadraticExtrema(xs, start[0], el.curve[0], end[0]);
|
|
130
|
-
pushQuadraticExtrema(ys, start[1], el.curve[1], end[1]);
|
|
131
|
-
}
|
|
132
|
-
else if (el.cubic) {
|
|
133
|
-
const [c1, c2] = el.cubic;
|
|
134
|
-
pushCubicExtrema(xs, start[0], c1[0], c2[0], end[0]);
|
|
135
|
-
pushCubicExtrema(ys, start[1], c1[1], c2[1], end[1]);
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
minX: el.left + Math.min(...xs),
|
|
139
|
-
maxX: el.left + Math.max(...xs),
|
|
140
|
-
minY: el.top + Math.min(...ys),
|
|
141
|
-
maxY: el.top + Math.max(...ys),
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/** Union bbox of a list of elements using editing-side ranges. */
|
|
145
|
-
function getEditingElementListRange(els) {
|
|
146
|
-
const leftValues = [];
|
|
147
|
-
const topValues = [];
|
|
148
|
-
const rightValues = [];
|
|
149
|
-
const bottomValues = [];
|
|
150
|
-
for (const el of els) {
|
|
151
|
-
const { minX, maxX, minY, maxY } = getEditingElementRange(el);
|
|
152
|
-
leftValues.push(minX);
|
|
153
|
-
topValues.push(minY);
|
|
154
|
-
rightValues.push(maxX);
|
|
155
|
-
bottomValues.push(maxY);
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
minX: Math.min(...leftValues),
|
|
159
|
-
maxX: Math.max(...rightValues),
|
|
160
|
-
minY: Math.min(...topValues),
|
|
161
|
-
maxY: Math.max(...bottomValues),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Dedup a list of alignment guide lines by `value`: for equal `value`, merges
|
|
166
|
-
* `range` by taking the min of range starts and max of range ends.
|
|
167
|
-
*/
|
|
168
|
-
function uniqAlignLines(lines) {
|
|
169
|
-
const uniqLines = [];
|
|
170
|
-
for (const line of lines) {
|
|
171
|
-
const index = uniqLines.findIndex((_line) => _line.value === line.value);
|
|
172
|
-
if (index === -1) {
|
|
173
|
-
uniqLines.push(line);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
const uniqLine = uniqLines[index];
|
|
177
|
-
const rangeMin = Math.min(uniqLine.range[0], line.range[0]);
|
|
178
|
-
const rangeMax = Math.max(uniqLine.range[1], line.range[1]);
|
|
179
|
-
uniqLines[index] = { value: line.value, range: [rangeMin, rangeMax] };
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return uniqLines;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export { getEditingElementListRange, getEditingElementRange, getElementRange, getVisualElementRange, uniqAlignLines };
|
|
186
|
-
//# sourceMappingURL=geometry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","sources":["../../../src/editing/core/geometry.ts"],"sourcesContent":["import type { PPTElement, PPTLineElement } from '@openmaic/dsl';\n\n// Reuse the renderer's single source of truth for element bounds instead of a\n// local re-implementation. `getElementRange` there is line-aware (derives\n// bounds from `start`/`end` for `PPTLineElement`) and rotation-aware, so\n// alignment guides built over a slide containing a line no longer produce NaN.\nimport { getElementRange } from '../../utils/element';\n\n/**\n * Pure geometry/bounds math for the editing surface (gesture engine, snapping,\n * alignment guides). No React, no store, no `@/` imports — this module only\n * consumes the DSL element shape and plain numbers, so it can be exercised with\n * plain unit tests and reused by any host.\n */\n\n// Re-exported so `snapping.ts`/`drag.ts` keep importing `getElementRange` from\n// `./geometry` unchanged, while the implementation lives in `utils/element`.\nexport { getElementRange };\n\n/** A single alignment/snap guide line: a fixed axis value plus the span it covers. */\nexport type AlignLine = {\n value: number;\n range: [number, number];\n};\n\n/** Axis-aligned bounding box, in canvas units. */\nexport interface ElementRange {\n minX: number;\n maxX: number;\n minY: number;\n maxY: number;\n}\n\ntype Point = [number, number];\n\nfunction quadraticAt(p0: number, c: number, p2: number, t: number): number {\n const mt = 1 - t;\n return mt * mt * p0 + 2 * mt * t * c + t * t * p2;\n}\n\nfunction cubicAt(p0: number, c1: number, c2: number, p3: number, t: number): number {\n const mt = 1 - t;\n return mt * mt * mt * p0 + 3 * mt * mt * t * c1 + 3 * mt * t * t * c2 + t * t * t * p3;\n}\n\nfunction pushQuadraticExtrema(values: number[], p0: number, c: number, p2: number): void {\n const denominator = p0 - 2 * c + p2;\n if (denominator === 0) return;\n const t = (p0 - c) / denominator;\n if (t > 0 && t < 1) values.push(quadraticAt(p0, c, p2, t));\n}\n\nfunction pushCubicRoot(\n values: number[],\n p0: number,\n c1: number,\n c2: number,\n p3: number,\n t: number,\n): void {\n if (t > 0 && t < 1) values.push(cubicAt(p0, c1, c2, p3, t));\n}\n\nfunction pushCubicExtrema(values: number[], p0: number, c1: number, c2: number, p3: number): void {\n const a = -p0 + 3 * c1 - 3 * c2 + p3;\n const b = 3 * p0 - 6 * c1 + 3 * c2;\n const c = -3 * p0 + 3 * c1;\n const derivativeA = 3 * a;\n const derivativeB = 2 * b;\n const derivativeC = c;\n\n if (derivativeA === 0) {\n if (derivativeB !== 0) pushCubicRoot(values, p0, c1, c2, p3, -derivativeC / derivativeB);\n return;\n }\n\n const discriminant = derivativeB * derivativeB - 4 * derivativeA * derivativeC;\n if (discriminant < 0) return;\n\n const root = Math.sqrt(discriminant);\n pushCubicRoot(values, p0, c1, c2, p3, (-derivativeB - root) / (2 * derivativeA));\n if (root !== 0) pushCubicRoot(values, p0, c1, c2, p3, (-derivativeB + root) / (2 * derivativeA));\n}\n\n/**\n * Conservative editing AABB for a line element's rendered path, in canvas\n * units: the box over `start`, `end`, and every present path control point\n * (`broken`, `broken2`, `curve`, `cubic`), offset by the element origin.\n *\n * Straight/broken/broken2 polylines draw through these vertices directly, and\n * quadratic/cubic Beziers stay inside the convex hull of their control points,\n * so this range never misses a visible bend. It is intentionally conservative:\n * a Bezier rarely reaches the control point itself, but editing hit-testing and\n * snap math prefer extra coverage over a false miss.\n */\nfunction getLineEditingRange(el: PPTLineElement): ElementRange {\n const xs = [el.start[0], el.end[0]];\n const ys = [el.start[1], el.end[1]];\n if (el.broken) {\n xs.push(el.broken[0]);\n ys.push(el.broken[1]);\n }\n if (el.broken2) {\n xs.push(el.broken2[0]);\n ys.push(el.broken2[1]);\n }\n if (el.curve) {\n xs.push(el.curve[0]);\n ys.push(el.curve[1]);\n }\n if (el.cubic) {\n for (const [cx, cy] of el.cubic) {\n xs.push(cx);\n ys.push(cy);\n }\n }\n return {\n minX: el.left + Math.min(...xs),\n maxX: el.left + Math.max(...xs),\n minY: el.top + Math.min(...ys),\n maxY: el.top + Math.max(...ys),\n };\n}\n\n/**\n * Editing-side element range. Non-line elements delegate to the renderer's\n * shared range helper; line elements use the control-point-aware path AABB so\n * marquee hit-testing and multi-drag union snapping answer \"could this be\n * here?\" without false misses.\n */\nexport function getEditingElementRange(el: PPTElement): ElementRange {\n return el.type === 'line' ? getLineEditingRange(el) : getElementRange(el);\n}\n\n/**\n * Visual element range for alignment guides. Non-line elements share their\n * normal range; line elements use the exact rendered path bounds so guides\n * answer \"what does the user see aligned?\" and never point at invisible\n * Bezier control-hull geometry.\n */\nexport function getVisualElementRange(el: PPTElement): ElementRange {\n if (el.type !== 'line') return getElementRange(el);\n\n const xs = [el.start[0], el.end[0]];\n const ys = [el.start[1], el.end[1]];\n const start: Point = el.start;\n const end: Point = el.end;\n\n if (el.broken) {\n xs.push(el.broken[0]);\n ys.push(el.broken[1]);\n } else if (el.broken2) {\n /**\n * Mirrors `getLineElementPath`: `broken2` selects two orthogonal elbows,\n * not a drawn vertex. Keep this in lockstep so visual snap bounds follow\n * the rendered stroke instead of the control handle.\n */\n const { minX, maxX, minY, maxY } = getElementRange(el);\n if (maxX - minX >= maxY - minY) {\n xs.push(el.broken2[0], el.broken2[0]);\n ys.push(start[1], end[1]);\n } else {\n xs.push(start[0], end[0]);\n ys.push(el.broken2[1], el.broken2[1]);\n }\n } else if (el.curve) {\n pushQuadraticExtrema(xs, start[0], el.curve[0], end[0]);\n pushQuadraticExtrema(ys, start[1], el.curve[1], end[1]);\n } else if (el.cubic) {\n const [c1, c2] = el.cubic;\n pushCubicExtrema(xs, start[0], c1[0], c2[0], end[0]);\n pushCubicExtrema(ys, start[1], c1[1], c2[1], end[1]);\n }\n\n return {\n minX: el.left + Math.min(...xs),\n maxX: el.left + Math.max(...xs),\n minY: el.top + Math.min(...ys),\n maxY: el.top + Math.max(...ys),\n };\n}\n\n/** Union bbox of a list of elements, in canvas units. */\nexport function getElementListRange(els: PPTElement[]): ElementRange {\n const leftValues: number[] = [];\n const topValues: number[] = [];\n const rightValues: number[] = [];\n const bottomValues: number[] = [];\n\n for (const el of els) {\n const { minX, maxX, minY, maxY } = getElementRange(el);\n leftValues.push(minX);\n topValues.push(minY);\n rightValues.push(maxX);\n bottomValues.push(maxY);\n }\n\n return {\n minX: Math.min(...leftValues),\n maxX: Math.max(...rightValues),\n minY: Math.min(...topValues),\n maxY: Math.max(...bottomValues),\n };\n}\n\n/** Union bbox of a list of elements using editing-side ranges. */\nexport function getEditingElementListRange(els: PPTElement[]): ElementRange {\n const leftValues: number[] = [];\n const topValues: number[] = [];\n const rightValues: number[] = [];\n const bottomValues: number[] = [];\n\n for (const el of els) {\n const { minX, maxX, minY, maxY } = getEditingElementRange(el);\n leftValues.push(minX);\n topValues.push(minY);\n rightValues.push(maxX);\n bottomValues.push(maxY);\n }\n\n return {\n minX: Math.min(...leftValues),\n maxX: Math.max(...rightValues),\n minY: Math.min(...topValues),\n maxY: Math.max(...bottomValues),\n };\n}\n\n/**\n * Dedup a list of alignment guide lines by `value`: for equal `value`, merges\n * `range` by taking the min of range starts and max of range ends.\n */\nexport function uniqAlignLines(lines: AlignLine[]): AlignLine[] {\n const uniqLines: AlignLine[] = [];\n for (const line of lines) {\n const index = uniqLines.findIndex((_line) => _line.value === line.value);\n if (index === -1) {\n uniqLines.push(line);\n } else {\n const uniqLine = uniqLines[index];\n const rangeMin = Math.min(uniqLine.range[0], line.range[0]);\n const rangeMax = Math.max(uniqLine.range[1], line.range[1]);\n uniqLines[index] = { value: line.value, range: [rangeMin, rangeMax] };\n }\n }\n return uniqLines;\n}\n\n/** Convert a screen-pixel delta to canvas units at the given zoom `scale`. */\nexport function pxToCanvas(px: number, scale: number): number {\n return px / scale;\n}\n\n/** Convert a canvas-unit delta to screen pixels at the given zoom `scale`. */\nexport function canvasToPx(u: number, scale: number): number {\n return u * scale;\n}\n"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;AA8BA,SAAS,WAAW,CAAC,EAAU,EAAE,CAAS,EAAE,EAAU,EAAE,CAAS,EAAA;AAC/D,IAAA,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;AAChB,IAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE;AACnD;AAEA,SAAS,OAAO,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,CAAS,EAAA;AACxE,IAAA,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;AAChB,IAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE;AACxF;AAEA,SAAS,oBAAoB,CAAC,MAAgB,EAAE,EAAU,EAAE,CAAS,EAAE,EAAU,EAAA;IAC/E,MAAM,WAAW,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE;IACnC,IAAI,WAAW,KAAK,CAAC;QAAE;IACvB,M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vE;IACF;AACA,IAAA,OAAO,SAAS;AAClB;;;;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { EditIntent } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Build the `element.update` intent for a completed move gesture: the host
|
|
4
|
-
* applies `props` (the element's new `left`/`top`) and owns undo. Pure
|
|
5
|
-
* construction — no React, no store, no `@/` imports.
|
|
6
|
-
*/
|
|
7
|
-
export declare function moveIntent(id: string, props: {
|
|
8
|
-
left: number;
|
|
9
|
-
top: number;
|
|
10
|
-
}): EditIntent;
|
|
11
|
-
/**
|
|
12
|
-
* Build the `element.update` intent for a completed resize gesture: the box
|
|
13
|
-
* props only (`left`/`top`/`width`/`height`). Kind-specific content that must
|
|
14
|
-
* track the box (a shape's path/viewBox, a table's `cellMinHeight`, an image's
|
|
15
|
-
* clip mode) is intentionally NOT recomputed here — the host can post-process
|
|
16
|
-
* in response to the intent, or a later slice moves that math into the package.
|
|
17
|
-
*/
|
|
18
|
-
export declare function resizeIntent(id: string, props: {
|
|
19
|
-
left: number;
|
|
20
|
-
top: number;
|
|
21
|
-
width: number;
|
|
22
|
-
height: number;
|
|
23
|
-
}): EditIntent;
|
|
24
|
-
/** Build the `element.update` intent for a completed rotate gesture. */
|
|
25
|
-
export declare function rotateIntent(id: string, rotate: number): EditIntent;
|
|
26
|
-
/**
|
|
27
|
-
* Build the single `element.updateMany` intent for a completed MULTI-element
|
|
28
|
-
* move gesture: every selected element's new `left`/`top` in one intent, so the
|
|
29
|
-
* whole rigid translation lands as ONE host undo entry (never one intent per
|
|
30
|
-
* element). Single-element drags keep emitting `element.update` (backward compat
|
|
31
|
-
* with hosts); this is only for N > 1.
|
|
32
|
-
*/
|
|
33
|
-
export declare function moveManyIntent(updates: Array<{
|
|
34
|
-
id: string;
|
|
35
|
-
props: {
|
|
36
|
-
left: number;
|
|
37
|
-
top: number;
|
|
38
|
-
};
|
|
39
|
-
}>): EditIntent;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build the `element.update` intent for a completed move gesture: the host
|
|
3
|
-
* applies `props` (the element's new `left`/`top`) and owns undo. Pure
|
|
4
|
-
* construction — no React, no store, no `@/` imports.
|
|
5
|
-
*/
|
|
6
|
-
function moveIntent(id, props) {
|
|
7
|
-
return { type: 'element.update', id, props };
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Build the `element.update` intent for a completed resize gesture: the box
|
|
11
|
-
* props only (`left`/`top`/`width`/`height`). Kind-specific content that must
|
|
12
|
-
* track the box (a shape's path/viewBox, a table's `cellMinHeight`, an image's
|
|
13
|
-
* clip mode) is intentionally NOT recomputed here — the host can post-process
|
|
14
|
-
* in response to the intent, or a later slice moves that math into the package.
|
|
15
|
-
*/
|
|
16
|
-
function resizeIntent(id, props) {
|
|
17
|
-
return { type: 'element.update', id, props };
|
|
18
|
-
}
|
|
19
|
-
/** Build the `element.update` intent for a completed rotate gesture. */
|
|
20
|
-
function rotateIntent(id, rotate) {
|
|
21
|
-
return { type: 'element.update', id, props: { rotate } };
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Build the single `element.updateMany` intent for a completed MULTI-element
|
|
25
|
-
* move gesture: every selected element's new `left`/`top` in one intent, so the
|
|
26
|
-
* whole rigid translation lands as ONE host undo entry (never one intent per
|
|
27
|
-
* element). Single-element drags keep emitting `element.update` (backward compat
|
|
28
|
-
* with hosts); this is only for N > 1.
|
|
29
|
-
*/
|
|
30
|
-
function moveManyIntent(updates) {
|
|
31
|
-
return { type: 'element.updateMany', updates };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { moveIntent, moveManyIntent, resizeIntent, rotateIntent };
|
|
35
|
-
//# sourceMappingURL=intent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent.js","sources":["../../../src/editing/core/intent.ts"],"sourcesContent":["import type { EditIntent } from '../types';\n\n/**\n * Build the `element.update` intent for a completed move gesture: the host\n * applies `props` (the element's new `left`/`top`) and owns undo. Pure\n * construction — no React, no store, no `@/` imports.\n */\nexport function moveIntent(id: string, props: { left: number; top: number }): EditIntent {\n return { type: 'element.update', id, props };\n}\n\n/**\n * Build the `element.update` intent for a completed resize gesture: the box\n * props only (`left`/`top`/`width`/`height`). Kind-specific content that must\n * track the box (a shape's path/viewBox, a table's `cellMinHeight`, an image's\n * clip mode) is intentionally NOT recomputed here — the host can post-process\n * in response to the intent, or a later slice moves that math into the package.\n */\nexport function resizeIntent(\n id: string,\n props: { left: number; top: number; width: number; height: number },\n): EditIntent {\n return { type: 'element.update', id, props };\n}\n\n/** Build the `element.update` intent for a completed rotate gesture. */\nexport function rotateIntent(id: string, rotate: number): EditIntent {\n return { type: 'element.update', id, props: { rotate } };\n}\n\n/**\n * Build the single `element.updateMany` intent for a completed MULTI-element\n * move gesture: every selected element's new `left`/`top` in one intent, so the\n * whole rigid translation lands as ONE host undo entry (never one intent per\n * element). Single-element drags keep emitting `element.update` (backward compat\n * with hosts); this is only for N > 1.\n */\nexport function moveManyIntent(\n updates: Array<{ id: string; props: { left: number; top: number } }>,\n): EditIntent {\n return { type: 'element.updateMany', updates };\n}\n"],"names":[],"mappings":"AAEA;;;;AAIG;AACG,SAAU,UAAU,CAAC,EAAU,EAAE,KAAoC,EAAA;IACzE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,KAAK,EAAE;AAC9C;AAEA;;;;;;AAMG;AACG,SAAU,YAAY,CAC1B,EAAU,EACV,KAAmE,EAAA;IAEnE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,KAAK,EAAE;AAC9C;AAEA;AACM,SAAU,YAAY,CAAC,EAAU,EAAE,MAAc,EAAA;AACrD,IAAA,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE;AAC1D;AAEA;;;;;;AAMG;AACG,SAAU,cAAc,CAC5B,OAAoE,EAAA;AAEpE,IAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE;AAChD;;;;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PPTLineElement } from '@openmaic/dsl';
|
|
2
|
-
import type { LineHandle } from '../types';
|
|
3
|
-
export interface LineDragInput {
|
|
4
|
-
element: PPTLineElement;
|
|
5
|
-
handle: LineHandle;
|
|
6
|
-
deltaCanvas: {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export interface LineDragResult {
|
|
12
|
-
props: {
|
|
13
|
-
left: number;
|
|
14
|
-
top: number;
|
|
15
|
-
start: [number, number];
|
|
16
|
-
end: [number, number];
|
|
17
|
-
} & Partial<Pick<PPTLineElement, 'broken' | 'broken2' | 'curve' | 'cubic'>>;
|
|
18
|
-
}
|
|
19
|
-
export declare function computeLineDrag(input: LineDragInput): LineDragResult;
|