dsh-timeback 0.7.7 → 0.7.8
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 +22 -2
- package/client.js +1535 -35
- package/docs/MARKET.md +2 -2
- package/index.js +16 -2
- package/package.json +1 -1
- package/src/notes.js +59 -4
- package/src/service.js +12 -2
package/client.js
CHANGED
|
@@ -23,12 +23,13 @@ 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.8+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. */
|
|
30
30
|
let openPanelBridge = null
|
|
31
31
|
let openBoardBridge = null
|
|
32
|
+
let sessionApi = null
|
|
32
33
|
|
|
33
34
|
const DICT = {
|
|
34
35
|
zh: {
|
|
@@ -60,6 +61,7 @@ window.__ModuleLoader__.load({
|
|
|
60
61
|
'panel.warning': '回退会按快照覆盖工作区文件,并删除快照之后新增的文件;回退前会自动保存安全快照。',
|
|
61
62
|
'panel.confirmRewind': '将创建新分支并恢复工作区到:{who}\n\n{warning}\n\n确定继续?',
|
|
62
63
|
'panel.confirmFiles': '将把工作区文件恢复为:{who}\n\n{warning}\n\n确定继续?',
|
|
64
|
+
'panel.branchNamePrompt': '输入新分支会话的名称:',
|
|
63
65
|
'panel.confirmBranchOnly': '将在该检查点创建新分支,不修改工作区文件:{who}\n\n确定继续?',
|
|
64
66
|
'panel.confirmCheckpoint': '将记录当前对话位置与工作区快照。确定继续?',
|
|
65
67
|
'panel.deleteWarning': '快照之后新增的文件会被删除,之后修改的文件会被覆盖。回退前会自动保存安全快照,可用它撤销本次恢复。',
|
|
@@ -119,6 +121,28 @@ window.__ModuleLoader__.load({
|
|
|
119
121
|
'md.empty': '空文档,直接输入即可',
|
|
120
122
|
'md.hint': '直接打字即可:选中文字后点工具栏按钮会立即格式化(例如选中“你好”按 B 立即加粗);也可切换源码/预览。',
|
|
121
123
|
'board.newSticky': '新建便签',
|
|
124
|
+
'board.newDoc': '新建完整 md',
|
|
125
|
+
'board.addText': '文本',
|
|
126
|
+
'board.newText': '添加文本',
|
|
127
|
+
'board.editText': '编辑文本',
|
|
128
|
+
'board.textPlaceholder': '输入文本…',
|
|
129
|
+
'board.fontColor': '字体颜色',
|
|
130
|
+
'board.fontSize': '字号',
|
|
131
|
+
'board.deleteText': '删除文本',
|
|
132
|
+
'board.insert': '插入',
|
|
133
|
+
'board.insertHint': '添加表格、导入表格或导入图片窗口',
|
|
134
|
+
'board.table': '表格',
|
|
135
|
+
'board.importTable': '导入表格',
|
|
136
|
+
'board.importImage': '导入图片',
|
|
137
|
+
'board.tableHint': '窗口可拖动;右下角可缩放。表格内容每行一行、单元格用 Tab 分隔,也支持 CSV 和 Markdown 表格。',
|
|
138
|
+
'board.addRow': '加行',
|
|
139
|
+
'board.addCol': '加列',
|
|
140
|
+
'board.tableTitle': '表格标题',
|
|
141
|
+
'board.fromFile': '从文件导入',
|
|
142
|
+
'board.chooseImage': '选择图片',
|
|
143
|
+
'board.imageHint': '图片窗口可拖动,右下角可缩放;大小上限约 1.5MB。',
|
|
144
|
+
'board.windowTitle': '窗口标题',
|
|
145
|
+
'board.docHint': '完整 Markdown 文档页:默认展开预览,可拖动右下角调整大小。',
|
|
122
146
|
'board.stickyColor': '便签颜色',
|
|
123
147
|
'board.stickyHint': '便签可拖动;画笔可在方格纸背景或便签上绘制,橡皮擦除笔画。',
|
|
124
148
|
'board.resizeNote': '拖动缩放便签',
|
|
@@ -126,6 +150,7 @@ window.__ModuleLoader__.load({
|
|
|
126
150
|
'board.drawOnStickyOn': '便签可画:开',
|
|
127
151
|
'board.drawOnStickyOff': '便签可画:关',
|
|
128
152
|
'board.drawOnStickyHint': '开启后画笔/图形可直接画在便签上;关闭则只画在方格纸背景。',
|
|
153
|
+
'board.drawOnStickyNotice': '便签可画当前为关:先在工具栏打开「便签可画:开」才能在便签上绘制。',
|
|
129
154
|
'board.center': '自动调整',
|
|
130
155
|
'board.zoomIn': '放大画布',
|
|
131
156
|
'board.zoomOut': '缩小画布',
|
|
@@ -313,6 +338,7 @@ window.__ModuleLoader__.load({
|
|
|
313
338
|
'panel.warning': 'Rewinding overwrites workspace files from the snapshot and deletes files created after it. A safety snapshot is taken first.',
|
|
314
339
|
'panel.confirmRewind': 'Create a new branch and restore the workspace to: {who}\n\n{warning}\n\nContinue?',
|
|
315
340
|
'panel.confirmFiles': 'Restore workspace files to: {who}\n\n{warning}\n\nContinue?',
|
|
341
|
+
'panel.branchNamePrompt': 'Name for the new branch session:',
|
|
316
342
|
'panel.confirmBranchOnly': 'Create a new branch at this checkpoint without touching files: {who}\n\nContinue?',
|
|
317
343
|
'panel.confirmCheckpoint': 'Record the current conversation position and a workspace snapshot?',
|
|
318
344
|
'panel.deleteWarning': 'Files created after the snapshot are deleted and files changed later are overwritten. A safety snapshot is taken first; it can undo this restore.',
|
|
@@ -372,6 +398,28 @@ window.__ModuleLoader__.load({
|
|
|
372
398
|
'md.empty': 'Empty document — just start typing',
|
|
373
399
|
'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.',
|
|
374
400
|
'board.newSticky': 'New sticky',
|
|
401
|
+
'board.newDoc': 'New full MD',
|
|
402
|
+
'board.addText': 'Text',
|
|
403
|
+
'board.newText': 'Add text',
|
|
404
|
+
'board.editText': 'Edit text',
|
|
405
|
+
'board.textPlaceholder': 'Type text…',
|
|
406
|
+
'board.fontColor': 'Font colour',
|
|
407
|
+
'board.fontSize': 'Font size',
|
|
408
|
+
'board.deleteText': 'Delete text',
|
|
409
|
+
'board.insert': 'Insert',
|
|
410
|
+
'board.insertHint': 'Add a table, import a table, or import an image window',
|
|
411
|
+
'board.table': 'Table',
|
|
412
|
+
'board.importTable': 'Import table',
|
|
413
|
+
'board.importImage': 'Import image',
|
|
414
|
+
'board.tableHint': 'Windows can be dragged and resized from the bottom-right. Each table line is a row; separate cells with Tab. CSV and Markdown tables are accepted.',
|
|
415
|
+
'board.addRow': 'Add row',
|
|
416
|
+
'board.addCol': 'Add column',
|
|
417
|
+
'board.tableTitle': 'Table title',
|
|
418
|
+
'board.fromFile': 'Import from file',
|
|
419
|
+
'board.chooseImage': 'Choose image',
|
|
420
|
+
'board.imageHint': 'Image windows can be dragged and resized from the bottom-right; max about 1.5MB.',
|
|
421
|
+
'board.windowTitle': 'Window title',
|
|
422
|
+
'board.docHint': 'Full Markdown document page: expanded preview by default, resize from the bottom-right corner.',
|
|
375
423
|
'board.stickyColor': 'Sticky colour',
|
|
376
424
|
'board.stickyHint': 'Sticky notes are draggable; draw on the grid or on a note, erase strokes with the eraser. Clicking outside the editor auto-saves.',
|
|
377
425
|
'board.resizeNote': 'Drag to resize the sticky',
|
|
@@ -379,6 +427,7 @@ window.__ModuleLoader__.load({
|
|
|
379
427
|
'board.drawOnStickyOn': 'Sticky drawing: on',
|
|
380
428
|
'board.drawOnStickyOff': 'Sticky drawing: off',
|
|
381
429
|
'board.drawOnStickyHint': 'When on, pen/shape tools draw directly on sticky notes; when off they only draw on the grid.',
|
|
430
|
+
'board.drawOnStickyNotice': 'Sticky drawing is off: turn on “Sticky drawing: on” in the toolbar before drawing on a sticky.',
|
|
382
431
|
'board.center': 'Auto fit',
|
|
383
432
|
'board.zoomIn': 'Zoom in',
|
|
384
433
|
'board.zoomOut': 'Zoom out',
|
|
@@ -624,6 +673,8 @@ window.__ModuleLoader__.load({
|
|
|
624
673
|
.tb-canvas-btn.on{color:var(--dsw-alias-state-success-primary,#3ecf8e)}
|
|
625
674
|
.tb-canvas-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
626
675
|
.tb-world{position:absolute;left:0;top:0;transform-origin:0 0}
|
|
676
|
+
.tb-tree-doodles{position:absolute;left:0;top:0;overflow:visible;z-index:50}
|
|
677
|
+
.tb-tree-doodles polyline{fill:none;stroke-linecap:round;stroke-linejoin:round}
|
|
627
678
|
.tb-world-links{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
|
|
628
679
|
.tb-link{fill:none;stroke-width:1.6;opacity:.55}
|
|
629
680
|
.tb-link.fork{stroke-width:2;opacity:.75}
|
|
@@ -671,6 +722,10 @@ window.__ModuleLoader__.load({
|
|
|
671
722
|
.tb-folder-row:active{cursor:grabbing}
|
|
672
723
|
.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}
|
|
673
724
|
.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}
|
|
725
|
+
.tb-folder-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}
|
|
726
|
+
.tb-folder-name-input{flex:1;min-width:0;box-sizing:border-box;background:var(--dsw-alias-bg-base,#16181d);color:var(--dsw-alias-label-primary,#e6e6e6);border:1px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);border-radius:4px;padding:1px 5px;font:inherit;outline:none}
|
|
727
|
+
.tb-folder-rename{appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));background:transparent;color:var(--dsw-alias-label-secondary,#9aa0a6);border-radius:4px;padding:0 5px;line-height:15px;font-size:10px;cursor:pointer;flex:0 0 auto}
|
|
728
|
+
.tb-folder-rename:hover{color:var(--dsw-alias-label-primary,#e6e6e6);border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6)}
|
|
674
729
|
.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}
|
|
675
730
|
.tb-folder-ghost-label{font-weight:700;color:var(--dsw-alias-label-primary,#e6e6e6);white-space:nowrap}
|
|
676
731
|
.tb-folder-ghost-prompt{color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
@@ -690,6 +745,17 @@ window.__ModuleLoader__.load({
|
|
|
690
745
|
.tb-card-editnote.has{color:var(--tb-color,#4d7cfe);border-color:color-mix(in srgb, var(--tb-color,#4d7cfe) 50%, transparent)}
|
|
691
746
|
.tb-overlay{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.35);display:flex;justify-content:flex-end;align-items:stretch}
|
|
692
747
|
.tb-overlay.center{justify-content:center;align-items:center;padding:16px}
|
|
748
|
+
.tb-chat-dialog{width:min(640px,94vw);height:min(680px,88vh);display:flex;flex-direction:column;gap:8px}
|
|
749
|
+
.tb-chat-messages{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:8px;padding:2px 2px 4px}
|
|
750
|
+
.tb-chat-msg{border-radius:8px;padding:7px 9px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));background:var(--dsw-alias-bg-base,#1b1d22)}
|
|
751
|
+
.tb-chat-msg.user{background:rgba(77,124,254,.13);border-color:rgba(77,124,254,.4)}
|
|
752
|
+
.tb-chat-msg.assistant{background:rgba(62,207,142,.1);border-color:rgba(62,207,142,.3)}
|
|
753
|
+
.tb-chat-role{font-size:10px;font-weight:700;opacity:.65;margin-bottom:4px}
|
|
754
|
+
.tb-chat-text{white-space:pre-wrap;word-break:break-word;font-size:13px;line-height:1.55}
|
|
755
|
+
.tb-chat-composer{display:flex;flex-direction:column;gap:6px;border-top:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));padding-top:8px}
|
|
756
|
+
.tb-chat-composer textarea{box-sizing:border-box;width:100%;min-height:64px;max-height:180px;resize:vertical;background:var(--dsw-alias-bg-base,#16181d);color:var(--dsw-alias-label-primary,#e6e6e6);border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:6px;padding:7px 8px;font:inherit;font-size:13px;line-height:1.5;outline:none}
|
|
757
|
+
.tb-chat-composer textarea:focus{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
758
|
+
.tb-chat-actions{display:flex;align-items:center;gap:8px}
|
|
693
759
|
.tb-note-dialog{width:min(520px,92vw);height:100%;background:var(--dsw-alias-bg-base,#16181d);border-left:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));padding:12px;display:flex;flex-direction:column;gap:8px;overflow:auto;box-shadow:-8px 0 24px rgba(0,0,0,.28)}
|
|
694
760
|
.tb-note-dialog textarea,.tb-board-dialog textarea,.tb-board-dialog input{width:100%;box-sizing:border-box;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.04));color:var(--dsw-alias-label-primary,#e6e6e6);border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:7px;padding:7px 9px;font-size:12px;line-height:1.5;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;resize:vertical}
|
|
695
761
|
.tb-note-dialog textarea{min-height:180px}
|
|
@@ -703,6 +769,7 @@ window.__ModuleLoader__.load({
|
|
|
703
769
|
.tb-resize-handle.se{right:0;bottom:0;width:18px;height:18px;cursor:nwse-resize}
|
|
704
770
|
.tb-resize-handle.se:after{content:"";position:absolute;right:3px;bottom:3px;width:8px;height:8px;border-right:2px solid var(--dsw-alias-label-secondary,#9aa0a6);border-bottom:2px solid var(--dsw-alias-label-secondary,#9aa0a6);opacity:.55}
|
|
705
771
|
.tb-board-testid{display:none}
|
|
772
|
+
.tb-board-toast{position:absolute;top:88px;left:50%;transform:translateX(-50%);z-index:60;max-width:min(520px,86vw);padding:8px 14px;border-radius:999px;background:#f7f3e8;color:#3a3326;border:1px solid rgba(0,0,0,.12);box-shadow:0 8px 22px rgba(0,0,0,.28);font-size:12px;line-height:1.45;text-align:center;pointer-events:none}
|
|
706
773
|
.tb-board-toolbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:6px 12px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))}
|
|
707
774
|
.tb-tool{appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));background:transparent;color:var(--dsw-alias-label-secondary,#9aa0a6);border-radius:6px;padding:3px 8px;font-size:11.5px;cursor:pointer;line-height:1.4}
|
|
708
775
|
.tb-shape-wrap{position:relative;display:inline-flex}
|
|
@@ -741,6 +808,44 @@ window.__ModuleLoader__.load({
|
|
|
741
808
|
.tb-board-world{position:relative;flex:none;contain:layout paint}
|
|
742
809
|
.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}
|
|
743
810
|
.tb-board-bgdraw{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
|
|
811
|
+
.tb-window-insert{position:relative;display:inline-flex}
|
|
812
|
+
.tb-insert-menu{left:0;top:calc(100% + 4px);min-width:180px}
|
|
813
|
+
.tb-board-window{position:absolute;display:flex;flex-direction:column;box-sizing:border-box;border-radius:8px;overflow:hidden;background:var(--dsw-alias-bg-elevated,#22252b);border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.18));box-shadow:0 8px 24px rgba(0,0,0,.3);color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
814
|
+
.tb-board-window.selected{outline:2px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);outline-offset:1px}
|
|
815
|
+
.tb-board-window-head{display:flex;align-items:center;gap:6px;padding:4px 6px;background:rgba(255,255,255,.05);cursor:grab;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));flex:0 0 auto;user-select:none}
|
|
816
|
+
.tb-board-window-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:600}
|
|
817
|
+
.tb-board-window-actions{display:flex;gap:2px}
|
|
818
|
+
.tb-board-window-actions button{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#c9ced6);border-radius:3px;font-size:10px;line-height:15px;padding:0 4px;cursor:pointer}
|
|
819
|
+
.tb-board-window-actions button:hover{background:rgba(255,255,255,.12);color:#fff}
|
|
820
|
+
.tb-board-window-body{flex:1;min-height:0;overflow:auto;position:relative}
|
|
821
|
+
.tb-board-window-body table{border-collapse:collapse;width:100%;background:rgba(255,255,255,.02);font-size:12px;color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
822
|
+
.tb-board-window-body th,.tb-board-window-body td{border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));padding:4px 6px;text-align:left;vertical-align:top;white-space:pre-wrap;word-break:break-word;min-width:48px}
|
|
823
|
+
.tb-board-window-body th{background:rgba(255,255,255,.07);font-weight:600;position:sticky;top:0;z-index:1}
|
|
824
|
+
.tb-board-window-body img{display:block;width:100%;height:100%;object-fit:contain;background:rgba(0,0,0,.14)}
|
|
825
|
+
.tb-board-window-resize{position:absolute;right:0;bottom:0;width:14px;height:14px;cursor:nwse-resize;z-index:5;opacity:.55;background:linear-gradient(135deg,transparent 45%,rgba(255,255,255,.55) 45%,rgba(255,255,255,.55) 55%,transparent 55%)}
|
|
826
|
+
.tb-window-editor-dialog{width:min(760px,94vw);height:auto;max-height:92vh;display:flex;flex-direction:column;gap:8px}
|
|
827
|
+
.tb-window-editor-body{display:flex;flex-direction:column;gap:6px;min-height:0}
|
|
828
|
+
.tb-table-editor-preview{max-height:150px;overflow:auto;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:6px;background:rgba(255,255,255,.02)}
|
|
829
|
+
.tb-table-editor-preview table{border-collapse:collapse;width:100%;font-size:12px}
|
|
830
|
+
.tb-table-editor-preview td{border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));padding:3px 5px;white-space:pre-wrap}
|
|
831
|
+
.tb-table-editor-preview img{display:block;max-width:100%;max-height:140px;object-fit:contain;margin:auto}
|
|
832
|
+
.tb-board-text{position:absolute;box-sizing:border-box;padding:5px 7px;border-radius:6px;line-height:1.45;white-space:pre-wrap;word-break:break-word;cursor:grab;user-select:none;border:1px solid transparent;text-shadow:0 1px 0 rgba(0,0,0,.12)}
|
|
833
|
+
.tb-board-text:hover{border-color:rgba(122,162,255,.5)}
|
|
834
|
+
.tb-board-text.selected{outline:2px dashed var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);outline-offset:2px}
|
|
835
|
+
.tb-board-text:active{cursor:grabbing}
|
|
836
|
+
.tb-board-text-content{white-space:pre-wrap;word-break:break-word;pointer-events:none}
|
|
837
|
+
.tb-board-text-actions{position:absolute;right:-1px;top:-24px;display:none;gap:2px;padding:1px;border-radius:5px;background:var(--dsw-alias-bg-elevated,#2a2d34);border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));z-index:4}
|
|
838
|
+
.tb-board-text:hover .tb-board-text-actions,.tb-board-text.selected .tb-board-text-actions{display:flex}
|
|
839
|
+
.tb-board-text-actions button{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#c9ced6);border-radius:3px;font-size:11px;line-height:16px;padding:0 4px;cursor:pointer}
|
|
840
|
+
.tb-board-text-actions button:hover{background:rgba(255,255,255,.12);color:#fff}
|
|
841
|
+
.tb-text-dialog{width:min(700px,94vw);height:auto;max-height:90vh;display:flex;flex-direction:column;gap:8px}
|
|
842
|
+
.tb-text-input{box-sizing:border-box;width:100%;min-height:110px;resize:vertical;background:var(--dsw-alias-bg-base,#16181d);color:var(--dsw-alias-label-primary,#e6e6e6);border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:6px;padding:8px;font:inherit;font-size:14px;line-height:1.55;outline:none}
|
|
843
|
+
.tb-text-input:focus{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
844
|
+
.tb-text-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
845
|
+
.tb-text-swatches{display:flex;gap:4px;flex-wrap:wrap}
|
|
846
|
+
.tb-text-swatch{width:24px;height:24px;border-radius:5px;border:2px solid transparent;box-shadow:inset 0 0 0 1px rgba(0,0,0,.2);cursor:pointer;padding:0}
|
|
847
|
+
.tb-text-swatch.on{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
848
|
+
.tb-text-preview{flex:1;min-height:64px;max-height:140px;overflow:auto;padding:8px;border:1px dashed var(--dsw-alias-border-l2,rgba(255,255,255,.2));border-radius:6px;background:var(--dsw-alias-bg-base,#16181d);white-space:pre-wrap;word-break:break-word}
|
|
744
849
|
.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}
|
|
745
850
|
.tb-sticky:active{cursor:grabbing}
|
|
746
851
|
.tb-sticky.selected{outline:2px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);outline-offset:1px}
|
|
@@ -764,6 +869,13 @@ window.__ModuleLoader__.load({
|
|
|
764
869
|
.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}
|
|
765
870
|
.tb-sticky-md a{color:#1c4d8f;text-decoration:underline}
|
|
766
871
|
.tb-sticky-md hr{border:0;border-top:1px solid rgba(0,0,0,.2);margin:4px 0}
|
|
872
|
+
.tb-sticky.tb-doc{background:#ffffff;color:#2a2418;box-shadow:0 8px 24px rgba(0,0,0,.32);border-color:rgba(0,0,0,.22)}
|
|
873
|
+
.tb-sticky.tb-doc .tb-sticky-head{flex:0 0 auto;cursor:grab}
|
|
874
|
+
.tb-doc-body{flex:1;min-height:0;overflow:auto;pointer-events:auto;user-select:text;cursor:text;color:#2a2418;background:#ffffff;border-radius:0 0 4px 4px;padding:2px 2px 4px}
|
|
875
|
+
.tb-doc-body .tb-md{font-size:13px;line-height:1.6;color:#2a2418}
|
|
876
|
+
.tb-doc-body .tb-md h1{font-size:21px}.tb-doc-body .tb-md h2{font-size:18px}.tb-doc-body .tb-md h3{font-size:16px}.tb-doc-body .tb-md h4{font-size:14px}
|
|
877
|
+
.tb-doc-body .tb-md pre{background:rgba(0,0,0,.07);color:#2a2418}
|
|
878
|
+
.tb-doc-body .tb-md code{background:rgba(0,0,0,.08)}
|
|
767
879
|
.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}
|
|
768
880
|
.tb-sticky-src{font-size:9.5px;font-weight:600;opacity:.6;white-space:nowrap}
|
|
769
881
|
.tb-sticky-draw{position:absolute;inset:0;pointer-events:none;z-index:3}
|
|
@@ -820,7 +932,7 @@ window.__ModuleLoader__.load({
|
|
|
820
932
|
.tb-md-line{display:block;font-size:10px;line-height:1.4;color:var(--dsw-alias-label-tertiary,#8a919c);margin-bottom:1px}
|
|
821
933
|
.tb-md-empty{padding:12px;text-align:center;color:var(--dsw-alias-label-secondary,#9aa0a6);font-size:13px}
|
|
822
934
|
@media (max-width: 760px){.tb-md-body{flex-direction:column}}
|
|
823
|
-
.tb-board-panel{display:flex;flex-direction:column;height:100%;min-height:100%;width:100%;font-size:12.5px;color:var(--dsw-alias-label-primary,#e6e6e6);background:var(--dsw-alias-bg-base,#16181d)}
|
|
935
|
+
.tb-board-panel{position:relative;display:flex;flex-direction:column;height:100%;min-height:100%;width:100%;font-size:12.5px;color:var(--dsw-alias-label-primary,#e6e6e6);background:var(--dsw-alias-bg-base,#16181d)}
|
|
824
936
|
.tb-board-head{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));flex-wrap:wrap}
|
|
825
937
|
.tb-board-title{font-weight:600;font-size:13.5px}
|
|
826
938
|
.tb-board-sub{font-size:11px;color:var(--dsw-alias-label-secondary,#9aa0a6)}
|
|
@@ -1244,6 +1356,19 @@ window.__ModuleLoader__.load({
|
|
|
1244
1356
|
return changed ? next : folders
|
|
1245
1357
|
}
|
|
1246
1358
|
|
|
1359
|
+
/** Rename one folder; empty names fall back to the default label. */
|
|
1360
|
+
function renameCardFolder(folders, folderId, name) {
|
|
1361
|
+
if (!Array.isArray(folders)) return folders
|
|
1362
|
+
const nextName = String(name ?? '').trim().slice(0, 40) || '卡片夹'
|
|
1363
|
+
let changed = false
|
|
1364
|
+
const next = folders.map((folder) => {
|
|
1365
|
+
if (folder.id !== folderId || folder.name === nextName) return folder
|
|
1366
|
+
changed = true
|
|
1367
|
+
return { ...folder, name: nextName }
|
|
1368
|
+
})
|
|
1369
|
+
return changed ? next : folders
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1247
1372
|
/** Unique keys in order. */
|
|
1248
1373
|
function uniqueKeys(values) {
|
|
1249
1374
|
const seen = new Set()
|
|
@@ -1273,6 +1398,7 @@ window.__ModuleLoader__.load({
|
|
|
1273
1398
|
let host = null
|
|
1274
1399
|
if (sourceFolder && targetFolder) {
|
|
1275
1400
|
targetFolder.members = uniqueKeys([...targetFolder.members, ...sourceFolder.members])
|
|
1401
|
+
if (!targetFolder.name || targetFolder.name === '卡片夹') targetFolder.name = sourceFolder.name || targetFolder.name
|
|
1276
1402
|
host = targetFolder
|
|
1277
1403
|
const index = list.indexOf(sourceFolder)
|
|
1278
1404
|
if (index !== -1) list.splice(index, 1)
|
|
@@ -1285,6 +1411,7 @@ window.__ModuleLoader__.load({
|
|
|
1285
1411
|
} else {
|
|
1286
1412
|
host = {
|
|
1287
1413
|
id: `fold-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`,
|
|
1414
|
+
name: '卡片夹',
|
|
1288
1415
|
members: uniqueKeys([target.key, source.key]),
|
|
1289
1416
|
x: Number.isFinite(target.x) ? target.x : 0,
|
|
1290
1417
|
y: Number.isFinite(target.y) ? target.y : 0,
|
|
@@ -1522,8 +1649,9 @@ window.__ModuleLoader__.load({
|
|
|
1522
1649
|
color: firstMember.color,
|
|
1523
1650
|
x: override?.x ?? (Number.isFinite(folder.x) ? folder.x : firstMember.x),
|
|
1524
1651
|
y: override?.y ?? (Number.isFinite(folder.y) ? folder.y : firstMember.y),
|
|
1525
|
-
label: '卡片夹',
|
|
1526
|
-
|
|
1652
|
+
label: folder.name || '卡片夹',
|
|
1653
|
+
folderName: folder.name || '卡片夹',
|
|
1654
|
+
title: `${session.title || session.sessionId.slice(0, 8)} · ${folder.name || '卡片夹'}(${members.length} 张)`,
|
|
1527
1655
|
prompt: null,
|
|
1528
1656
|
note: null,
|
|
1529
1657
|
checkpoints: [],
|
|
@@ -1621,7 +1749,7 @@ window.__ModuleLoader__.load({
|
|
|
1621
1749
|
}
|
|
1622
1750
|
|
|
1623
1751
|
/** One card of the conversation canvas. */
|
|
1624
|
-
function CanvasCard({ card, t, selectedKey, onSelect, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }) {
|
|
1752
|
+
function CanvasCard({ card, t, selectedKey, onSelect, onChat, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }) {
|
|
1625
1753
|
const files = (card.checkpoints ?? []).reduce(
|
|
1626
1754
|
(total, checkpoint) => ({
|
|
1627
1755
|
added: total.added + (checkpoint.files?.added ?? 0),
|
|
@@ -1663,6 +1791,7 @@ window.__ModuleLoader__.load({
|
|
|
1663
1791
|
event.stopPropagation()
|
|
1664
1792
|
if (consumeClick()) return
|
|
1665
1793
|
onSelect(card.key)
|
|
1794
|
+
if (typeof onChat === 'function') onChat(card)
|
|
1666
1795
|
},
|
|
1667
1796
|
onDoubleClick: (event) => {
|
|
1668
1797
|
event.stopPropagation()
|
|
@@ -1676,6 +1805,7 @@ window.__ModuleLoader__.load({
|
|
|
1676
1805
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
1677
1806
|
event.preventDefault()
|
|
1678
1807
|
onSelect(card.key)
|
|
1808
|
+
if (typeof onChat === 'function') onChat(card)
|
|
1679
1809
|
}
|
|
1680
1810
|
},
|
|
1681
1811
|
},
|
|
@@ -1772,7 +1902,24 @@ window.__ModuleLoader__.load({
|
|
|
1772
1902
|
}
|
|
1773
1903
|
|
|
1774
1904
|
/** One collapsed card folder: compact, with member labels and an unpack action. */
|
|
1775
|
-
function CanvasFolderCard({
|
|
1905
|
+
function CanvasFolderCard({
|
|
1906
|
+
card,
|
|
1907
|
+
t,
|
|
1908
|
+
onDragStart,
|
|
1909
|
+
onUnpackFolder,
|
|
1910
|
+
dropTargetKey,
|
|
1911
|
+
folding,
|
|
1912
|
+
expanded,
|
|
1913
|
+
onToggleFolder,
|
|
1914
|
+
onMemberDragStart,
|
|
1915
|
+
suppressClickRef,
|
|
1916
|
+
renaming,
|
|
1917
|
+
renameDraft,
|
|
1918
|
+
onRenameStart,
|
|
1919
|
+
onRenameChange,
|
|
1920
|
+
onRenameCommit,
|
|
1921
|
+
onRenameCancel,
|
|
1922
|
+
}) {
|
|
1776
1923
|
const members = card.members ?? []
|
|
1777
1924
|
return h(
|
|
1778
1925
|
'article',
|
|
@@ -1799,8 +1946,40 @@ window.__ModuleLoader__.load({
|
|
|
1799
1946
|
'div',
|
|
1800
1947
|
{ className: 'tb-card-head' },
|
|
1801
1948
|
h('span', { className: 'tb-card-badge' }, '📁'),
|
|
1802
|
-
|
|
1949
|
+
renaming
|
|
1950
|
+
? h('input', {
|
|
1951
|
+
className: 'tb-folder-name-input',
|
|
1952
|
+
value: renameDraft ?? '',
|
|
1953
|
+
placeholder: t('tree.folderNamePlaceholder'),
|
|
1954
|
+
autoFocus: true,
|
|
1955
|
+
'aria-label': t('tree.folderRename'),
|
|
1956
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1957
|
+
onChange: (event) => onRenameChange?.(event.target.value),
|
|
1958
|
+
onKeyDown: (event) => {
|
|
1959
|
+
event.stopPropagation()
|
|
1960
|
+
if (event.key === 'Enter') onRenameCommit?.()
|
|
1961
|
+
else if (event.key === 'Escape') onRenameCancel?.()
|
|
1962
|
+
},
|
|
1963
|
+
onBlur: () => onRenameCommit?.(),
|
|
1964
|
+
})
|
|
1965
|
+
: h('span', { className: 'tb-folder-name', title: card.folderName || '卡片夹' }, card.folderName || '卡片夹'),
|
|
1803
1966
|
h('span', { className: 'tb-card-spacer' }),
|
|
1967
|
+
!renaming && typeof onRenameStart === 'function'
|
|
1968
|
+
? h(
|
|
1969
|
+
'button',
|
|
1970
|
+
{
|
|
1971
|
+
type: 'button',
|
|
1972
|
+
className: 'tb-folder-rename',
|
|
1973
|
+
title: t('tree.folderRename'),
|
|
1974
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1975
|
+
onClick: (event) => {
|
|
1976
|
+
event.stopPropagation()
|
|
1977
|
+
onRenameStart(card.folderId)
|
|
1978
|
+
},
|
|
1979
|
+
},
|
|
1980
|
+
'✎',
|
|
1981
|
+
)
|
|
1982
|
+
: null,
|
|
1804
1983
|
card.createdAt ? h('span', { className: 'tb-card-time' }, clock(card.createdAt)) : null,
|
|
1805
1984
|
),
|
|
1806
1985
|
expanded
|
|
@@ -1876,6 +2055,7 @@ window.__ModuleLoader__.load({
|
|
|
1876
2055
|
t,
|
|
1877
2056
|
selectedKey,
|
|
1878
2057
|
onSelect,
|
|
2058
|
+
onChat,
|
|
1879
2059
|
onOpen,
|
|
1880
2060
|
onBranch,
|
|
1881
2061
|
onNote,
|
|
@@ -1887,6 +2067,17 @@ window.__ModuleLoader__.load({
|
|
|
1887
2067
|
expandedFolderId,
|
|
1888
2068
|
onToggleFolder,
|
|
1889
2069
|
onMemberDragStart,
|
|
2070
|
+
renamingFolderId,
|
|
2071
|
+
folderNameDraft,
|
|
2072
|
+
doodleMode,
|
|
2073
|
+
doodles,
|
|
2074
|
+
onToggleDoodle,
|
|
2075
|
+
onClearDoodles,
|
|
2076
|
+
onDoodlePointerDown,
|
|
2077
|
+
onRenameStart,
|
|
2078
|
+
onRenameChange,
|
|
2079
|
+
onRenameCommit,
|
|
2080
|
+
onRenameCancel,
|
|
1890
2081
|
onResetLayout,
|
|
1891
2082
|
autoPan,
|
|
1892
2083
|
panSpeed,
|
|
@@ -1938,6 +2129,20 @@ window.__ModuleLoader__.load({
|
|
|
1938
2129
|
},
|
|
1939
2130
|
panSpeed === 'slow' ? t('tree.panSpeedSlow') : panSpeed === 'fast' ? t('tree.panSpeedFast') : t('tree.panSpeedNormal'),
|
|
1940
2131
|
),
|
|
2132
|
+
h(
|
|
2133
|
+
'button',
|
|
2134
|
+
{
|
|
2135
|
+
type: 'button',
|
|
2136
|
+
className: `tb-canvas-btn${doodleMode ? ' on' : ''}`,
|
|
2137
|
+
title: t('tree.doodleHint'),
|
|
2138
|
+
'aria-pressed': doodleMode === true,
|
|
2139
|
+
onClick: onToggleDoodle,
|
|
2140
|
+
},
|
|
2141
|
+
doodleMode ? `✏️ ${t('tree.doodleOn')}` : `✏️ ${t('tree.doodleOff')}`,
|
|
2142
|
+
),
|
|
2143
|
+
doodleMode
|
|
2144
|
+
? h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.doodleClear'), onClick: onClearDoodles }, `🧽 ${t('tree.doodleClear')}`)
|
|
2145
|
+
: null,
|
|
1941
2146
|
h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.resetLayoutHint'), onClick: onResetLayout }, t('tree.resetLayout')),
|
|
1942
2147
|
h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.expandHint'), onClick: onToggleExpand }, expanded ? '⤡' : '⤢'),
|
|
1943
2148
|
h('span', { className: 'tb-canvas-hint' }, t('tree.folderHint')),
|
|
@@ -1979,6 +2184,30 @@ window.__ModuleLoader__.load({
|
|
|
1979
2184
|
h('span', null, t('tree.folderDropHint')),
|
|
1980
2185
|
)
|
|
1981
2186
|
})(),
|
|
2187
|
+
h(
|
|
2188
|
+
'svg',
|
|
2189
|
+
{
|
|
2190
|
+
className: `tb-tree-doodles${doodleMode ? ' active' : ''}`,
|
|
2191
|
+
width: layout.width,
|
|
2192
|
+
height: layout.height,
|
|
2193
|
+
style: { pointerEvents: doodleMode ? 'auto' : 'none', cursor: doodleMode ? 'crosshair' : 'default' },
|
|
2194
|
+
onPointerDown: (event) => {
|
|
2195
|
+
if (!doodleMode) return
|
|
2196
|
+
event.stopPropagation()
|
|
2197
|
+
onDoodlePointerDown?.(event)
|
|
2198
|
+
},
|
|
2199
|
+
},
|
|
2200
|
+
...(doodles ?? []).map((stroke, index) =>
|
|
2201
|
+
h('polyline', {
|
|
2202
|
+
key: `doodle-${index}`,
|
|
2203
|
+
points: (stroke.points ?? []).map((point) => `${point[0]},${point[1]}`).join(' '),
|
|
2204
|
+
stroke: stroke.color || '#ff5f56',
|
|
2205
|
+
strokeWidth: stroke.width || 3,
|
|
2206
|
+
opacity: 0.9,
|
|
2207
|
+
}),
|
|
2208
|
+
),
|
|
2209
|
+
doodleMode ? h('rect', { x: 0, y: 0, width: layout.width, height: layout.height, fill: 'transparent' }) : null,
|
|
2210
|
+
),
|
|
1982
2211
|
...layout.cards.map((card) =>
|
|
1983
2212
|
card.kind === 'folder'
|
|
1984
2213
|
? CanvasFolderCard({
|
|
@@ -1992,8 +2221,14 @@ window.__ModuleLoader__.load({
|
|
|
1992
2221
|
onToggleFolder,
|
|
1993
2222
|
onMemberDragStart,
|
|
1994
2223
|
suppressClickRef,
|
|
2224
|
+
renaming: renamingFolderId === card.folderId,
|
|
2225
|
+
renameDraft: folderNameDraft,
|
|
2226
|
+
onRenameStart,
|
|
2227
|
+
onRenameChange,
|
|
2228
|
+
onRenameCommit,
|
|
2229
|
+
onRenameCancel,
|
|
1995
2230
|
})
|
|
1996
|
-
: CanvasCard({ card, t, selectedKey, onSelect, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }),
|
|
2231
|
+
: CanvasCard({ card, t, selectedKey, onSelect, onChat, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }),
|
|
1997
2232
|
),
|
|
1998
2233
|
),
|
|
1999
2234
|
)
|
|
@@ -2136,6 +2371,69 @@ window.__ModuleLoader__.load({
|
|
|
2136
2371
|
)
|
|
2137
2372
|
}
|
|
2138
2373
|
|
|
2374
|
+
/** Extract text from one model/user message's content blocks. */
|
|
2375
|
+
function messageTextOf(message) {
|
|
2376
|
+
const blocks = Array.isArray(message?.content) ? message.content : []
|
|
2377
|
+
const parts = []
|
|
2378
|
+
for (const block of blocks) {
|
|
2379
|
+
if (!block || typeof block !== 'object') continue
|
|
2380
|
+
if (block.type === 'text' && typeof block.text === 'string') parts.push(block.text)
|
|
2381
|
+
else if (block.type === 'image') parts.push('[image]')
|
|
2382
|
+
else if (block.type === 'file') parts.push('[file]')
|
|
2383
|
+
}
|
|
2384
|
+
return parts.join('\n\n').trim()
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
/** Durable Session events from an event-window snapshot. */
|
|
2388
|
+
function durableSessionEvents(entries) {
|
|
2389
|
+
return (Array.isArray(entries) ? entries : [])
|
|
2390
|
+
.map((entry) => (entry?.type === 'event' ? entry.event : null))
|
|
2391
|
+
.filter(Boolean)
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
/** Messages belonging to one turn number, in conversation order. */
|
|
2395
|
+
function turnConversation(events, turn) {
|
|
2396
|
+
if (!Number.isInteger(turn)) return []
|
|
2397
|
+
const start = events.find((event) => event.type === 'turn/start' && event.data?.turn === turn)
|
|
2398
|
+
if (!start) return []
|
|
2399
|
+
const later = events.find((event) => event.type === 'turn/start' && event.seq > start.seq)
|
|
2400
|
+
const endSeq = later?.seq ?? Infinity
|
|
2401
|
+
const messages = []
|
|
2402
|
+
for (const event of events) {
|
|
2403
|
+
if (!Number.isInteger(event.seq) || event.seq < start.seq || event.seq >= endSeq) continue
|
|
2404
|
+
if (event.type === 'user/message' && event.data?.source?.kind === 'user') {
|
|
2405
|
+
const text = messageTextOf(event.data)
|
|
2406
|
+
if (text !== '') messages.push({ role: 'user', text, seq: event.seq })
|
|
2407
|
+
} else if (event.type === 'assistant/message') {
|
|
2408
|
+
const text = messageTextOf(event.data?.message)
|
|
2409
|
+
if (text !== '') messages.push({ role: 'assistant', text, seq: event.seq })
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
return messages
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
/** Best turn number for a card without an explicit turn (manual/start cards). */
|
|
2416
|
+
function turnForCheckpoint(events, checkpoint) {
|
|
2417
|
+
if (!checkpoint) return null
|
|
2418
|
+
const seq = Number.isInteger(checkpoint.seq) ? checkpoint.seq : Infinity
|
|
2419
|
+
let best = null
|
|
2420
|
+
for (const event of events) {
|
|
2421
|
+
if (event.type !== 'turn/start' || !Number.isInteger(event.data?.turn)) continue
|
|
2422
|
+
if (event.seq <= seq) best = event.data.turn
|
|
2423
|
+
else break
|
|
2424
|
+
}
|
|
2425
|
+
return best
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
/** Whether a card is the last card of the current session's branch. */
|
|
2429
|
+
function cardIsTail(card, layout, data) {
|
|
2430
|
+
if (!card || card.kind === 'folder' || !layout || !data) return false
|
|
2431
|
+
if (String(card.sessionId) !== String(data.currentSessionId)) return false
|
|
2432
|
+
const cards = (layout.cards ?? []).filter((entry) => entry.kind !== 'folder' && String(entry.sessionId) === String(card.sessionId))
|
|
2433
|
+
const last = cards[cards.length - 1]
|
|
2434
|
+
return Boolean(last && last.key === card.key)
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2139
2437
|
/* ---------------------------------------------------------------- */
|
|
2140
2438
|
/* panel */
|
|
2141
2439
|
/* ---------------------------------------------------------------- */
|
|
@@ -2161,6 +2459,11 @@ window.__ModuleLoader__.load({
|
|
|
2161
2459
|
}, [feedback])
|
|
2162
2460
|
const [view, setView] = React.useState('tree')
|
|
2163
2461
|
const [workspaceOpen, setWorkspaceOpen] = React.useState(false)
|
|
2462
|
+
const [renamingFolderId, setRenamingFolderId] = React.useState(null)
|
|
2463
|
+
const [folderNameDraft, setFolderNameDraft] = React.useState('')
|
|
2464
|
+
const [doodleMode, setDoodleMode] = React.useState(false)
|
|
2465
|
+
const [doodles, setDoodles] = React.useState([])
|
|
2466
|
+
const doodlesRef = React.useRef([])
|
|
2164
2467
|
const [selectedKey, setSelectedKey] = React.useState(null)
|
|
2165
2468
|
const [zoom, setZoom] = React.useState(1)
|
|
2166
2469
|
const [canvasExpanded, setCanvasExpanded] = React.useState(false)
|
|
@@ -2185,6 +2488,7 @@ window.__ModuleLoader__.load({
|
|
|
2185
2488
|
const panSpeedRef = React.useRef(panSpeed)
|
|
2186
2489
|
panSpeedRef.current = panSpeed
|
|
2187
2490
|
const [noteEditor, setNoteEditor] = React.useState(null)
|
|
2491
|
+
const [chat, setChat] = React.useState(null)
|
|
2188
2492
|
const viewportRef = React.useRef(null)
|
|
2189
2493
|
const worldRef = React.useRef(null)
|
|
2190
2494
|
const cameraRef = React.useRef({ x: 0, y: 0, scale: 1 })
|
|
@@ -2288,6 +2592,15 @@ window.__ModuleLoader__.load({
|
|
|
2288
2592
|
else if (action === 'restore-files') message = format(t('panel.confirmFiles'), { who, warning: t('panel.deleteWarning') })
|
|
2289
2593
|
else message = format(t('panel.confirmRewind'), { who, warning: t('panel.deleteWarning') })
|
|
2290
2594
|
if (!window.confirm(message)) return
|
|
2595
|
+
let branchName = ''
|
|
2596
|
+
if (action === 'rewind' && mode !== 'files-only') {
|
|
2597
|
+
const source = (data.sessions ?? []).find((entry) => entry.sessionId === actionSessionId)
|
|
2598
|
+
const suffix = Number.isInteger(checkpoint?.turn) ? ` · T${checkpoint.turn}` : ''
|
|
2599
|
+
const fallbackName = `${source?.title || t('panel.branch')} · ${t('panel.branch')}${suffix}`
|
|
2600
|
+
const entered = window.prompt(t('panel.branchNamePrompt'), fallbackName)
|
|
2601
|
+
if (entered === null) return
|
|
2602
|
+
branchName = (entered || '').trim() || fallbackName
|
|
2603
|
+
}
|
|
2291
2604
|
const busyKey = checkpoint ? checkpoint.id : action
|
|
2292
2605
|
setBusy(busyKey)
|
|
2293
2606
|
busyRef.current = busyKey
|
|
@@ -2310,6 +2623,7 @@ window.__ModuleLoader__.load({
|
|
|
2310
2623
|
const isFileAction = action === 'restore-files' || mode === 'files-only'
|
|
2311
2624
|
body = { action: isFileAction ? 'restore-files' : 'rewind', sessionId: actionSessionId, checkpointId: checkpoint.id }
|
|
2312
2625
|
if (mode) body.mode = mode
|
|
2626
|
+
if (branchName) body.name = branchName
|
|
2313
2627
|
}
|
|
2314
2628
|
const result = await request('action', { method: 'POST', body })
|
|
2315
2629
|
let tone = 'ok'
|
|
@@ -2548,28 +2862,45 @@ window.__ModuleLoader__.load({
|
|
|
2548
2862
|
|
|
2549
2863
|
const positionsKey = data?.rootSessionId ? `dsh-timeback:card-positions:${data.rootSessionId}` : null
|
|
2550
2864
|
const foldersKey = data?.rootSessionId ? `dsh-timeback:card-folders:${data.rootSessionId}` : null
|
|
2865
|
+
const doodlesKey = data?.rootSessionId ? `dsh-timeback:tree-doodles:${data.rootSessionId}` : null
|
|
2551
2866
|
|
|
2552
2867
|
// Restore dragged card positions and folders for this branch family.
|
|
2553
2868
|
React.useEffect(() => {
|
|
2554
2869
|
if (!positionsKey) return
|
|
2555
2870
|
let saved = {}
|
|
2556
2871
|
let savedFolders = []
|
|
2872
|
+
let savedDoodles = []
|
|
2557
2873
|
try {
|
|
2558
2874
|
const raw = window.localStorage.getItem(positionsKey)
|
|
2559
2875
|
if (raw) saved = JSON.parse(raw)
|
|
2560
2876
|
const rawFolders = window.localStorage.getItem(foldersKey)
|
|
2561
2877
|
if (rawFolders) savedFolders = JSON.parse(rawFolders)
|
|
2878
|
+
const rawDoodles = window.localStorage.getItem(doodlesKey)
|
|
2879
|
+
if (rawDoodles) savedDoodles = JSON.parse(rawDoodles)
|
|
2562
2880
|
} catch {
|
|
2563
2881
|
saved = {}
|
|
2564
2882
|
savedFolders = []
|
|
2883
|
+
savedDoodles = []
|
|
2565
2884
|
}
|
|
2566
2885
|
if (saved === null || typeof saved !== 'object' || Array.isArray(saved)) saved = {}
|
|
2567
2886
|
if (!Array.isArray(savedFolders)) savedFolders = []
|
|
2887
|
+
if (!Array.isArray(savedDoodles)) savedDoodles = []
|
|
2888
|
+
savedDoodles = savedDoodles
|
|
2889
|
+
.filter((stroke) => stroke && Array.isArray(stroke.points) && stroke.points.length > 1)
|
|
2890
|
+
.slice(-200)
|
|
2891
|
+
.map((stroke) => ({
|
|
2892
|
+
color: /^#[0-9a-f]{6}$/i.test(String(stroke.color || '')) ? String(stroke.color) : '#ff5f56',
|
|
2893
|
+
width: Math.min(12, Math.max(1, Number(stroke.width) || 3)),
|
|
2894
|
+
points: stroke.points.filter((point) => Array.isArray(point) && point.length >= 2 && Number.isFinite(point[0]) && Number.isFinite(point[1])).slice(0, 2000),
|
|
2895
|
+
}))
|
|
2896
|
+
.filter((stroke) => stroke.points.length > 1)
|
|
2568
2897
|
positionsRef.current = saved
|
|
2569
2898
|
setPositions(saved)
|
|
2570
2899
|
foldersRef.current = savedFolders
|
|
2571
2900
|
setFolders(savedFolders)
|
|
2572
|
-
|
|
2901
|
+
doodlesRef.current = savedDoodles
|
|
2902
|
+
setDoodles(savedDoodles)
|
|
2903
|
+
}, [positionsKey, foldersKey, doodlesKey])
|
|
2573
2904
|
|
|
2574
2905
|
// Wheel zoom must be non-passive, so it is bound directly to the viewport.
|
|
2575
2906
|
React.useEffect(() => {
|
|
@@ -2616,6 +2947,10 @@ window.__ModuleLoader__.load({
|
|
|
2616
2947
|
const unpackFolder = (folderId) => {
|
|
2617
2948
|
const next = foldersRef.current.filter((folder) => folder.id !== folderId)
|
|
2618
2949
|
storeFolders(next, true)
|
|
2950
|
+
if (renamingFolderId === folderId) {
|
|
2951
|
+
setRenamingFolderId(null)
|
|
2952
|
+
setFolderNameDraft('')
|
|
2953
|
+
}
|
|
2619
2954
|
}
|
|
2620
2955
|
|
|
2621
2956
|
/** Expand/collapse one folder's full member list. */
|
|
@@ -2623,6 +2958,81 @@ window.__ModuleLoader__.load({
|
|
|
2623
2958
|
setExpandedFolderId((current) => (current === folderId ? null : folderId))
|
|
2624
2959
|
}
|
|
2625
2960
|
|
|
2961
|
+
/** Start inline renaming for one folder card. */
|
|
2962
|
+
const startFolderRename = (folderId) => {
|
|
2963
|
+
const folder = foldersRef.current.find((entry) => entry.id === folderId)
|
|
2964
|
+
if (!folder) return
|
|
2965
|
+
setRenamingFolderId(folderId)
|
|
2966
|
+
setFolderNameDraft(folder.name || '卡片夹')
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
const commitFolderRename = () => {
|
|
2970
|
+
if (!renamingFolderId) return
|
|
2971
|
+
const next = renameCardFolder(foldersRef.current, renamingFolderId, folderNameDraft)
|
|
2972
|
+
storeFolders(next, true)
|
|
2973
|
+
setRenamingFolderId(null)
|
|
2974
|
+
setFolderNameDraft('')
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
const cancelFolderRename = () => {
|
|
2978
|
+
setRenamingFolderId(null)
|
|
2979
|
+
setFolderNameDraft('')
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
/** Persist freehand doodles over the conversation canvas. */
|
|
2983
|
+
const storeDoodles = (next, persist) => {
|
|
2984
|
+
doodlesRef.current = next
|
|
2985
|
+
setDoodles(next)
|
|
2986
|
+
if (persist !== true) return
|
|
2987
|
+
try {
|
|
2988
|
+
if (doodlesKey) window.localStorage.setItem(doodlesKey, JSON.stringify(next))
|
|
2989
|
+
} catch {
|
|
2990
|
+
// Storage can be disabled; doodles still work in memory.
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
const beginDoodle = (event) => {
|
|
2995
|
+
if (event.button !== 0) return
|
|
2996
|
+
const viewport = viewportRef.current
|
|
2997
|
+
if (!viewport) return
|
|
2998
|
+
event.preventDefault()
|
|
2999
|
+
const rect = viewport.getBoundingClientRect()
|
|
3000
|
+
const toWorld = (next) => {
|
|
3001
|
+
const camera = cameraRef.current
|
|
3002
|
+
return [
|
|
3003
|
+
Math.round((next.clientX - rect.left - camera.x) / camera.scale),
|
|
3004
|
+
Math.round((next.clientY - rect.top - camera.y) / camera.scale),
|
|
3005
|
+
]
|
|
3006
|
+
}
|
|
3007
|
+
const startPoint = toWorld(event)
|
|
3008
|
+
const stroke = { color: '#ff5f56', width: 3, points: [startPoint] }
|
|
3009
|
+
let strokes = [...doodlesRef.current, stroke]
|
|
3010
|
+
setDoodles(strokes)
|
|
3011
|
+
const move = (next) => {
|
|
3012
|
+
const point = toWorld(next)
|
|
3013
|
+
const last = stroke.points[stroke.points.length - 1]
|
|
3014
|
+
if (last && Math.abs(last[0] - point[0]) + Math.abs(last[1] - point[1]) < 2) return
|
|
3015
|
+
if (stroke.points.length >= 2000) return
|
|
3016
|
+
stroke.points = [...stroke.points, point]
|
|
3017
|
+
strokes = [...doodlesRef.current, stroke]
|
|
3018
|
+
setDoodles(strokes)
|
|
3019
|
+
}
|
|
3020
|
+
const finish = () => {
|
|
3021
|
+
window.removeEventListener('pointermove', move)
|
|
3022
|
+
window.removeEventListener('pointerup', finish)
|
|
3023
|
+
window.removeEventListener('pointercancel', finish)
|
|
3024
|
+
doodlesRef.current = [...doodlesRef.current.filter((item) => item !== stroke), stroke].slice(-200)
|
|
3025
|
+
storeDoodles(doodlesRef.current, true)
|
|
3026
|
+
}
|
|
3027
|
+
window.addEventListener('pointermove', move)
|
|
3028
|
+
window.addEventListener('pointerup', finish)
|
|
3029
|
+
window.addEventListener('pointercancel', finish)
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
const clearDoodles = () => {
|
|
3033
|
+
storeDoodles([], true)
|
|
3034
|
+
}
|
|
3035
|
+
|
|
2626
3036
|
/** Remove one card from a folder; a folder with <2 members dissolves. */
|
|
2627
3037
|
const detachFolderMember = (folderId, memberKey, position) => {
|
|
2628
3038
|
const next = removeFolderMember(foldersRef.current, folderId, memberKey)
|
|
@@ -2882,6 +3292,115 @@ window.__ModuleLoader__.load({
|
|
|
2882
3292
|
})
|
|
2883
3293
|
}
|
|
2884
3294
|
|
|
3295
|
+
/** Read the turn behind one card and open its conversation/composer. */
|
|
3296
|
+
const openCardConversation = async (card) => {
|
|
3297
|
+
if (!card || card.kind === 'folder') return
|
|
3298
|
+
const base = { card, loading: true, messages: [], error: null, input: '', sending: false }
|
|
3299
|
+
setChat(base)
|
|
3300
|
+
if (!sessionApi) {
|
|
3301
|
+
setChat({ ...base, loading: false, error: t('chat.unavailable') })
|
|
3302
|
+
return
|
|
3303
|
+
}
|
|
3304
|
+
try {
|
|
3305
|
+
const checkpoint = [...(card.checkpoints ?? [])].reverse().find((entry) => Number.isInteger(entry.seq))
|
|
3306
|
+
const entries = await sessionApi.using(card.sessionId, { source: 'gateway' }, async (reference) => {
|
|
3307
|
+
const binding = await reference.ready
|
|
3308
|
+
if (checkpoint) {
|
|
3309
|
+
try {
|
|
3310
|
+
await binding.session.loadThrough(checkpoint.seq)
|
|
3311
|
+
} catch {
|
|
3312
|
+
// The visible window may already cover the turn.
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
const source = binding.eventSource
|
|
3316
|
+
const window = typeof source?.getSnapshot === 'function' ? source.getSnapshot() : source?.snapshot
|
|
3317
|
+
return window?.entries ?? []
|
|
3318
|
+
})
|
|
3319
|
+
const events = durableSessionEvents(entries)
|
|
3320
|
+
const turn = Number.isInteger(card.turn) ? card.turn : turnForCheckpoint(events, checkpoint)
|
|
3321
|
+
let messages = turnConversation(events, turn)
|
|
3322
|
+
if (messages.length === 0 && card.prompt) messages = [{ role: 'user', text: card.prompt }]
|
|
3323
|
+
setChat((current) =>
|
|
3324
|
+
current && current.card.key === card.key
|
|
3325
|
+
? { ...current, loading: false, messages, error: null }
|
|
3326
|
+
: current,
|
|
3327
|
+
)
|
|
3328
|
+
} catch (error) {
|
|
3329
|
+
setChat((current) =>
|
|
3330
|
+
current && current.card.key === card.key
|
|
3331
|
+
? { ...current, loading: false, error: error?.message || String(error) }
|
|
3332
|
+
: current,
|
|
3333
|
+
)
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
/** Send the composer text: continue the tail session or branch then send. */
|
|
3338
|
+
const sendChatMessage = async () => {
|
|
3339
|
+
const current = chat
|
|
3340
|
+
if (!current || current.sending) return
|
|
3341
|
+
const text = String(current.input ?? '').trim()
|
|
3342
|
+
if (text === '') return
|
|
3343
|
+
if (!sessionApi) {
|
|
3344
|
+
setChat({ ...current, error: t('chat.unavailable') })
|
|
3345
|
+
return
|
|
3346
|
+
}
|
|
3347
|
+
setChat({ ...current, sending: true, error: null })
|
|
3348
|
+
try {
|
|
3349
|
+
const data = state.data
|
|
3350
|
+
const layout = data ? layoutTree(data.sessions ?? [], data.currentSessionId, positionsRef.current, foldersRef.current) : null
|
|
3351
|
+
const tail = cardIsTail(current.card, layout, data)
|
|
3352
|
+
let targetSessionId = current.card.sessionId
|
|
3353
|
+
let branched = false
|
|
3354
|
+
if (!tail) {
|
|
3355
|
+
const checkpoints = current.card.checkpoints ?? []
|
|
3356
|
+
const checkpoint =
|
|
3357
|
+
[...checkpoints].reverse().find((entry) => Number.isInteger(entry.seq) && entry.phase !== 'before') ??
|
|
3358
|
+
[...checkpoints].reverse().find((entry) => Number.isInteger(entry.seq))
|
|
3359
|
+
if (!checkpoint) throw new Error(t('chat.noCheckpoint'))
|
|
3360
|
+
const result = await request('action', {
|
|
3361
|
+
method: 'POST',
|
|
3362
|
+
body: {
|
|
3363
|
+
action: 'rewind',
|
|
3364
|
+
sessionId: current.card.sessionId,
|
|
3365
|
+
checkpointId: checkpoint.id,
|
|
3366
|
+
mode: 'branch-only',
|
|
3367
|
+
name: text.slice(0, 120),
|
|
3368
|
+
},
|
|
3369
|
+
})
|
|
3370
|
+
if (!result?.childSessionId) throw new Error(t('chat.noCheckpoint'))
|
|
3371
|
+
targetSessionId = result.childSessionId
|
|
3372
|
+
branched = true
|
|
3373
|
+
// Open the replacement session before prompting so its Client
|
|
3374
|
+
// session object is materialized and ready for the composer.
|
|
3375
|
+
openChild(targetSessionId)
|
|
3376
|
+
}
|
|
3377
|
+
const promptOnce = () =>
|
|
3378
|
+
sessionApi.using(targetSessionId, { source: 'gateway' }, async (reference) => {
|
|
3379
|
+
const binding = await reference.ready
|
|
3380
|
+
return binding.session.prompt([{ type: 'text', text }], 'queue')
|
|
3381
|
+
})
|
|
3382
|
+
let result
|
|
3383
|
+
try {
|
|
3384
|
+
result = await promptOnce()
|
|
3385
|
+
} catch (error) {
|
|
3386
|
+
await sessionApi.refresh().catch(() => {})
|
|
3387
|
+
result = await promptOnce()
|
|
3388
|
+
}
|
|
3389
|
+
if (result && result.ok === false) {
|
|
3390
|
+
throw new Error(result.error?.message ? String(result.error.message) : JSON.stringify(result.error))
|
|
3391
|
+
}
|
|
3392
|
+
setChat(null)
|
|
3393
|
+
setFeedback({ tone: 'ok', text: branched ? t('chat.branched') : t('chat.sent') })
|
|
3394
|
+
setTick((value) => value + 1)
|
|
3395
|
+
} catch (error) {
|
|
3396
|
+
setChat((previous) =>
|
|
3397
|
+
previous
|
|
3398
|
+
? { ...previous, sending: false, error: format(t('chat.failed'), { error: error?.message || String(error) }) }
|
|
3399
|
+
: previous,
|
|
3400
|
+
)
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
|
|
2885
3404
|
/** Saving close for the card-note sheet: outside clicks never discard text. */
|
|
2886
3405
|
const dismissCardNoteSaving = async () => {
|
|
2887
3406
|
const editor = noteEditor
|
|
@@ -3086,6 +3605,7 @@ window.__ModuleLoader__.load({
|
|
|
3086
3605
|
t,
|
|
3087
3606
|
selectedKey: effectiveSelectedKey,
|
|
3088
3607
|
onSelect: setSelectedKey,
|
|
3608
|
+
onChat: openCardConversation,
|
|
3089
3609
|
onOpen: openSessionByCard,
|
|
3090
3610
|
onBranch: branchFromCard,
|
|
3091
3611
|
onPrune: pruneFromCard,
|
|
@@ -3100,6 +3620,17 @@ window.__ModuleLoader__.load({
|
|
|
3100
3620
|
expandedFolderId,
|
|
3101
3621
|
onToggleFolder: toggleFolder,
|
|
3102
3622
|
onMemberDragStart: startFolderMemberDrag,
|
|
3623
|
+
renamingFolderId,
|
|
3624
|
+
folderNameDraft,
|
|
3625
|
+
onRenameStart: startFolderRename,
|
|
3626
|
+
onRenameChange: setFolderNameDraft,
|
|
3627
|
+
onRenameCommit: commitFolderRename,
|
|
3628
|
+
onRenameCancel: cancelFolderRename,
|
|
3629
|
+
doodleMode,
|
|
3630
|
+
doodles,
|
|
3631
|
+
onToggleDoodle: () => setDoodleMode((value) => !value),
|
|
3632
|
+
onClearDoodles: clearDoodles,
|
|
3633
|
+
onDoodlePointerDown: beginDoodle,
|
|
3103
3634
|
onResetLayout: resetCardPositions,
|
|
3104
3635
|
autoPan,
|
|
3105
3636
|
panSpeed,
|
|
@@ -3177,6 +3708,106 @@ window.__ModuleLoader__.load({
|
|
|
3177
3708
|
),
|
|
3178
3709
|
)
|
|
3179
3710
|
: null,
|
|
3711
|
+
chat
|
|
3712
|
+
? h(
|
|
3713
|
+
'div',
|
|
3714
|
+
{ className: 'tb-overlay', onClick: () => { if (!chat.sending) setChat(null) } },
|
|
3715
|
+
h(
|
|
3716
|
+
'div',
|
|
3717
|
+
{
|
|
3718
|
+
className: 'tb-note-dialog tb-chat-dialog',
|
|
3719
|
+
role: 'dialog',
|
|
3720
|
+
'aria-modal': true,
|
|
3721
|
+
onClick: (event) => event.stopPropagation(),
|
|
3722
|
+
},
|
|
3723
|
+
h(
|
|
3724
|
+
'div',
|
|
3725
|
+
{ className: 'tb-detail-head' },
|
|
3726
|
+
h(
|
|
3727
|
+
'span',
|
|
3728
|
+
{ className: 'tb-detail-title' },
|
|
3729
|
+
`${t('chat.title')} · ${chat.card.label}${chat.card.sessionTitle ? ` · ${chat.card.sessionTitle}` : ''}`,
|
|
3730
|
+
),
|
|
3731
|
+
h('span', { style: { flex: 1 } }),
|
|
3732
|
+
h(
|
|
3733
|
+
'button',
|
|
3734
|
+
{
|
|
3735
|
+
type: 'button',
|
|
3736
|
+
className: 'tb-btn',
|
|
3737
|
+
onClick: () => setChat(null),
|
|
3738
|
+
},
|
|
3739
|
+
t('chat.close'),
|
|
3740
|
+
),
|
|
3741
|
+
),
|
|
3742
|
+
h(
|
|
3743
|
+
'div',
|
|
3744
|
+
{ className: 'tb-ws-hint' },
|
|
3745
|
+
cardIsTail(chat.card, layout, state.data) ? t('chat.tailHint') : t('chat.branchHint'),
|
|
3746
|
+
),
|
|
3747
|
+
h(
|
|
3748
|
+
'div',
|
|
3749
|
+
{ className: 'tb-chat-messages' },
|
|
3750
|
+
chat.loading
|
|
3751
|
+
? h('div', { className: 'tb-empty tb-small' }, t('chat.loading'))
|
|
3752
|
+
: chat.messages.length > 0
|
|
3753
|
+
? chat.messages.map((message, index) =>
|
|
3754
|
+
h(
|
|
3755
|
+
'div',
|
|
3756
|
+
{ key: `msg-${index}`, className: `tb-chat-msg ${message.role}` },
|
|
3757
|
+
h('div', { className: 'tb-chat-role' }, message.role === 'user' ? t('chat.user') : t('chat.assistant')),
|
|
3758
|
+
message.role === 'assistant'
|
|
3759
|
+
? h('div', { className: 'tb-md' }, ...renderMarkdown(message.text, `chat-${index}`))
|
|
3760
|
+
: h('div', { className: 'tb-chat-text' }, message.text),
|
|
3761
|
+
),
|
|
3762
|
+
)
|
|
3763
|
+
: h('div', { className: 'tb-empty tb-small' }, chat.error || t('chat.empty')),
|
|
3764
|
+
),
|
|
3765
|
+
chat.error && !chat.loading
|
|
3766
|
+
? h('div', { className: 'tb-feedback err' }, chat.error)
|
|
3767
|
+
: null,
|
|
3768
|
+
h(
|
|
3769
|
+
'div',
|
|
3770
|
+
{ className: 'tb-chat-composer' },
|
|
3771
|
+
h('textarea', {
|
|
3772
|
+
value: chat.input,
|
|
3773
|
+
placeholder: t('chat.placeholder'),
|
|
3774
|
+
disabled: chat.sending,
|
|
3775
|
+
onChange: (event) => setChat((current) => (current ? { ...current, input: event.target.value } : current)),
|
|
3776
|
+
onKeyDown: (event) => {
|
|
3777
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
3778
|
+
event.preventDefault()
|
|
3779
|
+
sendChatMessage()
|
|
3780
|
+
}
|
|
3781
|
+
},
|
|
3782
|
+
}),
|
|
3783
|
+
h(
|
|
3784
|
+
'div',
|
|
3785
|
+
{ className: 'tb-chat-actions' },
|
|
3786
|
+
h(
|
|
3787
|
+
'button',
|
|
3788
|
+
{
|
|
3789
|
+
type: 'button',
|
|
3790
|
+
className: 'tb-btn',
|
|
3791
|
+
onClick: () => openSessionByCard(chat.card.sessionId),
|
|
3792
|
+
},
|
|
3793
|
+
t('chat.openSession'),
|
|
3794
|
+
),
|
|
3795
|
+
h('span', { style: { flex: 1 } }),
|
|
3796
|
+
h(
|
|
3797
|
+
'button',
|
|
3798
|
+
{
|
|
3799
|
+
type: 'button',
|
|
3800
|
+
className: 'tb-btn primary',
|
|
3801
|
+
disabled: chat.sending || String(chat.input ?? '').trim() === '',
|
|
3802
|
+
onClick: sendChatMessage,
|
|
3803
|
+
},
|
|
3804
|
+
chat.sending ? t('panel.acting') : t('chat.send'),
|
|
3805
|
+
),
|
|
3806
|
+
),
|
|
3807
|
+
),
|
|
3808
|
+
),
|
|
3809
|
+
)
|
|
3810
|
+
: null,
|
|
3180
3811
|
)
|
|
3181
3812
|
}
|
|
3182
3813
|
|
|
@@ -3801,7 +4432,66 @@ window.__ModuleLoader__.load({
|
|
|
3801
4432
|
const BOARD_ANCHORS = ['top', 'right', 'bottom', 'left']
|
|
3802
4433
|
|
|
3803
4434
|
function emptyBoardCanvas() {
|
|
3804
|
-
return { notes: {}, background: [], drawings: {}, edges: [] }
|
|
4435
|
+
return { notes: {}, background: [], drawings: {}, edges: [], texts: [], windows: [] }
|
|
4436
|
+
}
|
|
4437
|
+
|
|
4438
|
+
/** Parse CSV/TSV/Markdown-table text into a rectangular cell grid. */
|
|
4439
|
+
function parseTableText(text) {
|
|
4440
|
+
const lines = String(text ?? '')
|
|
4441
|
+
.replace(/\r\n?/g, '\n')
|
|
4442
|
+
.split('\n')
|
|
4443
|
+
while (lines.length > 0 && lines[lines.length - 1] === '') lines.pop()
|
|
4444
|
+
if (lines.length === 0) return [['']]
|
|
4445
|
+
if (lines.filter((line) => line.includes('|')).length >= 2) {
|
|
4446
|
+
const rows = []
|
|
4447
|
+
for (const line of lines) {
|
|
4448
|
+
const trimmed = line.trim()
|
|
4449
|
+
if (!trimmed.includes('|')) continue
|
|
4450
|
+
if (/^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?$/.test(trimmed)) continue
|
|
4451
|
+
let cells = trimmed.split('|').map((cell) => cell.trim())
|
|
4452
|
+
if (cells.length > 0 && cells[0] === '') cells = cells.slice(1)
|
|
4453
|
+
if (cells.length > 0 && cells[cells.length - 1] === '') cells = cells.slice(0, -1)
|
|
4454
|
+
rows.push(cells)
|
|
4455
|
+
}
|
|
4456
|
+
if (rows.length > 0) return rows.slice(0, 50).map((row) => row.slice(0, 20))
|
|
4457
|
+
}
|
|
4458
|
+
const delimiter = lines.some((line) => line.includes('\t')) ? '\t' : ','
|
|
4459
|
+
const rows = []
|
|
4460
|
+
let row = []
|
|
4461
|
+
let cell = ''
|
|
4462
|
+
let quoted = false
|
|
4463
|
+
const pushCell = () => {
|
|
4464
|
+
row.push(cell)
|
|
4465
|
+
cell = ''
|
|
4466
|
+
}
|
|
4467
|
+
const pushRow = () => {
|
|
4468
|
+
pushCell()
|
|
4469
|
+
rows.push(row)
|
|
4470
|
+
row = []
|
|
4471
|
+
}
|
|
4472
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
4473
|
+
const char = text[index]
|
|
4474
|
+
if (quoted) {
|
|
4475
|
+
if (char === '"' && text[index + 1] === '"') {
|
|
4476
|
+
cell += '"'
|
|
4477
|
+
index += 1
|
|
4478
|
+
} else if (char === '"') quoted = false
|
|
4479
|
+
else cell += char
|
|
4480
|
+
continue
|
|
4481
|
+
}
|
|
4482
|
+
if (char === '"') quoted = true
|
|
4483
|
+
else if (char === delimiter) pushCell()
|
|
4484
|
+
else if (char === '\n') pushRow()
|
|
4485
|
+
else if (char !== '\r') cell += char
|
|
4486
|
+
}
|
|
4487
|
+
if (cell !== '' || row.length > 0) pushRow()
|
|
4488
|
+
if (rows.length === 0) return [['']]
|
|
4489
|
+
return rows.slice(0, 50).map((entry) => entry.slice(0, 20).map((value) => value.slice(0, 500)))
|
|
4490
|
+
}
|
|
4491
|
+
|
|
4492
|
+
/** Serialize a table grid back to editable TSV text. */
|
|
4493
|
+
function tableRowsToText(rows) {
|
|
4494
|
+
return (Array.isArray(rows) ? rows : []).map((row) => (Array.isArray(row) ? row : []).join('\t')).join('\n')
|
|
3805
4495
|
}
|
|
3806
4496
|
|
|
3807
4497
|
/** Deep-copy the sticky canvas so React sees new references. */
|
|
@@ -3820,6 +4510,11 @@ window.__ModuleLoader__.load({
|
|
|
3820
4510
|
drawings: Object.fromEntries(
|
|
3821
4511
|
Object.entries(canvas.drawings && typeof canvas.drawings === 'object' ? canvas.drawings : {}).map(([id, strokes]) => [id, copyStrokes(strokes)]),
|
|
3822
4512
|
),
|
|
4513
|
+
texts: (Array.isArray(canvas.texts) ? canvas.texts : []).map((text) => ({ ...text })),
|
|
4514
|
+
windows: (Array.isArray(canvas.windows) ? canvas.windows : []).map((window) => ({
|
|
4515
|
+
...window,
|
|
4516
|
+
...(Array.isArray(window.rows) ? { rows: window.rows.map((row) => [...row]) } : {}),
|
|
4517
|
+
})),
|
|
3823
4518
|
edges: (Array.isArray(canvas.edges) ? canvas.edges : []).map((edge) => ({
|
|
3824
4519
|
...edge,
|
|
3825
4520
|
from: { ...(edge.from ?? {}) },
|
|
@@ -3973,6 +4668,7 @@ window.__ModuleLoader__.load({
|
|
|
3973
4668
|
width: BOARD_NOTE_W,
|
|
3974
4669
|
height: BOARD_NOTE_H,
|
|
3975
4670
|
z: index,
|
|
4671
|
+
kind: 'sticky',
|
|
3976
4672
|
color: '#ffffff',
|
|
3977
4673
|
}
|
|
3978
4674
|
}
|
|
@@ -4544,6 +5240,10 @@ window.__ModuleLoader__.load({
|
|
|
4544
5240
|
const selectedRef = React.useRef(selected)
|
|
4545
5241
|
selectedRef.current = selected
|
|
4546
5242
|
const [readerId, setReaderId] = React.useState('')
|
|
5243
|
+
const [textEditor, setTextEditor] = React.useState(null)
|
|
5244
|
+
const [windowEditor, setWindowEditor] = React.useState(null)
|
|
5245
|
+
const [insertMenu, setInsertMenu] = React.useState(false)
|
|
5246
|
+
const [notice, setNotice] = React.useState(null)
|
|
4547
5247
|
const [linkPreview, setLinkPreview] = React.useState(null)
|
|
4548
5248
|
const [zoom, setZoom] = React.useState(1)
|
|
4549
5249
|
const zoomRef = React.useRef(zoom)
|
|
@@ -4691,6 +5391,17 @@ window.__ModuleLoader__.load({
|
|
|
4691
5391
|
}
|
|
4692
5392
|
addStrokes(canvasRef.current.background)
|
|
4693
5393
|
for (const strokes of Object.values(canvasRef.current.drawings ?? {})) addStrokes(strokes)
|
|
5394
|
+
for (const item of canvasRef.current.windows ?? []) {
|
|
5395
|
+
include(Number(item.x) || 0, Number(item.y) || 0)
|
|
5396
|
+
include((Number(item.x) || 0) + (Number(item.width) || 480), (Number(item.y) || 0) + (Number(item.height) || 260))
|
|
5397
|
+
}
|
|
5398
|
+
for (const item of canvasRef.current.texts ?? []) {
|
|
5399
|
+
const width = Math.min(1200, Math.max(80, Number(item.width) || 320))
|
|
5400
|
+
const lines = String(item.text || '').split(String.fromCharCode(10)).length
|
|
5401
|
+
const height = Math.max(24, lines * (Number(item.fontSize) || 18) * 1.45)
|
|
5402
|
+
include(Number(item.x) || 0, Number(item.y) || 0)
|
|
5403
|
+
include((Number(item.x) || 0) + width, (Number(item.y) || 0) + height)
|
|
5404
|
+
}
|
|
4694
5405
|
if (!Number.isFinite(minX)) {
|
|
4695
5406
|
minX = BOARD_STAGE_W / 2 - 300
|
|
4696
5407
|
maxX = BOARD_STAGE_W / 2 + 300
|
|
@@ -4804,10 +5515,17 @@ window.__ModuleLoader__.load({
|
|
|
4804
5515
|
const sortedEntries = [...entries].sort((left, right) => (right.updatedAt ?? 0) - (left.updatedAt ?? 0))
|
|
4805
5516
|
const boardVersion = state.board?.version ?? 0
|
|
4806
5517
|
const layoutFor = (entry, index) => canvas.notes[entry.id] ?? autoBoardLayout(index)
|
|
4807
|
-
const noteSize = (layout) =>
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
5518
|
+
const noteSize = (layout) => {
|
|
5519
|
+
const doc = layout?.kind === 'doc'
|
|
5520
|
+
return {
|
|
5521
|
+
width: doc
|
|
5522
|
+
? Math.min(1200, Math.max(320, Number(layout?.width) || 560))
|
|
5523
|
+
: Math.min(640, Math.max(160, Number(layout?.width) || BOARD_NOTE_W)),
|
|
5524
|
+
height: doc
|
|
5525
|
+
? Math.min(900, Math.max(200, Number(layout?.height) || 420))
|
|
5526
|
+
: Math.min(560, Math.max(120, Number(layout?.height) || BOARD_NOTE_H)),
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
4811
5529
|
/** Viewport client point -> unscaled stage coordinates. */
|
|
4812
5530
|
const stagePoint = (event) => {
|
|
4813
5531
|
const stage = stageRef.current
|
|
@@ -4855,7 +5573,7 @@ window.__ModuleLoader__.load({
|
|
|
4855
5573
|
const stage = stageRef.current
|
|
4856
5574
|
return stage ? { layer: 'background', noteId: '', rect: stage.getBoundingClientRect() } : null
|
|
4857
5575
|
}
|
|
4858
|
-
const startCreate = () => setDraft({ id: '', title: '', body: '', preview: false, busy: false, error: null, color: '#ffffff' })
|
|
5576
|
+
const startCreate = (kind = 'sticky') => setDraft({ id: '', title: '', body: '', preview: false, busy: false, error: null, color: '#ffffff', kind })
|
|
4859
5577
|
const startEdit = (entry) =>
|
|
4860
5578
|
setDraft({
|
|
4861
5579
|
id: entry.id,
|
|
@@ -4865,6 +5583,7 @@ window.__ModuleLoader__.load({
|
|
|
4865
5583
|
busy: false,
|
|
4866
5584
|
error: null,
|
|
4867
5585
|
color: canvasRef.current.notes[entry.id]?.color || '#ffffff',
|
|
5586
|
+
kind: entry.kind === 'doc' ? 'doc' : 'sticky',
|
|
4868
5587
|
})
|
|
4869
5588
|
const closeDraft = () => {
|
|
4870
5589
|
if (draft && !draft.busy) setDraft(null)
|
|
@@ -4892,7 +5611,7 @@ window.__ModuleLoader__.load({
|
|
|
4892
5611
|
try {
|
|
4893
5612
|
const body = await request('action', {
|
|
4894
5613
|
method: 'POST',
|
|
4895
|
-
body: boardScope({ action: 'note-save', ...(draft.id ? { id: draft.id } : {}), title: draft.title, body: draft.body }),
|
|
5614
|
+
body: boardScope({ action: 'note-save', ...(draft.id ? { id: draft.id } : {}), title: draft.title, body: draft.body, kind: draft.kind === 'doc' ? 'doc' : 'sticky' }),
|
|
4896
5615
|
})
|
|
4897
5616
|
let board = body.board ?? state.board
|
|
4898
5617
|
setState({ loading: false, board, error: null })
|
|
@@ -4901,11 +5620,15 @@ window.__ModuleLoader__.load({
|
|
|
4901
5620
|
// the visible sticky and the stored layout can never disagree.
|
|
4902
5621
|
if (!draft.id && body.entry?.id && board && !canvasRef.current.notes[body.entry.id]) {
|
|
4903
5622
|
const index = Math.max(0, (board.entries?.length ?? 1) - 1)
|
|
5623
|
+
const isDoc = draft.kind === 'doc' || body.entry?.kind === 'doc'
|
|
5624
|
+
const base = autoBoardLayout(index)
|
|
4904
5625
|
const layoutBody = await saveCanvasNow({
|
|
4905
5626
|
...canvasRef.current,
|
|
4906
5627
|
notes: {
|
|
4907
5628
|
...canvasRef.current.notes,
|
|
4908
|
-
[body.entry.id]:
|
|
5629
|
+
[body.entry.id]: isDoc
|
|
5630
|
+
? { ...base, kind: 'doc', width: 560, height: 420, color: draft.color || '#ffffff' }
|
|
5631
|
+
: { ...base, kind: 'sticky', color: draft.color || '#ffffff' },
|
|
4909
5632
|
},
|
|
4910
5633
|
})
|
|
4911
5634
|
board = layoutBody?.board ?? board
|
|
@@ -4914,7 +5637,11 @@ window.__ModuleLoader__.load({
|
|
|
4914
5637
|
...canvasRef.current,
|
|
4915
5638
|
notes: {
|
|
4916
5639
|
...canvasRef.current.notes,
|
|
4917
|
-
[draft.id]: {
|
|
5640
|
+
[draft.id]: {
|
|
5641
|
+
...canvasRef.current.notes[draft.id],
|
|
5642
|
+
kind: draft.kind === 'doc' ? 'doc' : 'sticky',
|
|
5643
|
+
color: draft.color || '#ffffff',
|
|
5644
|
+
},
|
|
4918
5645
|
},
|
|
4919
5646
|
})
|
|
4920
5647
|
board = layoutBody?.board ?? board
|
|
@@ -4925,6 +5652,233 @@ window.__ModuleLoader__.load({
|
|
|
4925
5652
|
setDraft({ ...draft, busy: false, error: error?.message || String(error) })
|
|
4926
5653
|
}
|
|
4927
5654
|
}
|
|
5655
|
+
/** Stage point at the centre of the current viewport (used for new text). */
|
|
5656
|
+
const viewportStageCenter = () => {
|
|
5657
|
+
const viewport = viewportRef.current
|
|
5658
|
+
const stage = stageRef.current
|
|
5659
|
+
if (!viewport || !stage) return [180, 160]
|
|
5660
|
+
const rect = stage.getBoundingClientRect()
|
|
5661
|
+
return [
|
|
5662
|
+
Math.round((viewport.scrollLeft + viewport.clientWidth / 2 - rect.left) / zoomScale()),
|
|
5663
|
+
Math.round((viewport.scrollTop + viewport.clientHeight / 2 - rect.top) / zoomScale()),
|
|
5664
|
+
]
|
|
5665
|
+
}
|
|
5666
|
+
|
|
5667
|
+
const startAddText = () => {
|
|
5668
|
+
const [cx, cy] = viewportStageCenter()
|
|
5669
|
+
setTextEditor({ id: '', text: '', color: '#e6e6e6', fontSize: 18, x: Math.max(0, cx - 160), y: Math.max(0, cy - 24), width: 320 })
|
|
5670
|
+
}
|
|
5671
|
+
|
|
5672
|
+
const startEditText = (item) => {
|
|
5673
|
+
if (!item) return
|
|
5674
|
+
setTextEditor({ ...item })
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
const saveText = async () => {
|
|
5678
|
+
const editor = textEditor
|
|
5679
|
+
if (!editor) return
|
|
5680
|
+
const text = String(editor.text ?? '').trim()
|
|
5681
|
+
if (text === '') {
|
|
5682
|
+
if (editor.id) await deleteText(editor.id)
|
|
5683
|
+
else setTextEditor(null)
|
|
5684
|
+
return
|
|
5685
|
+
}
|
|
5686
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
5687
|
+
let id = editor.id
|
|
5688
|
+
if (!id) id = `tx-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`
|
|
5689
|
+
const item = {
|
|
5690
|
+
id,
|
|
5691
|
+
text,
|
|
5692
|
+
x: Math.max(0, Number(editor.x) || 0),
|
|
5693
|
+
y: Math.max(0, Number(editor.y) || 0),
|
|
5694
|
+
width: Math.min(1200, Math.max(80, Number(editor.width) || 320)),
|
|
5695
|
+
color: /^#[0-9a-f]{6}$/i.test(String(editor.color || '')) ? String(editor.color).toLowerCase() : '#e6e6e6',
|
|
5696
|
+
fontSize: Math.min(96, Math.max(8, Number(editor.fontSize) || 18)),
|
|
5697
|
+
}
|
|
5698
|
+
next.texts = [...(next.texts ?? []).filter((entry) => entry.id !== id), item]
|
|
5699
|
+
try {
|
|
5700
|
+
await saveCanvasNow(next)
|
|
5701
|
+
} catch (error) {
|
|
5702
|
+
setTextEditor({ ...editor, error: error?.message || String(error) })
|
|
5703
|
+
return
|
|
5704
|
+
}
|
|
5705
|
+
setSelected(id)
|
|
5706
|
+
setTextEditor(null)
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
const deleteText = async (id) => {
|
|
5710
|
+
if (!id) return
|
|
5711
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
5712
|
+
next.texts = (next.texts ?? []).filter((entry) => entry.id !== id)
|
|
5713
|
+
try {
|
|
5714
|
+
await saveCanvasNow(next)
|
|
5715
|
+
} catch {
|
|
5716
|
+
// The text stays visible if the save fails.
|
|
5717
|
+
return
|
|
5718
|
+
}
|
|
5719
|
+
if (selectedRef.current === id) setSelected('')
|
|
5720
|
+
setTextEditor(null)
|
|
5721
|
+
}
|
|
5722
|
+
|
|
5723
|
+
const emptyTableRows = (rows = 3, cols = 3) =>
|
|
5724
|
+
Array.from({ length: Math.max(1, rows) }, () => Array.from({ length: Math.max(1, cols) }, () => ''))
|
|
5725
|
+
|
|
5726
|
+
const startAddTable = (rows = 3, cols = 3) => {
|
|
5727
|
+
const [cx, cy] = viewportStageCenter()
|
|
5728
|
+
setInsertMenu(false)
|
|
5729
|
+
setWindowEditor({
|
|
5730
|
+
id: '',
|
|
5731
|
+
kind: 'table',
|
|
5732
|
+
title: '表格',
|
|
5733
|
+
rows: emptyTableRows(rows, cols),
|
|
5734
|
+
width: 500,
|
|
5735
|
+
height: 300,
|
|
5736
|
+
x: Math.max(0, cx - 250),
|
|
5737
|
+
y: Math.max(0, cy - 150),
|
|
5738
|
+
busy: false,
|
|
5739
|
+
error: null,
|
|
5740
|
+
})
|
|
5741
|
+
}
|
|
5742
|
+
|
|
5743
|
+
const pickFile = (accept, onFile) => {
|
|
5744
|
+
try {
|
|
5745
|
+
const input = document.createElement('input')
|
|
5746
|
+
input.type = 'file'
|
|
5747
|
+
input.accept = accept
|
|
5748
|
+
input.style.display = 'none'
|
|
5749
|
+
input.addEventListener('change', () => {
|
|
5750
|
+
const file = input.files?.[0]
|
|
5751
|
+
if (file) onFile(file)
|
|
5752
|
+
})
|
|
5753
|
+
input.click()
|
|
5754
|
+
} catch (error) {
|
|
5755
|
+
setState((previous) => ({ ...previous, error: error?.message || String(error) }))
|
|
5756
|
+
}
|
|
5757
|
+
}
|
|
5758
|
+
|
|
5759
|
+
const startImportTable = () => {
|
|
5760
|
+
setInsertMenu(false)
|
|
5761
|
+
pickFile('.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/plain,text/markdown', (file) => {
|
|
5762
|
+
if (file.size > 2_000_000) {
|
|
5763
|
+
setState((previous) => ({ ...previous, error: '表格文件过大' }))
|
|
5764
|
+
return
|
|
5765
|
+
}
|
|
5766
|
+
const reader = new FileReader()
|
|
5767
|
+
reader.onload = () => {
|
|
5768
|
+
const rows = parseTableText(String(reader.result ?? ''))
|
|
5769
|
+
const [cx, cy] = viewportStageCenter()
|
|
5770
|
+
setWindowEditor({
|
|
5771
|
+
id: '',
|
|
5772
|
+
kind: 'table',
|
|
5773
|
+
title: file.name.replace(/\.[^.]+$/, '') || '导入表格',
|
|
5774
|
+
rows,
|
|
5775
|
+
width: Math.min(900, Math.max(420, (rows[0]?.length ?? 3) * 120)),
|
|
5776
|
+
height: Math.min(700, Math.max(220, rows.length * 34 + 44)),
|
|
5777
|
+
x: Math.max(0, cx - 250),
|
|
5778
|
+
y: Math.max(0, cy - 150),
|
|
5779
|
+
busy: false,
|
|
5780
|
+
error: null,
|
|
5781
|
+
})
|
|
5782
|
+
}
|
|
5783
|
+
reader.onerror = () => setState((previous) => ({ ...previous, error: '表格读取失败' }))
|
|
5784
|
+
reader.readAsText(file)
|
|
5785
|
+
})
|
|
5786
|
+
}
|
|
5787
|
+
|
|
5788
|
+
const startImportImage = () => {
|
|
5789
|
+
setInsertMenu(false)
|
|
5790
|
+
pickFile('image/*', (file) => {
|
|
5791
|
+
if (!/^image\//i.test(file.type)) {
|
|
5792
|
+
setState((previous) => ({ ...previous, error: '请选择图片文件' }))
|
|
5793
|
+
return
|
|
5794
|
+
}
|
|
5795
|
+
if (file.size > 1_500_000) {
|
|
5796
|
+
setState((previous) => ({ ...previous, error: '图片过大(上限约 1.5MB)' }))
|
|
5797
|
+
return
|
|
5798
|
+
}
|
|
5799
|
+
const reader = new FileReader()
|
|
5800
|
+
reader.onload = () => {
|
|
5801
|
+
const [cx, cy] = viewportStageCenter()
|
|
5802
|
+
setWindowEditor({
|
|
5803
|
+
id: '',
|
|
5804
|
+
kind: 'image',
|
|
5805
|
+
title: file.name.replace(/\.[^.]+$/, '') || '图片',
|
|
5806
|
+
src: String(reader.result ?? ''),
|
|
5807
|
+
alt: file.name,
|
|
5808
|
+
width: 380,
|
|
5809
|
+
height: 280,
|
|
5810
|
+
x: Math.max(0, cx - 190),
|
|
5811
|
+
y: Math.max(0, cy - 140),
|
|
5812
|
+
busy: false,
|
|
5813
|
+
error: null,
|
|
5814
|
+
})
|
|
5815
|
+
}
|
|
5816
|
+
reader.onerror = () => setState((previous) => ({ ...previous, error: '图片读取失败' }))
|
|
5817
|
+
reader.readAsDataURL(file)
|
|
5818
|
+
})
|
|
5819
|
+
}
|
|
5820
|
+
|
|
5821
|
+
const startEditWindow = (item) => {
|
|
5822
|
+
if (!item) return
|
|
5823
|
+
setWindowEditor({
|
|
5824
|
+
...item,
|
|
5825
|
+
rows: Array.isArray(item.rows) ? item.rows.map((row) => [...row]) : item.rows,
|
|
5826
|
+
busy: false,
|
|
5827
|
+
error: null,
|
|
5828
|
+
})
|
|
5829
|
+
}
|
|
5830
|
+
|
|
5831
|
+
const saveWindow = async () => {
|
|
5832
|
+
const editor = windowEditor
|
|
5833
|
+
if (!editor) return
|
|
5834
|
+
const title = String(editor.title ?? '').trim() || (editor.kind === 'table' ? '表格' : '图片')
|
|
5835
|
+
if (editor.kind === 'image' && !editor.src) {
|
|
5836
|
+
setWindowEditor({ ...editor, error: '请先选择图片' })
|
|
5837
|
+
return
|
|
5838
|
+
}
|
|
5839
|
+
let rows = editor.rows
|
|
5840
|
+
if (editor.kind === 'table') {
|
|
5841
|
+
rows = (Array.isArray(editor.rows) ? editor.rows : [[]]).slice(0, 50).map((row) =>
|
|
5842
|
+
(Array.isArray(row) ? row : []).slice(0, 20).map((cell) => String(cell ?? '').slice(0, 500)),
|
|
5843
|
+
)
|
|
5844
|
+
if (rows.length === 0) rows = [['']]
|
|
5845
|
+
}
|
|
5846
|
+
const id = editor.id || `win-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`
|
|
5847
|
+
const item = {
|
|
5848
|
+
id,
|
|
5849
|
+
kind: editor.kind,
|
|
5850
|
+
title,
|
|
5851
|
+
x: Math.max(0, Number(editor.x) || 0),
|
|
5852
|
+
y: Math.max(0, Number(editor.y) || 0),
|
|
5853
|
+
width: Math.min(1600, Math.max(160, Number(editor.width) || (editor.kind === 'image' ? 380 : 500))),
|
|
5854
|
+
height: Math.min(1200, Math.max(120, Number(editor.height) || 280)),
|
|
5855
|
+
...(editor.kind === 'table' ? { rows } : { src: editor.src, alt: editor.alt || title }),
|
|
5856
|
+
}
|
|
5857
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
5858
|
+
next.windows = [...(next.windows ?? []).filter((entry) => entry.id !== id), item]
|
|
5859
|
+
try {
|
|
5860
|
+
await saveCanvasNow(next)
|
|
5861
|
+
} catch (error) {
|
|
5862
|
+
setWindowEditor({ ...editor, busy: false, error: error?.message || String(error) })
|
|
5863
|
+
return
|
|
5864
|
+
}
|
|
5865
|
+
setSelected(id)
|
|
5866
|
+
setWindowEditor(null)
|
|
5867
|
+
}
|
|
5868
|
+
|
|
5869
|
+
const deleteWindow = async (id) => {
|
|
5870
|
+
if (!id) return
|
|
5871
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
5872
|
+
next.windows = (next.windows ?? []).filter((entry) => entry.id !== id)
|
|
5873
|
+
try {
|
|
5874
|
+
await saveCanvasNow(next)
|
|
5875
|
+
} catch {
|
|
5876
|
+
return
|
|
5877
|
+
}
|
|
5878
|
+
if (selectedRef.current === id) setSelected('')
|
|
5879
|
+
setWindowEditor(null)
|
|
5880
|
+
}
|
|
5881
|
+
|
|
4928
5882
|
const removeEntry = async (id) => {
|
|
4929
5883
|
if (!id || busy !== '') return
|
|
4930
5884
|
let confirmed = true
|
|
@@ -5040,10 +5994,51 @@ window.__ModuleLoader__.load({
|
|
|
5040
5994
|
}
|
|
5041
5995
|
return
|
|
5042
5996
|
}
|
|
5997
|
+
if (current.type === 'window-drag') {
|
|
5998
|
+
const scale = zoomScale()
|
|
5999
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6000
|
+
const item = (next.windows ?? []).find((entry) => entry.id === current.windowId)
|
|
6001
|
+
if (item) {
|
|
6002
|
+
item.x = Math.max(0, Math.min(BOARD_STAGE_W - (Number(item.width) || 480), current.originX + (event.clientX - current.startX) / scale))
|
|
6003
|
+
item.y = Math.max(0, Math.min(BOARD_STAGE_H - 80, current.originY + (event.clientY - current.startY) / scale))
|
|
6004
|
+
next.windows = (next.windows ?? []).map((entry) => (entry.id === item.id ? item : entry))
|
|
6005
|
+
canvasRef.current = next
|
|
6006
|
+
setCanvas(next)
|
|
6007
|
+
}
|
|
6008
|
+
return
|
|
6009
|
+
}
|
|
6010
|
+
if (current.type === 'window-resize') {
|
|
6011
|
+
const scale = zoomScale()
|
|
6012
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6013
|
+
const item = (next.windows ?? []).find((entry) => entry.id === current.windowId)
|
|
6014
|
+
if (item) {
|
|
6015
|
+
item.width = Math.min(1600, Math.max(160, Math.round(current.startW + (event.clientX - current.startX) / scale)))
|
|
6016
|
+
item.height = Math.min(1200, Math.max(120, Math.round(current.startH + (event.clientY - current.startY) / scale)))
|
|
6017
|
+
next.windows = (next.windows ?? []).map((entry) => (entry.id === item.id ? item : entry))
|
|
6018
|
+
canvasRef.current = next
|
|
6019
|
+
setCanvas(next)
|
|
6020
|
+
}
|
|
6021
|
+
return
|
|
6022
|
+
}
|
|
6023
|
+
if (current.type === 'text-drag') {
|
|
6024
|
+
const scale = zoomScale()
|
|
6025
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6026
|
+
const item = (next.texts ?? []).find((entry) => entry.id === current.textId)
|
|
6027
|
+
if (item) {
|
|
6028
|
+
item.x = Math.max(0, Math.min(BOARD_STAGE_W - (Number(item.width) || 320), current.originX + (event.clientX - current.startX) / scale))
|
|
6029
|
+
item.y = Math.max(0, Math.min(BOARD_STAGE_H - 40, current.originY + (event.clientY - current.startY) / scale))
|
|
6030
|
+
next.texts = (next.texts ?? []).map((entry) => (entry.id === item.id ? item : entry))
|
|
6031
|
+
canvasRef.current = next
|
|
6032
|
+
setCanvas(next)
|
|
6033
|
+
}
|
|
6034
|
+
return
|
|
6035
|
+
}
|
|
5043
6036
|
if (current.type === 'resize') {
|
|
5044
6037
|
const scale = zoomScale()
|
|
5045
|
-
const
|
|
5046
|
-
const
|
|
6038
|
+
const currentLayout = canvasRef.current.notes[current.noteId] ?? autoBoardLayout(0)
|
|
6039
|
+
const doc = currentLayout.kind === 'doc'
|
|
6040
|
+
const width = Math.min(doc ? 1200 : 640, Math.max(doc ? 320 : 160, Math.round(current.startW + (event.clientX - current.startX) / scale)))
|
|
6041
|
+
const height = Math.min(doc ? 900 : 560, Math.max(doc ? 200 : 120, Math.round(current.startH + (event.clientY - current.startY) / scale)))
|
|
5047
6042
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
5048
6043
|
const layout = next.notes[current.noteId] ?? autoBoardLayout(0)
|
|
5049
6044
|
layout.width = width
|
|
@@ -5073,8 +6068,7 @@ window.__ModuleLoader__.load({
|
|
|
5073
6068
|
const under = layerAt(event)
|
|
5074
6069
|
const changed =
|
|
5075
6070
|
under &&
|
|
5076
|
-
(under.layer !== current.layer || (under.layer === 'note' && under.noteId !== current.noteId))
|
|
5077
|
-
!(under.layer === 'note' && !drawOnStickyRef.current)
|
|
6071
|
+
(under.layer !== current.layer || (under.layer === 'note' && under.noteId !== current.noteId))
|
|
5078
6072
|
if (changed) {
|
|
5079
6073
|
const previous = current.lastWorld ?? [event.clientX, event.clientY]
|
|
5080
6074
|
const crossScale = zoomScale()
|
|
@@ -5134,8 +6128,7 @@ window.__ModuleLoader__.load({
|
|
|
5134
6128
|
const underShape = layerAt(event)
|
|
5135
6129
|
const shapeChanged =
|
|
5136
6130
|
underShape &&
|
|
5137
|
-
(underShape.layer !== current.layer || (underShape.layer === 'note' && underShape.noteId !== current.noteId))
|
|
5138
|
-
!(underShape.layer === 'note' && !drawOnStickyRef.current)
|
|
6131
|
+
(underShape.layer !== current.layer || (underShape.layer === 'note' && underShape.noteId !== current.noteId))
|
|
5139
6132
|
if (shapeChanged) {
|
|
5140
6133
|
const startWorld = current.startWorld ?? [event.clientX, event.clientY]
|
|
5141
6134
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
@@ -5252,6 +6245,59 @@ window.__ModuleLoader__.load({
|
|
|
5252
6245
|
if (event.target?.closest?.('button') || event.target?.closest?.('.tb-sticky-linkline') || event.target?.closest?.('.tb-sticky-actions')) return
|
|
5253
6246
|
const stage = stageRef.current
|
|
5254
6247
|
if (!stage) return
|
|
6248
|
+
const windowElement = event.target?.closest?.('.tb-board-window')
|
|
6249
|
+
const windowId = windowElement?.getAttribute?.('data-window-id') || ''
|
|
6250
|
+
if (windowId) {
|
|
6251
|
+
if (toolRef.current !== 'select') return
|
|
6252
|
+
if (event.target?.closest?.('.tb-board-window-body')) {
|
|
6253
|
+
setSelected(windowId)
|
|
6254
|
+
return
|
|
6255
|
+
}
|
|
6256
|
+
event.preventDefault()
|
|
6257
|
+
setSelected(windowId)
|
|
6258
|
+
const item = (canvasRef.current.windows ?? []).find((entry) => entry.id === windowId)
|
|
6259
|
+
if (item) {
|
|
6260
|
+
if (event.target?.closest?.('.tb-board-window-resize')) {
|
|
6261
|
+
setGesture({
|
|
6262
|
+
type: 'window-resize',
|
|
6263
|
+
windowId,
|
|
6264
|
+
startX: event.clientX,
|
|
6265
|
+
startY: event.clientY,
|
|
6266
|
+
startW: Number(item.width) || 480,
|
|
6267
|
+
startH: Number(item.height) || 260,
|
|
6268
|
+
})
|
|
6269
|
+
} else {
|
|
6270
|
+
setGesture({
|
|
6271
|
+
type: 'window-drag',
|
|
6272
|
+
windowId,
|
|
6273
|
+
startX: event.clientX,
|
|
6274
|
+
startY: event.clientY,
|
|
6275
|
+
originX: Number(item.x) || 0,
|
|
6276
|
+
originY: Number(item.y) || 0,
|
|
6277
|
+
})
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6280
|
+
return
|
|
6281
|
+
}
|
|
6282
|
+
const textElement = event.target?.closest?.('.tb-board-text')
|
|
6283
|
+
const textId = textElement?.getAttribute?.('data-text-id') || ''
|
|
6284
|
+
if (textId && toolRef.current === 'select') {
|
|
6285
|
+
event.preventDefault()
|
|
6286
|
+
setSelected(textId)
|
|
6287
|
+
const item = (canvasRef.current.texts ?? []).find((entry) => entry.id === textId)
|
|
6288
|
+
if (item) {
|
|
6289
|
+
setGesture({
|
|
6290
|
+
type: 'text-drag',
|
|
6291
|
+
textId,
|
|
6292
|
+
startX: event.clientX,
|
|
6293
|
+
startY: event.clientY,
|
|
6294
|
+
originX: Number(item.x) || 0,
|
|
6295
|
+
originY: Number(item.y) || 0,
|
|
6296
|
+
})
|
|
6297
|
+
}
|
|
6298
|
+
return
|
|
6299
|
+
}
|
|
6300
|
+
if (event.target?.closest?.('.tb-doc-body') && toolRef.current === 'select') return
|
|
5255
6301
|
const noteElement = event.target?.closest?.('.tb-sticky')
|
|
5256
6302
|
const noteId = noteElement?.getAttribute?.('data-note-id') || ''
|
|
5257
6303
|
if (toolRef.current === 'link') {
|
|
@@ -5309,10 +6355,13 @@ window.__ModuleLoader__.load({
|
|
|
5309
6355
|
return
|
|
5310
6356
|
}
|
|
5311
6357
|
if (noteId && !drawOnStickyRef.current) {
|
|
5312
|
-
//
|
|
5313
|
-
//
|
|
6358
|
+
// Keep the user's "draw on stickies" choice off; explain why the
|
|
6359
|
+
// stroke did not start with a small light toast instead.
|
|
5314
6360
|
event.preventDefault()
|
|
5315
6361
|
setSelected(noteId)
|
|
6362
|
+
const message = t('board.drawOnStickyNotice')
|
|
6363
|
+
setNotice(message)
|
|
6364
|
+
window.setTimeout(() => setNotice((current) => (current === message ? null : current)), 3600)
|
|
5316
6365
|
return
|
|
5317
6366
|
}
|
|
5318
6367
|
event.preventDefault()
|
|
@@ -5514,11 +6563,12 @@ window.__ModuleLoader__.load({
|
|
|
5514
6563
|
const layout = layoutFor(entry, index)
|
|
5515
6564
|
const size = noteSize(layout)
|
|
5516
6565
|
const agent = entry.source === 'agent'
|
|
6566
|
+
const isDoc = entry.kind === 'doc' || layout.kind === 'doc'
|
|
5517
6567
|
return h(
|
|
5518
6568
|
'article',
|
|
5519
6569
|
{
|
|
5520
6570
|
key: entry.id,
|
|
5521
|
-
className: `tb-sticky${agent ? ' link' : ''}${selected === entry.id ? ' selected' : ''}`,
|
|
6571
|
+
className: `tb-sticky${isDoc ? ' tb-doc' : ''}${agent && !isDoc ? ' link' : ''}${selected === entry.id ? ' selected' : ''}`,
|
|
5522
6572
|
'data-note-id': entry.id,
|
|
5523
6573
|
style: {
|
|
5524
6574
|
left: Number(layout.x) || 0,
|
|
@@ -5536,16 +6586,25 @@ window.__ModuleLoader__.load({
|
|
|
5536
6586
|
h(
|
|
5537
6587
|
'div',
|
|
5538
6588
|
{ className: 'tb-sticky-head' },
|
|
5539
|
-
h('span', { className: 'tb-sticky-src' }, agent ? '🔗' : t('board.sourceUser')),
|
|
5540
|
-
h('span', { className: 'tb-sticky-title', title: entry.title }, entry.title || '未命名便签'),
|
|
6589
|
+
h('span', { className: 'tb-sticky-src' }, isDoc ? '📄' : agent ? '🔗' : t('board.sourceUser')),
|
|
6590
|
+
h('span', { className: 'tb-sticky-title', title: entry.title }, entry.title || (isDoc ? '未命名文档' : '未命名便签')),
|
|
5541
6591
|
h(
|
|
5542
6592
|
'div',
|
|
5543
6593
|
{ className: 'tb-sticky-actions' },
|
|
6594
|
+
h('button', { type: 'button', title: t('board.openMd'), onClick: (event) => { event.stopPropagation(); openReader(entry.id) } }, '📖'),
|
|
5544
6595
|
h('button', { type: 'button', title: t('board.edit'), onClick: (event) => { event.stopPropagation(); startEdit(entry) } }, '✎'),
|
|
5545
6596
|
h('button', { type: 'button', title: t('board.delete'), disabled: busy !== '', onClick: (event) => { event.stopPropagation(); removeEntry(entry.id) } }, '✕'),
|
|
5546
6597
|
),
|
|
5547
6598
|
),
|
|
5548
|
-
|
|
6599
|
+
isDoc
|
|
6600
|
+
? h(
|
|
6601
|
+
'div',
|
|
6602
|
+
{ className: 'tb-doc-body' },
|
|
6603
|
+
...(entry.body.trim()
|
|
6604
|
+
? [h('div', { key: 'md', className: 'tb-md' }, ...renderMarkdown(entry.body, `doc-${entry.id}`))]
|
|
6605
|
+
: [h('span', { key: 'empty' }, t('board.empty'))]),
|
|
6606
|
+
)
|
|
6607
|
+
: agent
|
|
5549
6608
|
? h(
|
|
5550
6609
|
'div',
|
|
5551
6610
|
{ className: 'tb-sticky-body' },
|
|
@@ -5628,6 +6687,34 @@ window.__ModuleLoader__.load({
|
|
|
5628
6687
|
)
|
|
5629
6688
|
: null,
|
|
5630
6689
|
),
|
|
6690
|
+
h(
|
|
6691
|
+
'button',
|
|
6692
|
+
{ type: 'button', className: 'tb-tool', title: t('board.newText'), onClick: startAddText },
|
|
6693
|
+
`T ${t('board.addText')}`,
|
|
6694
|
+
),
|
|
6695
|
+
h(
|
|
6696
|
+
'div',
|
|
6697
|
+
{ className: 'tb-window-insert' },
|
|
6698
|
+
h(
|
|
6699
|
+
'button',
|
|
6700
|
+
{
|
|
6701
|
+
type: 'button',
|
|
6702
|
+
className: `tb-tool${insertMenu ? ' on' : ''}`,
|
|
6703
|
+
title: t('board.insertHint'),
|
|
6704
|
+
onClick: () => setInsertMenu((value) => !value),
|
|
6705
|
+
},
|
|
6706
|
+
`+ ${t('board.insert')}`,
|
|
6707
|
+
),
|
|
6708
|
+
insertMenu
|
|
6709
|
+
? h(
|
|
6710
|
+
'div',
|
|
6711
|
+
{ className: 'tb-shape-menu tb-insert-menu', role: 'menu' },
|
|
6712
|
+
h('button', { type: 'button', role: 'menuitem', onClick: () => startAddTable(3, 3) }, `▦ ${t('board.table')}`),
|
|
6713
|
+
h('button', { type: 'button', role: 'menuitem', onClick: startImportTable }, `⇥ ${t('board.importTable')}`),
|
|
6714
|
+
h('button', { type: 'button', role: 'menuitem', onClick: startImportImage }, `🖼 ${t('board.importImage')}`),
|
|
6715
|
+
)
|
|
6716
|
+
: null,
|
|
6717
|
+
),
|
|
5631
6718
|
h('span', { className: 'tb-board-meta' }, t('board.brushSize')),
|
|
5632
6719
|
h('input', {
|
|
5633
6720
|
type: 'range',
|
|
@@ -5794,9 +6881,11 @@ window.__ModuleLoader__.load({
|
|
|
5794
6881
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomReset'), onClick: () => zoomBy(1 / zoomRef.current) }, `${Math.round(zoom * 100)}%`),
|
|
5795
6882
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomIn'), onClick: () => zoomBy(1.2) }, '+'),
|
|
5796
6883
|
h('button', { type: 'button', className: 'tb-btn', disabled: state.loading, onClick: refresh }, t('board.refresh')),
|
|
5797
|
-
h('button', { type: 'button', className: 'tb-btn primary', onClick: startCreate }, `+ ${t('board.newSticky')}`),
|
|
6884
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: () => startCreate('sticky') }, `+ ${t('board.newSticky')}`),
|
|
6885
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => startCreate('doc') }, `+ ${t('board.newDoc')}`),
|
|
5798
6886
|
),
|
|
5799
6887
|
toolbar,
|
|
6888
|
+
notice ? h('div', { className: 'tb-board-toast', role: 'status' }, notice) : null,
|
|
5800
6889
|
h('div', { className: 'tb-board-hint-wrap' }, h('span', { className: 'tb-ws-hint' }, `${t('board.stickyHint')} · ${t('board.panHint')}`)),
|
|
5801
6890
|
state.error ? h('div', { className: 'tb-feedback err' }, format(t('board.error'), { error: state.error })) : null,
|
|
5802
6891
|
h(
|
|
@@ -5815,10 +6904,160 @@ window.__ModuleLoader__.load({
|
|
|
5815
6904
|
drawingLayer(canvas.background, 'bg'),
|
|
5816
6905
|
edgeLayer(),
|
|
5817
6906
|
...entries.map((entry, index) => stickyFor(entry, index)),
|
|
6907
|
+
...(canvas.texts ?? []).map((item) =>
|
|
6908
|
+
h(
|
|
6909
|
+
'div',
|
|
6910
|
+
{
|
|
6911
|
+
key: item.id,
|
|
6912
|
+
className: `tb-board-text${selected === item.id ? ' selected' : ''}`,
|
|
6913
|
+
'data-text-id': item.id,
|
|
6914
|
+
style: {
|
|
6915
|
+
left: Number(item.x) || 0,
|
|
6916
|
+
top: Number(item.y) || 0,
|
|
6917
|
+
width: Math.min(1200, Math.max(80, Number(item.width) || 320)),
|
|
6918
|
+
color: item.color || '#e6e6e6',
|
|
6919
|
+
fontSize: Math.min(96, Math.max(8, Number(item.fontSize) || 18)),
|
|
6920
|
+
zIndex: 260,
|
|
6921
|
+
},
|
|
6922
|
+
onDoubleClick: (event) => {
|
|
6923
|
+
event.stopPropagation()
|
|
6924
|
+
startEditText(item)
|
|
6925
|
+
},
|
|
6926
|
+
},
|
|
6927
|
+
h('div', { className: 'tb-board-text-content' }, item.text || ''),
|
|
6928
|
+
h(
|
|
6929
|
+
'div',
|
|
6930
|
+
{ className: 'tb-board-text-actions' },
|
|
6931
|
+
h(
|
|
6932
|
+
'button',
|
|
6933
|
+
{
|
|
6934
|
+
type: 'button',
|
|
6935
|
+
title: t('board.editText'),
|
|
6936
|
+
onClick: (event) => {
|
|
6937
|
+
event.stopPropagation()
|
|
6938
|
+
startEditText(item)
|
|
6939
|
+
},
|
|
6940
|
+
},
|
|
6941
|
+
'✎',
|
|
6942
|
+
),
|
|
6943
|
+
h(
|
|
6944
|
+
'button',
|
|
6945
|
+
{
|
|
6946
|
+
type: 'button',
|
|
6947
|
+
title: t('board.deleteText'),
|
|
6948
|
+
onClick: (event) => {
|
|
6949
|
+
event.stopPropagation()
|
|
6950
|
+
deleteText(item.id)
|
|
6951
|
+
},
|
|
6952
|
+
},
|
|
6953
|
+
'✕',
|
|
6954
|
+
),
|
|
6955
|
+
),
|
|
6956
|
+
),
|
|
6957
|
+
),
|
|
6958
|
+
...(canvas.windows ?? []).map((item) =>
|
|
6959
|
+
h(
|
|
6960
|
+
'div',
|
|
6961
|
+
{
|
|
6962
|
+
key: item.id,
|
|
6963
|
+
className: `tb-board-window${selected === item.id ? ' selected' : ''}`,
|
|
6964
|
+
'data-window-id': item.id,
|
|
6965
|
+
style: {
|
|
6966
|
+
left: Number(item.x) || 0,
|
|
6967
|
+
top: Number(item.y) || 0,
|
|
6968
|
+
width: Math.min(1600, Math.max(160, Number(item.width) || 480)),
|
|
6969
|
+
height: Math.min(1200, Math.max(120, Number(item.height) || 260)),
|
|
6970
|
+
zIndex: 280,
|
|
6971
|
+
},
|
|
6972
|
+
onDoubleClick: (event) => {
|
|
6973
|
+
if (event.target?.closest?.('.tb-board-window-body')) return
|
|
6974
|
+
event.stopPropagation()
|
|
6975
|
+
startEditWindow(item)
|
|
6976
|
+
},
|
|
6977
|
+
},
|
|
6978
|
+
h(
|
|
6979
|
+
'div',
|
|
6980
|
+
{ className: 'tb-board-window-head' },
|
|
6981
|
+
h('span', { className: 'tb-board-window-title', title: item.title }, item.title || (item.kind === 'table' ? t('board.table') : t('board.importImage'))),
|
|
6982
|
+
h(
|
|
6983
|
+
'div',
|
|
6984
|
+
{ className: 'tb-board-window-actions' },
|
|
6985
|
+
h(
|
|
6986
|
+
'button',
|
|
6987
|
+
{
|
|
6988
|
+
type: 'button',
|
|
6989
|
+
title: t('board.edit'),
|
|
6990
|
+
onClick: (event) => {
|
|
6991
|
+
event.stopPropagation()
|
|
6992
|
+
startEditWindow(item)
|
|
6993
|
+
},
|
|
6994
|
+
},
|
|
6995
|
+
'✎',
|
|
6996
|
+
),
|
|
6997
|
+
h(
|
|
6998
|
+
'button',
|
|
6999
|
+
{
|
|
7000
|
+
type: 'button',
|
|
7001
|
+
title: t('board.delete'),
|
|
7002
|
+
onClick: (event) => {
|
|
7003
|
+
event.stopPropagation()
|
|
7004
|
+
deleteWindow(item.id)
|
|
7005
|
+
},
|
|
7006
|
+
},
|
|
7007
|
+
'✕',
|
|
7008
|
+
),
|
|
7009
|
+
),
|
|
7010
|
+
),
|
|
7011
|
+
h(
|
|
7012
|
+
'div',
|
|
7013
|
+
{ className: 'tb-board-window-body' },
|
|
7014
|
+
item.kind === 'table'
|
|
7015
|
+
? h(
|
|
7016
|
+
'table',
|
|
7017
|
+
null,
|
|
7018
|
+
...(item.rows ?? [['']]).map((row, rowIndex) =>
|
|
7019
|
+
h(
|
|
7020
|
+
'tr',
|
|
7021
|
+
{ key: `row-${rowIndex}` },
|
|
7022
|
+
...(row ?? []).map((cell, cellIndex) =>
|
|
7023
|
+
h(
|
|
7024
|
+
'td',
|
|
7025
|
+
{
|
|
7026
|
+
key: `cell-${rowIndex}-${cellIndex}`,
|
|
7027
|
+
contentEditable: true,
|
|
7028
|
+
suppressContentEditableWarning: true,
|
|
7029
|
+
onBlur: (event) => {
|
|
7030
|
+
const text = String(event.currentTarget?.textContent ?? '').replace(/\u00a0/g, '')
|
|
7031
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
7032
|
+
const target = (next.windows ?? []).find((entry) => entry.id === item.id)
|
|
7033
|
+
if (!target || !Array.isArray(target.rows)) return
|
|
7034
|
+
target.rows[rowIndex] = [...(target.rows[rowIndex] ?? [])]
|
|
7035
|
+
target.rows[rowIndex][cellIndex] = text
|
|
7036
|
+
next.windows = (next.windows ?? []).map((entry) => (entry.id === item.id ? target : entry))
|
|
7037
|
+
saveCanvasSoon(next)
|
|
7038
|
+
},
|
|
7039
|
+
},
|
|
7040
|
+
String(cell ?? '') === '' ? '\u00a0' : String(cell),
|
|
7041
|
+
),
|
|
7042
|
+
),
|
|
7043
|
+
),
|
|
7044
|
+
),
|
|
7045
|
+
)
|
|
7046
|
+
: h('img', { src: item.src, alt: item.alt || item.title || '', draggable: false }),
|
|
7047
|
+
),
|
|
7048
|
+
h('div', { className: 'tb-board-window-resize', title: t('board.resizeNote') }),
|
|
7049
|
+
),
|
|
7050
|
+
),
|
|
5818
7051
|
),
|
|
5819
7052
|
),
|
|
5820
7053
|
state.loading && !state.board ? h('p', { className: 'tb-board-md-empty' }, t('panel.loading')) : null,
|
|
5821
|
-
!state.loading &&
|
|
7054
|
+
!state.loading &&
|
|
7055
|
+
entries.length === 0 &&
|
|
7056
|
+
(canvas.texts ?? []).length === 0 &&
|
|
7057
|
+
(canvas.windows ?? []).length === 0 &&
|
|
7058
|
+
(canvas.background ?? []).length === 0
|
|
7059
|
+
? h('p', { className: 'tb-board-md-empty' }, t('board.empty'))
|
|
7060
|
+
: null,
|
|
5822
7061
|
),
|
|
5823
7062
|
h(
|
|
5824
7063
|
'div',
|
|
@@ -5897,7 +7136,7 @@ window.__ModuleLoader__.load({
|
|
|
5897
7136
|
h(
|
|
5898
7137
|
'div',
|
|
5899
7138
|
{ className: 'tb-detail-head' },
|
|
5900
|
-
h('span', { className: 'tb-detail-title' }, draft.id ? t('board.edit') : t('board.newSticky')),
|
|
7139
|
+
h('span', { className: 'tb-detail-title' }, draft.id ? t('board.edit') : draft.kind === 'doc' ? t('board.newDoc') : t('board.newSticky')),
|
|
5901
7140
|
h('span', { style: { flex: 1 } }),
|
|
5902
7141
|
h('button', { type: 'button', className: 'tb-btn', title: t('board.resizeHint'), onClick: resetDialogSize }, t('board.resetSize')),
|
|
5903
7142
|
),
|
|
@@ -5946,7 +7185,7 @@ window.__ModuleLoader__.load({
|
|
|
5946
7185
|
disabled: draft.busy,
|
|
5947
7186
|
placeholder: t('board.bodyPlaceholder'),
|
|
5948
7187
|
}),
|
|
5949
|
-
h('div', { className: 'tb-ws-hint' }, `${t('board.resizeHint')} · ${t('board.autosaveHint')}`),
|
|
7188
|
+
h('div', { className: 'tb-ws-hint' }, `${t('board.resizeHint')} · ${t('board.autosaveHint')}${draft.kind === 'doc' ? ` · ${t('board.docHint')}` : ''}`),
|
|
5950
7189
|
draft.error ? h('div', { className: 'tb-feedback err' }, format(t('board.error'), { error: draft.error })) : null,
|
|
5951
7190
|
h(
|
|
5952
7191
|
'div',
|
|
@@ -5960,10 +7199,267 @@ window.__ModuleLoader__.load({
|
|
|
5960
7199
|
),
|
|
5961
7200
|
)
|
|
5962
7201
|
: null,
|
|
7202
|
+
textEditor
|
|
7203
|
+
? h(
|
|
7204
|
+
'div',
|
|
7205
|
+
{ className: 'tb-overlay center', onClick: () => setTextEditor(null) },
|
|
7206
|
+
h(
|
|
7207
|
+
'div',
|
|
7208
|
+
{
|
|
7209
|
+
className: 'tb-board-dialog tb-text-dialog',
|
|
7210
|
+
role: 'dialog',
|
|
7211
|
+
'aria-modal': true,
|
|
7212
|
+
onClick: (event) => event.stopPropagation(),
|
|
7213
|
+
},
|
|
7214
|
+
h(
|
|
7215
|
+
'div',
|
|
7216
|
+
{ className: 'tb-detail-head' },
|
|
7217
|
+
h('span', { className: 'tb-detail-title' }, textEditor.id ? t('board.editText') : t('board.newText')),
|
|
7218
|
+
h('span', { style: { flex: 1 } }),
|
|
7219
|
+
textEditor.id
|
|
7220
|
+
? h(
|
|
7221
|
+
'button',
|
|
7222
|
+
{
|
|
7223
|
+
type: 'button',
|
|
7224
|
+
className: 'tb-btn danger',
|
|
7225
|
+
onClick: () => deleteText(textEditor.id),
|
|
7226
|
+
},
|
|
7227
|
+
t('board.deleteText'),
|
|
7228
|
+
)
|
|
7229
|
+
: null,
|
|
7230
|
+
),
|
|
7231
|
+
h('textarea', {
|
|
7232
|
+
className: 'tb-text-input',
|
|
7233
|
+
value: textEditor.text ?? '',
|
|
7234
|
+
placeholder: t('board.textPlaceholder'),
|
|
7235
|
+
autoFocus: true,
|
|
7236
|
+
onChange: (event) => setTextEditor((current) => (current ? { ...current, text: event.target.value } : current)),
|
|
7237
|
+
}),
|
|
7238
|
+
h(
|
|
7239
|
+
'div',
|
|
7240
|
+
{ className: 'tb-text-row' },
|
|
7241
|
+
h('span', { className: 'tb-color-label' }, t('board.fontColor')),
|
|
7242
|
+
...['#e6e6e6', '#2a2418', '#ffffff', '#ff5f56', '#f0b23e', '#3ecf8e', '#38bdf8', '#c084fc', '#f472b6', '#1c4d8f'].map((value) =>
|
|
7243
|
+
h('button', {
|
|
7244
|
+
key: `text-${value}`,
|
|
7245
|
+
type: 'button',
|
|
7246
|
+
className: `tb-text-swatch${String(textEditor.color || '').toLowerCase() === value ? ' on' : ''}`,
|
|
7247
|
+
style: { background: value },
|
|
7248
|
+
title: value,
|
|
7249
|
+
'aria-label': value,
|
|
7250
|
+
onClick: () => setTextEditor((current) => (current ? { ...current, color: value } : current)),
|
|
7251
|
+
}),
|
|
7252
|
+
),
|
|
7253
|
+
h('input', {
|
|
7254
|
+
type: 'color',
|
|
7255
|
+
value: textEditor.color || '#e6e6e6',
|
|
7256
|
+
title: t('md.customColor'),
|
|
7257
|
+
style: { width: 30, height: 24, padding: 0, border: 0, background: 'transparent' },
|
|
7258
|
+
onChange: (event) => setTextEditor((current) => (current ? { ...current, color: event.target.value } : current)),
|
|
7259
|
+
}),
|
|
7260
|
+
),
|
|
7261
|
+
h(
|
|
7262
|
+
'div',
|
|
7263
|
+
{ className: 'tb-text-row' },
|
|
7264
|
+
h('span', { className: 'tb-color-label' }, t('board.fontSize')),
|
|
7265
|
+
h('input', {
|
|
7266
|
+
type: 'range',
|
|
7267
|
+
min: 8,
|
|
7268
|
+
max: 72,
|
|
7269
|
+
step: 1,
|
|
7270
|
+
value: Number(textEditor.fontSize) || 18,
|
|
7271
|
+
style: { width: 220 },
|
|
7272
|
+
onChange: (event) => setTextEditor((current) => (current ? { ...current, fontSize: Number(event.target.value) || 18 } : current)),
|
|
7273
|
+
}),
|
|
7274
|
+
h('span', { className: 'tb-board-meta' }, `${Number(textEditor.fontSize) || 18}px`),
|
|
7275
|
+
),
|
|
7276
|
+
h(
|
|
7277
|
+
'div',
|
|
7278
|
+
{
|
|
7279
|
+
className: 'tb-text-preview',
|
|
7280
|
+
style: { color: textEditor.color || '#e6e6e6', fontSize: Number(textEditor.fontSize) || 18 },
|
|
7281
|
+
},
|
|
7282
|
+
textEditor.text || t('board.textPlaceholder'),
|
|
7283
|
+
),
|
|
7284
|
+
textEditor.error ? h('div', { className: 'tb-feedback err' }, textEditor.error) : null,
|
|
7285
|
+
h(
|
|
7286
|
+
'div',
|
|
7287
|
+
{ className: 'tb-note-actions' },
|
|
7288
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => setTextEditor(null) }, t('board.cancel')),
|
|
7289
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: saveText }, t('board.save')),
|
|
7290
|
+
),
|
|
7291
|
+
),
|
|
7292
|
+
)
|
|
7293
|
+
: null,
|
|
7294
|
+
windowEditor
|
|
7295
|
+
? h(
|
|
7296
|
+
'div',
|
|
7297
|
+
{ className: 'tb-overlay center', onClick: () => setWindowEditor(null) },
|
|
7298
|
+
h(
|
|
7299
|
+
'div',
|
|
7300
|
+
{
|
|
7301
|
+
className: 'tb-board-dialog tb-window-editor-dialog',
|
|
7302
|
+
role: 'dialog',
|
|
7303
|
+
'aria-modal': true,
|
|
7304
|
+
onClick: (event) => event.stopPropagation(),
|
|
7305
|
+
},
|
|
7306
|
+
h(
|
|
7307
|
+
'div',
|
|
7308
|
+
{ className: 'tb-detail-head' },
|
|
7309
|
+
h(
|
|
7310
|
+
'span',
|
|
7311
|
+
{ className: 'tb-detail-title' },
|
|
7312
|
+
`${windowEditor.kind === 'table' ? '▦' : '🖼'} ${
|
|
7313
|
+
windowEditor.id ? t('board.edit') : windowEditor.kind === 'table' ? t('board.table') : t('board.importImage')
|
|
7314
|
+
}`,
|
|
7315
|
+
),
|
|
7316
|
+
h('span', { style: { flex: 1 } }),
|
|
7317
|
+
windowEditor.id
|
|
7318
|
+
? h(
|
|
7319
|
+
'button',
|
|
7320
|
+
{ type: 'button', className: 'tb-btn danger', onClick: () => deleteWindow(windowEditor.id) },
|
|
7321
|
+
t('board.delete'),
|
|
7322
|
+
)
|
|
7323
|
+
: null,
|
|
7324
|
+
),
|
|
7325
|
+
h('input', {
|
|
7326
|
+
value: windowEditor.title ?? '',
|
|
7327
|
+
placeholder: t('board.windowTitle'),
|
|
7328
|
+
onChange: (event) => setWindowEditor((current) => (current ? { ...current, title: event.target.value } : current)),
|
|
7329
|
+
}),
|
|
7330
|
+
windowEditor.kind === 'table'
|
|
7331
|
+
? h(
|
|
7332
|
+
'div',
|
|
7333
|
+
{ className: 'tb-window-editor-body' },
|
|
7334
|
+
h(
|
|
7335
|
+
'div',
|
|
7336
|
+
{ className: 'tb-text-row' },
|
|
7337
|
+
h('button', {
|
|
7338
|
+
type: 'button',
|
|
7339
|
+
className: 'tb-btn',
|
|
7340
|
+
onClick: () =>
|
|
7341
|
+
setWindowEditor((current) => {
|
|
7342
|
+
if (!current) return current
|
|
7343
|
+
const rows = (current.rows ?? [[]]).map((row) => [...row])
|
|
7344
|
+
const cols = Math.max(1, ...rows.map((row) => row.length))
|
|
7345
|
+
rows.push(Array.from({ length: cols }, () => ''))
|
|
7346
|
+
return { ...current, rows }
|
|
7347
|
+
}),
|
|
7348
|
+
}, `+ ${t('board.addRow')}`),
|
|
7349
|
+
h('button', {
|
|
7350
|
+
type: 'button',
|
|
7351
|
+
className: 'tb-btn',
|
|
7352
|
+
onClick: () =>
|
|
7353
|
+
setWindowEditor((current) => {
|
|
7354
|
+
if (!current) return current
|
|
7355
|
+
const rows = (current.rows ?? [[]]).map((row) => [...row, ''])
|
|
7356
|
+
return { ...current, rows }
|
|
7357
|
+
}),
|
|
7358
|
+
}, `+ ${t('board.addCol')}`),
|
|
7359
|
+
h('button', {
|
|
7360
|
+
type: 'button',
|
|
7361
|
+
className: 'tb-btn',
|
|
7362
|
+
onClick: () => {
|
|
7363
|
+
const applyRows = (text, name) => {
|
|
7364
|
+
const rows = parseTableText(text)
|
|
7365
|
+
setWindowEditor((current) =>
|
|
7366
|
+
current
|
|
7367
|
+
? {
|
|
7368
|
+
...current,
|
|
7369
|
+
rows,
|
|
7370
|
+
...(name ? { title: name.replace(/\.[^.]+$/, '') || current.title } : {}),
|
|
7371
|
+
width: Math.min(900, Math.max(420, (rows[0]?.length ?? 3) * 120)),
|
|
7372
|
+
height: Math.min(700, Math.max(220, rows.length * 34 + 44)),
|
|
7373
|
+
}
|
|
7374
|
+
: current,
|
|
7375
|
+
)
|
|
7376
|
+
}
|
|
7377
|
+
pickFile('.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/plain,text/markdown', (file) => {
|
|
7378
|
+
if (file.size > 2_000_000) {
|
|
7379
|
+
setWindowEditor((current) => (current ? { ...current, error: '表格文件过大' } : current))
|
|
7380
|
+
return
|
|
7381
|
+
}
|
|
7382
|
+
const reader = new FileReader()
|
|
7383
|
+
reader.onload = () => applyRows(String(reader.result ?? ''), file.name)
|
|
7384
|
+
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: '表格读取失败' } : current))
|
|
7385
|
+
reader.readAsText(file)
|
|
7386
|
+
})
|
|
7387
|
+
},
|
|
7388
|
+
}, `⇥ ${t('board.fromFile')}`),
|
|
7389
|
+
),
|
|
7390
|
+
h('textarea', {
|
|
7391
|
+
className: 'tb-text-input',
|
|
7392
|
+
value: tableRowsToText(windowEditor.rows),
|
|
7393
|
+
placeholder: t('board.tableHint'),
|
|
7394
|
+
onChange: (event) => {
|
|
7395
|
+
const rows = parseTableText(event.target.value)
|
|
7396
|
+
setWindowEditor((current) => (current ? { ...current, rows } : current))
|
|
7397
|
+
},
|
|
7398
|
+
}),
|
|
7399
|
+
h(
|
|
7400
|
+
'div',
|
|
7401
|
+
{ className: 'tb-table-editor-preview' },
|
|
7402
|
+
h(
|
|
7403
|
+
'table',
|
|
7404
|
+
null,
|
|
7405
|
+
...(windowEditor.rows ?? [['']]).slice(0, 10).map((row, rowIndex) =>
|
|
7406
|
+
h(
|
|
7407
|
+
'tr',
|
|
7408
|
+
{ key: `preview-row-${rowIndex}` },
|
|
7409
|
+
...(row ?? []).slice(0, 8).map((cell, cellIndex) =>
|
|
7410
|
+
h('td', { key: `preview-cell-${rowIndex}-${cellIndex}` }, String(cell ?? '') === '' ? '\u00a0' : String(cell)),
|
|
7411
|
+
),
|
|
7412
|
+
),
|
|
7413
|
+
),
|
|
7414
|
+
),
|
|
7415
|
+
),
|
|
7416
|
+
)
|
|
7417
|
+
: h(
|
|
7418
|
+
'div',
|
|
7419
|
+
{ className: 'tb-window-editor-body' },
|
|
7420
|
+
h('div', { className: 'tb-table-editor-preview' }, h('img', { src: windowEditor.src, alt: windowEditor.alt || '' })),
|
|
7421
|
+
h(
|
|
7422
|
+
'div',
|
|
7423
|
+
{ className: 'tb-text-row' },
|
|
7424
|
+
h('button', {
|
|
7425
|
+
type: 'button',
|
|
7426
|
+
className: 'tb-btn',
|
|
7427
|
+
onClick: () => {
|
|
7428
|
+
pickFile('image/*', (file) => {
|
|
7429
|
+
if (!/^image\//i.test(file.type) || file.size > 1_500_000) {
|
|
7430
|
+
setWindowEditor((current) => (current ? { ...current, error: '请选择 1.5MB 以内的图片' } : current))
|
|
7431
|
+
return
|
|
7432
|
+
}
|
|
7433
|
+
const reader = new FileReader()
|
|
7434
|
+
reader.onload = () =>
|
|
7435
|
+
setWindowEditor((current) =>
|
|
7436
|
+
current ? { ...current, src: String(reader.result ?? ''), alt: file.name } : current,
|
|
7437
|
+
)
|
|
7438
|
+
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: '图片读取失败' } : current))
|
|
7439
|
+
reader.readAsDataURL(file)
|
|
7440
|
+
})
|
|
7441
|
+
},
|
|
7442
|
+
}, `🖼 ${t('board.chooseImage')}`),
|
|
7443
|
+
),
|
|
7444
|
+
h('div', { className: 'tb-ws-hint' }, t('board.imageHint')),
|
|
7445
|
+
),
|
|
7446
|
+
h('div', { className: 'tb-ws-hint' }, windowEditor.kind === 'table' ? t('board.tableHint') : t('board.imageHint')),
|
|
7447
|
+
windowEditor.error ? h('div', { className: 'tb-feedback err' }, windowEditor.error) : null,
|
|
7448
|
+
h(
|
|
7449
|
+
'div',
|
|
7450
|
+
{ className: 'tb-note-actions' },
|
|
7451
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => setWindowEditor(null) }, t('board.cancel')),
|
|
7452
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: saveWindow }, t('board.save')),
|
|
7453
|
+
),
|
|
7454
|
+
),
|
|
7455
|
+
)
|
|
7456
|
+
: null,
|
|
5963
7457
|
)
|
|
5964
7458
|
}
|
|
5965
7459
|
|
|
5966
7460
|
if (typeof window !== 'undefined' && window.__TIMEBACK_TEST__) {
|
|
7461
|
+
window.__TIMEBACK_TEST__.parseTableText = parseTableText
|
|
7462
|
+
window.__TIMEBACK_TEST__.tableRowsToText = tableRowsToText
|
|
5967
7463
|
window.__TIMEBACK_TEST__.edgePanVector = edgePanVector
|
|
5968
7464
|
window.__TIMEBACK_TEST__.renderMarkdown = renderMarkdown
|
|
5969
7465
|
window.__TIMEBACK_TEST__.stripMarkdown = stripMarkdown
|
|
@@ -5976,15 +7472,19 @@ window.__ModuleLoader__.load({
|
|
|
5976
7472
|
window.__TIMEBACK_TEST__.mergeCardFolder = mergeCardFolder
|
|
5977
7473
|
window.__TIMEBACK_TEST__.stableSessionColor = stableSessionColor
|
|
5978
7474
|
window.__TIMEBACK_TEST__.removeFolderMember = removeFolderMember
|
|
7475
|
+
window.__TIMEBACK_TEST__.renameCardFolder = renameCardFolder
|
|
5979
7476
|
window.__TIMEBACK_TEST__.layoutTree = layoutTree
|
|
7477
|
+
window.__TIMEBACK_TEST__.turnConversation = turnConversation
|
|
7478
|
+
window.__TIMEBACK_TEST__.messageTextOf = messageTextOf
|
|
5980
7479
|
window.__TIMEBACK_TEST__.CanvasFolderCard = CanvasFolderCard
|
|
5981
7480
|
window.__TIMEBACK_TEST__.TreeCanvas = TreeCanvas
|
|
5982
7481
|
}
|
|
5983
7482
|
|
|
5984
7483
|
return {
|
|
5985
|
-
inject: ['slots', 'locale', 'sidebarRight', 'sidebarRightTabs', 'uiWorkspace', 'uiSession', 'contextMenus'],
|
|
7484
|
+
inject: ['slots', 'locale', 'sidebarRight', 'sidebarRightTabs', 'uiWorkspace', 'uiSession', 'sessions', 'contextMenus'],
|
|
5986
7485
|
apply(ctx) {
|
|
5987
7486
|
const t = ctx.locale.bind(NS)
|
|
7487
|
+
sessionApi = ctx.sessions ?? null
|
|
5988
7488
|
console.log(`[timeback] client ${BUILD} loaded`)
|
|
5989
7489
|
openSessionBridge = (sessionId) => {
|
|
5990
7490
|
try {
|