Dialogue canvas: rewire linked outputs with red old edge.
Clicking a connected output keeps the existing edge (drawn red) and rubber-bands a new line to the cursor; RMB cancels wire mode.
@@ -278,6 +278,11 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh
278
278
const to = portWorldPos(draft.steps[targetIndex], targetIndex, 0, "in");
279
279
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
280
280
path.classList.add("dialogue-canvas-edge");
281
const rewiring = !!wiring
282
&& wiring.stepId === step.stepId
283
&& wiring.portIndex === portIndex;
284
if (rewiring)
285
{ path.classList.add("is-rewiring"); }
281
286
path.setAttribute("d", bezier(from.x, from.y, to.x, to.y));
282
287
path.setAttribute("fill", "none");
283
288
edgesSvg.insertBefore(path, rubberPath);
@@ -442,12 +447,8 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh
442
447
event.stopPropagation();
443
448
event.preventDefault();
444
449
hideContext();
445
if (wiring && wiring.stepId === step.stepId && wiring.portIndex === portIndex)
446
{
447
clearWiring();
448
refresh();
449
return;
450
}
450
// Clicking an output always starts/continues wire mode (existing link stays until
451
// a new input is chosen; that edge is drawn red via is-rewiring).
451
452
setWiring(step.stepId, portIndex, port.key);
452
453
drag = {
453
454
mode: "wire",
@@ -463,6 +464,7 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh
463
464
rubberPath.classList.add("active");
464
465
rubberPath.setAttribute("d", bezier(from.x, from.y, worldPt.x, worldPt.y));
465
466
refreshCardsOnly();
467
redrawEdges();
466
468
});
467
469
btn.addEventListener("pointerenter", (event) =>
468
470
{
@@ -590,6 +592,14 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh
590
592
viewport.addEventListener("contextmenu", (event) =>
591
593
{
592
594
event.preventDefault();
595
// RMB cancels an in-progress wire/rewire.
596
if (wiring)
597
{
598
clearWiring();
599
hideContext();
600
refresh();
601
return;
602
}
593
603
if (event.target.closest(".dialogue-canvas-card"))
594
604
{ return; }
595
605
const worldPt = clientToWorld(event.clientX, event.clientY);
@@ -278,6 +278,11 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh278
const to = portWorldPos(draft.steps[targetIndex], targetIndex, 0, "in");278
const to = portWorldPos(draft.steps[targetIndex], targetIndex, 0, "in");279
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");279
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");280
path.classList.add("dialogue-canvas-edge");280
path.classList.add("dialogue-canvas-edge");281
const rewiring = !!wiring282
&& wiring.stepId === step.stepId283
&& wiring.portIndex === portIndex;284
if (rewiring)285
{ path.classList.add("is-rewiring"); }281
path.setAttribute("d", bezier(from.x, from.y, to.x, to.y));286
path.setAttribute("d", bezier(from.x, from.y, to.x, to.y));282
path.setAttribute("fill", "none");287
path.setAttribute("fill", "none");283
edgesSvg.insertBefore(path, rubberPath);288
edgesSvg.insertBefore(path, rubberPath);@@ -442,12 +447,8 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh442
event.stopPropagation();447
event.stopPropagation();443
event.preventDefault();448
event.preventDefault();444
hideContext();449
hideContext();445
if (wiring && wiring.stepId === step.stepId && wiring.portIndex === portIndex)450
// Clicking an output always starts/continues wire mode (existing link stays until446
{451
// a new input is chosen; that edge is drawn red via is-rewiring).447
clearWiring();448
refresh();449
return;450
}451
setWiring(step.stepId, portIndex, port.key);452
setWiring(step.stepId, portIndex, port.key);452
drag = {453
drag = {453
mode: "wire",454
mode: "wire",@@ -463,6 +464,7 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh463
rubberPath.classList.add("active");464
rubberPath.classList.add("active");464
rubberPath.setAttribute("d", bezier(from.x, from.y, worldPt.x, worldPt.y));465
rubberPath.setAttribute("d", bezier(from.x, from.y, worldPt.x, worldPt.y));465
refreshCardsOnly();466
refreshCardsOnly();467
redrawEdges();466
});468
});467
btn.addEventListener("pointerenter", (event) =>469
btn.addEventListener("pointerenter", (event) =>468
{470
{@@ -590,6 +592,14 @@ export function createDialogueCanvas ({ getDraft, onOpenStep, onCreateStep, onCh590
viewport.addEventListener("contextmenu", (event) =>592
viewport.addEventListener("contextmenu", (event) =>591
{593
{592
event.preventDefault();594
event.preventDefault();595
// RMB cancels an in-progress wire/rewire.596
if (wiring)597
{598
clearWiring();599
hideContext();600
refresh();601
return;602
}593
if (event.target.closest(".dialogue-canvas-card"))603
if (event.target.closest(".dialogue-canvas-card"))594
{ return; }604
{ return; }595
const worldPt = clientToWorld(event.clientX, event.clientY);605
const worldPt = clientToWorld(event.clientX, event.clientY);@@ -2178,6 +2178,13 @@ label {
2178
2178
animation: dialogue-edge-dash 0.9s linear infinite;
2179
2179
}
2180
2180
2181
.dialogue-canvas-edge.is-rewiring {
2182
stroke: #e05050;
2183
stroke-width: 2.75;
2184
animation: none;
2185
stroke-dasharray: none;
2186
}
2187
2181
2188
.dialogue-canvas-rubber {
2182
2189
stroke: #e0a84a;
2183
2190
stroke-width: 2;
@@ -2178,6 +2178,13 @@ label {2178
animation: dialogue-edge-dash 0.9s linear infinite;2178
animation: dialogue-edge-dash 0.9s linear infinite;2179
}2179
}2180
2180
2181
.dialogue-canvas-edge.is-rewiring {2182
stroke: #e05050;2183
stroke-width: 2.75;2184
animation: none;2185
stroke-dasharray: none;2186
}2187
2181
.dialogue-canvas-rubber {2188
.dialogue-canvas-rubber {2182
stroke: #e0a84a;2189
stroke: #e0a84a;2183
stroke-width: 2;2190
stroke-width: 2;