cladogram 0.6.0-beta.2 → 0.6.0-beta.3

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.
@@ -276,4 +276,369 @@
276
276
  .clado-eq-bars i:nth-child(3){animation-delay:.4s;background:#ec4899}
277
277
  @keyframes cladoEqBounce{from{height:3px}to{height:12px}}
278
278
 
279
+ /* ── 原生卡片 AI 实时编辑中 + 临时行级 Diff 态(红删/绿增/逐行展开 → 自动回归常规卡片) ── */
280
+ @keyframes cladoDiffPulseDot{
281
+ 0%,100%{opacity:1;transform:scale(1)}
282
+ 50%{opacity:.38;transform:scale(.76)}
283
+ }
284
+ @keyframes cladoDiffRowReveal{
285
+ 0%{opacity:0;transform:translateX(-6px)}
286
+ 100%{opacity:1;transform:translateX(0)}
287
+ }
288
+ @keyframes cladoDiffSettledIn{
289
+ 0%{opacity:.35;background:rgba(16,185,129,.09);border-radius:7px}
290
+ 100%{opacity:1;background:transparent}
291
+ }
292
+
293
+ .canvas-card.clado-ai-editing:not(.clado-ai-selected),
294
+ .canvas-card.clado-card-diffing:not(.clado-ai-selected),
295
+ .mnode.clado-ai-editing:not(.clado-ai-selected),
296
+ .mnode.clado-card-diffing:not(.clado-ai-selected){
297
+ border-color:color-mix(in srgb,var(--accent) 44%,var(--line));
298
+ box-shadow:0 0 0 1px color-mix(in srgb,var(--accent) 18%,transparent),var(--shadow);
299
+ }
300
+ .canvas-card.clado-ai-editing:not(.clado-ai-selected)::before,
301
+ .mnode.clado-ai-editing:not(.clado-ai-selected)::before{
302
+ content:"";position:absolute;left:50%;bottom:-.5px;width:88%;height:1.5px;
303
+ transform:translateX(-50%);pointer-events:none;z-index:3;
304
+ background:linear-gradient(90deg,rgba(56,189,248,.78) 0%,rgba(16,185,129,.76) 33%,rgba(129,140,248,.74) 66%,rgba(56,189,248,.78) 100%);
305
+ background-size:200% 100%;
306
+ mask-image:linear-gradient(90deg,transparent 0%,#000 10%,#000 90%,transparent 100%);
307
+ -webkit-mask-image:linear-gradient(90deg,transparent 0%,#000 10%,#000 90%,transparent 100%);
308
+ animation:clado-aura-flow 1.8s linear infinite;
309
+ }
310
+ .slice.clado-ai-editing{
311
+ background:color-mix(in srgb,var(--accent) 8%,transparent);
312
+ border-radius:7px;
313
+ box-shadow:inset 2px 0 0 color-mix(in srgb,var(--accent) 68%,transparent);
314
+ }
315
+ .clado-card-edit-badge{
316
+ margin-left:auto;
317
+ display:inline-flex;align-items:center;gap:5px;
318
+ padding:1.5px 7px;border-radius:999px;
319
+ font-size:10px;font-weight:600;letter-spacing:.01em;
320
+ color:var(--accent);
321
+ background:color-mix(in srgb,var(--accent) 12%,var(--panel));
322
+ border:1px solid color-mix(in srgb,var(--accent) 28%,transparent);
323
+ pointer-events:none;
324
+ }
325
+ .clado-card-edit-badge .dot{
326
+ width:5.5px;height:5.5px;border-radius:50%;
327
+ background:var(--accent);
328
+ animation:cladoDiffPulseDot 1.1s ease-in-out infinite;
329
+ }
330
+
331
+ .clado-diff-hidden{display:none!important}
332
+ .clado-diff-settled-in{animation:cladoDiffSettledIn 650ms ease-out both}
333
+
334
+ .clado-live-diff-stage{
335
+ margin:4px 0 6px;
336
+ border-radius:10px;
337
+ border:1px solid color-mix(in srgb,var(--accent) 26%,var(--line));
338
+ background:color-mix(in srgb,var(--panel) 94%,var(--bg));
339
+ overflow:hidden;
340
+ box-shadow:0 4px 14px -6px rgba(15,23,42,.10);
341
+ transition:opacity 280ms ease,transform 280ms ease,max-height 300ms ease;
342
+ }
343
+ [data-theme="dark"] .clado-live-diff-stage{
344
+ background:rgba(15,23,42,.56);
345
+ box-shadow:0 6px 18px -6px rgba(0,0,0,.42);
346
+ }
347
+ .clado-live-diff-stage.settling{
348
+ opacity:0;
349
+ transform:translateY(-2px);
350
+ }
351
+ .clado-live-diff-stage.settling .clado-diff-row.is-del{
352
+ max-height:0!important;
353
+ padding-top:0;padding-bottom:0;
354
+ opacity:0;
355
+ overflow:hidden;
356
+ }
357
+
358
+ .clado-diff-head{
359
+ display:flex;align-items:center;justify-content:space-between;gap:8px;
360
+ padding:4.5px 9px;
361
+ border-bottom:1px solid var(--line);
362
+ background:color-mix(in srgb,var(--accent) 5%,transparent);
363
+ font-size:10.5px;
364
+ }
365
+ .clado-diff-label{
366
+ display:inline-flex;align-items:center;gap:5px;
367
+ font-weight:620;color:var(--fg);
368
+ }
369
+ .clado-diff-label .dot{
370
+ width:6px;height:6px;border-radius:50%;
371
+ background:#10b981;
372
+ animation:cladoDiffPulseDot 1.15s ease-in-out infinite;
373
+ }
374
+ .clado-diff-right{
375
+ display:inline-flex;align-items:center;gap:6px;flex:none;
376
+ }
377
+ .clado-diff-stat-add{
378
+ font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
379
+ font-size:10.5px;font-weight:650;
380
+ color:#059669;
381
+ background:rgba(16,185,129,.12);
382
+ padding:1px 5px;border-radius:5px;
383
+ }
384
+ .clado-diff-stat-del{
385
+ font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
386
+ font-size:10.5px;font-weight:650;
387
+ color:#e11d48;
388
+ background:rgba(244,63,94,.12);
389
+ padding:1px 5px;border-radius:5px;
390
+ }
391
+ [data-theme="dark"] .clado-diff-stat-add{color:#34d399;background:rgba(16,185,129,.18)}
392
+ [data-theme="dark"] .clado-diff-stat-del{color:#fb7185;background:rgba(244,63,94,.20)}
393
+
394
+ .clado-diff-done-btn{
395
+ appearance:none;border:1px solid var(--line);background:var(--panel);color:var(--fg-2);
396
+ border-radius:6px;padding:1px 7px;font:inherit;font-size:10px;font-weight:550;
397
+ cursor:pointer;transition:background-color 140ms ease,color 140ms ease,border-color 140ms ease;
398
+ }
399
+ .clado-diff-done-btn:hover{
400
+ color:var(--fg);border-color:color-mix(in srgb,var(--accent) 42%,var(--line));
401
+ background:var(--accent-soft);
402
+ }
403
+
404
+ .clado-diff-lines{
405
+ padding:4px 0;
406
+ font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;
407
+ font-size:11.5px;line-height:1.52;
408
+ }
409
+ .clado-diff-row{
410
+ display:flex;align-items:flex-start;gap:7px;
411
+ padding:2px 9px 2px 7px;
412
+ border-left:2.5px solid transparent;
413
+ max-height:180px;
414
+ transition:max-height 260ms ease,opacity 240ms ease,padding 240ms ease,background-color 240ms ease;
415
+ }
416
+ .clado-diff-gutter{
417
+ width:11px;flex:none;text-align:center;user-select:none;font-weight:700;opacity:.75;
418
+ }
419
+ .clado-diff-text{
420
+ flex:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;
421
+ }
422
+ .clado-diff-row.is-eq{
423
+ color:var(--fg-2);opacity:.74;
424
+ }
425
+ .clado-diff-row.is-sep{
426
+ justify-content:center;color:var(--fg-2);opacity:.48;font-size:10px;padding:1px 8px;
427
+ }
428
+ .clado-diff-row.is-del{
429
+ background:rgba(244,63,94,.11);
430
+ border-left-color:#f43f5e;
431
+ color:#9f1239;
432
+ }
433
+ .clado-diff-row.is-del .clado-diff-text{
434
+ text-decoration:line-through;
435
+ text-decoration-color:rgba(244,63,94,.46);
436
+ }
437
+ [data-theme="dark"] .clado-diff-row.is-del{
438
+ background:rgba(244,63,94,.17);
439
+ color:#fda4af;
440
+ }
441
+ .clado-diff-row.is-add{
442
+ background:rgba(16,185,129,.12);
443
+ border-left-color:#10b981;
444
+ color:#065f46;
445
+ }
446
+ [data-theme="dark"] .clado-diff-row.is-add{
447
+ background:rgba(16,185,129,.18);
448
+ color:#a7f3d0;
449
+ }
450
+ .clado-diff-row.is-add.is-streaming{
451
+ opacity:0;
452
+ animation:cladoDiffRowReveal 260ms cubic-bezier(.22,1,.36,1) forwards;
453
+ }
454
+ .clado-diff-hl-del{
455
+ background:rgba(244,63,94,.26);
456
+ color:inherit;border-radius:3px;padding:0 1.5px;
457
+ }
458
+ .clado-diff-hl-add{
459
+ background:rgba(16,185,129,.28);
460
+ color:inherit;border-radius:3px;padding:0 1.5px;
461
+ }
462
+ [data-theme="dark"] .clado-diff-hl-del{background:rgba(244,63,94,.36)}
463
+ [data-theme="dark"] .clado-diff-hl-add{background:rgba(16,185,129,.34)}
464
+
465
+ @media(prefers-reduced-motion:reduce){
466
+ .clado-diff-row.is-add.is-streaming{animation:none;opacity:1}
467
+ .clado-diff-settled-in{animation:none}
468
+ .clado-card-edit-badge .dot,.clado-diff-label .dot{animation:none}
469
+ }
279
470
 
471
+ /* ── 新增连线光束 + 落点脉冲 ── */
472
+ #wires path.w-new-beam{
473
+ stroke:var(--accent)!important;
474
+ stroke-width:2.5!important;
475
+ filter:drop-shadow(0 0 5px color-mix(in srgb,var(--accent) 55%,transparent));
476
+ }
477
+ @keyframes cladoPortPulse{
478
+ 0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 60%,transparent)}
479
+ 70%{box-shadow:0 0 0 9px transparent}
480
+ 100%{box-shadow:0 0 0 0 transparent}
481
+ }
482
+ .hbar.clado-port-pulse,.clado-tag.clado-tag-pulse{
483
+ animation:cladoPortPulse 900ms cubic-bezier(.22,1,.36,1) 2;
484
+ }
485
+
486
+ /* ── 孤立卡片温和角标 ── */
487
+ .clado-card-isolated-pill{
488
+ appearance:none;margin-left:auto;
489
+ border:1px dashed color-mix(in srgb,#f59e0b 55%,var(--line));
490
+ background:color-mix(in srgb,#f59e0b 10%,var(--panel));
491
+ color:#b45309;border-radius:999px;padding:1px 7px;
492
+ font:inherit;font-size:10px;font-weight:600;cursor:pointer;
493
+ transition:background-color 140ms ease,border-color 140ms ease,transform 140ms ease;
494
+ }
495
+ [data-theme="dark"] .clado-card-isolated-pill{color:#fbbf24}
496
+ .clado-card-isolated-pill:hover{
497
+ background:color-mix(in srgb,#f59e0b 20%,var(--panel));
498
+ border-color:#f59e0b;transform:translateY(-1px);
499
+ }
500
+
501
+ /* ── 开发落地中(真实代码编辑同步照亮对应架构卡片) ── */
502
+ .canvas-card.clado-ai-implementing:not(.clado-ai-selected){
503
+ border-color:rgba(16,185,129,.52);
504
+ box-shadow:0 0 0 1.5px rgba(16,185,129,.22),var(--shadow);
505
+ }
506
+ .clado-card-edit-badge.is-impl{
507
+ color:#059669;
508
+ background:rgba(16,185,129,.12);
509
+ border-color:rgba(16,185,129,.34);
510
+ }
511
+ [data-theme="dark"] .clado-card-edit-badge.is-impl{color:#34d399}
512
+ .clado-card-edit-badge.is-impl .dot{background:#10b981}
513
+
514
+ /* ── AI 流式起草幽灵卡片 ── */
515
+ .clado-draft-card{
516
+ position:fixed;left:22px;bottom:22px;z-index:48;
517
+ width:min(360px,calc(100vw - 44px));
518
+ padding:11px 13px;border-radius:14px;
519
+ background:color-mix(in srgb,var(--panel) 84%,transparent);
520
+ backdrop-filter:blur(18px) saturate(160%);
521
+ -webkit-backdrop-filter:blur(18px) saturate(160%);
522
+ border:1px solid color-mix(in srgb,var(--accent) 34%,var(--line));
523
+ box-shadow:0 16px 36px -14px rgba(15,23,42,.24);
524
+ pointer-events:none;
525
+ }
526
+ .clado-draft-head{
527
+ display:flex;align-items:center;justify-content:space-between;gap:8px;
528
+ font-size:10.5px;margin-bottom:6px;
529
+ }
530
+ .clado-draft-pill{
531
+ display:inline-flex;align-items:center;gap:5px;font-weight:650;color:var(--accent);
532
+ }
533
+ .clado-draft-pill .dot{
534
+ width:6px;height:6px;border-radius:50%;background:var(--accent);
535
+ animation:cladoDiffPulseDot 1.1s ease-in-out infinite;
536
+ }
537
+ .clado-draft-tool{
538
+ font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;color:var(--fg-2);opacity:.75;
539
+ }
540
+ .clado-draft-title{
541
+ font-size:13px;font-weight:650;color:var(--fg);margin-bottom:5px;
542
+ overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
543
+ }
544
+ .clado-draft-preview{
545
+ margin:0;padding:7px 9px;border-radius:8px;
546
+ background:color-mix(in srgb,var(--bg) 72%,transparent);
547
+ border:1px solid var(--line);
548
+ font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
549
+ font-size:11px;line-height:1.48;color:var(--fg-2);
550
+ max-height:124px;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere;
551
+ }
552
+
553
+ /* ── 纯粹原生「连接到…」目标拾取器 ── */
554
+ .clado-link-pick-banner{
555
+ position:fixed;top:16px;left:50%;transform:translateX(-50%);z-index:80;
556
+ width:min(620px,calc(100vw - 32px));
557
+ padding:10px 12px;border-radius:14px;
558
+ background:color-mix(in srgb,var(--panel) 90%,transparent);
559
+ backdrop-filter:blur(20px) saturate(165%);
560
+ -webkit-backdrop-filter:blur(20px) saturate(165%);
561
+ border:1px solid color-mix(in srgb,var(--accent) 44%,var(--line));
562
+ box-shadow:0 18px 42px -12px rgba(15,23,42,.28);
563
+ display:flex;flex-direction:column;gap:8px;
564
+ }
565
+ .clado-link-pick-row{
566
+ display:flex;align-items:center;gap:8px;font-size:12px;color:var(--fg);
567
+ }
568
+ .clado-link-pick-dot{
569
+ width:7px;height:7px;border-radius:50%;background:var(--accent);flex:none;
570
+ animation:cladoDiffPulseDot 1.1s ease-in-out infinite;
571
+ }
572
+ .clado-link-pick-title{flex:1;min-width:0;line-height:1.4}
573
+ .clado-link-pick-cancel{
574
+ appearance:none;border:1px solid var(--line);background:var(--panel);color:var(--fg-2);
575
+ border-radius:8px;padding:3px 9px;font:inherit;font-size:11px;font-weight:560;cursor:pointer;flex:none;
576
+ }
577
+ .clado-link-pick-cancel:hover{color:var(--fg);border-color:var(--accent)}
578
+ .clado-link-pick-search-wrap{display:flex;flex-direction:column;gap:5px}
579
+ .clado-link-pick-input{
580
+ width:100%;box-sizing:border-box;
581
+ border:1px solid var(--line);border-radius:9px;padding:6px 10px;
582
+ background:var(--bg);color:var(--fg);font:inherit;font-size:12px;outline:none;
583
+ }
584
+ .clado-link-pick-input:focus{border-color:var(--accent)}
585
+ .clado-link-pick-dropdown{
586
+ display:flex;flex-wrap:wrap;gap:5px;max-height:126px;overflow-y:auto;
587
+ }
588
+ .clado-link-pick-opt{
589
+ appearance:none;border:1px solid var(--line);background:var(--panel);color:var(--fg);
590
+ border-radius:8px;padding:4px 8px;font:inherit;font-size:11.5px;cursor:pointer;
591
+ display:inline-flex;align-items:center;gap:6px;max-width:100%;
592
+ transition:border-color 140ms ease,background-color 140ms ease;
593
+ }
594
+ .clado-link-pick-opt:hover{
595
+ border-color:var(--accent);background:var(--accent-soft);
596
+ }
597
+ .clado-link-pick-opt .opt-kind{
598
+ font-size:10px;font-weight:600;color:var(--fg-2);opacity:.82;flex:none;
599
+ }
600
+ .clado-link-pick-opt .opt-kind.is-tag{color:var(--accent)}
601
+ .clado-link-pick-opt .opt-label{
602
+ overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
603
+ }
604
+ .clado-link-pick-empty{font-size:11.5px;color:var(--fg-2);padding:3px 4px}
605
+
606
+ body.clado-link-picking #world > .card{
607
+ cursor:crosshair;
608
+ transition:border-color 150ms ease,box-shadow 150ms ease;
609
+ }
610
+ body.clado-link-picking #world > .card:hover{
611
+ border-color:var(--accent)!important;
612
+ box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 26%,transparent),var(--shadow)!important;
613
+ }
614
+ body.clado-link-picking .slice:hover,
615
+ body.clado-link-picking .clado-tag:hover{
616
+ outline:1.5px solid var(--accent);
617
+ outline-offset:2px;
618
+ border-radius:6px;
619
+ cursor:crosshair;
620
+ }
621
+
622
+ /* ── 卡内划词悬浮极简操作条 ── */
623
+ .clado-sel-quickbar{
624
+ position:fixed;z-index:76;
625
+ display:inline-flex;align-items:center;gap:2px;
626
+ padding:3px;border-radius:10px;
627
+ background:color-mix(in srgb,var(--panel) 92%,transparent);
628
+ backdrop-filter:blur(18px) saturate(165%);
629
+ -webkit-backdrop-filter:blur(18px) saturate(165%);
630
+ border:1px solid color-mix(in srgb,var(--accent) 28%,var(--line));
631
+ box-shadow:0 12px 28px -10px rgba(15,23,42,.28);
632
+ }
633
+ .clado-sel-quickbar button{
634
+ appearance:none;border:0;background:transparent;color:var(--fg);
635
+ border-radius:7px;padding:4px 8px;font:inherit;font-size:11.5px;font-weight:560;
636
+ cursor:pointer;white-space:nowrap;
637
+ transition:background-color 120ms ease,color 120ms ease;
638
+ }
639
+ .clado-sel-quickbar button:hover{
640
+ background:var(--accent-soft);color:var(--accent);
641
+ }
642
+ .clado-sel-quickbar .sep{
643
+ width:1px;height:14px;background:var(--line);margin:0 1px;
644
+ }
@@ -70,7 +70,11 @@ drawWires = function () {
70
70
  }
71
71
  var from = point ? canvasSourceStem(svg, port, point) : canvasPort(svg, port);
72
72
  var d = canvasWirePath(from, canvasPort(svg, input));
73
- paths.push('<path class="' + (port.dataset.soft ? 'w-soft' : '') + '" data-source-id="' + esc(sourceId) + '" data-target-id="' + esc(targetId) + '"' + (port.dataset.mediaPoint ? ' data-media-point="' + esc(port.dataset.mediaPoint) + '"' : '') + ' d="' + d + '"/>');
73
+ var edgePairKey = source.dataset.id + '->' + target.dataset.id;
74
+ var pathClasses = [];
75
+ if (port.dataset.soft) pathClasses.push('w-soft');
76
+ if (window.__cladoNewEdges && window.__cladoNewEdges.has(edgePairKey)) pathClasses.push('w-new-beam');
77
+ paths.push('<path class="' + pathClasses.join(' ') + '" data-edge-key="' + esc(edgePairKey) + '" data-source-id="' + esc(sourceId) + '" data-target-id="' + esc(targetId) + '"' + (port.dataset.mediaPoint ? ' data-media-point="' + esc(port.dataset.mediaPoint) + '"' : '') + ' d="' + d + '"/>');
74
78
  });
75
79
  svg.innerHTML = paths.join('');
76
80
  };
package/src/html/page.js CHANGED
@@ -93,7 +93,7 @@ export function renderHtml(doc, diagnostics = [], options = {}) {
93
93
  .replace('/*__MERMAID__*/', () => (doc.hasMermaid ? read('mermaid.min.js') : ''));
94
94
 
95
95
  runtime = fixCanvasRuntime(runtime);
96
- const helpers = ['canvas-wires.js','mindmap-connectors.js','mindmap-media.js','canvas-focus.js','canvas-chain.js','runtime-api.js']
96
+ const helpers = ['canvas-wires.js','mindmap-connectors.js','mindmap-media.js','canvas-focus.js','canvas-chain.js','canvas-live-diff.js','runtime-api.js']
97
97
  .map(name => readFileSync(join(HERE, name), 'utf8')).join('\n');
98
98
  const end = runtime.lastIndexOf('})();');
99
99
  runtime = runtime.slice(0, end) + helpers + runtime.slice(end);
@@ -59,7 +59,10 @@
59
59
  },
60
60
  captureView: function () {
61
61
  return { mode: document.body.dataset.mode, scale: scale, tx: tx, ty: ty,
62
- edges: Object.assign({}, openEdge), focusId: canvasFocusId,
62
+ edges: Object.assign({}, openEdge),
63
+ knownEdges: (DOC.edges || []).map(function (e) { return edgeKey(e[0], e[1]); }),
64
+ closedEdges: Object.assign({}, typeof userClosedEdge !== 'undefined' ? userClosedEdge : {}),
65
+ focusId: canvasFocusId,
63
66
  mindCards: Object.assign({}, MIND_CARD_STATE),
64
67
  cardPlacements: Object.assign({},CARD_PLACEMENTS),
65
68
  cards: Object.fromEntries(Object.keys(render.card).map(function(id){var el=render.card[id];return [id,{x:pos[id] && pos[id].x,y:pos[id] && pos[id].y,width:el.style.width,height:el.style.height}];})),
@@ -67,7 +70,31 @@
67
70
  },
68
71
  restoreView: function (view) {
69
72
  if (!view || view.mode !== document.body.dataset.mode) return;
70
- openEdge = Object.assign({}, view.edges);
73
+ var savedEdges = view.edges || {};
74
+ var closedMap = Object.assign({}, view.closedEdges || {});
75
+ var knownMap = null;
76
+ if (Array.isArray(view.knownEdges)) {
77
+ knownMap = {};
78
+ view.knownEdges.forEach(function (k) { knownMap[k] = 1; });
79
+ if (!view.closedEdges) {
80
+ view.knownEdges.forEach(function (k) {
81
+ if (!savedEdges[k]) closedMap[k] = 1;
82
+ });
83
+ }
84
+ }
85
+ openEdge = {};
86
+ if (typeof userClosedEdge !== 'undefined') userClosedEdge = {};
87
+ (DOC.edges || []).forEach(function (e) {
88
+ if (!Array.isArray(e) || e.length < 2) return;
89
+ var k = edgeKey(e[0], e[1]);
90
+ if (closedMap[k]) {
91
+ if (typeof userClosedEdge !== 'undefined') userClosedEdge[k] = 1;
92
+ return;
93
+ }
94
+ if (window.__CLADO_WORKSPACE_CHROME__ || savedEdges[k] || (knownMap && !knownMap[k])) {
95
+ openEdge[k] = 1;
96
+ }
97
+ });
71
98
  MIND_CARD_STATE = Object.assign({}, view.mindCards);
72
99
  CARD_PLACEMENTS = Object.assign({},view.cardPlacements);
73
100
  Object.keys(view.cards || {}).forEach(function(id){
@@ -88,7 +115,12 @@
88
115
  views: function () { return CladoViewRegistry.list(); },
89
116
  allEdges: function (open) {
90
117
  openEdge = {};
91
- if (open) DOC.edges.forEach(function (e) { openEdge[edgeKey(e[0], e[1])] = 1; });
118
+ if (typeof userClosedEdge !== 'undefined') userClosedEdge = {};
119
+ if (open) {
120
+ DOC.edges.forEach(function (e) { openEdge[edgeKey(e[0], e[1])] = 1; });
121
+ } else if (typeof userClosedEdge !== 'undefined') {
122
+ DOC.edges.forEach(function (e) { userClosedEdge[edgeKey(e[0], e[1])] = 1; });
123
+ }
92
124
  lastAnchor = null; lastPrev = null;
93
125
  applyVisibility(); layout(); fit(); repinPorts();
94
126
  return renderMermaid().then(afterMedia);
@@ -96,7 +128,25 @@
96
128
  whenMedia: function () { return renderMermaid().then(afterMedia); },
97
129
  highlightActivity: function (activity) {
98
130
  if (!activity) return;
99
- var cls = activity.kind === 'read' ? 'clado-ai-reading' : activity.kind === 'waiting' ? 'clado-ai-waiting' : 'clado-ai-touched';
131
+ if (window.__cladoAiHighlightTimer) clearTimeout(window.__cladoAiHighlightTimer);
132
+ $$('.clado-ai-touched, .clado-ai-reading, .clado-ai-waiting, .clado-ai-editing, .clado-ai-implementing').forEach(function (el) {
133
+ el.classList.remove('clado-ai-touched', 'clado-ai-reading', 'clado-ai-waiting', 'clado-ai-editing', 'clado-ai-implementing');
134
+ });
135
+ $$('.clado-card-edit-badge').forEach(function (el) { el.remove(); });
136
+ if (activity.kind === 'clear') {
137
+ var clearToast = document.getElementById('cladoAiToast');
138
+ if (clearToast) clearToast.classList.remove('open');
139
+ return;
140
+ }
141
+ var cls = activity.kind === 'editing'
142
+ ? 'clado-ai-editing'
143
+ : activity.kind === 'implementing'
144
+ ? 'clado-ai-implementing'
145
+ : activity.kind === 'read'
146
+ ? 'clado-ai-reading'
147
+ : activity.kind === 'waiting'
148
+ ? 'clado-ai-waiting'
149
+ : 'clado-ai-touched';
100
150
  var paths = Array.isArray(activity.nodes) ? activity.nodes : [];
101
151
  var records = Object.values(canvasRecords);
102
152
  var matched = [];
@@ -117,9 +167,11 @@
117
167
  });
118
168
  var mode = document.body.dataset.mode;
119
169
  var targets = [];
170
+ var editCards = new Set();
120
171
  matched.forEach(function (rec) {
121
172
  if (mode === 'cards') {
122
173
  var cardId = rec.card || rec.id;
174
+ if (render.card[cardId]) editCards.add(render.card[cardId]);
123
175
  if (rec.parent) {
124
176
  var sliceEl = $('#world .slice[data-id="' + rec.id + '"]');
125
177
  if (sliceEl) targets.push(sliceEl);
@@ -135,14 +187,23 @@
135
187
  if (sec) targets.push(sec);
136
188
  }
137
189
  });
138
- if (window.__cladoAiHighlightTimer) clearTimeout(window.__cladoAiHighlightTimer);
139
- $$('.clado-ai-touched, .clado-ai-reading, .clado-ai-waiting').forEach(function (el) {
140
- el.classList.remove('clado-ai-touched', 'clado-ai-reading', 'clado-ai-waiting');
141
- });
142
190
  targets.forEach(function (el) {
143
191
  void el.offsetWidth;
144
192
  el.classList.add(cls);
145
193
  });
194
+ if (activity.kind === 'editing' || activity.kind === 'implementing') {
195
+ var isImpl = activity.kind === 'implementing';
196
+ editCards.forEach(function (cardEl) {
197
+ cardEl.classList.add(isImpl ? 'clado-ai-implementing' : 'clado-ai-editing');
198
+ var bar = $('.bar', cardEl);
199
+ if (bar && !bar.querySelector('.clado-card-edit-badge')) {
200
+ var badge = document.createElement('span');
201
+ badge.className = 'clado-card-edit-badge' + (isImpl ? ' is-impl' : '');
202
+ badge.innerHTML = '<i class="dot" aria-hidden="true"></i>' + (isImpl ? '代码落地中…' : 'AI 编辑中…');
203
+ bar.appendChild(badge);
204
+ }
205
+ });
206
+ }
146
207
  function smoothPanTo(record) {
147
208
  if (!record) return;
148
209
  var curMode = document.body.dataset.mode;
@@ -202,6 +263,7 @@
202
263
  document.body.appendChild(toast);
203
264
  }
204
265
  toast.classList.toggle('waiting', activity.kind === 'waiting');
266
+ toast.classList.toggle('editing', activity.kind === 'editing' || activity.kind === 'implementing');
205
267
  toast.innerHTML = '<span class="dot" aria-hidden="true"></span><span>' + esc(String(activity.label)) + '</span>';
206
268
  toast.onclick = function () {
207
269
  if (matched[0]) smoothPanTo(matched[0]);
@@ -209,15 +271,83 @@
209
271
  };
210
272
  requestAnimationFrame(function () { toast.classList.add('open'); });
211
273
  }
212
- var ttl = activity.kind === 'waiting' ? 12000 : activity.kind === 'read' ? 2200 : 3200;
274
+ var ttl = activity.kind === 'editing' ? 15000 : activity.kind === 'implementing' ? 8000 : activity.kind === 'waiting' ? 12000 : activity.kind === 'read' ? 2200 : 3400;
213
275
  window.__cladoAiHighlightTimer = setTimeout(function () {
214
- targets.forEach(function (el) { el.classList.remove('clado-ai-touched', 'clado-ai-reading', 'clado-ai-waiting'); });
276
+ targets.forEach(function (el) { el.classList.remove('clado-ai-touched', 'clado-ai-reading', 'clado-ai-waiting', 'clado-ai-editing', 'clado-ai-implementing'); });
277
+ editCards.forEach(function (cardEl) {
278
+ cardEl.classList.remove('clado-ai-editing', 'clado-ai-implementing');
279
+ cardEl.querySelectorAll('.clado-card-edit-badge').forEach(function (b) { b.remove(); });
280
+ });
215
281
  var toast = document.getElementById('cladoAiToast');
216
282
  if (toast) toast.classList.remove('open');
217
283
  }, ttl);
218
284
  },
285
+ playLiveDiff: function (prevDoc, touch, follow) {
286
+ return typeof playCanvasLiveDiff === 'function' ? playCanvasLiveDiff(prevDoc, touch, follow) : { changedCount: 0 };
287
+ },
288
+ hotPatchDoc: function (nextDoc, diagnostics, nextVersion, touch, follow) {
289
+ return typeof hotPatchCanvasDoc === 'function' ? hotPatchCanvasDoc(nextDoc, diagnostics, nextVersion, touch, follow) : false;
290
+ },
291
+ setDraftCard: function (draft) {
292
+ if (typeof renderCanvasDraftGhost === 'function') renderCanvasDraftGhost(draft);
293
+ },
294
+ startLinkPick: function (sourceSpec) {
295
+ if (typeof startCanvasLinkPick === 'function') startCanvasLinkPick(sourceSpec);
296
+ },
297
+ cancelLinkPick: function () {
298
+ if (typeof cancelCanvasLinkPick === 'function') cancelCanvasLinkPick();
299
+ },
300
+ focusTag: function (tagId) {
301
+ var clean = String(tagId || '').replace(/^#/, '').trim();
302
+ if (!clean) return false;
303
+ var tagEl = $('.clado-tag[data-tag-id="' + clean.replace(/"/g, '') + '"]');
304
+ if (!tagEl) return false;
305
+ var cardEl = tagEl.closest('.card');
306
+ var rec = cardEl && canvasRecords[cardEl.dataset.id];
307
+ if (rec) {
308
+ if (document.body.dataset.mode === 'cards' && !VIS[rec.card]) {
309
+ (DOC.edges || []).forEach(function (e) { openEdge[edgeKey(e[0], e[1])] = 1; });
310
+ applyVisibility();
311
+ layout();
312
+ repinPorts();
313
+ drawWires();
314
+ }
315
+ window.CladoRuntime.highlightActivity({ nodes: [rec.titlePath], kind: 'read', label: '定位锚点 #' + clean, forcePan: true });
316
+ }
317
+ tagEl.classList.add('clado-tag-pulse');
318
+ setTimeout(function () { tagEl.classList.remove('clado-tag-pulse'); }, 1500);
319
+ return true;
320
+ },
321
+ getCanvasEntities: function () {
322
+ var cards = [];
323
+ var sections = [];
324
+ Object.values(canvasRecords || {}).forEach(function (r) {
325
+ if (r.parent) sections.push({ title: r.title, path: r.titlePath.slice() });
326
+ else cards.push({ id: r.id, title: r.title, path: r.titlePath.slice() });
327
+ });
328
+ var tags = [];
329
+ $$('#world .clado-tag[data-tag-id]').forEach(function (t) {
330
+ if (t.dataset.tagId) tags.push({ id: t.dataset.tagId, text: (t.textContent || '').trim() });
331
+ });
332
+ return { cards: cards, sections: sections, tags: tags };
333
+ },
334
+ captureDocSnapshot: function () {
335
+ return typeof cladoCaptureDocSnapshot === 'function' ? cladoCaptureDocSnapshot(DOC) : null;
336
+ },
219
337
  focusNodePath: function (path, label) {
220
338
  if (!path || (Array.isArray(path) && !path.length)) return;
339
+ if (document.body.dataset.mode === 'cards') {
340
+ var recs = Object.values(canvasRecords || {});
341
+ var arr = Array.isArray(path) ? path : [path];
342
+ var match = recs.find(function (r) { return r.title === arr[0] || r.fullPath === arr.join('.'); });
343
+ if (match && !VIS[match.card]) {
344
+ (DOC.edges || []).forEach(function (e) { openEdge[edgeKey(e[0], e[1])] = 1; });
345
+ applyVisibility();
346
+ layout();
347
+ repinPorts();
348
+ drawWires();
349
+ }
350
+ }
221
351
  window.CladoRuntime.highlightActivity({
222
352
  nodes: [path],
223
353
  kind: 'read',