dsh-plugin-inspiration-workbench 0.7.0 → 0.8.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 +5 -1
- package/lib/client.js +61 -25
- package/lib/client.js.map +2 -2
- package/package.json +1 -1
- package/src/client/board.js +48 -15
- package/src/client/index.jsx +2 -2
- package/src/client/styles.css +13 -6
package/package.json
CHANGED
package/src/client/board.js
CHANGED
|
@@ -624,7 +624,11 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
624
624
|
node.dataset.sessionId = sessionId;
|
|
625
625
|
card.el = node;
|
|
626
626
|
world.appendChild(node);
|
|
627
|
-
|
|
627
|
+
for (const side of ['top', 'right', 'bottom', 'left']) {
|
|
628
|
+
const port = el('span', 'iwb-port');
|
|
629
|
+
port.dataset.side = side;
|
|
630
|
+
node.appendChild(port);
|
|
631
|
+
}
|
|
628
632
|
node.querySelector('.iwb-card-title').textContent = card.title;
|
|
629
633
|
const bodyRegion = node.querySelector('.iwb-body');
|
|
630
634
|
bodyRegion.tabIndex = 0;
|
|
@@ -1438,28 +1442,48 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1438
1442
|
return target?.id || '';
|
|
1439
1443
|
}
|
|
1440
1444
|
|
|
1441
|
-
function addPipeTarget(card, targetCard) {
|
|
1445
|
+
function addPipeTarget(card, targetCard, fromSide) {
|
|
1442
1446
|
const kind = targetCard.kind === 'note' ? 'note' : 'session';
|
|
1443
1447
|
const id = kind === 'note' ? targetCard.id : targetCard.sessionId;
|
|
1444
1448
|
if (!id || targetCard === card) return false;
|
|
1445
1449
|
const targets = pipeTargets(card).filter((target) => !(target.kind === kind && target.id === id));
|
|
1446
1450
|
const expanded = targets.length !== pipeTargets(card).length;
|
|
1447
|
-
targets.push({ kind, id, mode: 'send' });
|
|
1451
|
+
targets.push({ kind, id, mode: 'send', from: fromSide || 'right' });
|
|
1448
1452
|
setPipeTargets(card, targets);
|
|
1449
1453
|
return !expanded;
|
|
1450
1454
|
}
|
|
1451
1455
|
|
|
1452
|
-
|
|
1453
|
-
|
|
1456
|
+
const EDGE_NORMAL = {
|
|
1457
|
+
left: { x: -1, y: 0 },
|
|
1458
|
+
right: { x: 1, y: 0 },
|
|
1459
|
+
top: { x: 0, y: -1 },
|
|
1460
|
+
bottom: { x: 0, y: 1 },
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
/** Anchor at the middle of one card edge. */
|
|
1464
|
+
function edgeAnchor(card, side) {
|
|
1465
|
+
if (side === 'left') return { x: card.x, y: card.y + card.h / 2 };
|
|
1466
|
+
if (side === 'top') return { x: card.x + card.w / 2, y: card.y };
|
|
1467
|
+
if (side === 'bottom') return { x: card.x + card.w / 2, y: card.y + card.h };
|
|
1468
|
+
return { x: card.x + card.w, y: card.y + card.h / 2 };
|
|
1454
1469
|
}
|
|
1455
1470
|
|
|
1456
|
-
|
|
1457
|
-
|
|
1471
|
+
/** Which edge of the target faces the source anchor. */
|
|
1472
|
+
function sideFacing(fromPoint, target) {
|
|
1473
|
+
const dx = target.x + target.w / 2 - fromPoint.x;
|
|
1474
|
+
const dy = target.y + target.h / 2 - fromPoint.y;
|
|
1475
|
+
if (Math.abs(dx) >= Math.abs(dy)) return dx > 0 ? 'left' : 'right';
|
|
1476
|
+
return dy > 0 ? 'top' : 'bottom';
|
|
1458
1477
|
}
|
|
1459
1478
|
|
|
1460
|
-
function linkPath(from, to) {
|
|
1461
|
-
const
|
|
1462
|
-
|
|
1479
|
+
function linkPath(from, to, fromSide, toSide) {
|
|
1480
|
+
const distance = Math.hypot(to.x - from.x, to.y - from.y);
|
|
1481
|
+
const bend = Math.max(36, Math.min(140, distance * 0.42));
|
|
1482
|
+
const fromNormal = EDGE_NORMAL[fromSide] || EDGE_NORMAL.right;
|
|
1483
|
+
const toNormal = EDGE_NORMAL[toSide] || EDGE_NORMAL.left;
|
|
1484
|
+
const c1 = { x: from.x + fromNormal.x * bend, y: from.y + fromNormal.y * bend };
|
|
1485
|
+
const c2 = { x: to.x + toNormal.x * bend, y: to.y + toNormal.y * bend };
|
|
1486
|
+
return 'M ' + from.x + ' ' + from.y + ' C ' + c1.x + ' ' + c1.y + ', ' + c2.x + ' ' + c2.y + ', ' + to.x + ' ' + to.y;
|
|
1463
1487
|
}
|
|
1464
1488
|
|
|
1465
1489
|
/** Draw one curve per pipeline target, plus a fat invisible hit area each. */
|
|
@@ -1469,7 +1493,10 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1469
1493
|
for (const target of pipeTargets(card)) {
|
|
1470
1494
|
const targetCard = cardOfPipeTarget(target);
|
|
1471
1495
|
if (!targetCard || targetCard === card) continue;
|
|
1472
|
-
const
|
|
1496
|
+
const fromSide = target.from || 'right';
|
|
1497
|
+
const fromPoint = edgeAnchor(card, fromSide);
|
|
1498
|
+
const toSide = sideFacing(fromPoint, targetCard);
|
|
1499
|
+
const d = linkPath(fromPoint, edgeAnchor(targetCard, toSide), fromSide, toSide);
|
|
1473
1500
|
const hit = document.createElementNS(SVG_NS, 'path');
|
|
1474
1501
|
hit.setAttribute('d', d);
|
|
1475
1502
|
hit.setAttribute('class', 'iwb-link-hit');
|
|
@@ -1497,8 +1524,11 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1497
1524
|
|
|
1498
1525
|
/** Drag from a card's port to another card (session or note) to wire it up. */
|
|
1499
1526
|
function bindPort(card) {
|
|
1500
|
-
const
|
|
1501
|
-
|
|
1527
|
+
const ports = [...card.el.querySelectorAll('.iwb-port')];
|
|
1528
|
+
for (const port of ports) bindOnePort(card, port);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
function bindOnePort(card, port) {
|
|
1502
1532
|
port.setAttribute('title', t('pipe.port'));
|
|
1503
1533
|
port.setAttribute('aria-label', t('pipe.port'));
|
|
1504
1534
|
port.addEventListener('pointerdown', (event) => {
|
|
@@ -1509,12 +1539,15 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1509
1539
|
x: (clientX - canvasRect.left - state.pan.x) / state.zoom,
|
|
1510
1540
|
y: (clientY - canvasRect.top - state.pan.y) / state.zoom,
|
|
1511
1541
|
});
|
|
1542
|
+
const fromSide = port.dataset.side || 'right';
|
|
1543
|
+
const fromPoint = edgeAnchor(card, fromSide);
|
|
1512
1544
|
const temp = document.createElementNS(SVG_NS, 'path');
|
|
1513
1545
|
temp.setAttribute('class', 'iwb-link-temp');
|
|
1514
1546
|
linkLayer.appendChild(temp);
|
|
1515
1547
|
let hovered = null;
|
|
1516
1548
|
const draw = (clientX, clientY) => {
|
|
1517
|
-
|
|
1549
|
+
const to = point(clientX, clientY);
|
|
1550
|
+
temp.setAttribute('d', linkPath(fromPoint, to, fromSide, sideFacing(fromPoint, { x: to.x, y: to.y, w: 0, h: 0 })));
|
|
1518
1551
|
};
|
|
1519
1552
|
draw(event.clientX, event.clientY);
|
|
1520
1553
|
try {
|
|
@@ -1545,7 +1578,7 @@ export function createBoard({ host, adapter, approvals, t, onOpenSession }) {
|
|
|
1545
1578
|
temp.remove();
|
|
1546
1579
|
if (hovered) {
|
|
1547
1580
|
hovered.el.classList.remove('iwb-link-target');
|
|
1548
|
-
const created = addPipeTarget(card, hovered);
|
|
1581
|
+
const created = addPipeTarget(card, hovered, fromSide);
|
|
1549
1582
|
renderPipeBadge(card);
|
|
1550
1583
|
schedulePipelines();
|
|
1551
1584
|
saveSoon();
|
package/src/client/index.jsx
CHANGED
|
@@ -139,7 +139,7 @@ const zh = {
|
|
|
139
139
|
'pipe.modeReplace': '便签:只保留最新一段',
|
|
140
140
|
'pipe.notedReplaced': '已覆盖便签「{name}」为最新结果',
|
|
141
141
|
'pipe.removeNote': '删除这条便签流水线',
|
|
142
|
-
'pipe.port': '
|
|
142
|
+
'pipe.port': '按住拖动到另一张卡上,建立流水线',
|
|
143
143
|
'pipe.created': '流水线已连到「{name}」',
|
|
144
144
|
'pipe.needTarget': '拖到另一张卡(会话卡或便签)上才算连线',
|
|
145
145
|
'pipe.remove': '删除这条流水线',
|
|
@@ -439,7 +439,7 @@ const en = {
|
|
|
439
439
|
'pipe.modeReplace': 'Note: keep only the latest',
|
|
440
440
|
'pipe.notedReplaced': 'Note “{name}” replaced with the latest result',
|
|
441
441
|
'pipe.removeNote': 'Remove this note pipeline',
|
|
442
|
-
'pipe.port': 'Drag
|
|
442
|
+
'pipe.port': 'Drag onto another card to wire a pipeline',
|
|
443
443
|
'pipe.created': 'Pipeline wired to “{name}”',
|
|
444
444
|
'pipe.needTarget': 'Drop it on another card (session or note) to connect',
|
|
445
445
|
'pipe.remove': 'Remove this pipeline',
|
package/src/client/styles.css
CHANGED
|
@@ -471,17 +471,24 @@
|
|
|
471
471
|
.iwb-links path.iwb-link:hover { opacity: .95; stroke-width: 2; }
|
|
472
472
|
.iwb-links path.iwb-link-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
|
|
473
473
|
.iwb-links path.iwb-link-temp { fill: none; stroke: var(--dsw-alias-label-deep-diving); stroke-width: 2; stroke-dasharray: 5 4; opacity: .9; }
|
|
474
|
+
/* Connection handles: one at the middle of each edge, always visible. */
|
|
474
475
|
.iwb-port {
|
|
475
|
-
position: absolute;
|
|
476
|
-
border
|
|
476
|
+
position: absolute; width: 16px; height: 16px; border-radius: 50%;
|
|
477
|
+
border: 2px solid var(--dsw-alias-label-deep-diving);
|
|
477
478
|
background: var(--dsw-alias-bg-layer-1); cursor: crosshair;
|
|
478
|
-
opacity: .
|
|
479
|
+
opacity: .62; transition: opacity .12s, transform .12s, background .12s; z-index: 3;
|
|
480
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--dsw-alias-bg-layer-1) 70%, transparent);
|
|
479
481
|
}
|
|
480
|
-
.iwb-card:hover .iwb-port, .iwb-card.iwb-focus .iwb-port
|
|
482
|
+
.iwb-card:hover .iwb-port, .iwb-card.iwb-focus .iwb-port { opacity: .95; }
|
|
483
|
+
.iwb-port:hover { opacity: 1; transform: scale(1.15); background: var(--dsw-alias-bg-layer-2); }
|
|
481
484
|
.iwb-port::after {
|
|
482
|
-
content: "
|
|
483
|
-
font-size:
|
|
485
|
+
content: "+"; position: absolute; inset: 0; display: grid; place-items: center;
|
|
486
|
+
font-size: 11px; line-height: 1; font-weight: 500; color: var(--dsw-alias-label-deep-diving);
|
|
484
487
|
}
|
|
488
|
+
.iwb-port[data-side="right"] { right: -8px; top: calc(50% - 8px); }
|
|
489
|
+
.iwb-port[data-side="left"] { left: -8px; top: calc(50% - 8px); }
|
|
490
|
+
.iwb-port[data-side="top"] { top: -8px; left: calc(50% - 8px); }
|
|
491
|
+
.iwb-port[data-side="bottom"] { bottom: -8px; left: calc(50% - 8px); }
|
|
485
492
|
.iwb-card.iwb-link-target { outline: 2px dashed var(--dsw-alias-label-deep-diving); outline-offset: 3px; }
|
|
486
493
|
.iwb-card-note.iwb-link-target { outline-style: solid; }
|
|
487
494
|
.iwb-link-menu { min-width: 230px; }
|