@oh-just-another/state 0.59.0 → 0.61.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/CHANGELOG.md +189 -0
- package/README.md +6 -4
- package/dist/.tsbuildinfo +1 -1
- package/dist/actions/actionArrange.js +4 -4
- package/dist/actions/actionArrange.js.map +1 -1
- package/dist/actions/actionClipboard.d.ts.map +1 -1
- package/dist/actions/actionClipboard.js +5 -0
- package/dist/actions/actionClipboard.js.map +1 -1
- package/dist/actions/actionKeyboard.d.ts.map +1 -1
- package/dist/actions/actionKeyboard.js +79 -11
- package/dist/actions/actionKeyboard.js.map +1 -1
- package/dist/actions/actionMode.d.ts +2 -0
- package/dist/actions/actionMode.d.ts.map +1 -1
- package/dist/actions/actionMode.js +81 -27
- package/dist/actions/actionMode.js.map +1 -1
- package/dist/actions/actionSelection.d.ts.map +1 -1
- package/dist/actions/actionSelection.js +1 -0
- package/dist/actions/actionSelection.js.map +1 -1
- package/dist/actions/actionView.d.ts +6 -0
- package/dist/actions/actionView.d.ts.map +1 -1
- package/dist/actions/actionView.js +19 -1
- package/dist/actions/actionView.js.map +1 -1
- package/dist/actions/actionZoom.d.ts.map +1 -1
- package/dist/actions/actionZoom.js +5 -0
- package/dist/actions/actionZoom.js.map +1 -1
- package/dist/actions/index.d.ts +3 -3
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +3 -3
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/registry.d.ts.map +1 -1
- package/dist/actions/registry.js +13 -0
- package/dist/actions/registry.js.map +1 -1
- package/dist/actions/types.d.ts +10 -1
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/actions/types.js.map +1 -1
- package/dist/built-in-handlers.d.ts +8 -0
- package/dist/built-in-handlers.d.ts.map +1 -1
- package/dist/built-in-handlers.js +31 -16
- package/dist/built-in-handlers.js.map +1 -1
- package/dist/clipboard.d.ts +0 -14
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +1 -1
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +253 -18
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +255 -2
- package/dist/constants.js.map +1 -1
- package/dist/dom-events.d.ts +1 -2
- package/dist/dom-events.d.ts.map +1 -1
- package/dist/dom-events.js.map +1 -1
- package/dist/editor/animation-scene.d.ts +15 -0
- package/dist/editor/animation-scene.d.ts.map +1 -1
- package/dist/editor/animation-scene.js +159 -0
- package/dist/editor/animation-scene.js.map +1 -1
- package/dist/editor/applies/create.d.ts +0 -6
- package/dist/editor/applies/create.d.ts.map +1 -1
- package/dist/editor/applies/create.js +1 -1
- package/dist/editor/applies/create.js.map +1 -1
- package/dist/editor/applies/link-move.d.ts +0 -8
- package/dist/editor/applies/link-move.d.ts.map +1 -1
- package/dist/editor/applies/link-move.js +1 -1
- package/dist/editor/applies/link-move.js.map +1 -1
- package/dist/editor/event-fanout.d.ts +6 -6
- package/dist/editor/event-fanout.d.ts.map +1 -1
- package/dist/editor/event-fanout.js +8 -8
- package/dist/editor/event-fanout.js.map +1 -1
- package/dist/editor/hit-test.d.ts +8 -0
- package/dist/editor/hit-test.d.ts.map +1 -1
- package/dist/editor/hit-test.js +31 -16
- package/dist/editor/hit-test.js.map +1 -1
- package/dist/editor/interaction-state.d.ts +184 -0
- package/dist/editor/interaction-state.d.ts.map +1 -0
- package/dist/editor/interaction-state.js +139 -0
- package/dist/editor/interaction-state.js.map +1 -0
- package/dist/editor/link-handle-drag.d.ts +172 -0
- package/dist/editor/link-handle-drag.d.ts.map +1 -0
- package/dist/editor/link-handle-drag.js +369 -0
- package/dist/editor/link-handle-drag.js.map +1 -0
- package/dist/editor/pointer-binding.d.ts +9 -11
- package/dist/editor/pointer-binding.d.ts.map +1 -1
- package/dist/editor/pointer-binding.js +1247 -909
- package/dist/editor/pointer-binding.js.map +1 -1
- package/dist/editor/public/brush.d.ts +93 -13
- package/dist/editor/public/brush.d.ts.map +1 -1
- package/dist/editor/public/brush.js +240 -22
- package/dist/editor/public/brush.js.map +1 -1
- package/dist/editor/public/cursor.d.ts +1 -15
- package/dist/editor/public/cursor.d.ts.map +1 -1
- package/dist/editor/public/cursor.js +17 -7
- package/dist/editor/public/cursor.js.map +1 -1
- package/dist/editor/public/eraser.d.ts +55 -0
- package/dist/editor/public/eraser.d.ts.map +1 -0
- package/dist/editor/public/eraser.js +65 -0
- package/dist/editor/public/eraser.js.map +1 -0
- package/dist/editor/public/laser.d.ts +38 -0
- package/dist/editor/public/laser.d.ts.map +1 -0
- package/dist/editor/public/laser.js +42 -0
- package/dist/editor/public/laser.js.map +1 -0
- package/dist/editor/public/placement.d.ts.map +1 -1
- package/dist/editor/public/placement.js +9 -1
- package/dist/editor/public/placement.js.map +1 -1
- package/dist/editor/public/selection-ops.d.ts +12 -0
- package/dist/editor/public/selection-ops.d.ts.map +1 -1
- package/dist/editor/public/selection-ops.js +19 -1
- package/dist/editor/public/selection-ops.js.map +1 -1
- package/dist/editor/public/stroke-eraser-coverage.d.ts +37 -0
- package/dist/editor/public/stroke-eraser-coverage.d.ts.map +1 -0
- package/dist/editor/public/stroke-eraser-coverage.js +168 -0
- package/dist/editor/public/stroke-eraser-coverage.js.map +1 -0
- package/dist/editor/public/stroke-eraser.d.ts +50 -0
- package/dist/editor/public/stroke-eraser.d.ts.map +1 -0
- package/dist/editor/public/stroke-eraser.js +176 -0
- package/dist/editor/public/stroke-eraser.js.map +1 -0
- package/dist/editor/public/stroke-smoothing.d.ts +21 -0
- package/dist/editor/public/stroke-smoothing.d.ts.map +1 -0
- package/dist/editor/public/stroke-smoothing.js +37 -0
- package/dist/editor/public/stroke-smoothing.js.map +1 -0
- package/dist/editor/public/tool-ops.d.ts +130 -0
- package/dist/editor/public/tool-ops.d.ts.map +1 -0
- package/dist/editor/public/tool-ops.js +392 -0
- package/dist/editor/public/tool-ops.js.map +1 -0
- package/dist/editor/public/z-order.d.ts +1 -12
- package/dist/editor/public/z-order.d.ts.map +1 -1
- package/dist/editor/public/z-order.js +1 -1
- package/dist/editor/public/z-order.js.map +1 -1
- package/dist/editor/public/zoom-pan.d.ts +9 -0
- package/dist/editor/public/zoom-pan.d.ts.map +1 -1
- package/dist/editor/public/zoom-pan.js +31 -0
- package/dist/editor/public/zoom-pan.js.map +1 -1
- package/dist/editor/render-orchestrator.d.ts +180 -5
- package/dist/editor/render-orchestrator.d.ts.map +1 -1
- package/dist/editor/render-orchestrator.js +516 -353
- package/dist/editor/render-orchestrator.js.map +1 -1
- package/dist/editor/text-edit.d.ts +136 -0
- package/dist/editor/text-edit.d.ts.map +1 -0
- package/dist/editor/text-edit.js +328 -0
- package/dist/editor/text-edit.js.map +1 -0
- package/dist/editor-events.d.ts +5 -5
- package/dist/editor-events.d.ts.map +1 -1
- package/dist/editor.d.ts +560 -250
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +1650 -743
- package/dist/editor.js.map +1 -1
- package/dist/handle.d.ts +0 -2
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +0 -6
- package/dist/handle.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/modes.d.ts +34 -1
- package/dist/modes.d.ts.map +1 -1
- package/dist/modes.js.map +1 -1
- package/dist/overlay.d.ts +98 -21
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +442 -116
- package/dist/overlay.js.map +1 -1
- package/dist/search.d.ts +37 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +45 -0
- package/dist/search.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ephemeral interaction / gesture state for a single {@link Editor}.
|
|
3
|
+
*
|
|
4
|
+
* Collects the short-lived preview and gesture-origin fields that the pointer
|
|
5
|
+
* handlers, render orchestrator and container-ops helpers read and write while
|
|
6
|
+
* a gesture is in flight. Long-lived state (scene, selection, history,
|
|
7
|
+
* viewport, mode) lives on the editor itself — never here.
|
|
8
|
+
*
|
|
9
|
+
* The editor owns one instance and exposes thin delegate accessors for the
|
|
10
|
+
* fields external writers already reference by name, so this consolidation is
|
|
11
|
+
* behaviour-preserving.
|
|
12
|
+
*/
|
|
13
|
+
export class InteractionState {
|
|
14
|
+
// --- Visual previews (cleared by resetPreviews) ---
|
|
15
|
+
/** Live preview while drawing a new shape; null when not drawing. */
|
|
16
|
+
drawingPreview = null;
|
|
17
|
+
/** Live preview of an edge being drawn. */
|
|
18
|
+
edgePreview = null;
|
|
19
|
+
/** Live lasso bounds during a rubber-band select gesture. */
|
|
20
|
+
lassoPreview = null;
|
|
21
|
+
/** Element hovered in draw-edge mode (drives the port overlay). */
|
|
22
|
+
hoveredLinkTarget = null;
|
|
23
|
+
/** Last idle cursor position (world) in select mode — grows the nearest dot. */
|
|
24
|
+
hoverCursorWorld = null;
|
|
25
|
+
// --- Other gesture / interaction state ---
|
|
26
|
+
/** In-progress annotation-pin drag. */
|
|
27
|
+
annotationDrag = null;
|
|
28
|
+
/** Active drag-a-link-from-anchor gesture. */
|
|
29
|
+
linkDragFromAnchor = null;
|
|
30
|
+
/** Pending link-drop shape-picker. */
|
|
31
|
+
pendingLinkDropMenu = null;
|
|
32
|
+
/**
|
|
33
|
+
* Selection captured at lasso-press time — lets `add`-mode marquee start
|
|
34
|
+
* from the pre-press selection instead of empty.
|
|
35
|
+
*/
|
|
36
|
+
lassoBaseSelection = null;
|
|
37
|
+
/** Link-selection counterpart of `lassoBaseSelection`. */
|
|
38
|
+
lassoBaseLinks = null;
|
|
39
|
+
/** Per-shape `position` snapshot at press-down for a multi-shape drag. */
|
|
40
|
+
groupMoveOrigin = null;
|
|
41
|
+
/** Press-time snapshot of connectors that follow a multi-element drag rigidly. */
|
|
42
|
+
groupLinkMoveOrigin = null;
|
|
43
|
+
/** Per-shape snapshot for a group-resize gesture. */
|
|
44
|
+
groupResizeOrigin = null;
|
|
45
|
+
/** Press-time snapshot for a rotate gesture. */
|
|
46
|
+
rotateGestureOrigin = null;
|
|
47
|
+
/** Pristine shape snapshot for a single-shape text resize. */
|
|
48
|
+
resizeOriginElement = null;
|
|
49
|
+
/** Host-mirrored snap-suppress modifier (Cmd/Ctrl) held during a drag. */
|
|
50
|
+
snapSuppressed = false;
|
|
51
|
+
/** Host-mirrored transform-modifier: symmetric resize about centre. */
|
|
52
|
+
transformAltKey = false;
|
|
53
|
+
/** Host-mirrored transform-modifier: aspect-lock resize / axis-lock move. */
|
|
54
|
+
transformShiftKey = false;
|
|
55
|
+
/** Timestamp of the last non-drag pointer-up (double-click detection). */
|
|
56
|
+
lastClickAt = 0;
|
|
57
|
+
/** World point of the last non-drag pointer-up (double-click detection). */
|
|
58
|
+
lastClickWorldPoint = null;
|
|
59
|
+
/** In-progress brush stroke (live overlay preview). */
|
|
60
|
+
brushStroke = null;
|
|
61
|
+
/** In-progress eraser stroke (pending-delete set + last sample point). */
|
|
62
|
+
eraseStroke = null;
|
|
63
|
+
/** Ephemeral laser-pointer trails — fade by TTL, never touch the scene. */
|
|
64
|
+
laserStrokes = [];
|
|
65
|
+
/**
|
|
66
|
+
* Ephemeral eraser drag trail — a laser-style fading trail laid while an
|
|
67
|
+
* erase stroke is active. Reuses {@link LaserStroke} so the same TTL fade /
|
|
68
|
+
* prune tick drives it; painted in a neutral grey, never the laser red.
|
|
69
|
+
*/
|
|
70
|
+
eraserTrail = [];
|
|
71
|
+
/** True only while the pointer is DOWN in laser mode (a trail is being laid). */
|
|
72
|
+
laserDrawing = false;
|
|
73
|
+
/** Last world-space pointer position observed by the host's onMove handler. */
|
|
74
|
+
lastPointerWorld = null;
|
|
75
|
+
/** Element id the user started dragging on press-down. */
|
|
76
|
+
dragElementId = null;
|
|
77
|
+
/** Element the current press added to the selection additively. */
|
|
78
|
+
additivePressAdded = null;
|
|
79
|
+
/** Live container highlight for the shape being dragged. */
|
|
80
|
+
containerHover = null;
|
|
81
|
+
/** Active screen-space pointer positions keyed by `pointerId`. */
|
|
82
|
+
activePointers = new Map();
|
|
83
|
+
/** One-finger-pan candidate (screen-space origin) set at touch press-down. */
|
|
84
|
+
touchPanCandidate = null;
|
|
85
|
+
/** Space-bar held → next pointer drag pans the canvas. */
|
|
86
|
+
spaceHeld = false;
|
|
87
|
+
/** Active pan gesture, or null between gestures. */
|
|
88
|
+
panGesture = null;
|
|
89
|
+
/** Set on right-click pointerdown so the next native contextmenu is suppressed. */
|
|
90
|
+
suppressNextContextMenu = false;
|
|
91
|
+
/** Link whose caption is being inline-edited, or null. */
|
|
92
|
+
editingLinkCaption = null;
|
|
93
|
+
/**
|
|
94
|
+
* Reset ONLY the visual-preview fields (draw / edge / lasso previews and the
|
|
95
|
+
* draw-edge hover overlay). Leaves gesture origins and modifier state intact.
|
|
96
|
+
*/
|
|
97
|
+
resetPreviews() {
|
|
98
|
+
this.drawingPreview = null;
|
|
99
|
+
this.edgePreview = null;
|
|
100
|
+
this.lassoPreview = null;
|
|
101
|
+
this.hoveredLinkTarget = null;
|
|
102
|
+
this.hoverCursorWorld = null;
|
|
103
|
+
}
|
|
104
|
+
/** Full teardown — return every ephemeral field to its default. */
|
|
105
|
+
reset() {
|
|
106
|
+
this.resetPreviews();
|
|
107
|
+
this.annotationDrag = null;
|
|
108
|
+
this.linkDragFromAnchor = null;
|
|
109
|
+
this.pendingLinkDropMenu = null;
|
|
110
|
+
this.lassoBaseSelection = null;
|
|
111
|
+
this.lassoBaseLinks = null;
|
|
112
|
+
this.groupMoveOrigin = null;
|
|
113
|
+
this.groupLinkMoveOrigin = null;
|
|
114
|
+
this.groupResizeOrigin = null;
|
|
115
|
+
this.rotateGestureOrigin = null;
|
|
116
|
+
this.resizeOriginElement = null;
|
|
117
|
+
this.snapSuppressed = false;
|
|
118
|
+
this.transformAltKey = false;
|
|
119
|
+
this.transformShiftKey = false;
|
|
120
|
+
this.lastClickAt = 0;
|
|
121
|
+
this.lastClickWorldPoint = null;
|
|
122
|
+
this.brushStroke = null;
|
|
123
|
+
this.eraseStroke = null;
|
|
124
|
+
this.laserStrokes = [];
|
|
125
|
+
this.eraserTrail = [];
|
|
126
|
+
this.laserDrawing = false;
|
|
127
|
+
this.lastPointerWorld = null;
|
|
128
|
+
this.dragElementId = null;
|
|
129
|
+
this.additivePressAdded = null;
|
|
130
|
+
this.containerHover = null;
|
|
131
|
+
this.activePointers.clear();
|
|
132
|
+
this.touchPanCandidate = null;
|
|
133
|
+
this.spaceHeld = false;
|
|
134
|
+
this.panGesture = null;
|
|
135
|
+
this.suppressNextContextMenu = false;
|
|
136
|
+
this.editingLinkCaption = null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=interaction-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction-state.js","sourceRoot":"","sources":["../../src/editor/interaction-state.ts"],"names":[],"mappings":"AA2FA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,gBAAgB;IAC3B,qDAAqD;IAErD,qEAAqE;IACrE,cAAc,GAAkB,IAAI,CAAC;IACrC,2CAA2C;IAC3C,WAAW,GAAuB,IAAI,CAAC;IACvC,6DAA6D;IAC7D,YAAY,GAAkB,IAAI,CAAC;IACnC,mEAAmE;IACnE,iBAAiB,GAA6B,IAAI,CAAC;IACnD,gFAAgF;IAChF,gBAAgB,GAAgB,IAAI,CAAC;IAErC,4CAA4C;IAE5C,uCAAuC;IACvC,cAAc,GAA0B,IAAI,CAAC;IAC7C,8CAA8C;IAC9C,kBAAkB,GAA8B,IAAI,CAAC;IACrD,sCAAsC;IACtC,mBAAmB,GAA+B,IAAI,CAAC;IAEvD;;;OAGG;IACH,kBAAkB,GAA+B,IAAI,CAAC;IACtD,0DAA0D;IAC1D,cAAc,GAAuC,IAAI,CAAC;IAE1D,0EAA0E;IAC1E,eAAe,GAAwC,IAAI,CAAC;IAC5D,kFAAkF;IAClF,mBAAmB,GAAqC,IAAI,CAAC;IAC7D,qDAAqD;IACrD,iBAAiB,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AAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,uBAAuB,GAAG,KAAK,CAAC;QACrC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type LinkEndpoint, type Patch, type Scene } from "@oh-just-another/scene";
|
|
2
|
+
import type { ElementId, LinkId, Vec2 } from "@oh-just-another/types";
|
|
3
|
+
import type { InteractionEmit, PressTarget } from "../machine.js";
|
|
4
|
+
/**
|
|
5
|
+
* Editor capabilities the link handle drags need. Keeps the controller off
|
|
6
|
+
* the god-class: scene access, gesture transaction lifecycle, endpoint
|
|
7
|
+
* snapping and hover feedback are delegated back to the Editor through this
|
|
8
|
+
* narrow interface.
|
|
9
|
+
*/
|
|
10
|
+
export interface LinkHandleDragHost {
|
|
11
|
+
/** Current scene (read + replace — live drags mutate through the gesture tx). */
|
|
12
|
+
scene: Scene;
|
|
13
|
+
/** Record a patch as one undo step (double-click delete / reset paths). */
|
|
14
|
+
pushHistory(patch: Patch): void;
|
|
15
|
+
/** Apply a live-drag patch into the open gesture transaction. */
|
|
16
|
+
recordGesturePatch(patch: Patch): void;
|
|
17
|
+
/** Commit the gesture transaction (one undo step for the whole drag). */
|
|
18
|
+
commitGesture(): void;
|
|
19
|
+
/** Cancel the gesture transaction (revert the live drag). */
|
|
20
|
+
cancelGesture(): void;
|
|
21
|
+
/** True while a gesture transaction is open (an endpoint move happened). */
|
|
22
|
+
hasGestureTx(): boolean;
|
|
23
|
+
/** Repaint + listener fan-out. */
|
|
24
|
+
notify(): void;
|
|
25
|
+
/** Attach target under the cursor (same resolution the drop uses). */
|
|
26
|
+
linkAttachTargetAt(worldPoint: Vec2): PressTarget | undefined;
|
|
27
|
+
/** Snap an endpoint to a target element / free point. */
|
|
28
|
+
snapLinkEndpoint(targetId: ElementId | null, worldPoint: Vec2): LinkEndpoint;
|
|
29
|
+
/** Drive the attach-point highlight (candidate dots + halo). */
|
|
30
|
+
updateHoveredLinkTarget(worldPoint: Vec2): void;
|
|
31
|
+
/** Drop the attach-point highlight. */
|
|
32
|
+
clearHoveredLinkTarget(): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Owns the link edit-handle drags: waypoint (bend point) drags, elbow
|
|
36
|
+
* segment drags, endpoint rebind drags and the handle double-click
|
|
37
|
+
* detector (delete waypoint / reset segment pin). Extracted from the
|
|
38
|
+
* Editor god-class; the Editor keeps thin delegate wrappers so its public
|
|
39
|
+
* API is unchanged.
|
|
40
|
+
*/
|
|
41
|
+
export declare class LinkHandleDragController {
|
|
42
|
+
private readonly host;
|
|
43
|
+
/**
|
|
44
|
+
* Mid-drag preview state when the user is dragging an edge endpoint.
|
|
45
|
+
* Drawn as an overlay line + handle dot so the user sees the target.
|
|
46
|
+
*/
|
|
47
|
+
private _endpointDrag;
|
|
48
|
+
/**
|
|
49
|
+
* Host-managed waypoint (bend-point) drag of the selected link. `index`
|
|
50
|
+
* is the position in `edge.waypoints`. `pendingInsert` means the gesture
|
|
51
|
+
* began on a segment midpoint and will splice a new waypoint on the
|
|
52
|
+
* first move (so a no-move click adds nothing). Live-mutated through the
|
|
53
|
+
* gesture transaction → one undo step per drag.
|
|
54
|
+
*/
|
|
55
|
+
private _waypointDrag;
|
|
56
|
+
/**
|
|
57
|
+
* Host-managed elbow segment drag. `axis` is the segment's orientation.
|
|
58
|
+
* Dragging pins the segment's perpendicular coordinate into
|
|
59
|
+
* `Link.fixedSegments`; the reroute pass re-flows the rest. One undo
|
|
60
|
+
* step via the gesture tx.
|
|
61
|
+
*/
|
|
62
|
+
private _segmentDrag;
|
|
63
|
+
/**
|
|
64
|
+
* Host-managed caption (label pill) drag along the link's path. The cursor
|
|
65
|
+
* is projected back onto the drawn polyline so the pill can only slide
|
|
66
|
+
* ALONG the link; near the arc-length middle it snaps back to the default
|
|
67
|
+
* position (`label.position` removed). One undo step via the gesture tx.
|
|
68
|
+
* `moved` distinguishes a click (kept for the double-click-to-edit chain)
|
|
69
|
+
* from a real drag.
|
|
70
|
+
*/
|
|
71
|
+
private _labelDrag;
|
|
72
|
+
/** Wall-clock of the previous handle press — drives `isHandleDoubleClick`. */
|
|
73
|
+
private lastHandleClickAt;
|
|
74
|
+
private lastHandleClickWorld;
|
|
75
|
+
constructor(host: LinkHandleDragHost);
|
|
76
|
+
get endpointDrag(): {
|
|
77
|
+
linkId: LinkId;
|
|
78
|
+
side: "from" | "to";
|
|
79
|
+
toPoint: Vec2;
|
|
80
|
+
} | null;
|
|
81
|
+
get waypointDrag(): {
|
|
82
|
+
linkId: LinkId;
|
|
83
|
+
index: number;
|
|
84
|
+
pendingInsert: boolean;
|
|
85
|
+
} | null;
|
|
86
|
+
get segmentDrag(): {
|
|
87
|
+
linkId: LinkId;
|
|
88
|
+
axis: "h" | "v";
|
|
89
|
+
at: number;
|
|
90
|
+
} | null;
|
|
91
|
+
get labelDrag(): {
|
|
92
|
+
linkId: LinkId;
|
|
93
|
+
moved: boolean;
|
|
94
|
+
} | null;
|
|
95
|
+
get isDraggingLabel(): boolean;
|
|
96
|
+
/** Drop all drag state without committing (Escape / cancelInteraction). */
|
|
97
|
+
reset(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Live endpoint-rebind move: re-point the dragged end to the cursor in the
|
|
100
|
+
* scene (a free `point` endpoint), recorded in the gesture transaction so the
|
|
101
|
+
* WHOLE link redraws under the cursor with full fidelity — real style,
|
|
102
|
+
* arrowhead, curved bow, and (via `rerouteElbows` in `render`) a live elbow
|
|
103
|
+
* re-route. One undo step on commit; Escape cancels the transaction and the
|
|
104
|
+
* link snaps back to where it was. The handle dot follows via `endpointDrag`.
|
|
105
|
+
*/
|
|
106
|
+
applyEndpointMove(linkId: LinkId, side: "from" | "to", toPoint: Vec2): void;
|
|
107
|
+
applyEndpointUpdate(emit: Extract<InteractionEmit, {
|
|
108
|
+
type: "UPDATE_EDGE_ENDPOINT";
|
|
109
|
+
}>): void;
|
|
110
|
+
/** True while a waypoint of the selected link is being dragged. */
|
|
111
|
+
get isDraggingWaypoint(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Begin a host-managed waypoint drag. `insert` splices a new waypoint at
|
|
114
|
+
* `index` on the first move (segment-midpoint "add" handle); otherwise an
|
|
115
|
+
* existing waypoint at `index` is moved. Live-mutated through the gesture
|
|
116
|
+
* transaction so the whole drag is one undo step.
|
|
117
|
+
*/
|
|
118
|
+
beginWaypointDrag(linkId: LinkId, index: number, insert: boolean): void;
|
|
119
|
+
/** Live update of the dragged waypoint to `world`. */
|
|
120
|
+
updateWaypointDrag(world: Vec2): void;
|
|
121
|
+
/**
|
|
122
|
+
* Finish the waypoint drag. If the dragged waypoint landed within
|
|
123
|
+
* `WAYPOINT_COLLAPSE_RADIUS` of an adjacent path point, it is removed
|
|
124
|
+
* (drag-onto-the-line to delete). A no-move insert adds nothing.
|
|
125
|
+
*/
|
|
126
|
+
endWaypointDrag(): void;
|
|
127
|
+
/** True while an elbow segment is being dragged. */
|
|
128
|
+
get isDraggingSegment(): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Begin a host-managed elbow segment drag. `axis` is the segment's
|
|
131
|
+
* orientation; `at` is its centre along its own axis (used to re-identify it
|
|
132
|
+
* across re-routes).
|
|
133
|
+
*/
|
|
134
|
+
beginSegmentDrag(linkId: LinkId, axis: "h" | "v", at: number): void;
|
|
135
|
+
/**
|
|
136
|
+
* Move the dragged elbow segment perpendicular to its axis: pin its
|
|
137
|
+
* perpendicular coordinate to the cursor. The reroute pass re-flows the
|
|
138
|
+
* rest around the pin (one undo step via the gesture transaction).
|
|
139
|
+
*/
|
|
140
|
+
updateSegmentDrag(world: Vec2): void;
|
|
141
|
+
/** Finish the elbow segment drag (commit the gesture as one undo step). */
|
|
142
|
+
endSegmentDrag(): void;
|
|
143
|
+
/** Begin dragging the selected link's caption pill along its path. */
|
|
144
|
+
beginLabelDrag(linkId: LinkId): void;
|
|
145
|
+
/** Live update: project the cursor onto the path, snap near the middle. */
|
|
146
|
+
updateLabelDrag(world: Vec2): void;
|
|
147
|
+
/** Finish the caption drag (commits the gesture as one undo step). */
|
|
148
|
+
endLabelDrag(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Double-click detector for link edit handles (waypoint / segment).
|
|
151
|
+
* Returns true when this press follows the previous handle press within
|
|
152
|
+
* the double-click window + tolerance. Updates state every call. Kept
|
|
153
|
+
* separate from the up-side double-click path (handles return early in
|
|
154
|
+
* `onDown`, so that path never sees them).
|
|
155
|
+
*/
|
|
156
|
+
isHandleDoubleClick(world: Vec2): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Delete a free bend point (waypoint) from a straight / bezier link by
|
|
159
|
+
* index — double-click a waypoint handle to remove it. One undo step.
|
|
160
|
+
*/
|
|
161
|
+
deleteWaypoint(linkId: LinkId, index: number): void;
|
|
162
|
+
/**
|
|
163
|
+
* Remove the pinned (fixed) elbow segment that matches the given
|
|
164
|
+
* geometry — double-click a segment handle to return it to the auto
|
|
165
|
+
* route. Matches by axis + nearest pinned perpendicular `pos` (exact for
|
|
166
|
+
* a pinned segment), `at` as tiebreak. The reroute pass re-flows on the
|
|
167
|
+
* next render (fixedSegments is part of the elbow signature). One undo
|
|
168
|
+
* step.
|
|
169
|
+
*/
|
|
170
|
+
resetSegmentPin(linkId: LinkId, axis: "h" | "v", pos: number, at: number): void;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=link-handle-drag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-handle-drag.d.ts","sourceRoot":"","sources":["../../src/editor/link-handle-drag.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC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