dsh-plugin-inspiration-workbench 0.1.1 → 0.3.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 +17 -1
- package/lib/client.js +590 -58
- package/lib/client.js.map +3 -3
- package/package.json +10 -6
- package/scripts/build-client.mjs +1 -1
- package/src/client/board.js +491 -55
- package/src/client/icons.js +5 -0
- package/src/client/index.jsx +56 -0
- package/src/client/persistence.js +27 -0
- package/src/client/popovers.js +2 -0
- package/src/client/styles.css +67 -5
- package/src/host/index.js +61 -1
package/lib/client.js
CHANGED
|
@@ -162,7 +162,7 @@ var styles_default = `/* Inspiration workbench \u2014 scoped to .iwb-root; colou
|
|
|
162
162
|
}
|
|
163
163
|
.iwb-meta {
|
|
164
164
|
font-size: 10.5px; color: var(--dsw-alias-label-tertiary); border: .5px solid var(--dsw-alias-border-l2);
|
|
165
|
-
border-radius: 5px; padding: 0 4px; line-height: 15px; flex: 0
|
|
165
|
+
border-radius: 5px; padding: 0 4px; line-height: 15px; flex: 0 1 auto; max-width: 96px; min-width: 0;
|
|
166
166
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
167
167
|
background: none; font-family: inherit; cursor: pointer;
|
|
168
168
|
transition: background .12s, border-color .12s, color .12s;
|
|
@@ -242,13 +242,21 @@ var styles_default = `/* Inspiration workbench \u2014 scoped to .iwb-root; colou
|
|
|
242
242
|
font-size: 10px; line-height: 15px; padding: 0 4px; flex: 0 0 auto; color: var(--dsw-alias-label-secondary);
|
|
243
243
|
background: var(--dsw-alias-bg-layer-2); border: .5px solid var(--dsw-alias-border-l2); border-radius: 5px;
|
|
244
244
|
}
|
|
245
|
-
.iwb-actions { display: flex; gap:
|
|
246
|
-
.iwb-card:hover .iwb-actions
|
|
245
|
+
.iwb-actions { display: flex; gap: 0; flex: 0 0 auto; opacity: .92; transition: opacity .12s; }
|
|
246
|
+
.iwb-card:hover .iwb-actions,
|
|
247
|
+
.iwb-card:focus-within .iwb-actions,
|
|
248
|
+
.iwb-card.iwb-focus .iwb-actions { opacity: 1; }
|
|
249
|
+
.iwb-acts-more { display: none; }
|
|
250
|
+
.iwb-act-more { opacity: .9; }
|
|
251
|
+
.iwb-more { min-width: 190px; }
|
|
252
|
+
.iwb-more .iwb-model-row { gap: 8px; }
|
|
253
|
+
.iwb-more-ico { display: inline-flex; color: var(--dsw-alias-label-tertiary); }
|
|
247
254
|
.iwb-actions button {
|
|
248
|
-
width:
|
|
249
|
-
color: var(--dsw-alias-label-
|
|
255
|
+
width: 23px; height: 23px; border-radius: 6px; display: grid; place-items: center;
|
|
256
|
+
color: var(--dsw-alias-label-secondary); background: none; border: 0; cursor: pointer;
|
|
250
257
|
}
|
|
251
258
|
.iwb-actions button:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
259
|
+
.iwb-actions button:focus-visible { outline: 2px solid var(--dsw-alias-label-deep-diving); outline-offset: -1px; }
|
|
252
260
|
|
|
253
261
|
.iwb-body {
|
|
254
262
|
flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 4px;
|
|
@@ -444,6 +452,33 @@ var styles_default = `/* Inspiration workbench \u2014 scoped to .iwb-root; colou
|
|
|
444
452
|
background: color-mix(in srgb, var(--dsw-alias-label-deep-diving) 14%, transparent);
|
|
445
453
|
}
|
|
446
454
|
|
|
455
|
+
/* \u2500\u2500 canvas menu \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
456
|
+
.iwb-toolbar .iwb-btn > span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
457
|
+
.iwb-canvas-menu { min-width: 260px; max-width: 320px; }
|
|
458
|
+
.iwb-canvas-form { display: flex; gap: 6px; padding: 4px 2px 8px; }
|
|
459
|
+
.iwb-canvas-input {
|
|
460
|
+
flex: 1; min-width: 0; height: 26px; padding: 0 8px; box-sizing: border-box;
|
|
461
|
+
border-radius: 6px; border: .5px solid var(--dsw-alias-border-l2);
|
|
462
|
+
background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary);
|
|
463
|
+
font-family: inherit; font-size: 12px; outline: none;
|
|
464
|
+
}
|
|
465
|
+
.iwb-canvas-input:focus { border-color: var(--dsw-alias-label-deep-diving); }
|
|
466
|
+
.iwb-canvas-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; max-height: 260px; overflow-y: auto; }
|
|
467
|
+
.iwb-canvas-row { display: flex; align-items: center; gap: 2px; border-radius: 7px; }
|
|
468
|
+
.iwb-canvas-row.current { background: var(--dsw-alias-interactive-bg-hover); }
|
|
469
|
+
.iwb-canvas-pick {
|
|
470
|
+
flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
|
|
471
|
+
padding: 5px 7px; border: 0; border-radius: 7px; background: none; cursor: pointer; text-align: left;
|
|
472
|
+
font-family: inherit;
|
|
473
|
+
}
|
|
474
|
+
.iwb-canvas-pick:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
475
|
+
.iwb-canvas-pick .iwb-model-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
476
|
+
.iwb-canvas-remove {
|
|
477
|
+
flex: 0 0 auto; width: 22px; height: 22px; border: 0; border-radius: 6px;
|
|
478
|
+
background: none; color: var(--dsw-alias-label-tertiary); cursor: pointer; font-size: 14px; line-height: 1;
|
|
479
|
+
}
|
|
480
|
+
.iwb-canvas-remove:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-state-error-primary); }
|
|
481
|
+
|
|
447
482
|
/* \u2500\u2500 approval card note \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
448
483
|
.iwb-approval-note {
|
|
449
484
|
font-size: 10.5px; line-height: 15px; color: var(--dsw-alias-label-tertiary);
|
|
@@ -460,6 +495,33 @@ var styles_default = `/* Inspiration workbench \u2014 scoped to .iwb-root; colou
|
|
|
460
495
|
}
|
|
461
496
|
.iwb-msg-attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
462
497
|
|
|
498
|
+
/* \u2500\u2500 pipeline edges \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
499
|
+
.iwb-links {
|
|
500
|
+
position: absolute; left: 0; top: 0; width: 1px; height: 1px;
|
|
501
|
+
overflow: visible; pointer-events: none; z-index: 1;
|
|
502
|
+
}
|
|
503
|
+
.iwb-links path.iwb-link {
|
|
504
|
+
fill: none; stroke: var(--dsw-alias-label-deep-diving); stroke-width: 1.6;
|
|
505
|
+
opacity: .55; pointer-events: stroke; cursor: pointer;
|
|
506
|
+
}
|
|
507
|
+
.iwb-links path.iwb-link:hover { opacity: .95; stroke-width: 2; }
|
|
508
|
+
.iwb-links path.iwb-link-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
|
|
509
|
+
.iwb-links path.iwb-link-temp { fill: none; stroke: var(--dsw-alias-label-deep-diving); stroke-width: 2; stroke-dasharray: 5 4; opacity: .9; }
|
|
510
|
+
.iwb-port {
|
|
511
|
+
position: absolute; right: -7px; top: 30px; width: 14px; height: 14px;
|
|
512
|
+
border-radius: 50%; border: 1.5px solid var(--dsw-alias-label-deep-diving);
|
|
513
|
+
background: var(--dsw-alias-bg-layer-1); cursor: crosshair;
|
|
514
|
+
opacity: .55; transition: opacity .12s, transform .12s; z-index: 3;
|
|
515
|
+
}
|
|
516
|
+
.iwb-card:hover .iwb-port, .iwb-card.iwb-focus .iwb-port, .iwb-port:hover { opacity: 1; }
|
|
517
|
+
.iwb-port::after {
|
|
518
|
+
content: "\u2192"; position: absolute; inset: 0; display: grid; place-items: center;
|
|
519
|
+
font-size: 9px; line-height: 1; color: var(--dsw-alias-label-deep-diving);
|
|
520
|
+
}
|
|
521
|
+
.iwb-card.iwb-link-target { outline: 2px dashed var(--dsw-alias-label-deep-diving); outline-offset: 3px; }
|
|
522
|
+
.iwb-link-menu { min-width: 230px; }
|
|
523
|
+
.iwb-link-remove .iwb-model-name { color: var(--dsw-alias-state-error-primary); }
|
|
524
|
+
|
|
463
525
|
/* \u2500\u2500 pipeline \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
464
526
|
.iwb-pipe-badge {
|
|
465
527
|
flex: 0 0 auto; font-size: 10px; padding: 1px 5px; border-radius: 5px;
|
|
@@ -787,6 +849,30 @@ function subscribeRemoteLayout(listener) {
|
|
|
787
849
|
source.close();
|
|
788
850
|
};
|
|
789
851
|
}
|
|
852
|
+
async function fetchCanvases() {
|
|
853
|
+
try {
|
|
854
|
+
const response = await request("/canvases", { method: "GET" });
|
|
855
|
+
const body = await response.json();
|
|
856
|
+
return {
|
|
857
|
+
canvases: Array.isArray(body?.canvases) ? body.canvases : [],
|
|
858
|
+
activeCanvas: typeof body?.activeCanvas === "string" ? body.activeCanvas : null
|
|
859
|
+
};
|
|
860
|
+
} catch {
|
|
861
|
+
return null;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
async function pushCanvases(canvases, activeCanvas) {
|
|
865
|
+
try {
|
|
866
|
+
const response = await request("/canvases", {
|
|
867
|
+
method: "PUT",
|
|
868
|
+
headers: { "content-type": "application/json" },
|
|
869
|
+
body: JSON.stringify({ canvases, activeCanvas })
|
|
870
|
+
});
|
|
871
|
+
return await response.json().catch(() => ({}));
|
|
872
|
+
} catch {
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
790
876
|
|
|
791
877
|
// src/client/dom.js
|
|
792
878
|
var clamp = (v, min, max) => Math.min(max, Math.max(min, v));
|
|
@@ -800,6 +886,11 @@ function el(tag, className, html) {
|
|
|
800
886
|
// src/client/icons.js
|
|
801
887
|
var ICONS = {
|
|
802
888
|
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
889
|
+
flow: '<path d="M4 7h9l-2-2"/><path d="M13 7l-2 2"/><circle cx="18" cy="7" r="2.4"/><path d="M4 17h9l-2-2"/><path d="M13 17l-2 2"/><circle cx="18" cy="17" r="2.4"/>',
|
|
890
|
+
more: '<circle cx="5" cy="12" r="1.7"/><circle cx="12" cy="12" r="1.7"/><circle cx="19" cy="12" r="1.7"/>',
|
|
891
|
+
canvas: '<rect x="3" y="7" width="14" height="14" rx="2"/><path d="M7 7V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2"/>',
|
|
892
|
+
quote: '<path d="M7 7h5v5a4 4 0 0 1-4 4H7"/><path d="M15 7h5v5a4 4 0 0 1-4 4h-1"/>',
|
|
893
|
+
board: '<rect x="3" y="4" width="5.5" height="16" rx="1.4"/><rect x="9.5" y="4" width="5.5" height="11" rx="1.4"/><rect x="16" y="4" width="5" height="7" rx="1.4"/>',
|
|
803
894
|
arrange: '<rect x="3" y="3" width="7" height="7" rx="1.6"/><rect x="14" y="3" width="7" height="7" rx="1.6"/><rect x="3" y="14" width="7" height="7" rx="1.6"/><rect x="14" y="14" width="7" height="7" rx="1.6"/>',
|
|
804
895
|
fit: '<path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M8 21H5a2 2 0 0 1-2-2v-3M16 21h3a2 2 0 0 0 2-2v-3"/>',
|
|
805
896
|
open: '<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><path d="M15 3h6v6"/><path d="M10 14L21 3"/>',
|
|
@@ -2096,7 +2187,8 @@ function createArrangeMenu(deps) {
|
|
|
2096
2187
|
toast,
|
|
2097
2188
|
defaultSize,
|
|
2098
2189
|
gap,
|
|
2099
|
-
anchor
|
|
2190
|
+
anchor,
|
|
2191
|
+
afterArrange
|
|
2100
2192
|
} = deps;
|
|
2101
2193
|
const el2 = el;
|
|
2102
2194
|
const DEFAULT_W2 = defaultSize.w;
|
|
@@ -2151,6 +2243,7 @@ function createArrangeMenu(deps) {
|
|
|
2151
2243
|
}
|
|
2152
2244
|
saveSoon();
|
|
2153
2245
|
void fitView();
|
|
2246
|
+
afterArrange?.();
|
|
2154
2247
|
toast(t2("arrange.done"));
|
|
2155
2248
|
}
|
|
2156
2249
|
function openArrangeMenu() {
|
|
@@ -2434,6 +2527,7 @@ function createSettingsMenu(deps) {
|
|
|
2434
2527
|
|
|
2435
2528
|
// src/client/board.js
|
|
2436
2529
|
var STORAGE_KEY = "dsh.inspiration-workbench.v1";
|
|
2530
|
+
var CANVAS_KEY = "dsh.inspiration-workbench.canvases.v1";
|
|
2437
2531
|
var DEFAULT_W = 380;
|
|
2438
2532
|
var DEFAULT_H = 500;
|
|
2439
2533
|
var GAP = 20;
|
|
@@ -2457,7 +2551,9 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2457
2551
|
zTop: 20,
|
|
2458
2552
|
focusedId: null,
|
|
2459
2553
|
savedView: false,
|
|
2460
|
-
board: { active: false, key: "status", saved: /* @__PURE__ */ new Map() }
|
|
2554
|
+
board: { active: false, key: "status", saved: /* @__PURE__ */ new Map() },
|
|
2555
|
+
canvases: [],
|
|
2556
|
+
activeCanvas: null
|
|
2461
2557
|
};
|
|
2462
2558
|
const expandedTurns = /* @__PURE__ */ new Map();
|
|
2463
2559
|
const tools = createCardTools({ t: t2, el, toast, ensureVisible, state });
|
|
@@ -2523,6 +2619,8 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2523
2619
|
if (t2("hint.pan")) hint.hidden = false;
|
|
2524
2620
|
const btnNew = el("button", "iwb-btn primary", icon("plus", 13) + "<span>" + t2("new") + "</span>");
|
|
2525
2621
|
btnNew.type = "button";
|
|
2622
|
+
const btnCanvas = el("button", "iwb-btn", icon("canvas", 13) + "<span>" + t2("canvas") + "</span>");
|
|
2623
|
+
btnCanvas.type = "button";
|
|
2526
2624
|
const btnArrange = el("button", "iwb-btn", icon("arrange", 13) + "<span>" + t2("arrange") + "</span>");
|
|
2527
2625
|
btnArrange.type = "button";
|
|
2528
2626
|
const btnBoard = el("button", "iwb-btn", icon("board", 13) + "<span>" + t2("boardMode") + "</span>");
|
|
@@ -2539,7 +2637,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2539
2637
|
const btnSettings = el("button", "iwb-btn", icon("sliders", 13) + "<span>" + t2("settings") + "</span>");
|
|
2540
2638
|
btnSettings.type = "button";
|
|
2541
2639
|
const actions = el("div", "iwb-toolbar-actions");
|
|
2542
|
-
actions.append(todoBar, btnNew, btnNote, btnArrange, btnBoard, btnFit, btnCollapse, btnSettings);
|
|
2640
|
+
actions.append(todoBar, btnNew, btnNote, btnCanvas, btnArrange, btnBoard, btnFit, btnCollapse, btnSettings);
|
|
2543
2641
|
toolbar.append(titles, hint, actions);
|
|
2544
2642
|
const canvas = el("div", "iwb-canvas");
|
|
2545
2643
|
canvas.tabIndex = 0;
|
|
@@ -2547,6 +2645,11 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2547
2645
|
canvas.setAttribute("aria-label", t2("a11y.canvas"));
|
|
2548
2646
|
const world = el("div", "iwb-world");
|
|
2549
2647
|
canvas.appendChild(world);
|
|
2648
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
2649
|
+
const linkLayer = document.createElementNS(SVG_NS, "svg");
|
|
2650
|
+
linkLayer.setAttribute("class", "iwb-links");
|
|
2651
|
+
linkLayer.setAttribute("aria-hidden", "true");
|
|
2652
|
+
world.appendChild(linkLayer);
|
|
2550
2653
|
const emptyState = el(
|
|
2551
2654
|
"div",
|
|
2552
2655
|
"iwb-empty",
|
|
@@ -2579,7 +2682,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2579
2682
|
tools.closeRefPicker();
|
|
2580
2683
|
}
|
|
2581
2684
|
});
|
|
2582
|
-
const arrangeMenu = createArrangeMenu({ t: t2, state, canvas, fitView, saveSoon, toast, defaultSize: { w: DEFAULT_W, h: DEFAULT_H }, gap: GAP, anchor: btnArrange });
|
|
2685
|
+
const arrangeMenu = createArrangeMenu({ t: t2, state, canvas, fitView, saveSoon, toast, defaultSize: { w: DEFAULT_W, h: DEFAULT_H }, gap: GAP, anchor: btnArrange, afterArrange: () => schedulePipelines() });
|
|
2583
2686
|
const workspaceMenu = createWorkspaceMenu({
|
|
2584
2687
|
t: t2,
|
|
2585
2688
|
adapter,
|
|
@@ -2725,6 +2828,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2725
2828
|
function layoutStack(stack) {
|
|
2726
2829
|
const cards = stackCards(stack);
|
|
2727
2830
|
if (!cards.length) return;
|
|
2831
|
+
schedulePipelines();
|
|
2728
2832
|
state.zTop += cards.length + 1;
|
|
2729
2833
|
const base = state.zTop;
|
|
2730
2834
|
const inStack = cards.length > 1;
|
|
@@ -2847,7 +2951,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2847
2951
|
return { x: 0, y: (state.cards.length + 1) * (DEFAULT_H + GAP) };
|
|
2848
2952
|
}
|
|
2849
2953
|
function cardMarkup(card) {
|
|
2850
|
-
return '<div class="iwb-progress"></div><header class="iwb-head"><span class="iwb-dot" title="' + t2("state.idle") + '"></span><span class="iwb-card-title"></span><span class="iwb-card-workspace" hidden></span><span class="iwb-status" hidden></span><span class="iwb-unread" hidden></span><button type="button" class="iwb-meta"></button><span class="iwb-elapsed"></span><span class="iwb-stack-badge" hidden></span><span class="iwb-pipe-badge" hidden></span><span class="iwb-actions"><button type="button" data-act="
|
|
2954
|
+
return '<div class="iwb-progress"></div><header class="iwb-head"><span class="iwb-dot" title="' + t2("state.idle") + '"></span><span class="iwb-card-title"></span><span class="iwb-card-workspace" hidden></span><span class="iwb-status" hidden></span><span class="iwb-unread" hidden></span><button type="button" class="iwb-meta"></button><span class="iwb-elapsed"></span><span class="iwb-stack-badge" hidden></span><span class="iwb-pipe-badge" hidden></span><span class="iwb-actions"><button type="button" data-act="outline" title="' + t2("card.outline") + '" aria-label="' + t2("card.outline") + '">' + icon("list") + '</button><button type="button" data-act="search" title="' + t2("card.search") + '" aria-label="' + t2("card.search") + '">' + icon("search") + '</button><button type="button" data-act="more" class="iwb-act-more" title="' + t2("card.more") + '" aria-label="' + t2("card.more") + '">' + icon("more") + '</button><button type="button" data-act="close" title="' + t2("remove") + '" aria-label="' + t2("remove") + '">' + icon("close") + '</button><span class="iwb-acts-more" hidden><button type="button" data-act="pin" title="' + t2("card.pin") + '" aria-label="' + t2("card.pin") + '">' + icon("pin") + '</button><button type="button" data-act="copy" title="' + t2("card.copy") + '" aria-label="' + t2("card.copy") + '">' + icon("copy") + '</button><button type="button" data-act="detach" title="' + t2("detach") + '" aria-label="' + t2("detach") + '" style="display:none">' + icon("layers") + '</button><button type="button" data-act="open" title="' + t2("openNative") + '" aria-label="' + t2("openNative") + '">' + icon("open") + '</button></span></span></header><div class="iwb-search" hidden><input class="iwb-search-input" type="text" /><span class="iwb-search-count"></span></div><div class="iwb-body"></div><div class="iwb-queue" hidden></div><div class="iwb-foot"></div><div class="iwb-resize"></div>';
|
|
2851
2955
|
}
|
|
2852
2956
|
function noteBody(card) {
|
|
2853
2957
|
const body = card.el.querySelector(".iwb-body");
|
|
@@ -2944,18 +3048,21 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
2944
3048
|
node.dataset.sessionId = sessionId;
|
|
2945
3049
|
card.el = node;
|
|
2946
3050
|
world.appendChild(node);
|
|
3051
|
+
node.appendChild(el("span", "iwb-port"));
|
|
2947
3052
|
node.querySelector(".iwb-card-title").textContent = card.title;
|
|
2948
3053
|
const bodyRegion = node.querySelector(".iwb-body");
|
|
2949
3054
|
bodyRegion.tabIndex = 0;
|
|
2950
3055
|
bodyRegion.setAttribute("role", "log");
|
|
2951
3056
|
bodyRegion.setAttribute("aria-label", t2("a11y.body"));
|
|
2952
3057
|
bindCard(card);
|
|
3058
|
+
bindPort(card);
|
|
2953
3059
|
for (const [boardKey, value] of expandedTurns) {
|
|
2954
3060
|
if (!boardKey.startsWith(sessionId + ":")) continue;
|
|
2955
3061
|
card.toolOpen.set("turn:" + boardKey.slice(sessionId.length + 1), value);
|
|
2956
3062
|
}
|
|
2957
3063
|
renderFoot(card);
|
|
2958
3064
|
renderPipeBadge(card);
|
|
3065
|
+
schedulePipelines();
|
|
2959
3066
|
state.cards.push(card);
|
|
2960
3067
|
updateCounts();
|
|
2961
3068
|
updateEmptyState();
|
|
@@ -3244,6 +3351,220 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3244
3351
|
clearSelection();
|
|
3245
3352
|
toast(t2("batch.closed").replace("{n}", String(picked.length)));
|
|
3246
3353
|
}
|
|
3354
|
+
let canvasPop = null;
|
|
3355
|
+
function closeCanvasMenu() {
|
|
3356
|
+
canvasPop?.remove();
|
|
3357
|
+
canvasPop = null;
|
|
3358
|
+
}
|
|
3359
|
+
function loadLocalCanvases() {
|
|
3360
|
+
try {
|
|
3361
|
+
const raw = window.localStorage.getItem(CANVAS_KEY);
|
|
3362
|
+
if (!raw) return null;
|
|
3363
|
+
const parsed = JSON.parse(raw);
|
|
3364
|
+
if (!parsed || !Array.isArray(parsed.canvases)) return null;
|
|
3365
|
+
return parsed;
|
|
3366
|
+
} catch {
|
|
3367
|
+
return null;
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
function syncCanvases() {
|
|
3371
|
+
state.canvases = Array.isArray(state.canvases) ? state.canvases : [];
|
|
3372
|
+
return state.canvases;
|
|
3373
|
+
}
|
|
3374
|
+
function storeCanvases() {
|
|
3375
|
+
const payload = { canvases: state.canvases, activeCanvas: state.activeCanvas };
|
|
3376
|
+
try {
|
|
3377
|
+
window.localStorage.setItem(CANVAS_KEY, JSON.stringify(payload));
|
|
3378
|
+
} catch {
|
|
3379
|
+
}
|
|
3380
|
+
void pushCanvases(payload.canvases, payload.activeCanvas);
|
|
3381
|
+
renderCanvasButton();
|
|
3382
|
+
}
|
|
3383
|
+
function renderCanvasButton() {
|
|
3384
|
+
const active = syncCanvases().find((canvas2) => canvas2.id === state.activeCanvas);
|
|
3385
|
+
btnCanvas.querySelector("span").textContent = active ? t2("canvas") + " \xB7 " + active.name : t2("canvas");
|
|
3386
|
+
btnCanvas.title = active ? t2("canvas.active").replace("{name}", active.name) : t2("canvas.title");
|
|
3387
|
+
btnCanvas.classList.toggle("iwb-btn-active", Boolean(active));
|
|
3388
|
+
}
|
|
3389
|
+
function usableCanvases(list) {
|
|
3390
|
+
return (Array.isArray(list) ? list : []).filter(
|
|
3391
|
+
(canvas2) => canvas2 && typeof canvas2.id === "string" && canvas2.layout && Array.isArray(canvas2.layout.cards)
|
|
3392
|
+
);
|
|
3393
|
+
}
|
|
3394
|
+
function mergeCanvases(remoteList, localList) {
|
|
3395
|
+
const byId2 = /* @__PURE__ */ new Map();
|
|
3396
|
+
for (const canvas2 of usableCanvases(localList)) byId2.set(canvas2.id, canvas2);
|
|
3397
|
+
for (const canvas2 of usableCanvases(remoteList)) {
|
|
3398
|
+
const existing = byId2.get(canvas2.id);
|
|
3399
|
+
if (!existing || (canvas2.savedAt || 0) >= (existing.savedAt || 0)) byId2.set(canvas2.id, canvas2);
|
|
3400
|
+
}
|
|
3401
|
+
return [...byId2.values()].sort((left, right) => (left.savedAt || 0) - (right.savedAt || 0));
|
|
3402
|
+
}
|
|
3403
|
+
async function loadCanvases() {
|
|
3404
|
+
const remote = await fetchCanvases();
|
|
3405
|
+
const local = loadLocalCanvases();
|
|
3406
|
+
const remoteCanvases = remote?.canvases || [];
|
|
3407
|
+
const localCanvases = local?.canvases || [];
|
|
3408
|
+
const merged = mergeCanvases(remoteCanvases, localCanvases);
|
|
3409
|
+
state.canvases = merged;
|
|
3410
|
+
state.activeCanvas = remote?.activeCanvas || local?.activeCanvas || null;
|
|
3411
|
+
if (!merged.some((canvas2) => canvas2.id === state.activeCanvas)) state.activeCanvas = null;
|
|
3412
|
+
renderCanvasButton();
|
|
3413
|
+
}
|
|
3414
|
+
function canvasStamp() {
|
|
3415
|
+
return (/* @__PURE__ */ new Date()).toLocaleString(void 0, { month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit" });
|
|
3416
|
+
}
|
|
3417
|
+
function saveCanvasAs(name) {
|
|
3418
|
+
const trimmed = String(name || "").trim();
|
|
3419
|
+
if (!trimmed) {
|
|
3420
|
+
toast(t2("canvas.nameRequired"));
|
|
3421
|
+
return false;
|
|
3422
|
+
}
|
|
3423
|
+
state.canvases = syncCanvases().filter((canvas3) => canvas3.name !== trimmed);
|
|
3424
|
+
const canvas2 = {
|
|
3425
|
+
id: "cv" + Date.now().toString(36),
|
|
3426
|
+
name: trimmed,
|
|
3427
|
+
savedAt: Date.now(),
|
|
3428
|
+
layout: layoutPayload()
|
|
3429
|
+
};
|
|
3430
|
+
state.canvases = [...state.canvases, canvas2];
|
|
3431
|
+
state.activeCanvas = canvas2.id;
|
|
3432
|
+
storeCanvases();
|
|
3433
|
+
toast(t2("canvas.saved").replace("{name}", trimmed));
|
|
3434
|
+
return true;
|
|
3435
|
+
}
|
|
3436
|
+
function updateActiveCanvas() {
|
|
3437
|
+
const active = syncCanvases().find((canvas2) => canvas2.id === state.activeCanvas);
|
|
3438
|
+
if (!active) return false;
|
|
3439
|
+
active.layout = layoutPayload();
|
|
3440
|
+
active.savedAt = Date.now();
|
|
3441
|
+
storeCanvases();
|
|
3442
|
+
toast(t2("canvas.updated").replace("{name}", active.name));
|
|
3443
|
+
return true;
|
|
3444
|
+
}
|
|
3445
|
+
function switchCanvas(id) {
|
|
3446
|
+
const target = syncCanvases().find((canvas2) => canvas2.id === id);
|
|
3447
|
+
if (!target) return;
|
|
3448
|
+
if (state.activeCanvas && state.activeCanvas !== id) {
|
|
3449
|
+
const current = syncCanvases().find((canvas2) => canvas2.id === state.activeCanvas);
|
|
3450
|
+
if (current) {
|
|
3451
|
+
current.layout = layoutPayload();
|
|
3452
|
+
current.savedAt = Date.now();
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
state.activeCanvas = id;
|
|
3456
|
+
storeCanvases();
|
|
3457
|
+
closeCanvasMenu();
|
|
3458
|
+
try {
|
|
3459
|
+
applyLayout(target.layout, { toast: t2("canvas.switched").replace("{name}", target.name) });
|
|
3460
|
+
save();
|
|
3461
|
+
void fitView();
|
|
3462
|
+
} catch {
|
|
3463
|
+
toast(t2("canvas.broken"));
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
function deleteCanvas(id) {
|
|
3467
|
+
const target = syncCanvases().find((canvas2) => canvas2.id === id);
|
|
3468
|
+
state.canvases = syncCanvases().filter((canvas2) => canvas2.id !== id);
|
|
3469
|
+
if (state.activeCanvas === id) state.activeCanvas = null;
|
|
3470
|
+
storeCanvases();
|
|
3471
|
+
if (target) toast(t2("canvas.deleted").replace("{name}", target.name));
|
|
3472
|
+
}
|
|
3473
|
+
function openCanvasMenu() {
|
|
3474
|
+
if (canvasPop) {
|
|
3475
|
+
closeCanvasMenu();
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3478
|
+
const pop = el("div", "iwb-popover iwb-canvas-menu");
|
|
3479
|
+
pop.setAttribute("role", "dialog");
|
|
3480
|
+
pop.setAttribute("aria-label", t2("canvas.title"));
|
|
3481
|
+
const head = el("div", "iwb-popover-head");
|
|
3482
|
+
head.textContent = t2("canvas.title");
|
|
3483
|
+
pop.appendChild(head);
|
|
3484
|
+
const active = syncCanvases().find((canvas2) => canvas2.id === state.activeCanvas);
|
|
3485
|
+
const status = el("div", "iwb-popover-note");
|
|
3486
|
+
status.textContent = active ? t2("canvas.current").replace("{name}", active.name) : t2("canvas.unsaved");
|
|
3487
|
+
pop.appendChild(status);
|
|
3488
|
+
const form = el("div", "iwb-canvas-form");
|
|
3489
|
+
const input = document.createElement("input");
|
|
3490
|
+
input.type = "text";
|
|
3491
|
+
input.className = "iwb-canvas-input";
|
|
3492
|
+
input.placeholder = t2("canvas.placeholder");
|
|
3493
|
+
input.value = active ? active.name : "";
|
|
3494
|
+
const saveBtn = el("button", "iwb-btn primary");
|
|
3495
|
+
saveBtn.type = "button";
|
|
3496
|
+
saveBtn.textContent = t2("canvas.save");
|
|
3497
|
+
saveBtn.addEventListener("click", (event) => {
|
|
3498
|
+
event.stopPropagation();
|
|
3499
|
+
if (saveCanvasAs(input.value)) {
|
|
3500
|
+
closeCanvasMenu();
|
|
3501
|
+
}
|
|
3502
|
+
});
|
|
3503
|
+
input.addEventListener("keydown", (event) => {
|
|
3504
|
+
event.stopPropagation();
|
|
3505
|
+
if (event.key === "Enter") {
|
|
3506
|
+
event.preventDefault();
|
|
3507
|
+
if (saveCanvasAs(input.value)) closeCanvasMenu();
|
|
3508
|
+
}
|
|
3509
|
+
});
|
|
3510
|
+
form.append(input, saveBtn);
|
|
3511
|
+
pop.appendChild(form);
|
|
3512
|
+
if (active) {
|
|
3513
|
+
const overwrite = el("button", "iwb-btn");
|
|
3514
|
+
overwrite.type = "button";
|
|
3515
|
+
overwrite.textContent = t2("canvas.overwrite").replace("{name}", active.name);
|
|
3516
|
+
overwrite.addEventListener("click", (event) => {
|
|
3517
|
+
event.stopPropagation();
|
|
3518
|
+
updateActiveCanvas();
|
|
3519
|
+
closeCanvasMenu();
|
|
3520
|
+
});
|
|
3521
|
+
pop.appendChild(overwrite);
|
|
3522
|
+
}
|
|
3523
|
+
const list = el("div", "iwb-canvas-list");
|
|
3524
|
+
const canvases = syncCanvases();
|
|
3525
|
+
if (!canvases.length) {
|
|
3526
|
+
const empty = el("div", "iwb-popover-note");
|
|
3527
|
+
empty.textContent = t2("canvas.none");
|
|
3528
|
+
list.appendChild(empty);
|
|
3529
|
+
}
|
|
3530
|
+
for (const canvas2 of canvases) {
|
|
3531
|
+
const row = el("div", "iwb-canvas-row" + (canvas2.id === state.activeCanvas ? " current" : ""));
|
|
3532
|
+
const pick = el("button", "iwb-canvas-pick");
|
|
3533
|
+
pick.type = "button";
|
|
3534
|
+
pick.innerHTML = '<span class="iwb-model-name"></span><span class="iwb-model-desc"></span>';
|
|
3535
|
+
pick.querySelector(".iwb-model-name").textContent = canvas2.name;
|
|
3536
|
+
const cards = Array.isArray(canvas2.layout?.cards) ? canvas2.layout.cards.length : Number(canvas2.layout?.cards) || 0;
|
|
3537
|
+
pick.querySelector(".iwb-model-desc").textContent = t2("canvas.meta").replace("{n}", String(cards)).replace("{time}", canvas2.savedAt ? canvasStamp(canvas2.savedAt) : "");
|
|
3538
|
+
pick.addEventListener("click", (event) => {
|
|
3539
|
+
event.stopPropagation();
|
|
3540
|
+
switchCanvas(canvas2.id);
|
|
3541
|
+
});
|
|
3542
|
+
const remove = el("button", "iwb-canvas-remove");
|
|
3543
|
+
remove.type = "button";
|
|
3544
|
+
remove.title = t2("canvas.delete");
|
|
3545
|
+
remove.setAttribute("aria-label", t2("canvas.delete"));
|
|
3546
|
+
remove.textContent = "\xD7";
|
|
3547
|
+
remove.addEventListener("click", (event) => {
|
|
3548
|
+
event.stopPropagation();
|
|
3549
|
+
deleteCanvas(canvas2.id);
|
|
3550
|
+
closeCanvasMenu();
|
|
3551
|
+
});
|
|
3552
|
+
row.append(pick, remove);
|
|
3553
|
+
list.appendChild(row);
|
|
3554
|
+
}
|
|
3555
|
+
pop.appendChild(list);
|
|
3556
|
+
const rect = btnCanvas.getBoundingClientRect();
|
|
3557
|
+
pop.style.left = Math.round(Math.max(8, Math.min(rect.left - 80, window.innerWidth - 300))) + "px";
|
|
3558
|
+
pop.style.top = Math.round(rect.bottom + 6) + "px";
|
|
3559
|
+
document.body.appendChild(pop);
|
|
3560
|
+
canvasPop = pop;
|
|
3561
|
+
const measured = pop.getBoundingClientRect();
|
|
3562
|
+
if (measured.bottom > window.innerHeight - 8) {
|
|
3563
|
+
pop.style.top = Math.max(8, Math.round(rect.top - measured.height - 6)) + "px";
|
|
3564
|
+
}
|
|
3565
|
+
input.focus();
|
|
3566
|
+
input.select();
|
|
3567
|
+
}
|
|
3247
3568
|
let kanbanPop = null;
|
|
3248
3569
|
let kanbanTimer = 0;
|
|
3249
3570
|
const kanbanHeads = [];
|
|
@@ -3340,6 +3661,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3340
3661
|
});
|
|
3341
3662
|
saveSoon();
|
|
3342
3663
|
void fitView();
|
|
3664
|
+
schedulePipelines();
|
|
3343
3665
|
}
|
|
3344
3666
|
function exitKanban() {
|
|
3345
3667
|
state.board.active = false;
|
|
@@ -3355,6 +3677,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3355
3677
|
state.board.saved.clear();
|
|
3356
3678
|
saveSoon();
|
|
3357
3679
|
void fitView();
|
|
3680
|
+
schedulePipelines();
|
|
3358
3681
|
btnBoard.classList.remove("iwb-btn-active");
|
|
3359
3682
|
}
|
|
3360
3683
|
function enterKanban(key, label) {
|
|
@@ -3422,6 +3745,99 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3422
3745
|
function sessionCardOf(sessionId) {
|
|
3423
3746
|
return state.cards.find((card) => card.sessionId === sessionId) || null;
|
|
3424
3747
|
}
|
|
3748
|
+
function portAnchor(card) {
|
|
3749
|
+
return { x: card.x + card.w, y: card.y + 30 };
|
|
3750
|
+
}
|
|
3751
|
+
function targetAnchor(card) {
|
|
3752
|
+
return { x: card.x, y: card.y + 30 };
|
|
3753
|
+
}
|
|
3754
|
+
function linkPath(from, to) {
|
|
3755
|
+
const dx = Math.max(40, Math.abs(to.x - from.x) * 0.45);
|
|
3756
|
+
return "M " + from.x + " " + from.y + " C " + (from.x + dx) + " " + from.y + ", " + (to.x - dx) + " " + to.y + ", " + to.x + " " + to.y;
|
|
3757
|
+
}
|
|
3758
|
+
function renderPipelines() {
|
|
3759
|
+
while (linkLayer.firstChild) linkLayer.removeChild(linkLayer.firstChild);
|
|
3760
|
+
for (const card of state.cards) {
|
|
3761
|
+
const target = card.pipeline?.targetSessionId ? sessionCardOf(card.pipeline.targetSessionId) : null;
|
|
3762
|
+
if (!target || target === card) continue;
|
|
3763
|
+
const d = linkPath(portAnchor(card), targetAnchor(target));
|
|
3764
|
+
const hit = document.createElementNS(SVG_NS, "path");
|
|
3765
|
+
hit.setAttribute("d", d);
|
|
3766
|
+
hit.setAttribute("class", "iwb-link-hit");
|
|
3767
|
+
hit.addEventListener("pointerdown", (event) => {
|
|
3768
|
+
event.stopPropagation();
|
|
3769
|
+
openPipeMenu(card, event.currentTarget);
|
|
3770
|
+
});
|
|
3771
|
+
const path = document.createElementNS(SVG_NS, "path");
|
|
3772
|
+
path.setAttribute("d", d);
|
|
3773
|
+
path.setAttribute("class", "iwb-link");
|
|
3774
|
+
if (card.pipeline.mode === "draft") path.setAttribute("stroke-dasharray", "4 4");
|
|
3775
|
+
linkLayer.append(hit, path);
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
let pipelineFrame = 0;
|
|
3779
|
+
function schedulePipelines() {
|
|
3780
|
+
if (pipelineFrame) return;
|
|
3781
|
+
pipelineFrame = requestAnimationFrame(() => {
|
|
3782
|
+
pipelineFrame = 0;
|
|
3783
|
+
renderPipelines();
|
|
3784
|
+
});
|
|
3785
|
+
}
|
|
3786
|
+
function bindPort(card) {
|
|
3787
|
+
const port = card.el.querySelector(".iwb-port");
|
|
3788
|
+
if (!port) return;
|
|
3789
|
+
port.setAttribute("title", t2("pipe.port"));
|
|
3790
|
+
port.setAttribute("aria-label", t2("pipe.port"));
|
|
3791
|
+
port.addEventListener("pointerdown", (event) => {
|
|
3792
|
+
event.preventDefault();
|
|
3793
|
+
event.stopPropagation();
|
|
3794
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
3795
|
+
const point = (clientX, clientY) => ({
|
|
3796
|
+
x: (clientX - canvasRect.left - state.pan.x) / state.zoom,
|
|
3797
|
+
y: (clientY - canvasRect.top - state.pan.y) / state.zoom
|
|
3798
|
+
});
|
|
3799
|
+
const temp = document.createElementNS(SVG_NS, "path");
|
|
3800
|
+
temp.setAttribute("class", "iwb-link-temp");
|
|
3801
|
+
linkLayer.appendChild(temp);
|
|
3802
|
+
let hovered = null;
|
|
3803
|
+
const draw = (clientX, clientY) => {
|
|
3804
|
+
temp.setAttribute("d", linkPath(portAnchor(card), point(clientX, clientY)));
|
|
3805
|
+
};
|
|
3806
|
+
draw(event.clientX, event.clientY);
|
|
3807
|
+
port.setPointerCapture?.(event.pointerId);
|
|
3808
|
+
const onMove = (moveEvent) => {
|
|
3809
|
+
draw(moveEvent.clientX, moveEvent.clientY);
|
|
3810
|
+
const under = document.elementFromPoint(moveEvent.clientX, moveEvent.clientY);
|
|
3811
|
+
const candidate = under?.closest?.(".iwb-card");
|
|
3812
|
+
const targetCard = candidate ? state.cards.find((entry) => entry.el === candidate) : null;
|
|
3813
|
+
if (hovered && hovered !== targetCard) hovered.el.classList.remove("iwb-link-target");
|
|
3814
|
+
hovered = targetCard && targetCard !== card && targetCard.sessionId ? targetCard : null;
|
|
3815
|
+
if (hovered) hovered.el.classList.add("iwb-link-target");
|
|
3816
|
+
};
|
|
3817
|
+
const finish = (upEvent) => {
|
|
3818
|
+
port.releasePointerCapture?.(event.pointerId);
|
|
3819
|
+
port.removeEventListener("pointermove", onMove);
|
|
3820
|
+
port.removeEventListener("pointerup", finish);
|
|
3821
|
+
port.removeEventListener("pointercancel", cancel);
|
|
3822
|
+
temp.remove();
|
|
3823
|
+
if (hovered) {
|
|
3824
|
+
hovered.el.classList.remove("iwb-link-target");
|
|
3825
|
+
card.pipeline = { targetSessionId: hovered.sessionId, mode: card.pipeline?.mode || "send" };
|
|
3826
|
+
renderPipeBadge(card);
|
|
3827
|
+
schedulePipelines();
|
|
3828
|
+
saveSoon();
|
|
3829
|
+
toast(t2("pipe.created").replace("{name}", hovered.title || t2("untitled")));
|
|
3830
|
+
} else if (upEvent) {
|
|
3831
|
+
toast(t2("pipe.needTarget"));
|
|
3832
|
+
}
|
|
3833
|
+
hovered = null;
|
|
3834
|
+
};
|
|
3835
|
+
const cancel = () => finish(null);
|
|
3836
|
+
port.addEventListener("pointermove", onMove);
|
|
3837
|
+
port.addEventListener("pointerup", finish);
|
|
3838
|
+
port.addEventListener("pointercancel", cancel);
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3425
3841
|
function renderPipeBadge(card) {
|
|
3426
3842
|
const badge = card.el?.querySelector(".iwb-pipe-badge");
|
|
3427
3843
|
if (!badge) return;
|
|
@@ -3440,6 +3856,47 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3440
3856
|
}
|
|
3441
3857
|
return "";
|
|
3442
3858
|
}
|
|
3859
|
+
let morePop = null;
|
|
3860
|
+
function closeMoreMenu() {
|
|
3861
|
+
morePop?.remove();
|
|
3862
|
+
morePop = null;
|
|
3863
|
+
}
|
|
3864
|
+
function openMoreMenu(card, anchor) {
|
|
3865
|
+
if (morePop) {
|
|
3866
|
+
closeMoreMenu();
|
|
3867
|
+
return;
|
|
3868
|
+
}
|
|
3869
|
+
const pop = el("div", "iwb-popover iwb-more");
|
|
3870
|
+
pop.setAttribute("role", "dialog");
|
|
3871
|
+
pop.setAttribute("aria-label", t2("card.more"));
|
|
3872
|
+
const rows = [
|
|
3873
|
+
{ act: "pin", label: card.pinned ? t2("card.unpin") : t2("card.pin"), icon: "pin" },
|
|
3874
|
+
{ act: "copy", label: t2("card.copy"), icon: "copy" },
|
|
3875
|
+
{ act: "open", label: t2("openNative"), icon: "open" }
|
|
3876
|
+
];
|
|
3877
|
+
if (card.stackId) rows.push({ act: "detach", label: t2("detach"), icon: "layers" });
|
|
3878
|
+
for (const row of rows) {
|
|
3879
|
+
const button = el("button", "iwb-model-row");
|
|
3880
|
+
button.type = "button";
|
|
3881
|
+
button.innerHTML = '<span class="iwb-more-ico">' + icon(row.icon, 13) + '</span><span class="iwb-model-main"><span class="iwb-model-name"></span></span>';
|
|
3882
|
+
button.querySelector(".iwb-model-name").textContent = row.label;
|
|
3883
|
+
button.addEventListener("click", (event) => {
|
|
3884
|
+
event.stopPropagation();
|
|
3885
|
+
closeMoreMenu();
|
|
3886
|
+
card.el.querySelector('.iwb-acts-more [data-act="' + row.act + '"]')?.click();
|
|
3887
|
+
});
|
|
3888
|
+
pop.appendChild(button);
|
|
3889
|
+
}
|
|
3890
|
+
const rect = anchor.getBoundingClientRect();
|
|
3891
|
+
pop.style.left = Math.round(Math.max(8, Math.min(rect.left - 120, window.innerWidth - 200))) + "px";
|
|
3892
|
+
pop.style.top = Math.round(rect.bottom + 6) + "px";
|
|
3893
|
+
document.body.appendChild(pop);
|
|
3894
|
+
morePop = pop;
|
|
3895
|
+
const measured = pop.getBoundingClientRect();
|
|
3896
|
+
if (measured.bottom > window.innerHeight - 8) {
|
|
3897
|
+
pop.style.top = Math.max(8, Math.round(rect.top - measured.height - 6)) + "px";
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3443
3900
|
async function deliverPipeline(card) {
|
|
3444
3901
|
const pipeline = card.pipeline;
|
|
3445
3902
|
if (!pipeline?.targetSessionId) return;
|
|
@@ -3478,70 +3935,60 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3478
3935
|
closePipeMenu();
|
|
3479
3936
|
return;
|
|
3480
3937
|
}
|
|
3481
|
-
const
|
|
3482
|
-
|
|
3938
|
+
const target = sessionCardOf(card.pipeline?.targetSessionId);
|
|
3939
|
+
if (!target) return;
|
|
3940
|
+
const pop = el("div", "iwb-popover iwb-link-menu");
|
|
3483
3941
|
pop.setAttribute("role", "dialog");
|
|
3484
3942
|
pop.setAttribute("aria-label", t2("pipe.title"));
|
|
3485
3943
|
const head = el("div", "iwb-popover-head");
|
|
3486
3944
|
head.textContent = t2("pipe.title");
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3945
|
+
const status = el("div", "iwb-popover-note");
|
|
3946
|
+
status.textContent = t2("pipe.linked").replace("{name}", target.title || t2("untitled"));
|
|
3947
|
+
pop.append(head, status);
|
|
3948
|
+
const mode = card.pipeline.mode === "draft" ? "draft" : "send";
|
|
3949
|
+
const modes = [
|
|
3950
|
+
{ id: "send", label: t2("pipe.send"), hint: t2("pipe.sendHint") },
|
|
3951
|
+
{ id: "draft", label: t2("pipe.draft"), hint: t2("pipe.draftHint") }
|
|
3952
|
+
];
|
|
3953
|
+
for (const option of modes) {
|
|
3954
|
+
const row = el("button", "iwb-model-row" + (mode === option.id ? " current" : ""));
|
|
3496
3955
|
row.type = "button";
|
|
3497
|
-
row.innerHTML = '<span class="iwb-model-main"><span class="iwb-model-name"></span><span class="iwb-model-desc"></span></span>' + (
|
|
3498
|
-
row.querySelector(".iwb-model-name").textContent = label;
|
|
3499
|
-
row.querySelector(".iwb-model-desc").textContent =
|
|
3956
|
+
row.innerHTML = '<span class="iwb-model-main"><span class="iwb-model-name"></span><span class="iwb-model-desc"></span></span>' + (mode === option.id ? '<span class="iwb-check">\u2713</span>' : "");
|
|
3957
|
+
row.querySelector(".iwb-model-name").textContent = option.label;
|
|
3958
|
+
row.querySelector(".iwb-model-desc").textContent = option.hint;
|
|
3500
3959
|
row.addEventListener("click", (event) => {
|
|
3501
3960
|
event.stopPropagation();
|
|
3961
|
+
card.pipeline = { ...card.pipeline, mode: option.id };
|
|
3962
|
+
renderPipeBadge(card);
|
|
3963
|
+
schedulePipelines();
|
|
3964
|
+
saveSoon();
|
|
3502
3965
|
closePipeMenu();
|
|
3503
|
-
|
|
3966
|
+
toast(option.id === "draft" ? t2("pipe.modeDraft") : t2("pipe.modeSend"));
|
|
3504
3967
|
});
|
|
3505
3968
|
pop.appendChild(row);
|
|
3506
|
-
};
|
|
3507
|
-
for (const target of targets) {
|
|
3508
|
-
addRow(
|
|
3509
|
-
target.title || t2("untitled"),
|
|
3510
|
-
target.workspace || t2("workspace.none"),
|
|
3511
|
-
() => {
|
|
3512
|
-
card.pipeline = { targetSessionId: target.sessionId, mode: card.pipeline?.mode || "send" };
|
|
3513
|
-
renderPipeBadge(card);
|
|
3514
|
-
saveSoon();
|
|
3515
|
-
toast(t2("pipe.linked").replace("{name}", target.title || t2("untitled")));
|
|
3516
|
-
},
|
|
3517
|
-
current === target.sessionId
|
|
3518
|
-
);
|
|
3519
|
-
}
|
|
3520
|
-
if (card.pipeline?.targetSessionId) {
|
|
3521
|
-
addRow(
|
|
3522
|
-
card.pipeline.mode === "draft" ? t2("pipe.send") : t2("pipe.draft"),
|
|
3523
|
-
card.pipeline.mode === "draft" ? t2("pipe.modeDraftHint") : t2("pipe.modeSendHint"),
|
|
3524
|
-
() => {
|
|
3525
|
-
card.pipeline = { ...card.pipeline, mode: card.pipeline.mode === "draft" ? "send" : "draft" };
|
|
3526
|
-
saveSoon();
|
|
3527
|
-
toast(card.pipeline.mode === "draft" ? t2("pipe.draft") : t2("pipe.send"));
|
|
3528
|
-
},
|
|
3529
|
-
false
|
|
3530
|
-
);
|
|
3531
|
-
addRow(t2("pipe.off"), "", () => {
|
|
3532
|
-
card.pipeline = null;
|
|
3533
|
-
renderPipeBadge(card);
|
|
3534
|
-
saveSoon();
|
|
3535
|
-
}, false);
|
|
3536
3969
|
}
|
|
3970
|
+
const remove = el("button", "iwb-model-row iwb-link-remove");
|
|
3971
|
+
remove.type = "button";
|
|
3972
|
+
remove.innerHTML = '<span class="iwb-model-main"><span class="iwb-model-name"></span></span>';
|
|
3973
|
+
remove.querySelector(".iwb-model-name").textContent = t2("pipe.remove");
|
|
3974
|
+
remove.addEventListener("click", (event) => {
|
|
3975
|
+
event.stopPropagation();
|
|
3976
|
+
card.pipeline = null;
|
|
3977
|
+
renderPipeBadge(card);
|
|
3978
|
+
schedulePipelines();
|
|
3979
|
+
saveSoon();
|
|
3980
|
+
closePipeMenu();
|
|
3981
|
+
toast(t2("pipe.removed"));
|
|
3982
|
+
});
|
|
3983
|
+
pop.appendChild(remove);
|
|
3537
3984
|
const rect = anchor.getBoundingClientRect();
|
|
3538
|
-
pop.style.left = Math.round(Math.max(8, Math.min(rect.left -
|
|
3539
|
-
pop.style.top = Math.round(rect.
|
|
3985
|
+
pop.style.left = Math.round(Math.max(8, Math.min(rect.left + rect.width / 2 - 110, window.innerWidth - 240))) + "px";
|
|
3986
|
+
pop.style.top = Math.round(rect.top + rect.height + 8) + "px";
|
|
3540
3987
|
document.body.appendChild(pop);
|
|
3541
3988
|
pipePop = pop;
|
|
3542
3989
|
const measured = pop.getBoundingClientRect();
|
|
3543
3990
|
if (measured.bottom > window.innerHeight - 8) {
|
|
3544
|
-
pop.style.top = Math.max(8, Math.round(rect.top - measured.height -
|
|
3991
|
+
pop.style.top = Math.max(8, Math.round(rect.top - measured.height - 8)) + "px";
|
|
3545
3992
|
}
|
|
3546
3993
|
}
|
|
3547
3994
|
function syncApprovalSessions() {
|
|
@@ -3561,6 +4008,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
3561
4008
|
} catch {
|
|
3562
4009
|
}
|
|
3563
4010
|
state.cards = state.cards.filter((c) => c !== card);
|
|
4011
|
+
schedulePipelines();
|
|
3564
4012
|
if (state.selected.delete(card.id)) renderBatchBar();
|
|
3565
4013
|
if (state.focusedId === card.id) {
|
|
3566
4014
|
state.focusedId = null;
|
|
@@ -4068,6 +4516,10 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4068
4516
|
node.addEventListener("pointerleave", () => {
|
|
4069
4517
|
card.hovered = false;
|
|
4070
4518
|
});
|
|
4519
|
+
node.querySelector('[data-act="more"]')?.addEventListener("click", (event) => {
|
|
4520
|
+
event.stopPropagation();
|
|
4521
|
+
openMoreMenu(card, event.currentTarget);
|
|
4522
|
+
});
|
|
4071
4523
|
node.querySelector('[data-act="pipe"]')?.addEventListener("click", (event) => {
|
|
4072
4524
|
event.stopPropagation();
|
|
4073
4525
|
openPipeMenu(card, event.currentTarget);
|
|
@@ -4188,6 +4640,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4188
4640
|
node.style.left = nx + "px";
|
|
4189
4641
|
node.style.top = ny + "px";
|
|
4190
4642
|
}
|
|
4643
|
+
schedulePipelines();
|
|
4191
4644
|
};
|
|
4192
4645
|
const up = () => {
|
|
4193
4646
|
interactionActive = false;
|
|
@@ -4286,6 +4739,7 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4286
4739
|
if (!saved || !Array.isArray(saved.cards)) {
|
|
4287
4740
|
syncApprovalSessions();
|
|
4288
4741
|
void syncFromRemote().then(() => startRemoteSync());
|
|
4742
|
+
void loadCanvases();
|
|
4289
4743
|
return false;
|
|
4290
4744
|
}
|
|
4291
4745
|
localUpdatedAt = Number(saved.updatedAt) || 0;
|
|
@@ -4333,9 +4787,11 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4333
4787
|
updateEmptyState();
|
|
4334
4788
|
syncApprovalSessions();
|
|
4335
4789
|
updateTodoBar();
|
|
4790
|
+
schedulePipelines();
|
|
4336
4791
|
clearTimeout(saveTimer);
|
|
4337
4792
|
saveTimer = 0;
|
|
4338
4793
|
void syncFromRemote().then(() => startRemoteSync());
|
|
4794
|
+
void loadCanvases();
|
|
4339
4795
|
return true;
|
|
4340
4796
|
}
|
|
4341
4797
|
function layoutPayload() {
|
|
@@ -4576,6 +5032,16 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4576
5032
|
event.stopPropagation();
|
|
4577
5033
|
workspaceMenu.open();
|
|
4578
5034
|
});
|
|
5035
|
+
btnCanvas.addEventListener("click", (event) => {
|
|
5036
|
+
event.stopPropagation();
|
|
5037
|
+
openCanvasMenu();
|
|
5038
|
+
});
|
|
5039
|
+
const onCanvasPointerDown = (event) => {
|
|
5040
|
+
if (!canvasPop) return;
|
|
5041
|
+
if (event.target?.closest?.(".iwb-canvas-menu") || event.target?.closest?.(".iwb-toolbar")) return;
|
|
5042
|
+
closeCanvasMenu();
|
|
5043
|
+
};
|
|
5044
|
+
document.addEventListener("pointerdown", onCanvasPointerDown, true);
|
|
4579
5045
|
btnBoard.addEventListener("click", (event) => {
|
|
4580
5046
|
event.stopPropagation();
|
|
4581
5047
|
openKanbanMenu();
|
|
@@ -4586,6 +5052,12 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4586
5052
|
closeKanbanMenu();
|
|
4587
5053
|
};
|
|
4588
5054
|
document.addEventListener("pointerdown", onKanbanPointerDown, true);
|
|
5055
|
+
const onMorePointerDown = (event) => {
|
|
5056
|
+
if (!morePop) return;
|
|
5057
|
+
if (event.target?.closest?.(".iwb-more") || event.target?.closest?.('[data-act="more"]')) return;
|
|
5058
|
+
closeMoreMenu();
|
|
5059
|
+
};
|
|
5060
|
+
document.addEventListener("pointerdown", onMorePointerDown, true);
|
|
4589
5061
|
const onPipePointerDown = (event) => {
|
|
4590
5062
|
if (!pipePop) return;
|
|
4591
5063
|
if (event.target?.closest?.(".iwb-pipe") || event.target?.closest?.('[data-act="pipe"]')) return;
|
|
@@ -4603,6 +5075,10 @@ function createBoard({ host, adapter, approvals, t: t2, onOpenSession }) {
|
|
|
4603
5075
|
if (event.key === "Escape") {
|
|
4604
5076
|
clearSelection();
|
|
4605
5077
|
closePipeMenu();
|
|
5078
|
+
closeMoreMenu();
|
|
5079
|
+
closeCanvasMenu();
|
|
5080
|
+
document.removeEventListener("pointerdown", onMorePointerDown, true);
|
|
5081
|
+
document.removeEventListener("pointerdown", onCanvasPointerDown, true);
|
|
4606
5082
|
closeKanbanMenu();
|
|
4607
5083
|
}
|
|
4608
5084
|
if (event.key === "0") fitView();
|
|
@@ -5537,6 +6013,25 @@ var zh = {
|
|
|
5537
6013
|
new: "\u65B0\u5EFA\u4F1A\u8BDD\u5361",
|
|
5538
6014
|
arrange: "\u6392\u5217",
|
|
5539
6015
|
"attach.file": "\u9644\u4EF6",
|
|
6016
|
+
canvas: "\u753B\u5E03",
|
|
6017
|
+
"canvas.title": "\u753B\u5E03",
|
|
6018
|
+
"canvas.active": "\u5F53\u524D\u753B\u5E03\uFF1A{name}",
|
|
6019
|
+
"canvas.current": "\u5F53\u524D\uFF1A{name}",
|
|
6020
|
+
"canvas.unsaved": "\u5F53\u524D\u753B\u5E03\u8FD8\u6CA1\u4FDD\u5B58",
|
|
6021
|
+
"canvas.placeholder": "\u7ED9\u8FD9\u5F20\u753B\u5E03\u8D77\u4E2A\u540D\u5B57",
|
|
6022
|
+
"canvas.save": "\u4FDD\u5B58",
|
|
6023
|
+
"canvas.overwrite": "\u8986\u76D6\u300C{name}\u300D",
|
|
6024
|
+
"canvas.meta": "{n} \u5F20\u5361 \xB7 {time}",
|
|
6025
|
+
"canvas.none": "\u8FD8\u6CA1\u6709\u4FDD\u5B58\u8FC7\u753B\u5E03",
|
|
6026
|
+
"canvas.saved": "\u5DF2\u4FDD\u5B58\u753B\u5E03\u300C{name}\u300D",
|
|
6027
|
+
"canvas.updated": "\u5DF2\u66F4\u65B0\u753B\u5E03\u300C{name}\u300D",
|
|
6028
|
+
"canvas.switched": "\u5DF2\u5207\u6362\u5230\u300C{name}\u300D",
|
|
6029
|
+
"canvas.deleted": "\u5DF2\u5220\u9664\u753B\u5E03\u300C{name}\u300D",
|
|
6030
|
+
"canvas.delete": "\u5220\u9664\u8FD9\u5F20\u753B\u5E03",
|
|
6031
|
+
"canvas.nameRequired": "\u5148\u7ED9\u753B\u5E03\u8D77\u4E2A\u540D\u5B57",
|
|
6032
|
+
"canvas.broken": "\u8FD9\u5F20\u753B\u5E03\u8BFB\u4E0D\u51FA\u6765",
|
|
6033
|
+
"card.more": "\u66F4\u591A\u64CD\u4F5C",
|
|
6034
|
+
"card.unpin": "\u53D6\u6D88\u56FA\u5B9A",
|
|
5540
6035
|
boardMode: "\u770B\u677F",
|
|
5541
6036
|
"board.title": "\u770B\u677F\u5206\u7EC4",
|
|
5542
6037
|
"board.byStatus": "\u6309\u72B6\u6001\u5206\u680F",
|
|
@@ -5629,6 +6124,15 @@ var zh = {
|
|
|
5629
6124
|
"pipe.linked": "\u6D41\u6C34\u7EBF\u5DF2\u6307\u5411\u300C{name}\u300D",
|
|
5630
6125
|
"pipe.modeSendHint": "\u5F53\u524D\uFF1A\u5B8C\u6210\u540E\u81EA\u52A8\u53D1\u9001",
|
|
5631
6126
|
"pipe.modeDraftHint": "\u5F53\u524D\uFF1A\u53EA\u586B\u5165\u8349\u7A3F",
|
|
6127
|
+
"pipe.port": "\u62D6\u8FD9\u6761\u7EBF\u5230\u53E6\u4E00\u5F20\u5361\uFF0C\u5EFA\u7ACB\u6D41\u6C34\u7EBF",
|
|
6128
|
+
"pipe.created": "\u6D41\u6C34\u7EBF\u5DF2\u8FDE\u5230\u300C{name}\u300D",
|
|
6129
|
+
"pipe.needTarget": "\u62D6\u5230\u53E6\u4E00\u5F20\u4F1A\u8BDD\u5361\u4E0A\u624D\u7B97\u8FDE\u7EBF",
|
|
6130
|
+
"pipe.remove": "\u5220\u9664\u8FD9\u6761\u6D41\u6C34\u7EBF",
|
|
6131
|
+
"pipe.removed": "\u6D41\u6C34\u7EBF\u5DF2\u5220\u9664",
|
|
6132
|
+
"pipe.sendHint": "\u5B8C\u6210\u540E\u81EA\u52A8\u628A\u7ED3\u679C\u53D1\u8FC7\u53BB",
|
|
6133
|
+
"pipe.draftHint": "\u53EA\u586B\u8FDB\u4E0B\u6E38\u8F93\u5165\u6846\uFF0C\u7B49\u4EBA\u786E\u8BA4",
|
|
6134
|
+
"pipe.modeSend": "\u5DF2\u5207\u5230\uFF1A\u81EA\u52A8\u53D1\u9001",
|
|
6135
|
+
"pipe.modeDraft": "\u5DF2\u5207\u5230\uFF1A\u53EA\u586B\u8349\u7A3F",
|
|
5632
6136
|
"pipe.title": "\u6D41\u6C34\u7EBF\uFF1A\u5B8C\u6210\u540E\u628A\u7ED3\u679C\u9001\u5230\u4E0B\u6E38\u5361",
|
|
5633
6137
|
"pipe.to": "\u4E0B\u6E38\u5361\u7247",
|
|
5634
6138
|
"pipe.send": "\u81EA\u52A8\u53D1\u9001\u5230\u4E0B\u6E38",
|
|
@@ -5794,6 +6298,25 @@ var en = {
|
|
|
5794
6298
|
new: "New conversation card",
|
|
5795
6299
|
arrange: "Arrange",
|
|
5796
6300
|
"attach.file": "Attachment",
|
|
6301
|
+
canvas: "Canvas",
|
|
6302
|
+
"canvas.title": "Canvas",
|
|
6303
|
+
"canvas.active": "Current canvas: {name}",
|
|
6304
|
+
"canvas.current": "Current: {name}",
|
|
6305
|
+
"canvas.unsaved": "This canvas is not saved yet",
|
|
6306
|
+
"canvas.placeholder": "Name this canvas",
|
|
6307
|
+
"canvas.save": "Save",
|
|
6308
|
+
"canvas.overwrite": "Overwrite \u201C{name}\u201D",
|
|
6309
|
+
"canvas.meta": "{n} cards \xB7 {time}",
|
|
6310
|
+
"canvas.none": "No saved canvases yet",
|
|
6311
|
+
"canvas.saved": "Saved canvas \u201C{name}\u201D",
|
|
6312
|
+
"canvas.updated": "Updated canvas \u201C{name}\u201D",
|
|
6313
|
+
"canvas.switched": "Switched to \u201C{name}\u201D",
|
|
6314
|
+
"canvas.deleted": "Deleted canvas \u201C{name}\u201D",
|
|
6315
|
+
"canvas.delete": "Delete this canvas",
|
|
6316
|
+
"canvas.nameRequired": "Give the canvas a name first",
|
|
6317
|
+
"canvas.broken": "That canvas could not be read",
|
|
6318
|
+
"card.more": "More actions",
|
|
6319
|
+
"card.unpin": "Unpin",
|
|
5797
6320
|
boardMode: "Board",
|
|
5798
6321
|
"board.title": "Group into columns",
|
|
5799
6322
|
"board.byStatus": "By status",
|
|
@@ -5886,6 +6409,15 @@ var en = {
|
|
|
5886
6409
|
"pipe.linked": "Pipeline points at \u201C{name}\u201D",
|
|
5887
6410
|
"pipe.modeSendHint": "Currently: auto-send on completion",
|
|
5888
6411
|
"pipe.modeDraftHint": "Currently: draft only",
|
|
6412
|
+
"pipe.port": "Drag this line onto another card to wire a pipeline",
|
|
6413
|
+
"pipe.created": "Pipeline wired to \u201C{name}\u201D",
|
|
6414
|
+
"pipe.needTarget": "Drop it on another session card to connect",
|
|
6415
|
+
"pipe.remove": "Remove this pipeline",
|
|
6416
|
+
"pipe.removed": "Pipeline removed",
|
|
6417
|
+
"pipe.sendHint": "Send the result downstream when the turn finishes",
|
|
6418
|
+
"pipe.draftHint": "Only fill the downstream composer",
|
|
6419
|
+
"pipe.modeSend": "Mode: auto-send",
|
|
6420
|
+
"pipe.modeDraft": "Mode: draft only",
|
|
5889
6421
|
"pipe.title": "Pipeline: forward this card's result downstream",
|
|
5890
6422
|
"pipe.to": "Downstream card",
|
|
5891
6423
|
"pipe.send": "Auto-send downstream",
|