dsh-timeback 0.7.4 → 0.7.5
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 +1 -1
- package/client.js +676 -70
- package/docs/MARKET.md +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ desktop app):
|
|
|
104
104
|
```bash
|
|
105
105
|
# From npm (published: https://www.npmjs.com/package/dsh-timeback)
|
|
106
106
|
dsh plugin --profile web add dsh-timeback
|
|
107
|
-
dsh plugin --profile web add dsh-timeback@0.7.
|
|
107
|
+
dsh plugin --profile web add dsh-timeback@0.7.5 # pin a release
|
|
108
108
|
|
|
109
109
|
# Straight from GitHub (no npm release needed)
|
|
110
110
|
dsh plugin --profile web add github:<owner>/dsh-timeback
|
package/client.js
CHANGED
|
@@ -23,7 +23,7 @@ window.__ModuleLoader__.load({
|
|
|
23
23
|
const REFRESH_MS = 3000
|
|
24
24
|
const MAX_ROWS = 240
|
|
25
25
|
/** Bump together with package.json so a stale browser bundle is obvious. */
|
|
26
|
-
const BUILD = '0.7.
|
|
26
|
+
const BUILD = '0.7.5+sticky'
|
|
27
27
|
/** Set by apply(): opens another Session in the main column. */
|
|
28
28
|
let openSessionBridge = null
|
|
29
29
|
/** Set by apply(): opens the Timeback tab in the right sidebar. */
|
|
@@ -119,6 +119,7 @@ window.__ModuleLoader__.load({
|
|
|
119
119
|
'md.empty': '空文档,直接输入即可',
|
|
120
120
|
'md.hint': '直接打字即可:选中文字后点工具栏按钮会立即格式化(例如选中“你好”按 B 立即加粗);也可切换源码/预览。',
|
|
121
121
|
'board.newSticky': '新建便签',
|
|
122
|
+
'board.stickyColor': '便签颜色',
|
|
122
123
|
'board.stickyHint': '便签可拖动;画笔可在方格纸背景或便签上绘制,橡皮擦除笔画。',
|
|
123
124
|
'board.resizeNote': '拖动缩放便签',
|
|
124
125
|
'board.drawOnSticky': '便签可画',
|
|
@@ -367,6 +368,7 @@ window.__ModuleLoader__.load({
|
|
|
367
368
|
'md.empty': 'Empty document — just start typing',
|
|
368
369
|
'md.hint': 'Type directly: select text and press a toolbar button to format it immediately (e.g. select 你好 and press B). Source and preview tabs are still available.',
|
|
369
370
|
'board.newSticky': 'New sticky',
|
|
371
|
+
'board.stickyColor': 'Sticky colour',
|
|
370
372
|
'board.stickyHint': 'Sticky notes are draggable; draw on the grid or on a note, erase strokes with the eraser.',
|
|
371
373
|
'board.resizeNote': 'Drag to resize the sticky',
|
|
372
374
|
'board.drawOnSticky': 'Draw on stickies',
|
|
@@ -581,7 +583,7 @@ window.__ModuleLoader__.load({
|
|
|
581
583
|
.tb-ws-item{display:flex;align-items:center;gap:6px;font-size:11.5px}
|
|
582
584
|
.tb-ws-item .tb-ws-path{flex:1}
|
|
583
585
|
.tb-note{margin:0;padding:7px 9px;border-radius:7px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));color:var(--dsw-alias-label-secondary,#9aa0a6);font-size:11px;line-height:1.5}
|
|
584
|
-
.tb-feedback{position:
|
|
586
|
+
.tb-feedback{position:relative;padding:7px 9px;border-radius:7px;font-size:11.5px;line-height:1.55;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));background:var(--dsw-alias-bg-layer-1,rgba(28,32,40,.96));display:flex;flex-direction:column;gap:6px}
|
|
585
587
|
.tb-feedback.ok{color:var(--dsw-alias-state-success-primary,#3ecf8e);border-color:var(--dsw-alias-state-success-primary,rgba(62,207,142,.4))}
|
|
586
588
|
.tb-feedback.warn{color:var(--dsw-alias-state-warning-primary,#f0b23e);border-color:var(--dsw-alias-state-warning-primary,rgba(240,178,62,.45))}
|
|
587
589
|
.tb-feedback.err{color:var(--dsw-alias-state-error-primary,#ff7a59);border-color:var(--dsw-alias-state-error-primary,rgba(255,122,89,.45))}
|
|
@@ -607,6 +609,7 @@ window.__ModuleLoader__.load({
|
|
|
607
609
|
.tb-canvas-toolbar{position:absolute;top:8px;right:8px;z-index:3;display:flex;gap:4px;align-items:center;background:var(--dsw-alias-bg-layer-2,rgba(24,28,36,.85));border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));border-radius:8px;padding:3px;backdrop-filter:blur(4px)}
|
|
608
610
|
.tb-canvas-btn{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#9aa0a6);border-radius:6px;min-width:22px;height:22px;padding:0 6px;font-size:11.5px;cursor:pointer;line-height:1}
|
|
609
611
|
.tb-canvas-btn.off{opacity:.5}
|
|
612
|
+
.tb-canvas-hint{font-size:10.5px;line-height:20px;color:var(--dsw-alias-label-tertiary,#8a919c);margin-left:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:300px}
|
|
610
613
|
.tb-canvas-btn.on{color:var(--dsw-alias-state-success-primary,#3ecf8e)}
|
|
611
614
|
.tb-canvas-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
612
615
|
.tb-world{position:absolute;left:0;top:0;transform-origin:0 0}
|
|
@@ -616,9 +619,19 @@ window.__ModuleLoader__.load({
|
|
|
616
619
|
.tb-link.current{stroke-width:2.6;opacity:1;filter:drop-shadow(0 0 3px currentColor)}
|
|
617
620
|
.tb-lane-label{position:absolute;transform:translateY(-50%);max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10.5px;line-height:16px;border:1px solid;border-radius:999px;padding:0 8px;background:var(--dsw-alias-bg-base,#16181d);color:var(--dsw-alias-label-secondary,#9aa0a6);opacity:.85}
|
|
618
621
|
.tb-lane-label.current{opacity:1;font-weight:600}
|
|
619
|
-
.tb-card{position:absolute;width:246px;height:116px;box-sizing:border-box;border-radius:12px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));background:var(--dsw-alias-bg-layer-2,rgba(28,32,40,.96));box-shadow:0 2px 8px rgba(0,0,0,.18);padding:8px 10px;display:flex;flex-direction:column;gap:5px;cursor:pointer;overflow:hidden;transition:box-shadow .12s, border-color .12s, transform .12s}
|
|
622
|
+
.tb-card{position:absolute;width:246px;height:116px;animation:tb-card-pop .19s ease-out;box-sizing:border-box;border-radius:12px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));background:var(--dsw-alias-bg-layer-2,rgba(28,32,40,.96));box-shadow:0 2px 8px rgba(0,0,0,.18);padding:8px 10px;display:flex;flex-direction:column;gap:5px;cursor:pointer;overflow:hidden;transition:box-shadow .12s, border-color .12s, transform .12s}
|
|
620
623
|
.tb-card:before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--tb-color,#4d7cfe);opacity:.55;border-radius:12px 0 0 12px}
|
|
621
624
|
.tb-card:hover{transform:translateY(-1px);box-shadow:0 6px 16px rgba(0,0,0,.26)}
|
|
625
|
+
.tb-folder-slot{position:absolute;z-index:0;border:2px dashed var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);border-radius:14px;background:color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6) 10%, transparent);display:flex;align-items:center;justify-content:center;pointer-events:none;animation:tb-slot-in .16s ease-out}
|
|
626
|
+
.tb-folder-slot span{font-size:10.5px;color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);background:var(--dsw-alias-bg-base,#16181d);border-radius:999px;padding:2px 8px;white-space:nowrap}
|
|
627
|
+
.tb-card.tb-drop-target{z-index:2;transform:scale(.9);opacity:.42;filter:blur(.8px);border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);box-shadow:0 0 0 2px color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6) 45%, transparent)}
|
|
628
|
+
.tb-card.tb-folding{z-index:3;transform:scale(.42);opacity:0;filter:blur(1.4px);transition:transform .22s cubic-bezier(.4,0,.6,1),opacity .22s ease,filter .22s ease}
|
|
629
|
+
.tb-card.folder{animation:tb-folder-pop .24s cubic-bezier(.2,.9,.25,1.25)}
|
|
630
|
+
.tb-card.folder .tb-folder-member{animation:tb-folder-member-in .22s ease-out both}
|
|
631
|
+
@keyframes tb-slot-in{from{opacity:0;transform:scale(.94)}to{opacity:1;transform:scale(1)}}
|
|
632
|
+
@keyframes tb-folder-pop{from{opacity:0;transform:scale(.72);filter:blur(1px)}to{opacity:1;transform:scale(1);filter:blur(0)}}
|
|
633
|
+
@keyframes tb-folder-member-in{from{opacity:0;transform:translateX(-4px)}to{opacity:1;transform:none}}
|
|
634
|
+
@media (prefers-reduced-motion: reduce){.tb-folder-slot,.tb-card.folder,.tb-card.folder .tb-folder-member{animation:none}.tb-card.tb-folding{transition:none}}
|
|
622
635
|
.tb-card.onpath{border-color:color-mix(in srgb, var(--tb-color,#4d7cfe) 55%, transparent)}
|
|
623
636
|
.tb-card.current{border-color:var(--tb-color,#4d7cfe);box-shadow:0 0 0 2px color-mix(in srgb, var(--tb-color,#4d7cfe) 32%, transparent), 0 6px 16px rgba(0,0,0,.24)}
|
|
624
637
|
.tb-card.selected{border-color:var(--tb-color,#4d7cfe);box-shadow:0 0 0 3px color-mix(in srgb, var(--tb-color,#4d7cfe) 42%, transparent), 0 8px 20px rgba(0,0,0,.3)}
|
|
@@ -635,6 +648,23 @@ window.__ModuleLoader__.load({
|
|
|
635
648
|
.tb-card-chip.warn{color:var(--dsw-alias-state-warning-primary,#f0b23e);border-color:currentColor}
|
|
636
649
|
.tb-card-action{margin-left:auto;appearance:none;border:1px solid color-mix(in srgb, var(--tb-color,#4d7cfe) 45%, transparent);background:color-mix(in srgb, var(--tb-color,#4d7cfe) 12%, transparent);color:var(--tb-color,#4d7cfe);border-radius:4px;padding:0 5px;line-height:15px;font-size:9.5px;cursor:pointer;white-space:nowrap}
|
|
637
650
|
.tb-card-action:hover{background:color-mix(in srgb, var(--tb-color,#4d7cfe) 24%, transparent)}
|
|
651
|
+
.tb-card.folder{border-style:dashed;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.05))}
|
|
652
|
+
.tb-card.folder.expanded{width:370px;height:auto;min-height:116px;max-height:460px;z-index:6;overflow:auto;cursor:grab;background:var(--dsw-alias-bg-layer-2,rgba(28,32,40,.98))}
|
|
653
|
+
.tb-folder-expanded{display:flex;flex-direction:column;gap:3px;overflow:auto;min-height:0}
|
|
654
|
+
.tb-folder-hint{font-size:10px;line-height:1.4;color:var(--dsw-alias-label-tertiary,#8a919c);margin-bottom:1px}
|
|
655
|
+
.tb-folder-row{display:flex;gap:7px;align-items:flex-start;padding:3px 6px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));border-radius:5px;background:var(--dsw-alias-bg-base,rgba(0,0,0,.18));cursor:grab;touch-action:none}
|
|
656
|
+
.tb-folder-row:hover{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6)}
|
|
657
|
+
.tb-folder-row:active{cursor:grabbing}
|
|
658
|
+
.tb-folder-row-label{flex:0 0 auto;font-size:10.5px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e6);line-height:1.45}
|
|
659
|
+
.tb-folder-row-prompt{flex:1;min-width:0;font-size:10.5px;line-height:1.45;color:var(--dsw-alias-label-secondary,#9aa0a6);white-space:normal;word-break:break-word}
|
|
660
|
+
.tb-folder-ghost{position:fixed;z-index:10000;pointer-events:none;max-width:320px;padding:5px 8px;border-radius:8px;border:1px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);background:var(--dsw-alias-bg-layer-2,rgba(28,32,40,.98));box-shadow:0 10px 26px rgba(0,0,0,.4);display:flex;gap:6px;font-size:11px}
|
|
661
|
+
.tb-folder-ghost-label{font-weight:700;color:var(--dsw-alias-label-primary,#e6e6e6);white-space:nowrap}
|
|
662
|
+
.tb-folder-ghost-prompt{color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
663
|
+
.tb-folder-ghost.dropping{animation:tb-ghost-drop .2s ease-in forwards}
|
|
664
|
+
@keyframes tb-card-pop{from{opacity:0;transform:scale(.72) translateY(4px)}to{opacity:1;transform:scale(1) translateY(0)}}
|
|
665
|
+
@keyframes tb-ghost-drop{to{opacity:0;transform:scale(.18) translateY(2px);filter:blur(1px)}}
|
|
666
|
+
.tb-folder-members{display:flex;flex-direction:column;gap:2px;overflow:hidden;flex:1;min-height:0}
|
|
667
|
+
.tb-folder-member{font-size:10.5px;line-height:1.35;color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));border-radius:4px;padding:1px 4px;background:var(--dsw-alias-bg-base,rgba(0,0,0,.18))}
|
|
638
668
|
.tb-card-action.danger{border-color:color-mix(in srgb, var(--dsw-alias-state-error-primary,#ff7a59) 55%, transparent);background:color-mix(in srgb, var(--dsw-alias-state-error-primary,#ff7a59) 10%, transparent);color:var(--dsw-alias-state-error-primary,#ff7a59)}
|
|
639
669
|
.tb-card-action.danger:hover{background:color-mix(in srgb, var(--dsw-alias-state-error-primary,#ff7a59) 22%, transparent)}
|
|
640
670
|
.tb-card:active{cursor:grabbing}
|
|
@@ -679,7 +709,7 @@ window.__ModuleLoader__.load({
|
|
|
679
709
|
.tb-hex-row input[type=text]{flex:1;min-width:0;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.05));color:var(--dsw-alias-label-primary,#e6e6e6);border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:5px;padding:3px 6px;font-size:11px;font-family:ui-monospace,monospace}
|
|
680
710
|
.tb-swatch{width:18px;height:18px;border-radius:50%;border:2px solid transparent;cursor:pointer;padding:0}
|
|
681
711
|
.tb-swatch.on{border-color:var(--dsw-alias-label-primary,#e6e6e6);box-shadow:0 0 0 2px rgba(0,0,0,.3)}
|
|
682
|
-
.tb-board-canvas{position:relative;touch-action:none;flex:1;min-height:240px;overflow:auto;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-alias-bg-base,#16181d);cursor:crosshair}
|
|
712
|
+
.tb-board-canvas{position:relative;touch-action:none;flex:1;min-height:240px;overflow:auto;scrollbar-gutter:stable;overscroll-behavior:contain;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-alias-bg-base,#16181d);cursor:crosshair}
|
|
683
713
|
.tb-board-canvas.select{cursor:grab}
|
|
684
714
|
.tb-board-canvas.draw,.tb-board-canvas.draw .tb-sticky{cursor:crosshair}
|
|
685
715
|
.tb-board-canvas.link,.tb-board-canvas.link .tb-sticky{cursor:crosshair}
|
|
@@ -693,8 +723,8 @@ window.__ModuleLoader__.load({
|
|
|
693
723
|
.tb-board-edge-preview{fill:none;stroke-dasharray:6 5;stroke-width:2;opacity:.7}
|
|
694
724
|
.tb-board-canvas.draw .tb-sticky-resize{cursor:nwse-resize}
|
|
695
725
|
.tb-board-canvas.select:active{cursor:grabbing}
|
|
696
|
-
.tb-board-world{position:relative;flex:none}
|
|
697
|
-
.tb-board-stage{position:absolute;left:0;top:0;transform-origin:0 0;will-change:transform;background-color:var(--dsw-alias-bg-base,#16181d);background-image:linear-gradient(to right,var(--dsw-alias-border-l2,rgba(255,255,255,.07)) 1px,transparent 1px),linear-gradient(to bottom,var(--dsw-alias-border-l2,rgba(255,255,255,.07)) 1px,transparent 1px),linear-gradient(to right,var(--dsw-alias-border-l2,rgba(255,255,255,.12)) 1px,transparent 1px),linear-gradient(to bottom,var(--dsw-alias-border-l2,rgba(255,255,255,.12)) 1px,transparent 1px);background-size:22px 22px,22px 22px,110px 110px,110px 110px}
|
|
726
|
+
.tb-board-world{position:relative;flex:none;contain:layout paint}
|
|
727
|
+
.tb-board-stage{position:absolute;left:0;top:0;transform-origin:0 0;will-change:transform;backface-visibility:hidden;background-color:var(--dsw-alias-bg-base,#16181d);background-image:linear-gradient(to right,var(--dsw-alias-border-l2,rgba(255,255,255,.07)) 1px,transparent 1px),linear-gradient(to bottom,var(--dsw-alias-border-l2,rgba(255,255,255,.07)) 1px,transparent 1px),linear-gradient(to right,var(--dsw-alias-border-l2,rgba(255,255,255,.12)) 1px,transparent 1px),linear-gradient(to bottom,var(--dsw-alias-border-l2,rgba(255,255,255,.12)) 1px,transparent 1px);background-size:22px 22px,22px 22px,110px 110px,110px 110px}
|
|
698
728
|
.tb-board-bgdraw{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
|
|
699
729
|
.tb-sticky{position:absolute;width:232px;height:176px;min-width:160px;min-height:120px;box-sizing:border-box;border-radius:5px;padding:8px 9px;display:flex;flex-direction:column;gap:5px;color:#2a2418;box-shadow:0 6px 16px rgba(0,0,0,.28);border:1px solid rgba(0,0,0,.18);overflow:hidden;cursor:grab;user-select:none}
|
|
700
730
|
.tb-sticky:active{cursor:grabbing}
|
|
@@ -705,13 +735,30 @@ window.__ModuleLoader__.load({
|
|
|
705
735
|
.tb-sticky-actions{display:flex;gap:3px;opacity:.65}
|
|
706
736
|
.tb-sticky-actions button{appearance:none;border:0;background:rgba(0,0,0,.08);border-radius:4px;font-size:10px;line-height:16px;padding:0 4px;cursor:pointer;color:#2a2418}
|
|
707
737
|
.tb-sticky-actions button:hover{background:rgba(0,0,0,.16)}
|
|
708
|
-
.tb-sticky-body{flex:1;min-height:0;overflow:hidden;font-size:11px;line-height:1.45;color:#3a3326;word-break:break-word;position:relative;z-index:2;pointer-events:none}
|
|
709
|
-
.tb-sticky-
|
|
710
|
-
.tb-sticky-
|
|
738
|
+
.tb-sticky-body{flex:1;min-height:0;overflow:hidden;font-size:11px;line-height:1.45;color:#3a3326;word-break:break-word;position:relative;z-index:2;pointer-events:none;display:flex;flex-direction:column;gap:4px}
|
|
739
|
+
.tb-sticky-md{flex:1;min-height:0;overflow:hidden;color:#2a2418;font-size:11.5px;line-height:1.42;word-break:break-word}
|
|
740
|
+
.tb-sticky-md>*:first-child{margin-top:0}
|
|
741
|
+
.tb-sticky-md>*:last-child{margin-bottom:0}
|
|
742
|
+
.tb-sticky-md h1,.tb-sticky-md h2,.tb-sticky-md h3,.tb-sticky-md h4,.tb-sticky-md h5,.tb-sticky-md h6{margin:3px 0 1px;line-height:1.25;font-weight:700}
|
|
743
|
+
.tb-sticky-md h1{font-size:16px}.tb-sticky-md h2{font-size:14px}.tb-sticky-md h3{font-size:12.5px}.tb-sticky-md h4,.tb-sticky-md h5,.tb-sticky-md h6{font-size:11.5px}
|
|
744
|
+
.tb-sticky-md p{margin:2px 0}
|
|
745
|
+
.tb-sticky-md ul,.tb-sticky-md ol{margin:2px 0;padding-left:16px}
|
|
746
|
+
.tb-sticky-md li{margin:1px 0}
|
|
747
|
+
.tb-sticky-md blockquote{margin:2px 0;padding-left:6px;border-left:2px solid rgba(0,0,0,.25);opacity:.8}
|
|
748
|
+
.tb-sticky-md code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:rgba(0,0,0,.08);border-radius:3px;padding:0 2px;font-size:10.5px}
|
|
749
|
+
.tb-sticky-md pre{margin:3px 0;padding:4px 6px;background:rgba(0,0,0,.1);border-radius:4px;font-size:10px;line-height:1.35;overflow:hidden;white-space:pre-wrap}
|
|
750
|
+
.tb-sticky-md a{color:#1c4d8f;text-decoration:underline}
|
|
751
|
+
.tb-sticky-md hr{border:0;border-top:1px solid rgba(0,0,0,.2);margin:4px 0}
|
|
752
|
+
.tb-sticky-linkline{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:#1c4d8f;text-decoration:underline;cursor:pointer;background:rgba(255,255,255,.35);border-radius:5px;padding:6px 8px;pointer-events:auto;flex:0 0 auto}
|
|
711
753
|
.tb-sticky-src{font-size:9.5px;font-weight:600;opacity:.6;white-space:nowrap}
|
|
712
754
|
.tb-sticky-draw{position:absolute;inset:0;pointer-events:none;z-index:3}
|
|
713
755
|
.tb-sticky-head{position:relative;z-index:4}
|
|
714
756
|
.tb-sticky-resize{position:absolute;right:0;bottom:0;width:16px;height:16px;cursor:nwse-resize;z-index:6;opacity:.55}
|
|
757
|
+
.tb-sticky-color-row{display:flex;align-items:center;gap:6px;flex-wrap:nowrap;padding:4px 5px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));border-radius:7px;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.03))}
|
|
758
|
+
.tb-sticky-color-btn{width:26px;height:26px;min-width:26px;min-height:26px;padding:0;border-radius:5px;border:2px solid transparent;box-shadow:inset 0 0 0 1px rgba(0,0,0,.18);cursor:pointer;flex:0 0 auto;box-sizing:border-box}
|
|
759
|
+
.tb-sticky-color-btn.on{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);box-shadow:0 0 0 1px var(--dsw-alias-bg-base,#16181d),inset 0 0 0 1px rgba(0,0,0,.18)}
|
|
760
|
+
.tb-sticky-color-input{width:30px;height:26px;min-width:30px;min-height:26px;padding:2px;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.24));border-radius:5px;background:transparent;cursor:pointer;flex:0 0 auto}
|
|
761
|
+
.tb-sticky-color-preview{width:26px;height:26px;min-width:26px;border-radius:5px;border:1px solid rgba(0,0,0,.25);box-shadow:inset 0 0 0 1px rgba(255,255,255,.18)}
|
|
715
762
|
.tb-sticky-resize:after{content:"";position:absolute;right:3px;bottom:3px;width:8px;height:8px;border-right:2px solid rgba(0,0,0,.45);border-bottom:2px solid rgba(0,0,0,.45)}
|
|
716
763
|
.tb-sticky:hover .tb-sticky-resize{opacity:.9}
|
|
717
764
|
.tb-sticky-linkline,.tb-sticky-actions{position:relative;z-index:4}
|
|
@@ -1063,11 +1110,20 @@ window.__ModuleLoader__.load({
|
|
|
1063
1110
|
const order = { after: 3, before: 1, manual: 4, inherited: 0, safety: 5 }
|
|
1064
1111
|
const rows = checkpoints.map((checkpoint) => ({ key: checkpoint.id, checkpoint }))
|
|
1065
1112
|
rows.sort((left, right) => {
|
|
1066
|
-
const
|
|
1113
|
+
const leftCheckpoint = left.checkpoint
|
|
1114
|
+
const rightCheckpoint = right.checkpoint
|
|
1115
|
+
// A manual checkpoint created between turns has no turn number; order it
|
|
1116
|
+
// by creation time instead of forcing it below every turn.
|
|
1117
|
+
if (!Number.isInteger(leftCheckpoint.turn) || !Number.isInteger(rightCheckpoint.turn)) {
|
|
1118
|
+
const timeDelta = (rightCheckpoint.createdAt ?? 0) - (leftCheckpoint.createdAt ?? 0)
|
|
1119
|
+
if (timeDelta !== 0) return timeDelta
|
|
1120
|
+
return (rightCheckpoint.seq ?? 0) - (leftCheckpoint.seq ?? 0)
|
|
1121
|
+
}
|
|
1122
|
+
const turnDelta = leftCheckpoint.turn - rightCheckpoint.turn
|
|
1067
1123
|
if (turnDelta !== 0) return -turnDelta
|
|
1068
|
-
const phaseDelta = (order[
|
|
1124
|
+
const phaseDelta = (order[leftCheckpoint.phase] ?? 2) - (order[rightCheckpoint.phase] ?? 2)
|
|
1069
1125
|
if (phaseDelta !== 0) return -phaseDelta
|
|
1070
|
-
return (
|
|
1126
|
+
return (rightCheckpoint.createdAt ?? 0) - (leftCheckpoint.createdAt ?? 0)
|
|
1071
1127
|
})
|
|
1072
1128
|
return {
|
|
1073
1129
|
rows: rows.slice(0, MAX_ROWS),
|
|
@@ -1153,13 +1209,87 @@ window.__ModuleLoader__.load({
|
|
|
1153
1209
|
return { x: leftDepth - rightDepth, y: topDepth - bottomDepth }
|
|
1154
1210
|
}
|
|
1155
1211
|
|
|
1212
|
+
/** Remove one card from a folder; a folder with <2 members dissolves. */
|
|
1213
|
+
function removeFolderMember(folders, folderId, memberKey) {
|
|
1214
|
+
if (!Array.isArray(folders)) return folders
|
|
1215
|
+
let changed = false
|
|
1216
|
+
const next = []
|
|
1217
|
+
for (const folder of folders) {
|
|
1218
|
+
if (folder.id !== folderId) {
|
|
1219
|
+
next.push(folder)
|
|
1220
|
+
continue
|
|
1221
|
+
}
|
|
1222
|
+
const members = uniqueKeys(folder.members ?? []).filter((key) => key !== memberKey)
|
|
1223
|
+
changed = changed || members.length !== (folder.members?.length ?? 0)
|
|
1224
|
+
if (members.length >= 2) next.push({ ...folder, members })
|
|
1225
|
+
}
|
|
1226
|
+
return changed ? next : folders
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
/** Unique keys in order. */
|
|
1230
|
+
function uniqueKeys(values) {
|
|
1231
|
+
const seen = new Set()
|
|
1232
|
+
return values.filter((value) => {
|
|
1233
|
+
if (typeof value !== 'string' || seen.has(value)) return false
|
|
1234
|
+
seen.add(value)
|
|
1235
|
+
return true
|
|
1236
|
+
})
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Merge a dragged card/folder into a drop target underneath it.
|
|
1241
|
+
* Returns the same array reference when the drop is a no-op (different
|
|
1242
|
+
* sessions, same card, same folder), so callers can keep normal dragging.
|
|
1243
|
+
* @param {object[]} folders - saved folders for this branch family.
|
|
1244
|
+
* @param {object} source - dragged layout card.
|
|
1245
|
+
* @param {object} target - layout card/folder under the pointer.
|
|
1246
|
+
*/
|
|
1247
|
+
function mergeCardFolder(folders, source, target) {
|
|
1248
|
+
if (!source || !target || source.key === target.key) return folders
|
|
1249
|
+
if (!source.sessionId || !target.sessionId || source.sessionId !== target.sessionId) return folders
|
|
1250
|
+
if (!Array.isArray(folders)) return folders
|
|
1251
|
+
const list = folders.map((folder) => ({ ...folder, members: uniqueKeys(folder.members ?? []) }))
|
|
1252
|
+
const sourceFolder = source.kind === 'folder' ? list.find((folder) => folder.id === source.folderId) : null
|
|
1253
|
+
const targetFolder = target.kind === 'folder' ? list.find((folder) => folder.id === target.folderId) : null
|
|
1254
|
+
if (sourceFolder && targetFolder && sourceFolder.id === targetFolder.id) return folders
|
|
1255
|
+
let host = null
|
|
1256
|
+
if (sourceFolder && targetFolder) {
|
|
1257
|
+
targetFolder.members = uniqueKeys([...targetFolder.members, ...sourceFolder.members])
|
|
1258
|
+
host = targetFolder
|
|
1259
|
+
const index = list.indexOf(sourceFolder)
|
|
1260
|
+
if (index !== -1) list.splice(index, 1)
|
|
1261
|
+
} else if (sourceFolder) {
|
|
1262
|
+
sourceFolder.members = uniqueKeys([...sourceFolder.members, target.key])
|
|
1263
|
+
host = sourceFolder
|
|
1264
|
+
} else if (targetFolder) {
|
|
1265
|
+
targetFolder.members = uniqueKeys([...targetFolder.members, source.key])
|
|
1266
|
+
host = targetFolder
|
|
1267
|
+
} else {
|
|
1268
|
+
host = {
|
|
1269
|
+
id: `fold-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`,
|
|
1270
|
+
members: uniqueKeys([target.key, source.key]),
|
|
1271
|
+
x: Number.isFinite(target.x) ? target.x : 0,
|
|
1272
|
+
y: Number.isFinite(target.y) ? target.y : 0,
|
|
1273
|
+
createdAt: Date.now(),
|
|
1274
|
+
}
|
|
1275
|
+
list.push(host)
|
|
1276
|
+
}
|
|
1277
|
+
// One card belongs to exactly one folder; drop duplicates from the others.
|
|
1278
|
+
for (const folder of list) {
|
|
1279
|
+
if (folder === host) continue
|
|
1280
|
+
folder.members = folder.members.filter((key) => !host.members.includes(key))
|
|
1281
|
+
}
|
|
1282
|
+
const next = list.filter((folder) => folder.members.length >= 2)
|
|
1283
|
+
return next.length === folders.length && next.every((folder, index) => folder === folders[index]) ? folders : next
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1156
1286
|
/**
|
|
1157
1287
|
* Lay out branch cards left-to-right (turn chain) with one horizontal lane
|
|
1158
1288
|
* per branch Session, fork edges from the parent turn card to the child's
|
|
1159
1289
|
* first card, and the current root→Session path marked.
|
|
1160
1290
|
* @returns {{width:number,height:number,cards:object[],links:object[],lanes:object[],byId:Map,currentKey:string|null,truncated:boolean}}
|
|
1161
1291
|
*/
|
|
1162
|
-
function layoutTree(sessions, currentSessionId, overrides) {
|
|
1292
|
+
function layoutTree(sessions, currentSessionId, overrides, folders = []) {
|
|
1163
1293
|
const byId = new Map(sessions.map((session) => [session.sessionId, session]))
|
|
1164
1294
|
const laneOf = new Map()
|
|
1165
1295
|
for (const session of sessions) {
|
|
@@ -1265,6 +1395,10 @@ window.__ModuleLoader__.load({
|
|
|
1265
1395
|
})
|
|
1266
1396
|
x += CARD_WIDTH + CARD_GAP_X
|
|
1267
1397
|
}
|
|
1398
|
+
// Turn cards and turn-less manual cards are placed chronologically by
|
|
1399
|
+
// createdAt. A manual checkpoint created between two turns used to be
|
|
1400
|
+
// appended after every turn card, so the next turn appeared before it.
|
|
1401
|
+
const orderedCards = []
|
|
1268
1402
|
for (const turn of shown) {
|
|
1269
1403
|
const group = groups.get(turn)
|
|
1270
1404
|
const list = []
|
|
@@ -1273,47 +1407,125 @@ window.__ModuleLoader__.load({
|
|
|
1273
1407
|
if (group.after) list.push(group.after)
|
|
1274
1408
|
for (const manual of group.manual ?? []) list.push(manual)
|
|
1275
1409
|
const prompt = group.after?.prompt ?? group.before?.prompt ?? null
|
|
1276
|
-
|
|
1410
|
+
const createdAt = group.after?.createdAt ?? group.before?.createdAt ?? 0
|
|
1411
|
+
orderedCards.push({
|
|
1277
1412
|
key: `${session.sessionId}:turn:${turn}`,
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1413
|
+
sortTime: createdAt,
|
|
1414
|
+
sortTurn: turn,
|
|
1415
|
+
card: {
|
|
1416
|
+
key: `${session.sessionId}:turn:${turn}`,
|
|
1417
|
+
kind: 'turn',
|
|
1418
|
+
sessionId: session.sessionId,
|
|
1419
|
+
sessionTitle: session.title || `${session.sessionId.slice(0, 8)}…`,
|
|
1420
|
+
lane,
|
|
1421
|
+
color,
|
|
1422
|
+
turn,
|
|
1423
|
+
label: `T${turn}`,
|
|
1424
|
+
title: `${session.title || session.sessionId.slice(0, 8)} · 第 ${turn} 回合${prompt ? ` · ${prompt}` : ''}`,
|
|
1425
|
+
prompt,
|
|
1426
|
+
note: [...list].reverse().find((checkpoint) => checkpoint.note)?.note ?? null,
|
|
1427
|
+
checkpoints: list,
|
|
1428
|
+
manualCount: group.manual?.length ?? 0,
|
|
1429
|
+
onPath,
|
|
1430
|
+
createdAt,
|
|
1431
|
+
},
|
|
1294
1432
|
})
|
|
1295
|
-
x += CARD_WIDTH + CARD_GAP_X
|
|
1296
1433
|
}
|
|
1297
1434
|
for (const manual of looseManuals) {
|
|
1298
|
-
|
|
1435
|
+
orderedCards.push({
|
|
1299
1436
|
key: `${session.sessionId}:manual:${manual.id}`,
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1437
|
+
sortTime: manual.createdAt ?? 0,
|
|
1438
|
+
sortTurn: Number.MAX_SAFE_INTEGER,
|
|
1439
|
+
card: {
|
|
1440
|
+
key: `${session.sessionId}:manual:${manual.id}`,
|
|
1441
|
+
kind: 'manual',
|
|
1442
|
+
sessionId: session.sessionId,
|
|
1443
|
+
sessionTitle: session.title || `${session.sessionId.slice(0, 8)}…`,
|
|
1444
|
+
lane,
|
|
1445
|
+
color,
|
|
1446
|
+
label: '手动',
|
|
1447
|
+
title: `${session.title || session.sessionId.slice(0, 8)} · 手动检查点`,
|
|
1448
|
+
prompt: manual.prompt ?? null,
|
|
1449
|
+
note: manual.note ?? null,
|
|
1450
|
+
checkpoints: [manual],
|
|
1451
|
+
onPath,
|
|
1452
|
+
createdAt: manual.createdAt ?? null,
|
|
1453
|
+
},
|
|
1314
1454
|
})
|
|
1455
|
+
}
|
|
1456
|
+
orderedCards.sort((left, right) => {
|
|
1457
|
+
if (left.sortTime !== right.sortTime) return left.sortTime - right.sortTime
|
|
1458
|
+
if (left.sortTurn !== right.sortTurn) return left.sortTurn - right.sortTurn
|
|
1459
|
+
return left.key.localeCompare(right.key)
|
|
1460
|
+
})
|
|
1461
|
+
for (const ordered of orderedCards) {
|
|
1462
|
+
const card = ordered.card
|
|
1463
|
+
card.x = x
|
|
1464
|
+
card.y = y
|
|
1465
|
+
pushCard(card)
|
|
1315
1466
|
x += CARD_WIDTH + CARD_GAP_X
|
|
1316
1467
|
}
|
|
1468
|
+
// Folders collapse member cards into one compact card until unpacked.
|
|
1469
|
+
if (Array.isArray(folders) && folders.length > 0 && sessionCards.length > 0) {
|
|
1470
|
+
const consumed = new Set()
|
|
1471
|
+
const inserts = []
|
|
1472
|
+
for (const folder of folders) {
|
|
1473
|
+
if (!folder || !Array.isArray(folder.members) || folder.members.length < 2) continue
|
|
1474
|
+
const members = sessionCards.filter((card) => folder.members.includes(card.key))
|
|
1475
|
+
if (members.length < 2) continue
|
|
1476
|
+
if (members.some((card) => consumed.has(card.key))) continue
|
|
1477
|
+
const firstIndex = sessionCards.indexOf(members[0])
|
|
1478
|
+
for (const member of members) consumed.add(member.key)
|
|
1479
|
+
const key = `folder:${session.sessionId}:${folder.id}`
|
|
1480
|
+
const override = overrides?.[key]
|
|
1481
|
+
const firstMember = members[0]
|
|
1482
|
+
inserts.push({
|
|
1483
|
+
index: firstIndex,
|
|
1484
|
+
card: {
|
|
1485
|
+
key,
|
|
1486
|
+
kind: 'folder',
|
|
1487
|
+
folderId: folder.id,
|
|
1488
|
+
folderMembers: [...folder.members],
|
|
1489
|
+
members,
|
|
1490
|
+
sessionId: session.sessionId,
|
|
1491
|
+
sessionTitle: session.title || `${session.sessionId.slice(0, 8)}…`,
|
|
1492
|
+
lane,
|
|
1493
|
+
color: firstMember.color,
|
|
1494
|
+
x: override?.x ?? (Number.isFinite(folder.x) ? folder.x : firstMember.x),
|
|
1495
|
+
y: override?.y ?? (Number.isFinite(folder.y) ? folder.y : firstMember.y),
|
|
1496
|
+
label: '卡片夹',
|
|
1497
|
+
title: `${session.title || session.sessionId.slice(0, 8)} · 卡片夹(${members.length} 张)`,
|
|
1498
|
+
prompt: null,
|
|
1499
|
+
note: null,
|
|
1500
|
+
checkpoints: [],
|
|
1501
|
+
onPath: members.some((member) => member.onPath),
|
|
1502
|
+
createdAt: members[0].createdAt ?? null,
|
|
1503
|
+
},
|
|
1504
|
+
})
|
|
1505
|
+
}
|
|
1506
|
+
if (inserts.length > 0) {
|
|
1507
|
+
const original = [...sessionCards]
|
|
1508
|
+
const remaining = original.filter((card) => !consumed.has(card.key))
|
|
1509
|
+
const positions = inserts
|
|
1510
|
+
.map((insert) => ({
|
|
1511
|
+
...insert,
|
|
1512
|
+
position: original.slice(0, insert.index).filter((card) => !consumed.has(card.key)).length,
|
|
1513
|
+
}))
|
|
1514
|
+
.sort((left, right) => left.position - right.position)
|
|
1515
|
+
for (const insert of positions) remaining.splice(insert.position, 0, insert.card)
|
|
1516
|
+
sessionCards.length = 0
|
|
1517
|
+
sessionCards.push(...remaining)
|
|
1518
|
+
// `cards` is the global render list: replace the hidden member cards
|
|
1519
|
+
// with the folder card so the canvas actually collapses them.
|
|
1520
|
+
const visibleKeys = new Set(remaining.map((card) => card.key))
|
|
1521
|
+
for (let cardIndex = cards.length - 1; cardIndex >= 0; cardIndex -= 1) {
|
|
1522
|
+
if (cards[cardIndex].sessionId === session.sessionId && !visibleKeys.has(cards[cardIndex].key)) cards.splice(cardIndex, 1)
|
|
1523
|
+
}
|
|
1524
|
+
for (const card of remaining) {
|
|
1525
|
+
if (card.kind === 'folder' && !cards.some((existing) => existing.key === card.key)) cards.push(card)
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1317
1529
|
cardsBySession.set(session.sessionId, sessionCards)
|
|
1318
1530
|
for (let index = 1; index < sessionCards.length; index += 1) {
|
|
1319
1531
|
const from = sessionCards[index - 1]
|
|
@@ -1378,7 +1590,7 @@ window.__ModuleLoader__.load({
|
|
|
1378
1590
|
}
|
|
1379
1591
|
|
|
1380
1592
|
/** One card of the conversation canvas. */
|
|
1381
|
-
function CanvasCard({ card, t, selectedKey, onSelect, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef }) {
|
|
1593
|
+
function CanvasCard({ card, t, selectedKey, onSelect, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding }) {
|
|
1382
1594
|
const files = (card.checkpoints ?? []).reduce(
|
|
1383
1595
|
(total, checkpoint) => ({
|
|
1384
1596
|
added: total.added + (checkpoint.files?.added ?? 0),
|
|
@@ -1408,7 +1620,9 @@ window.__ModuleLoader__.load({
|
|
|
1408
1620
|
'article',
|
|
1409
1621
|
{
|
|
1410
1622
|
key: card.key,
|
|
1411
|
-
className: `tb-card${card.onPath ? ' onpath' : ''}${card.isCurrentPosition ? ' current' : ''}${card.key === selectedKey ? ' selected' : ''}`,
|
|
1623
|
+
className: `tb-card${card.onPath ? ' onpath' : ''}${card.isCurrentPosition ? ' current' : ''}${card.key === selectedKey ? ' selected' : ''}${dropTargetKey === card.key ? ' tb-drop-target' : ''}${folding && (folding.sourceKey === card.key || folding.targetKey === card.key) ? ' tb-folding' : ''}`,
|
|
1624
|
+
'data-card-key': card.key,
|
|
1625
|
+
'data-card-kind': card.kind ?? 'turn',
|
|
1412
1626
|
style: { left: card.x, top: card.y, '--tb-color': card.color },
|
|
1413
1627
|
title: card.title,
|
|
1414
1628
|
role: 'button',
|
|
@@ -1510,6 +1724,105 @@ window.__ModuleLoader__.load({
|
|
|
1510
1724
|
)
|
|
1511
1725
|
}
|
|
1512
1726
|
|
|
1727
|
+
/** One collapsed card folder: compact, with member labels and an unpack action. */
|
|
1728
|
+
function CanvasFolderCard({ card, t, onDragStart, onUnpackFolder, dropTargetKey, folding, expanded, onToggleFolder, onMemberDragStart, suppressClickRef }) {
|
|
1729
|
+
const members = card.members ?? []
|
|
1730
|
+
return h(
|
|
1731
|
+
'article',
|
|
1732
|
+
{
|
|
1733
|
+
key: card.key,
|
|
1734
|
+
className: `tb-card folder${expanded ? ' expanded' : ''}${dropTargetKey === card.key ? ' tb-drop-target' : ''}${folding && (folding.sourceKey === card.key || folding.targetKey === card.key) ? ' tb-folding' : ''}`,
|
|
1735
|
+
style: { left: card.x, top: card.y, '--tb-color': card.color },
|
|
1736
|
+
title: card.title,
|
|
1737
|
+
'data-card-key': card.key,
|
|
1738
|
+
'data-card-kind': 'folder',
|
|
1739
|
+
onPointerDown: (event) => {
|
|
1740
|
+
if (typeof onDragStart === 'function') onDragStart(event, card)
|
|
1741
|
+
},
|
|
1742
|
+
onClick: (event) => {
|
|
1743
|
+
event.stopPropagation()
|
|
1744
|
+
if (suppressClickRef?.current) {
|
|
1745
|
+
suppressClickRef.current = false
|
|
1746
|
+
return
|
|
1747
|
+
}
|
|
1748
|
+
if (typeof onToggleFolder === 'function') onToggleFolder(card.folderId)
|
|
1749
|
+
},
|
|
1750
|
+
},
|
|
1751
|
+
h(
|
|
1752
|
+
'div',
|
|
1753
|
+
{ className: 'tb-card-head' },
|
|
1754
|
+
h('span', { className: 'tb-card-badge' }, '📁'),
|
|
1755
|
+
h('span', { className: 'tb-card-branch', title: card.sessionTitle, style: { color: card.color } }, card.sessionTitle),
|
|
1756
|
+
h('span', { className: 'tb-card-spacer' }),
|
|
1757
|
+
card.createdAt ? h('span', { className: 'tb-card-time' }, clock(card.createdAt)) : null,
|
|
1758
|
+
),
|
|
1759
|
+
expanded
|
|
1760
|
+
? h(
|
|
1761
|
+
'div',
|
|
1762
|
+
{ className: 'tb-folder-expanded' },
|
|
1763
|
+
h('div', { className: 'tb-folder-hint' }, t('tree.folderMemberDrag')),
|
|
1764
|
+
...members.map((member) =>
|
|
1765
|
+
h(
|
|
1766
|
+
'div',
|
|
1767
|
+
{
|
|
1768
|
+
key: member.key,
|
|
1769
|
+
className: 'tb-folder-row',
|
|
1770
|
+
title: member.prompt || member.title,
|
|
1771
|
+
'data-member-key': member.key,
|
|
1772
|
+
onPointerDown: (event) => {
|
|
1773
|
+
if (typeof onMemberDragStart === 'function') onMemberDragStart(event, card, member)
|
|
1774
|
+
},
|
|
1775
|
+
},
|
|
1776
|
+
h('span', { className: 'tb-folder-row-label' }, member.label),
|
|
1777
|
+
h('span', { className: 'tb-folder-row-prompt' }, stripMarkdown(member.prompt || member.title || '')),
|
|
1778
|
+
),
|
|
1779
|
+
),
|
|
1780
|
+
)
|
|
1781
|
+
: h(
|
|
1782
|
+
'div',
|
|
1783
|
+
{ className: 'tb-folder-members' },
|
|
1784
|
+
...members.slice(0, 4).map((member) =>
|
|
1785
|
+
h(
|
|
1786
|
+
'div',
|
|
1787
|
+
{ key: member.key, className: 'tb-folder-member', title: `${member.label}${member.prompt ? ` · ${stripMarkdown(member.prompt)}` : ''}` },
|
|
1788
|
+
`${member.label}${member.prompt ? ` · ${stripMarkdown(member.prompt).slice(0, 36)}` : ''}`,
|
|
1789
|
+
),
|
|
1790
|
+
),
|
|
1791
|
+
members.length > 4 ? h('div', { className: 'tb-folder-member more' }, `+${members.length - 4}`) : null,
|
|
1792
|
+
),
|
|
1793
|
+
h(
|
|
1794
|
+
'div',
|
|
1795
|
+
{ className: 'tb-card-foot' },
|
|
1796
|
+
h(
|
|
1797
|
+
'button',
|
|
1798
|
+
{
|
|
1799
|
+
type: 'button',
|
|
1800
|
+
className: 'tb-card-action',
|
|
1801
|
+
title: expanded ? t('tree.folderCollapse') : t('tree.folderExpand'),
|
|
1802
|
+
onClick: (event) => {
|
|
1803
|
+
event.stopPropagation()
|
|
1804
|
+
if (typeof onToggleFolder === 'function') onToggleFolder(card.folderId)
|
|
1805
|
+
},
|
|
1806
|
+
},
|
|
1807
|
+
expanded ? `▴ ${t('tree.folderCollapse')}` : `▾ ${t('tree.folderExpand')}`,
|
|
1808
|
+
),
|
|
1809
|
+
h(
|
|
1810
|
+
'button',
|
|
1811
|
+
{
|
|
1812
|
+
type: 'button',
|
|
1813
|
+
className: 'tb-card-action',
|
|
1814
|
+
title: t('tree.unpackHint'),
|
|
1815
|
+
onClick: (event) => {
|
|
1816
|
+
event.stopPropagation()
|
|
1817
|
+
if (typeof onUnpackFolder === 'function') onUnpackFolder(card.folderId)
|
|
1818
|
+
},
|
|
1819
|
+
},
|
|
1820
|
+
`↔ ${t('tree.unpack')}`,
|
|
1821
|
+
),
|
|
1822
|
+
),
|
|
1823
|
+
)
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1513
1826
|
/** Render the pannable/zoomable conversation canvas. */
|
|
1514
1827
|
function TreeCanvas({
|
|
1515
1828
|
layout,
|
|
@@ -1520,6 +1833,12 @@ window.__ModuleLoader__.load({
|
|
|
1520
1833
|
onBranch,
|
|
1521
1834
|
onNote,
|
|
1522
1835
|
onDragStart,
|
|
1836
|
+
onUnpackFolder,
|
|
1837
|
+
dropTargetKey,
|
|
1838
|
+
folding,
|
|
1839
|
+
expandedFolderId,
|
|
1840
|
+
onToggleFolder,
|
|
1841
|
+
onMemberDragStart,
|
|
1523
1842
|
onResetLayout,
|
|
1524
1843
|
autoPan,
|
|
1525
1844
|
panSpeed,
|
|
@@ -1573,6 +1892,7 @@ window.__ModuleLoader__.load({
|
|
|
1573
1892
|
),
|
|
1574
1893
|
h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.resetLayoutHint'), onClick: onResetLayout }, t('tree.resetLayout')),
|
|
1575
1894
|
h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.expandHint'), onClick: onToggleExpand }, expanded ? '⤡' : '⤢'),
|
|
1895
|
+
h('span', { className: 'tb-canvas-hint' }, t('tree.folderHint')),
|
|
1576
1896
|
),
|
|
1577
1897
|
h(
|
|
1578
1898
|
'div',
|
|
@@ -1593,8 +1913,39 @@ window.__ModuleLoader__.load({
|
|
|
1593
1913
|
}),
|
|
1594
1914
|
),
|
|
1595
1915
|
),
|
|
1916
|
+
(() => {
|
|
1917
|
+
const targetCard = dropTargetKey ? layout.cards.find((card) => card.key === dropTargetKey) : null
|
|
1918
|
+
if (!targetCard) return null
|
|
1919
|
+
return h(
|
|
1920
|
+
'div',
|
|
1921
|
+
{
|
|
1922
|
+
className: 'tb-folder-slot',
|
|
1923
|
+
style: {
|
|
1924
|
+
left: targetCard.x - 5,
|
|
1925
|
+
top: targetCard.y - 5,
|
|
1926
|
+
width: CARD_WIDTH + 10,
|
|
1927
|
+
height: CARD_HEIGHT + 10,
|
|
1928
|
+
},
|
|
1929
|
+
'aria-hidden': true,
|
|
1930
|
+
},
|
|
1931
|
+
h('span', null, t('tree.folderDropHint')),
|
|
1932
|
+
)
|
|
1933
|
+
})(),
|
|
1596
1934
|
...layout.cards.map((card) =>
|
|
1597
|
-
|
|
1935
|
+
card.kind === 'folder'
|
|
1936
|
+
? CanvasFolderCard({
|
|
1937
|
+
card,
|
|
1938
|
+
t,
|
|
1939
|
+
onDragStart,
|
|
1940
|
+
onUnpackFolder,
|
|
1941
|
+
dropTargetKey,
|
|
1942
|
+
folding,
|
|
1943
|
+
expanded: expandedFolderId === card.folderId,
|
|
1944
|
+
onToggleFolder,
|
|
1945
|
+
onMemberDragStart,
|
|
1946
|
+
suppressClickRef,
|
|
1947
|
+
})
|
|
1948
|
+
: CanvasCard({ card, t, selectedKey, onSelect, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding }),
|
|
1598
1949
|
),
|
|
1599
1950
|
),
|
|
1600
1951
|
)
|
|
@@ -1748,6 +2099,18 @@ window.__ModuleLoader__.load({
|
|
|
1748
2099
|
const [tick, setTick] = React.useState(0)
|
|
1749
2100
|
const [busy, setBusy] = React.useState('')
|
|
1750
2101
|
const [feedback, setFeedback] = React.useState(null)
|
|
2102
|
+
|
|
2103
|
+
React.useEffect(() => {
|
|
2104
|
+
if (!feedback) return undefined
|
|
2105
|
+
if (feedback.tone === 'err' || feedback.tone === 'warn') return undefined
|
|
2106
|
+
// Actionable successes (open branch / undo restore) stay longer; plain
|
|
2107
|
+
// toasts such as "卡片记录已保存" disappear on their own.
|
|
2108
|
+
const actionable = Boolean(feedback.childSessionId || feedback.safetyCheckpointId || feedback.pruneCandidate)
|
|
2109
|
+
const timer = window.setTimeout(() => {
|
|
2110
|
+
setFeedback((current) => (current === feedback ? null : current))
|
|
2111
|
+
}, actionable ? 8000 : 3500)
|
|
2112
|
+
return () => window.clearTimeout(timer)
|
|
2113
|
+
}, [feedback])
|
|
1751
2114
|
const [view, setView] = React.useState('tree')
|
|
1752
2115
|
const [selectedKey, setSelectedKey] = React.useState(null)
|
|
1753
2116
|
const [zoom, setZoom] = React.useState(1)
|
|
@@ -1781,6 +2144,14 @@ window.__ModuleLoader__.load({
|
|
|
1781
2144
|
const applyCameraRef = React.useRef(() => {})
|
|
1782
2145
|
const [positions, setPositions] = React.useState({})
|
|
1783
2146
|
const positionsRef = React.useRef({})
|
|
2147
|
+
const [folders, setFolders] = React.useState([])
|
|
2148
|
+
const foldersRef = React.useRef([])
|
|
2149
|
+
const [dropTargetKey, setDropTargetKey] = React.useState(null)
|
|
2150
|
+
const dropTargetRef = React.useRef(null)
|
|
2151
|
+
const [folding, setFolding] = React.useState(null)
|
|
2152
|
+
const foldTimerRef = React.useRef(null)
|
|
2153
|
+
const [expandedFolderId, setExpandedFolderId] = React.useState(null)
|
|
2154
|
+
const [folderGhost, setFolderGhost] = React.useState(null)
|
|
1784
2155
|
const suppressClickRef = React.useRef(false)
|
|
1785
2156
|
const draggingRef = React.useRef(false)
|
|
1786
2157
|
const busyRef = React.useRef('')
|
|
@@ -2087,7 +2458,7 @@ window.__ModuleLoader__.load({
|
|
|
2087
2458
|
const sessions = data?.sessions ?? []
|
|
2088
2459
|
const checkpointTotal = sessions.reduce((total, session) => total + (session.checkpointCount ?? session.checkpoints?.length ?? 0), 0)
|
|
2089
2460
|
const gitOff = data?.git === false
|
|
2090
|
-
const layout = data ? layoutTree(sessions, data.currentSessionId, positions) : null
|
|
2461
|
+
const layout = data ? layoutTree(sessions, data.currentSessionId, positions, folders) : null
|
|
2091
2462
|
layoutRef.current = layout
|
|
2092
2463
|
const clientVersion = BUILD.split('+')[0]
|
|
2093
2464
|
const serverVersion = typeof data?.serverVersion === 'string' ? data.serverVersion : null
|
|
@@ -2097,34 +2468,45 @@ window.__ModuleLoader__.load({
|
|
|
2097
2468
|
const selectedNode = (selectedKey ? layout?.cards.find((card) => card.key === selectedKey) : null) ?? fallbackNode
|
|
2098
2469
|
const effectiveSelectedKey = selectedNode?.key ?? null
|
|
2099
2470
|
|
|
2100
|
-
// Fit the canvas the first time a layout
|
|
2471
|
+
// Fit the canvas the first time a Session's layout appears. Later layout
|
|
2472
|
+
// size changes (folding/unfolding/dragging) must not re-center the camera,
|
|
2473
|
+
// otherwise a freshly formed folder appears to jump to the middle.
|
|
2474
|
+
const layoutReady = Boolean(layout && layout.cards.length > 0)
|
|
2101
2475
|
React.useEffect(() => {
|
|
2102
|
-
if (view !== 'tree' || !
|
|
2476
|
+
if (view !== 'tree' || !layoutReady) return
|
|
2103
2477
|
if (draggingRef.current) return
|
|
2104
|
-
const key =
|
|
2478
|
+
const key = String(data?.currentSessionId ?? '')
|
|
2105
2479
|
if (fittedRef.current === key) return
|
|
2106
2480
|
fittedRef.current = key
|
|
2107
2481
|
window.requestAnimationFrame(() => fitCanvas())
|
|
2108
2482
|
// fitCanvas only reads refs; it is intentionally excluded from deps.
|
|
2109
2483
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2110
|
-
}, [view, data?.currentSessionId,
|
|
2484
|
+
}, [view, data?.currentSessionId, layoutReady])
|
|
2111
2485
|
|
|
2112
2486
|
const positionsKey = data?.rootSessionId ? `dsh-timeback:card-positions:${data.rootSessionId}` : null
|
|
2487
|
+
const foldersKey = data?.rootSessionId ? `dsh-timeback:card-folders:${data.rootSessionId}` : null
|
|
2113
2488
|
|
|
2114
|
-
// Restore dragged card positions for this branch family.
|
|
2489
|
+
// Restore dragged card positions and folders for this branch family.
|
|
2115
2490
|
React.useEffect(() => {
|
|
2116
2491
|
if (!positionsKey) return
|
|
2117
2492
|
let saved = {}
|
|
2493
|
+
let savedFolders = []
|
|
2118
2494
|
try {
|
|
2119
2495
|
const raw = window.localStorage.getItem(positionsKey)
|
|
2120
2496
|
if (raw) saved = JSON.parse(raw)
|
|
2497
|
+
const rawFolders = window.localStorage.getItem(foldersKey)
|
|
2498
|
+
if (rawFolders) savedFolders = JSON.parse(rawFolders)
|
|
2121
2499
|
} catch {
|
|
2122
2500
|
saved = {}
|
|
2501
|
+
savedFolders = []
|
|
2123
2502
|
}
|
|
2124
2503
|
if (saved === null || typeof saved !== 'object' || Array.isArray(saved)) saved = {}
|
|
2504
|
+
if (!Array.isArray(savedFolders)) savedFolders = []
|
|
2125
2505
|
positionsRef.current = saved
|
|
2126
2506
|
setPositions(saved)
|
|
2127
|
-
|
|
2507
|
+
foldersRef.current = savedFolders
|
|
2508
|
+
setFolders(savedFolders)
|
|
2509
|
+
}, [positionsKey, foldersKey])
|
|
2128
2510
|
|
|
2129
2511
|
// Wheel zoom must be non-passive, so it is bound directly to the viewport.
|
|
2130
2512
|
React.useEffect(() => {
|
|
@@ -2155,6 +2537,91 @@ window.__ModuleLoader__.load({
|
|
|
2155
2537
|
}
|
|
2156
2538
|
}
|
|
2157
2539
|
|
|
2540
|
+
/** Persist card folders for this branch family. */
|
|
2541
|
+
const storeFolders = (next, persist) => {
|
|
2542
|
+
foldersRef.current = next
|
|
2543
|
+
setFolders(next)
|
|
2544
|
+
if (persist !== true) return
|
|
2545
|
+
try {
|
|
2546
|
+
if (foldersKey) window.localStorage.setItem(foldersKey, JSON.stringify(next))
|
|
2547
|
+
} catch {
|
|
2548
|
+
// Storage can be disabled; folding still works in memory.
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
/** Dissolve one folder and restore its member cards. */
|
|
2553
|
+
const unpackFolder = (folderId) => {
|
|
2554
|
+
const next = foldersRef.current.filter((folder) => folder.id !== folderId)
|
|
2555
|
+
storeFolders(next, true)
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
/** Expand/collapse one folder's full member list. */
|
|
2559
|
+
const toggleFolder = (folderId) => {
|
|
2560
|
+
setExpandedFolderId((current) => (current === folderId ? null : folderId))
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
/** Remove one card from a folder; a folder with <2 members dissolves. */
|
|
2564
|
+
const detachFolderMember = (folderId, memberKey, position) => {
|
|
2565
|
+
const next = removeFolderMember(foldersRef.current, folderId, memberKey)
|
|
2566
|
+
if (next === foldersRef.current) return
|
|
2567
|
+
storeFolders(next, true)
|
|
2568
|
+
if (next.every((folder) => folder.id !== folderId)) setExpandedFolderId(null)
|
|
2569
|
+
if (position && Number.isFinite(position.x) && Number.isFinite(position.y)) {
|
|
2570
|
+
storePositions({ ...positionsRef.current, [memberKey]: position }, true)
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* Drag one row out of an expanded folder. Dropping it over the canvas
|
|
2576
|
+
* detaches the card and places it at the pointer; dropping back over the
|
|
2577
|
+
* folder cancels.
|
|
2578
|
+
*/
|
|
2579
|
+
const startFolderMemberDrag = (event, folderCard, member) => {
|
|
2580
|
+
if (event.button !== 0) return
|
|
2581
|
+
event.preventDefault()
|
|
2582
|
+
event.stopPropagation()
|
|
2583
|
+
const startX = event.clientX
|
|
2584
|
+
const startY = event.clientY
|
|
2585
|
+
let moved = false
|
|
2586
|
+
const move = (next) => {
|
|
2587
|
+
if (!moved && Math.hypot(next.clientX - startX, next.clientY - startY) < 5) return
|
|
2588
|
+
moved = true
|
|
2589
|
+
setFolderGhost({ x: next.clientX, y: next.clientY, member, moved: true })
|
|
2590
|
+
}
|
|
2591
|
+
const finish = (next) => {
|
|
2592
|
+
window.removeEventListener('pointermove', move)
|
|
2593
|
+
window.removeEventListener('pointerup', finish)
|
|
2594
|
+
window.removeEventListener('pointercancel', finish)
|
|
2595
|
+
setFolderGhost(null)
|
|
2596
|
+
if (!moved) return
|
|
2597
|
+
const viewport = viewportRef.current
|
|
2598
|
+
if (!viewport) return
|
|
2599
|
+
const bounds = viewport.getBoundingClientRect()
|
|
2600
|
+
const insideCanvas =
|
|
2601
|
+
next.clientX >= bounds.left && next.clientX <= bounds.right && next.clientY >= bounds.top && next.clientY <= bounds.bottom
|
|
2602
|
+
if (!insideCanvas) return
|
|
2603
|
+
const camera = cameraRef.current
|
|
2604
|
+
const worldX = (next.clientX - bounds.left - camera.x) / camera.scale
|
|
2605
|
+
const worldY = (next.clientY - bounds.top - camera.y) / camera.scale
|
|
2606
|
+
// Dropping back on the expanded folder itself keeps the card filed.
|
|
2607
|
+
if (
|
|
2608
|
+
worldX >= folderCard.x && worldX <= folderCard.x + CARD_WIDTH &&
|
|
2609
|
+
worldY >= folderCard.y && worldY <= folderCard.y + CARD_HEIGHT
|
|
2610
|
+
) return
|
|
2611
|
+
detachFolderMember(folderCard.folderId, member.key, {
|
|
2612
|
+
x: Math.round(worldX - CARD_WIDTH / 2),
|
|
2613
|
+
y: Math.round(worldY - CARD_HEIGHT / 2),
|
|
2614
|
+
})
|
|
2615
|
+
// Leave the ghost on screen for a short drop animation while the real
|
|
2616
|
+
// card pops in at the pointer.
|
|
2617
|
+
setFolderGhost({ x: next.clientX, y: next.clientY, member, moved: true, dropping: true })
|
|
2618
|
+
window.setTimeout(() => setFolderGhost((current) => (current?.dropping ? null : current)), 200)
|
|
2619
|
+
}
|
|
2620
|
+
window.addEventListener('pointermove', move)
|
|
2621
|
+
window.addEventListener('pointerup', finish)
|
|
2622
|
+
window.addEventListener('pointercancel', finish)
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2158
2625
|
/** Drag one card inside the world layer (screen delta ÷ zoom). */
|
|
2159
2626
|
const onCardDragStart = (event, card) => {
|
|
2160
2627
|
if (event.button !== 0) return
|
|
@@ -2229,6 +2696,26 @@ window.__ModuleLoader__.load({
|
|
|
2229
2696
|
moved = true
|
|
2230
2697
|
suppressClickRef.current = true
|
|
2231
2698
|
scheduleApply()
|
|
2699
|
+
const target = dropTargetAt()
|
|
2700
|
+
const targetKey = target?.key ?? null
|
|
2701
|
+
if (dropTargetRef.current !== targetKey) {
|
|
2702
|
+
dropTargetRef.current = targetKey
|
|
2703
|
+
setDropTargetKey(targetKey)
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
const dropTargetAt = () => {
|
|
2707
|
+
const cards = layoutRef.current?.cards ?? []
|
|
2708
|
+
const camera = cameraRef.current
|
|
2709
|
+
const worldX = (pointer.x - rect.left - camera.x) / camera.scale
|
|
2710
|
+
const worldY = (pointer.y - rect.top - camera.y) / camera.scale
|
|
2711
|
+
for (let index = cards.length - 1; index >= 0; index -= 1) {
|
|
2712
|
+
const candidate = cards[index]
|
|
2713
|
+
if (candidate.key === card.key) continue
|
|
2714
|
+
if (worldX < candidate.x || worldX > candidate.x + CARD_WIDTH) continue
|
|
2715
|
+
if (worldY < candidate.y || worldY > candidate.y + CARD_HEIGHT) continue
|
|
2716
|
+
return candidate
|
|
2717
|
+
}
|
|
2718
|
+
return null
|
|
2232
2719
|
}
|
|
2233
2720
|
const finish = () => {
|
|
2234
2721
|
window.removeEventListener('pointermove', move)
|
|
@@ -2244,7 +2731,28 @@ window.__ModuleLoader__.load({
|
|
|
2244
2731
|
if (latest !== null) apply()
|
|
2245
2732
|
}
|
|
2246
2733
|
draggingRef.current = false
|
|
2734
|
+
dropTargetRef.current = null
|
|
2735
|
+
setDropTargetKey(null)
|
|
2247
2736
|
if (moved) {
|
|
2737
|
+
const target = dropTargetAt()
|
|
2738
|
+
if (target) {
|
|
2739
|
+
const nextFolders = mergeCardFolder(foldersRef.current, card, target)
|
|
2740
|
+
if (nextFolders !== foldersRef.current) {
|
|
2741
|
+
// Let the hovered card dim/scale and the dragged card shrink into it
|
|
2742
|
+
// for a moment before the folder appears, like a phone home-screen
|
|
2743
|
+
// folder animation.
|
|
2744
|
+
setFolding({ sourceKey: card.key, targetKey: target.key })
|
|
2745
|
+
if (foldTimerRef.current) clearTimeout(foldTimerRef.current)
|
|
2746
|
+
foldTimerRef.current = window.setTimeout(() => {
|
|
2747
|
+
foldTimerRef.current = null
|
|
2748
|
+
storeFolders(nextFolders, true)
|
|
2749
|
+
setFolding(null)
|
|
2750
|
+
window.setTimeout(() => { suppressClickRef.current = false }, 80)
|
|
2751
|
+
}, 230)
|
|
2752
|
+
return
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
setFolding(null)
|
|
2248
2756
|
storePositions(positionsRef.current, true)
|
|
2249
2757
|
window.setTimeout(() => { suppressClickRef.current = false }, 80)
|
|
2250
2758
|
}
|
|
@@ -2342,6 +2850,13 @@ window.__ModuleLoader__.load({
|
|
|
2342
2850
|
}
|
|
2343
2851
|
positionsRef.current = {}
|
|
2344
2852
|
setPositions({})
|
|
2853
|
+
try {
|
|
2854
|
+
if (foldersKey) window.localStorage.removeItem(foldersKey)
|
|
2855
|
+
} catch {
|
|
2856
|
+
// Storage can be disabled.
|
|
2857
|
+
}
|
|
2858
|
+
foldersRef.current = []
|
|
2859
|
+
setFolders([])
|
|
2345
2860
|
}
|
|
2346
2861
|
return h(
|
|
2347
2862
|
'div',
|
|
@@ -2492,6 +3007,12 @@ window.__ModuleLoader__.load({
|
|
|
2492
3007
|
expanded: canvasExpanded,
|
|
2493
3008
|
onToggleExpand: () => setCanvasExpanded((value) => !value),
|
|
2494
3009
|
onDragStart: onCardDragStart,
|
|
3010
|
+
onUnpackFolder: unpackFolder,
|
|
3011
|
+
dropTargetKey,
|
|
3012
|
+
folding,
|
|
3013
|
+
expandedFolderId,
|
|
3014
|
+
onToggleFolder: toggleFolder,
|
|
3015
|
+
onMemberDragStart: startFolderMemberDrag,
|
|
2495
3016
|
onResetLayout: resetCardPositions,
|
|
2496
3017
|
autoPan,
|
|
2497
3018
|
panSpeed,
|
|
@@ -3362,7 +3883,7 @@ window.__ModuleLoader__.load({
|
|
|
3362
3883
|
width: BOARD_NOTE_W,
|
|
3363
3884
|
height: BOARD_NOTE_H,
|
|
3364
3885
|
z: index,
|
|
3365
|
-
color:
|
|
3886
|
+
color: '#ffffff',
|
|
3366
3887
|
}
|
|
3367
3888
|
}
|
|
3368
3889
|
|
|
@@ -3826,18 +4347,26 @@ window.__ModuleLoader__.load({
|
|
|
3826
4347
|
const [state, setState] = React.useState({ loading: true, board: null, error: null })
|
|
3827
4348
|
const [draft, setDraft] = React.useState(null)
|
|
3828
4349
|
const [busy, setBusy] = React.useState('')
|
|
4350
|
+
const defaultDialogSize = () => {
|
|
4351
|
+
const viewportWidth = typeof window !== 'undefined' && Number.isFinite(window.innerWidth) ? window.innerWidth : 1280
|
|
4352
|
+
const viewportHeight = typeof window !== 'undefined' && Number.isFinite(window.innerHeight) ? window.innerHeight : 900
|
|
4353
|
+
return {
|
|
4354
|
+
width: Math.min(1100, Math.max(680, Math.round(viewportWidth * 0.8))),
|
|
4355
|
+
height: Math.min(820, Math.max(480, Math.round(viewportHeight * 0.82))),
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
3829
4358
|
const [dialogSize, setDialogSize] = React.useState(() => {
|
|
3830
|
-
const fallback = { width: 680, height: 520 }
|
|
3831
4359
|
try {
|
|
3832
4360
|
const raw = JSON.parse(window.localStorage.getItem('dsh-timeback:board-dialog-size') || 'null')
|
|
3833
4361
|
if (raw && Number.isFinite(raw.width) && Number.isFinite(raw.height)) {
|
|
4362
|
+
// Migrate the old fixed 680x520 default to the new larger responsive one.
|
|
4363
|
+
if (raw.width === 680 && raw.height === 520) return defaultDialogSize()
|
|
3834
4364
|
return { width: Math.min(1200, Math.max(340, raw.width)), height: Math.min(900, Math.max(260, raw.height)) }
|
|
3835
4365
|
}
|
|
3836
4366
|
} catch {
|
|
3837
4367
|
// fall through to the default
|
|
3838
4368
|
}
|
|
3839
|
-
|
|
3840
|
-
return { width: fallback.width, height: Math.max(320, Math.min(640, height)) }
|
|
4369
|
+
return defaultDialogSize()
|
|
3841
4370
|
})
|
|
3842
4371
|
const dialogSizeRef = React.useRef(dialogSize)
|
|
3843
4372
|
dialogSizeRef.current = dialogSize
|
|
@@ -3929,6 +4458,7 @@ window.__ModuleLoader__.load({
|
|
|
3929
4458
|
|
|
3930
4459
|
React.useEffect(() => () => {
|
|
3931
4460
|
if (saveTimerRef.current) clearTimeout(saveTimerRef.current)
|
|
4461
|
+
if (foldTimerRef.current) clearTimeout(foldTimerRef.current)
|
|
3932
4462
|
}, [])
|
|
3933
4463
|
|
|
3934
4464
|
/** Zoom around one viewport point while keeping that content anchored. */
|
|
@@ -4079,6 +4609,19 @@ window.__ModuleLoader__.load({
|
|
|
4079
4609
|
}, 420)
|
|
4080
4610
|
}
|
|
4081
4611
|
|
|
4612
|
+
/** Persist a critical canvas layout change immediately (not debounced). */
|
|
4613
|
+
const saveCanvasNow = async (next) => {
|
|
4614
|
+
canvasRef.current = next
|
|
4615
|
+
setCanvas(next)
|
|
4616
|
+
if (saveTimerRef.current) {
|
|
4617
|
+
clearTimeout(saveTimerRef.current)
|
|
4618
|
+
saveTimerRef.current = null
|
|
4619
|
+
}
|
|
4620
|
+
const body = await request('action', { method: 'POST', body: { action: 'board-canvas', canvas: next } })
|
|
4621
|
+
setState((previous) => ({ ...previous, board: body.board ?? previous.board, error: null }))
|
|
4622
|
+
return body
|
|
4623
|
+
}
|
|
4624
|
+
|
|
4082
4625
|
const persistDialogSize = (value) => {
|
|
4083
4626
|
try {
|
|
4084
4627
|
window.localStorage.setItem('dsh-timeback:board-dialog-size', JSON.stringify(value))
|
|
@@ -4087,7 +4630,7 @@ window.__ModuleLoader__.load({
|
|
|
4087
4630
|
}
|
|
4088
4631
|
}
|
|
4089
4632
|
const resetDialogSize = () => {
|
|
4090
|
-
const next =
|
|
4633
|
+
const next = defaultDialogSize()
|
|
4091
4634
|
setDialogSize(next)
|
|
4092
4635
|
persistDialogSize(next)
|
|
4093
4636
|
}
|
|
@@ -4179,8 +4722,17 @@ window.__ModuleLoader__.load({
|
|
|
4179
4722
|
const stage = stageRef.current
|
|
4180
4723
|
return stage ? { layer: 'background', noteId: '', rect: stage.getBoundingClientRect() } : null
|
|
4181
4724
|
}
|
|
4182
|
-
const startCreate = () => setDraft({ id: '', title: '', body: '', preview: false, busy: false, error: null })
|
|
4183
|
-
const startEdit = (entry) =>
|
|
4725
|
+
const startCreate = () => setDraft({ id: '', title: '', body: '', preview: false, busy: false, error: null, color: '#ffffff' })
|
|
4726
|
+
const startEdit = (entry) =>
|
|
4727
|
+
setDraft({
|
|
4728
|
+
id: entry.id,
|
|
4729
|
+
title: entry.title,
|
|
4730
|
+
body: entry.body,
|
|
4731
|
+
preview: false,
|
|
4732
|
+
busy: false,
|
|
4733
|
+
error: null,
|
|
4734
|
+
color: canvasRef.current.notes[entry.id]?.color || '#ffffff',
|
|
4735
|
+
})
|
|
4184
4736
|
const closeDraft = () => {
|
|
4185
4737
|
if (draft && !draft.busy) setDraft(null)
|
|
4186
4738
|
}
|
|
@@ -4200,17 +4752,33 @@ window.__ModuleLoader__.load({
|
|
|
4200
4752
|
method: 'POST',
|
|
4201
4753
|
body: { action: 'note-save', ...(draft.id ? { id: draft.id } : {}), title: draft.title, body: draft.body },
|
|
4202
4754
|
})
|
|
4203
|
-
|
|
4204
|
-
setDraft(null)
|
|
4755
|
+
let board = body.board ?? state.board
|
|
4205
4756
|
setState({ loading: false, board, error: null })
|
|
4206
|
-
// Put a brand-new note where the sticky board expects one
|
|
4757
|
+
// Put a brand-new note where the sticky board expects one, with the
|
|
4758
|
+
// colour chosen in the dialog; persist it before closing the dialog so
|
|
4759
|
+
// the visible sticky and the stored layout can never disagree.
|
|
4207
4760
|
if (!draft.id && body.entry?.id && board && !canvasRef.current.notes[body.entry.id]) {
|
|
4208
4761
|
const index = Math.max(0, (board.entries?.length ?? 1) - 1)
|
|
4209
|
-
|
|
4762
|
+
const layoutBody = await saveCanvasNow({
|
|
4210
4763
|
...canvasRef.current,
|
|
4211
|
-
notes: {
|
|
4764
|
+
notes: {
|
|
4765
|
+
...canvasRef.current.notes,
|
|
4766
|
+
[body.entry.id]: { ...autoBoardLayout(index), color: draft.color || '#ffffff' },
|
|
4767
|
+
},
|
|
4212
4768
|
})
|
|
4769
|
+
board = layoutBody?.board ?? board
|
|
4770
|
+
} else if (draft.id && canvasRef.current.notes[draft.id]) {
|
|
4771
|
+
const layoutBody = await saveCanvasNow({
|
|
4772
|
+
...canvasRef.current,
|
|
4773
|
+
notes: {
|
|
4774
|
+
...canvasRef.current.notes,
|
|
4775
|
+
[draft.id]: { ...canvasRef.current.notes[draft.id], color: draft.color || '#ffffff' },
|
|
4776
|
+
},
|
|
4777
|
+
})
|
|
4778
|
+
board = layoutBody?.board ?? board
|
|
4213
4779
|
}
|
|
4780
|
+
setDraft(null)
|
|
4781
|
+
setState({ loading: false, board, error: null })
|
|
4214
4782
|
} catch (error) {
|
|
4215
4783
|
setDraft({ ...draft, busy: false, error: error?.message || String(error) })
|
|
4216
4784
|
}
|
|
@@ -4852,9 +5420,9 @@ window.__ModuleLoader__.load({
|
|
|
4852
5420
|
},
|
|
4853
5421
|
`🔗 ${t('board.openMd')}`,
|
|
4854
5422
|
),
|
|
4855
|
-
h('div', { className: 'tb-
|
|
5423
|
+
h('div', { className: 'tb-sticky-md' }, ...(entry.body.trim() ? renderMarkdown(entry.body, `sticky-${entry.id}`) : [h('span', { key: 'empty' }, t('board.empty'))])),
|
|
4856
5424
|
)
|
|
4857
|
-
: h('div', { className: 'tb-sticky-body md' },
|
|
5425
|
+
: h('div', { className: 'tb-sticky-body' }, h('div', { className: 'tb-sticky-md' }, ...(entry.body.trim() ? renderMarkdown(entry.body, `sticky-${entry.id}`) : [h('span', { key: 'empty' }, t('board.empty'))]))),
|
|
4858
5426
|
drawingLayer(canvas.drawings[entry.id] ?? [], `d-${entry.id}`),
|
|
4859
5427
|
...BOARD_ANCHORS.map((anchor) =>
|
|
4860
5428
|
h('div', {
|
|
@@ -5197,6 +5765,38 @@ window.__ModuleLoader__.load({
|
|
|
5197
5765
|
disabled: draft.busy,
|
|
5198
5766
|
onChange: (event) => setDraft({ ...draft, title: event.target.value }),
|
|
5199
5767
|
}),
|
|
5768
|
+
h(
|
|
5769
|
+
'div',
|
|
5770
|
+
{ className: 'tb-sticky-color-row', style: { flexWrap: 'nowrap', overflow: 'hidden' } },
|
|
5771
|
+
h('span', { className: 'tb-color-label', style: { flex: '0 0 auto' } }, t('board.stickyColor')),
|
|
5772
|
+
h('span', {
|
|
5773
|
+
className: 'tb-sticky-color-preview',
|
|
5774
|
+
style: { background: draft.color || '#ffffff', flex: '0 0 auto' },
|
|
5775
|
+
title: draft.color || '#ffffff',
|
|
5776
|
+
}),
|
|
5777
|
+
...BOARD_COLORS.map((value) =>
|
|
5778
|
+
h('button', {
|
|
5779
|
+
key: `sticky-${value}`,
|
|
5780
|
+
type: 'button',
|
|
5781
|
+
className: `tb-sticky-color-btn${(draft.color || '#ffffff').toLowerCase() === value ? ' on' : ''}`,
|
|
5782
|
+
style: { background: value, width: 26, height: 26, minWidth: 26, minHeight: 26, flex: '0 0 auto', padding: 0 },
|
|
5783
|
+
title: value,
|
|
5784
|
+
'aria-label': `${t('board.stickyColor')} ${value}`,
|
|
5785
|
+
disabled: draft.busy,
|
|
5786
|
+
onClick: () => setDraft({ ...draft, color: value }),
|
|
5787
|
+
}),
|
|
5788
|
+
),
|
|
5789
|
+
h('span', { className: 'tb-color-label', style: { marginLeft: 'auto', flex: '0 0 auto' } }, t('md.customColor')),
|
|
5790
|
+
h('input', {
|
|
5791
|
+
type: 'color',
|
|
5792
|
+
className: 'tb-sticky-color-input',
|
|
5793
|
+
value: draft.color || '#ffffff',
|
|
5794
|
+
title: t('board.stickyColor'),
|
|
5795
|
+
disabled: draft.busy,
|
|
5796
|
+
style: { width: 30, height: 26, minWidth: 30, flex: '0 0 auto' },
|
|
5797
|
+
onChange: (event) => setDraft({ ...draft, color: event.target.value }),
|
|
5798
|
+
}),
|
|
5799
|
+
),
|
|
5200
5800
|
h(MarkdownEditor, {
|
|
5201
5801
|
value: draft.body,
|
|
5202
5802
|
onChange: (next) => setDraft({ ...draft, body: next }),
|
|
@@ -5230,6 +5830,12 @@ window.__ModuleLoader__.load({
|
|
|
5230
5830
|
window.__TIMEBACK_TEST__.WorkspacePathSelector = WorkspacePathSelector
|
|
5231
5831
|
window.__TIMEBACK_TEST__.markdownToEditorHtml = markdownToEditorHtml
|
|
5232
5832
|
window.__TIMEBACK_TEST__.domToMarkdown = domToMarkdown
|
|
5833
|
+
window.__TIMEBACK_TEST__.turnRows = turnRows
|
|
5834
|
+
window.__TIMEBACK_TEST__.mergeCardFolder = mergeCardFolder
|
|
5835
|
+
window.__TIMEBACK_TEST__.removeFolderMember = removeFolderMember
|
|
5836
|
+
window.__TIMEBACK_TEST__.layoutTree = layoutTree
|
|
5837
|
+
window.__TIMEBACK_TEST__.CanvasFolderCard = CanvasFolderCard
|
|
5838
|
+
window.__TIMEBACK_TEST__.TreeCanvas = TreeCanvas
|
|
5233
5839
|
}
|
|
5234
5840
|
|
|
5235
5841
|
return {
|
package/docs/MARKET.md
CHANGED
|
@@ -78,12 +78,12 @@ dshmarket;要让所有人的 dshmarket 搜到,必须走下一节的公共目
|
|
|
78
78
|
|
|
79
79
|
## 4. npm(已发布 0.6.0)
|
|
80
80
|
|
|
81
|
-
`dsh-timeback@0.7.
|
|
81
|
+
`dsh-timeback@0.7.5` 已发布到官方 npm(<https://www.npmjs.com/package/dsh-timeback>),
|
|
82
82
|
用户可以直接安装/固定版本:
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
85
|
dsh plugin --profile web add dsh-timeback
|
|
86
|
-
dsh plugin --profile web add dsh-timeback@0.7.
|
|
86
|
+
dsh plugin --profile web add dsh-timeback@0.7.5
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
awesome 目录 CI 会从 npm 自动补充映射,之后市场安装和更新会走 registry。发布流程参考:
|
package/package.json
CHANGED