dsh-timeback 0.7.7 → 0.7.9
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 +2039 -189
- 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.9+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,13 @@ 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': '输入新分支会话的名称:',
|
|
65
|
+
'panel.branchNameTitle': '新分支名称',
|
|
66
|
+
'panel.confirm': '确定',
|
|
67
|
+
'panel.cancel': '取消',
|
|
68
|
+
'panel.close': '关闭',
|
|
69
|
+
'panel.branchNameHint': '输入新分支会话的名称;留空则使用默认名称。',
|
|
70
|
+
'panel.createBranch': '创建分支',
|
|
63
71
|
'panel.confirmBranchOnly': '将在该检查点创建新分支,不修改工作区文件:{who}\n\n确定继续?',
|
|
64
72
|
'panel.confirmCheckpoint': '将记录当前对话位置与工作区快照。确定继续?',
|
|
65
73
|
'panel.deleteWarning': '快照之后新增的文件会被删除,之后修改的文件会被覆盖。回退前会自动保存安全快照,可用它撤销本次恢复。',
|
|
@@ -119,6 +127,35 @@ window.__ModuleLoader__.load({
|
|
|
119
127
|
'md.empty': '空文档,直接输入即可',
|
|
120
128
|
'md.hint': '直接打字即可:选中文字后点工具栏按钮会立即格式化(例如选中“你好”按 B 立即加粗);也可切换源码/预览。',
|
|
121
129
|
'board.newSticky': '新建便签',
|
|
130
|
+
'board.newDoc': '新建完整 md',
|
|
131
|
+
'board.addText': '文本',
|
|
132
|
+
'board.newText': '添加文本',
|
|
133
|
+
'board.editText': '编辑文本',
|
|
134
|
+
'board.textPlaceholder': '输入文本…',
|
|
135
|
+
'board.fontColor': '字体颜色',
|
|
136
|
+
'board.fontSize': '字号',
|
|
137
|
+
'board.deleteText': '删除文本',
|
|
138
|
+
'board.insert': '插入',
|
|
139
|
+
'board.clear': '清理',
|
|
140
|
+
'board.insertHint': '添加表格、导入表格或导入图片窗口',
|
|
141
|
+
'board.clearHint': '清理背景笔迹、路径或选中便签的笔迹',
|
|
142
|
+
'board.table': '表格',
|
|
143
|
+
'board.importTable': '导入表格',
|
|
144
|
+
'board.importImage': '导入图片',
|
|
145
|
+
'board.tableHint': '窗口可拖动;右下角可缩放。表格内容每行一行、单元格用 Tab 分隔,也支持 CSV 和 Markdown 表格。',
|
|
146
|
+
'board.addRow': '加行',
|
|
147
|
+
'board.addCol': '加列',
|
|
148
|
+
'board.tableTitle': '表格标题',
|
|
149
|
+
'board.fromFile': '从文件导入',
|
|
150
|
+
'board.chooseImage': '选择图片',
|
|
151
|
+
'board.imageHint': '图片窗口可拖动,右下角可缩放;大小上限约 1.5MB。',
|
|
152
|
+
'board.windowTitle': '窗口标题',
|
|
153
|
+
'board.tableTooLarge': '表格文件过大(上限约 2MB)',
|
|
154
|
+
'board.tableReadFailed': '表格读取失败',
|
|
155
|
+
'board.imageType': '请选择图片文件',
|
|
156
|
+
'board.imageTooLarge': '图片过大(上限约 1.5MB)',
|
|
157
|
+
'board.imageReadFailed': '图片读取失败',
|
|
158
|
+
'board.docHint': '完整 Markdown 文档页:默认展开预览,可拖动右下角调整大小。',
|
|
122
159
|
'board.stickyColor': '便签颜色',
|
|
123
160
|
'board.stickyHint': '便签可拖动;画笔可在方格纸背景或便签上绘制,橡皮擦除笔画。',
|
|
124
161
|
'board.resizeNote': '拖动缩放便签',
|
|
@@ -126,6 +163,7 @@ window.__ModuleLoader__.load({
|
|
|
126
163
|
'board.drawOnStickyOn': '便签可画:开',
|
|
127
164
|
'board.drawOnStickyOff': '便签可画:关',
|
|
128
165
|
'board.drawOnStickyHint': '开启后画笔/图形可直接画在便签上;关闭则只画在方格纸背景。',
|
|
166
|
+
'board.drawOnStickyNotice': '便签可画当前为关:先在工具栏打开「便签可画:开」才能在便签上绘制。',
|
|
129
167
|
'board.center': '自动调整',
|
|
130
168
|
'board.zoomIn': '放大画布',
|
|
131
169
|
'board.zoomOut': '缩小画布',
|
|
@@ -313,6 +351,13 @@ window.__ModuleLoader__.load({
|
|
|
313
351
|
'panel.warning': 'Rewinding overwrites workspace files from the snapshot and deletes files created after it. A safety snapshot is taken first.',
|
|
314
352
|
'panel.confirmRewind': 'Create a new branch and restore the workspace to: {who}\n\n{warning}\n\nContinue?',
|
|
315
353
|
'panel.confirmFiles': 'Restore workspace files to: {who}\n\n{warning}\n\nContinue?',
|
|
354
|
+
'panel.branchNamePrompt': 'Name for the new branch session:',
|
|
355
|
+
'panel.branchNameTitle': 'New branch name',
|
|
356
|
+
'panel.confirm': 'Confirm',
|
|
357
|
+
'panel.cancel': 'Cancel',
|
|
358
|
+
'panel.close': 'Close',
|
|
359
|
+
'panel.branchNameHint': 'Name the new branch session; leave blank to use the default.',
|
|
360
|
+
'panel.createBranch': 'Create branch',
|
|
316
361
|
'panel.confirmBranchOnly': 'Create a new branch at this checkpoint without touching files: {who}\n\nContinue?',
|
|
317
362
|
'panel.confirmCheckpoint': 'Record the current conversation position and a workspace snapshot?',
|
|
318
363
|
'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 +417,35 @@ window.__ModuleLoader__.load({
|
|
|
372
417
|
'md.empty': 'Empty document — just start typing',
|
|
373
418
|
'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
419
|
'board.newSticky': 'New sticky',
|
|
420
|
+
'board.newDoc': 'New full MD',
|
|
421
|
+
'board.addText': 'Text',
|
|
422
|
+
'board.newText': 'Add text',
|
|
423
|
+
'board.editText': 'Edit text',
|
|
424
|
+
'board.textPlaceholder': 'Type text…',
|
|
425
|
+
'board.fontColor': 'Font colour',
|
|
426
|
+
'board.fontSize': 'Font size',
|
|
427
|
+
'board.deleteText': 'Delete text',
|
|
428
|
+
'board.insert': 'Insert',
|
|
429
|
+
'board.clear': 'Clear',
|
|
430
|
+
'board.insertHint': 'Add a table, import a table, or import an image window',
|
|
431
|
+
'board.clearHint': 'Clear background drawings, links, or the selected note drawing',
|
|
432
|
+
'board.table': 'Table',
|
|
433
|
+
'board.importTable': 'Import table',
|
|
434
|
+
'board.importImage': 'Import image',
|
|
435
|
+
'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.',
|
|
436
|
+
'board.addRow': 'Add row',
|
|
437
|
+
'board.addCol': 'Add column',
|
|
438
|
+
'board.tableTitle': 'Table title',
|
|
439
|
+
'board.fromFile': 'Import from file',
|
|
440
|
+
'board.chooseImage': 'Choose image',
|
|
441
|
+
'board.imageHint': 'Image windows can be dragged and resized from the bottom-right; max about 1.5MB.',
|
|
442
|
+
'board.windowTitle': 'Window title',
|
|
443
|
+
'board.tableTooLarge': 'Table file is too large (max about 2MB)',
|
|
444
|
+
'board.tableReadFailed': 'Could not read the table file',
|
|
445
|
+
'board.imageType': 'Please choose an image file',
|
|
446
|
+
'board.imageTooLarge': 'Image is too large (max about 1.5MB)',
|
|
447
|
+
'board.imageReadFailed': 'Could not read the image file',
|
|
448
|
+
'board.docHint': 'Full Markdown document page: expanded preview by default, resize from the bottom-right corner.',
|
|
375
449
|
'board.stickyColor': 'Sticky colour',
|
|
376
450
|
'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
451
|
'board.resizeNote': 'Drag to resize the sticky',
|
|
@@ -379,6 +453,7 @@ window.__ModuleLoader__.load({
|
|
|
379
453
|
'board.drawOnStickyOn': 'Sticky drawing: on',
|
|
380
454
|
'board.drawOnStickyOff': 'Sticky drawing: off',
|
|
381
455
|
'board.drawOnStickyHint': 'When on, pen/shape tools draw directly on sticky notes; when off they only draw on the grid.',
|
|
456
|
+
'board.drawOnStickyNotice': 'Sticky drawing is off: turn on “Sticky drawing: on” in the toolbar before drawing on a sticky.',
|
|
382
457
|
'board.center': 'Auto fit',
|
|
383
458
|
'board.zoomIn': 'Zoom in',
|
|
384
459
|
'board.zoomOut': 'Zoom out',
|
|
@@ -566,6 +641,7 @@ window.__ModuleLoader__.load({
|
|
|
566
641
|
.tb-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1))}
|
|
567
642
|
.tb-btn:disabled{opacity:.5;cursor:default}
|
|
568
643
|
.tb-btn.primary{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
644
|
+
.tb-btn.on{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
569
645
|
.tb-btn.danger{border-color:var(--dsw-alias-state-warning-primary,rgba(240,178,62,.5));color:var(--dsw-alias-state-warning-primary,#f0b23e)}
|
|
570
646
|
.tb-body{flex:1;min-height:120px;overflow:auto;padding:10px 12px 28px;display:flex;flex-direction:column;gap:8px}
|
|
571
647
|
.tb-ws-select{display:flex;flex-direction:column;gap:5px;margin:3px 0 4px}
|
|
@@ -624,6 +700,8 @@ window.__ModuleLoader__.load({
|
|
|
624
700
|
.tb-canvas-btn.on{color:var(--dsw-alias-state-success-primary,#3ecf8e)}
|
|
625
701
|
.tb-canvas-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
626
702
|
.tb-world{position:absolute;left:0;top:0;transform-origin:0 0}
|
|
703
|
+
.tb-tree-doodles{position:absolute;left:0;top:0;overflow:visible;z-index:50}
|
|
704
|
+
.tb-tree-doodles polyline,.tb-tree-doodles path{fill:none;stroke-linecap:round;stroke-linejoin:round}
|
|
627
705
|
.tb-world-links{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
|
|
628
706
|
.tb-link{fill:none;stroke-width:1.6;opacity:.55}
|
|
629
707
|
.tb-link.fork{stroke-width:2;opacity:.75}
|
|
@@ -671,6 +749,10 @@ window.__ModuleLoader__.load({
|
|
|
671
749
|
.tb-folder-row:active{cursor:grabbing}
|
|
672
750
|
.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
751
|
.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}
|
|
752
|
+
.tb-folder-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}
|
|
753
|
+
.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}
|
|
754
|
+
.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}
|
|
755
|
+
.tb-folder-rename:hover{color:var(--dsw-alias-label-primary,#e6e6e6);border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6)}
|
|
674
756
|
.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
757
|
.tb-folder-ghost-label{font-weight:700;color:var(--dsw-alias-label-primary,#e6e6e6);white-space:nowrap}
|
|
676
758
|
.tb-folder-ghost-prompt{color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
@@ -690,6 +772,21 @@ window.__ModuleLoader__.load({
|
|
|
690
772
|
.tb-card-editnote.has{color:var(--tb-color,#4d7cfe);border-color:color-mix(in srgb, var(--tb-color,#4d7cfe) 50%, transparent)}
|
|
691
773
|
.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
774
|
.tb-overlay.center{justify-content:center;align-items:center;padding:16px}
|
|
775
|
+
.tb-board-dialog.tb-branch-dialog{width:min(470px,92vw);height:auto;min-height:0;display:flex;flex-direction:column;gap:8px}
|
|
776
|
+
.tb-board-dialog.tb-branch-dialog input{font-family:inherit;font-size:13px}
|
|
777
|
+
.tb-branch-message{white-space:pre-wrap;font-size:12px;line-height:1.6;color:var(--dsw-alias-label-primary,#e6e6e6);background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.05));border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));border-radius:7px;padding:7px 9px;max-height:180px;overflow:auto}
|
|
778
|
+
.tb-note-dialog.tb-chat-dialog{width:min(640px,94vw);height:100%;display:flex;flex-direction:column;gap:8px}
|
|
779
|
+
.tb-note-dialog.tb-chat-dialog .tb-chat-composer textarea{min-height:64px;max-height:180px;font-family:inherit}
|
|
780
|
+
.tb-chat-messages{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:8px;padding:2px 2px 4px}
|
|
781
|
+
.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)}
|
|
782
|
+
.tb-chat-msg.user{background:rgba(77,124,254,.13);border-color:rgba(77,124,254,.4)}
|
|
783
|
+
.tb-chat-msg.assistant{background:rgba(62,207,142,.1);border-color:rgba(62,207,142,.3)}
|
|
784
|
+
.tb-chat-role{font-size:10px;font-weight:700;opacity:.65;margin-bottom:4px}
|
|
785
|
+
.tb-chat-text{white-space:pre-wrap;word-break:break-word;font-size:13px;line-height:1.55}
|
|
786
|
+
.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}
|
|
787
|
+
.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}
|
|
788
|
+
.tb-chat-composer textarea:focus{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
789
|
+
.tb-chat-actions{display:flex;align-items:center;gap:8px}
|
|
693
790
|
.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
791
|
.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
792
|
.tb-note-dialog textarea{min-height:180px}
|
|
@@ -703,6 +800,7 @@ window.__ModuleLoader__.load({
|
|
|
703
800
|
.tb-resize-handle.se{right:0;bottom:0;width:18px;height:18px;cursor:nwse-resize}
|
|
704
801
|
.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
802
|
.tb-board-testid{display:none}
|
|
803
|
+
.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
804
|
.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
805
|
.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
806
|
.tb-shape-wrap{position:relative;display:inline-flex}
|
|
@@ -741,6 +839,49 @@ window.__ModuleLoader__.load({
|
|
|
741
839
|
.tb-board-world{position:relative;flex:none;contain:layout paint}
|
|
742
840
|
.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
841
|
.tb-board-bgdraw{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
|
|
842
|
+
.tb-window-insert{position:relative;display:inline-flex}
|
|
843
|
+
.tb-insert-menu{left:0;top:calc(100% + 4px);min-width:180px}
|
|
844
|
+
.tb-clear-menu{left:0;top:calc(100% + 4px);min-width:160px}
|
|
845
|
+
.tb-clear-menu button:disabled{opacity:.4;cursor:default}
|
|
846
|
+
.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)}
|
|
847
|
+
.tb-board-window.selected{outline:2px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);outline-offset:1px}
|
|
848
|
+
.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}
|
|
849
|
+
.tb-board-window-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:600}
|
|
850
|
+
.tb-board-window-actions{display:flex;gap:2px}
|
|
851
|
+
.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}
|
|
852
|
+
.tb-board-window-actions button:hover{background:rgba(255,255,255,.12);color:#fff}
|
|
853
|
+
.tb-board-window-body{flex:1;min-height:0;overflow:auto;position:relative}
|
|
854
|
+
.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)}
|
|
855
|
+
.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}
|
|
856
|
+
.tb-board-window-body th{background:rgba(255,255,255,.07);font-weight:600;position:sticky;top:0;z-index:1}
|
|
857
|
+
.tb-board-window-body img{display:block;width:100%;height:100%;object-fit:contain;background:rgba(0,0,0,.14)}
|
|
858
|
+
.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%)}
|
|
859
|
+
.tb-window-editor-dialog{width:min(760px,94vw);height:auto;max-height:92vh;display:flex;flex-direction:column;gap:8px}
|
|
860
|
+
.tb-window-editor-dialog .tb-text-input{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12.5px}
|
|
861
|
+
.tb-window-editor-body{display:flex;flex-direction:column;gap:6px;min-height:0}
|
|
862
|
+
.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)}
|
|
863
|
+
.tb-table-editor-preview table{border-collapse:collapse;width:100%;font-size:12px}
|
|
864
|
+
.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}
|
|
865
|
+
.tb-table-editor-preview img{display:block;max-width:100%;max-height:140px;object-fit:contain;margin:auto}
|
|
866
|
+
.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)}
|
|
867
|
+
.tb-board-text:hover{border-color:rgba(122,162,255,.5)}
|
|
868
|
+
.tb-board-text.selected{outline:2px dashed var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);outline-offset:2px}
|
|
869
|
+
.tb-board-text:active{cursor:grabbing}
|
|
870
|
+
.tb-board-text-content{white-space:pre-wrap;word-break:break-word;pointer-events:none}
|
|
871
|
+
.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}
|
|
872
|
+
.tb-board-text:hover .tb-board-text-actions,.tb-board-text.selected .tb-board-text-actions{display:flex}
|
|
873
|
+
.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}
|
|
874
|
+
.tb-board-text-actions button:hover{background:rgba(255,255,255,.12);color:#fff}
|
|
875
|
+
.tb-text-dialog{width:min(700px,94vw);height:auto;max-height:90vh;display:flex;flex-direction:column;gap:8px}
|
|
876
|
+
.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}
|
|
877
|
+
.tb-board-dialog .tb-text-input{font-family:inherit;font-size:13px;line-height:1.55}
|
|
878
|
+
.tb-board-dialog input{font-family:inherit;font-size:13px}
|
|
879
|
+
.tb-text-input:focus{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
880
|
+
.tb-text-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
881
|
+
.tb-text-swatches{display:flex;gap:4px;flex-wrap:wrap}
|
|
882
|
+
.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}
|
|
883
|
+
.tb-text-swatch.on{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
884
|
+
.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
885
|
.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
886
|
.tb-sticky:active{cursor:grabbing}
|
|
746
887
|
.tb-sticky.selected{outline:2px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);outline-offset:1px}
|
|
@@ -764,6 +905,13 @@ window.__ModuleLoader__.load({
|
|
|
764
905
|
.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
906
|
.tb-sticky-md a{color:#1c4d8f;text-decoration:underline}
|
|
766
907
|
.tb-sticky-md hr{border:0;border-top:1px solid rgba(0,0,0,.2);margin:4px 0}
|
|
908
|
+
.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)}
|
|
909
|
+
.tb-sticky.tb-doc .tb-sticky-head{flex:0 0 auto;cursor:grab}
|
|
910
|
+
.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}
|
|
911
|
+
.tb-doc-body .tb-md{font-size:13px;line-height:1.6;color:#2a2418}
|
|
912
|
+
.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}
|
|
913
|
+
.tb-doc-body .tb-md pre{background:rgba(0,0,0,.07);color:#2a2418}
|
|
914
|
+
.tb-doc-body .tb-md code{background:rgba(0,0,0,.08)}
|
|
767
915
|
.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
916
|
.tb-sticky-src{font-size:9.5px;font-weight:600;opacity:.6;white-space:nowrap}
|
|
769
917
|
.tb-sticky-draw{position:absolute;inset:0;pointer-events:none;z-index:3}
|
|
@@ -809,6 +957,8 @@ window.__ModuleLoader__.load({
|
|
|
809
957
|
.tb-md-tool:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
810
958
|
.tb-md-tool.on{color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6)}
|
|
811
959
|
.tb-md-mode{margin-left:auto;display:flex;gap:2px;flex:0 0 auto}
|
|
960
|
+
.tb-md-linkbar{display:flex;align-items:center;gap:6px;padding:4px 5px;border:1px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);border-radius:7px;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.04))}
|
|
961
|
+
.tb-md-link-input{flex:1;min-width:120px;box-sizing:border-box;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:5px;padding:4px 7px;font-size:12px;outline:none}
|
|
812
962
|
.tb-md-colorbar{display:flex;align-items:center;gap:5px;flex-wrap:nowrap;overflow:hidden;padding:3px 5px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.10));border-radius:7px;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.02))}
|
|
813
963
|
.tb-md-color-label{font-size:12px;color:var(--dsw-alias-label-secondary,#9aa0a6);margin-right:1px}
|
|
814
964
|
.tb-md-body{display:flex;gap:8px;flex:1;min-height:0;overflow:hidden}
|
|
@@ -820,7 +970,7 @@ window.__ModuleLoader__.load({
|
|
|
820
970
|
.tb-md-line{display:block;font-size:10px;line-height:1.4;color:var(--dsw-alias-label-tertiary,#8a919c);margin-bottom:1px}
|
|
821
971
|
.tb-md-empty{padding:12px;text-align:center;color:var(--dsw-alias-label-secondary,#9aa0a6);font-size:13px}
|
|
822
972
|
@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)}
|
|
973
|
+
.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
974
|
.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
975
|
.tb-board-title{font-weight:600;font-size:13.5px}
|
|
826
976
|
.tb-board-sub{font-size:11px;color:var(--dsw-alias-label-secondary,#9aa0a6)}
|
|
@@ -1244,6 +1394,19 @@ window.__ModuleLoader__.load({
|
|
|
1244
1394
|
return changed ? next : folders
|
|
1245
1395
|
}
|
|
1246
1396
|
|
|
1397
|
+
/** Rename one folder; empty names fall back to the default label. */
|
|
1398
|
+
function renameCardFolder(folders, folderId, name) {
|
|
1399
|
+
if (!Array.isArray(folders)) return folders
|
|
1400
|
+
const nextName = String(name ?? '').trim().slice(0, 40) || '卡片夹'
|
|
1401
|
+
let changed = false
|
|
1402
|
+
const next = folders.map((folder) => {
|
|
1403
|
+
if (folder.id !== folderId || folder.name === nextName) return folder
|
|
1404
|
+
changed = true
|
|
1405
|
+
return { ...folder, name: nextName }
|
|
1406
|
+
})
|
|
1407
|
+
return changed ? next : folders
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1247
1410
|
/** Unique keys in order. */
|
|
1248
1411
|
function uniqueKeys(values) {
|
|
1249
1412
|
const seen = new Set()
|
|
@@ -1273,6 +1436,7 @@ window.__ModuleLoader__.load({
|
|
|
1273
1436
|
let host = null
|
|
1274
1437
|
if (sourceFolder && targetFolder) {
|
|
1275
1438
|
targetFolder.members = uniqueKeys([...targetFolder.members, ...sourceFolder.members])
|
|
1439
|
+
if (!targetFolder.name || targetFolder.name === '卡片夹') targetFolder.name = sourceFolder.name || targetFolder.name
|
|
1276
1440
|
host = targetFolder
|
|
1277
1441
|
const index = list.indexOf(sourceFolder)
|
|
1278
1442
|
if (index !== -1) list.splice(index, 1)
|
|
@@ -1285,6 +1449,7 @@ window.__ModuleLoader__.load({
|
|
|
1285
1449
|
} else {
|
|
1286
1450
|
host = {
|
|
1287
1451
|
id: `fold-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`,
|
|
1452
|
+
name: '卡片夹',
|
|
1288
1453
|
members: uniqueKeys([target.key, source.key]),
|
|
1289
1454
|
x: Number.isFinite(target.x) ? target.x : 0,
|
|
1290
1455
|
y: Number.isFinite(target.y) ? target.y : 0,
|
|
@@ -1522,8 +1687,9 @@ window.__ModuleLoader__.load({
|
|
|
1522
1687
|
color: firstMember.color,
|
|
1523
1688
|
x: override?.x ?? (Number.isFinite(folder.x) ? folder.x : firstMember.x),
|
|
1524
1689
|
y: override?.y ?? (Number.isFinite(folder.y) ? folder.y : firstMember.y),
|
|
1525
|
-
label: '卡片夹',
|
|
1526
|
-
|
|
1690
|
+
label: folder.name || '卡片夹',
|
|
1691
|
+
folderName: folder.name || '卡片夹',
|
|
1692
|
+
title: `${session.title || session.sessionId.slice(0, 8)} · ${folder.name || '卡片夹'}(${members.length} 张)`,
|
|
1527
1693
|
prompt: null,
|
|
1528
1694
|
note: null,
|
|
1529
1695
|
checkpoints: [],
|
|
@@ -1621,7 +1787,7 @@ window.__ModuleLoader__.load({
|
|
|
1621
1787
|
}
|
|
1622
1788
|
|
|
1623
1789
|
/** One card of the conversation canvas. */
|
|
1624
|
-
function CanvasCard({ card, t, selectedKey, onSelect, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }) {
|
|
1790
|
+
function CanvasCard({ card, t, selectedKey, onSelect, onChat, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }) {
|
|
1625
1791
|
const files = (card.checkpoints ?? []).reduce(
|
|
1626
1792
|
(total, checkpoint) => ({
|
|
1627
1793
|
added: total.added + (checkpoint.files?.added ?? 0),
|
|
@@ -1663,6 +1829,7 @@ window.__ModuleLoader__.load({
|
|
|
1663
1829
|
event.stopPropagation()
|
|
1664
1830
|
if (consumeClick()) return
|
|
1665
1831
|
onSelect(card.key)
|
|
1832
|
+
if (typeof onChat === 'function') onChat(card)
|
|
1666
1833
|
},
|
|
1667
1834
|
onDoubleClick: (event) => {
|
|
1668
1835
|
event.stopPropagation()
|
|
@@ -1676,6 +1843,7 @@ window.__ModuleLoader__.load({
|
|
|
1676
1843
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
1677
1844
|
event.preventDefault()
|
|
1678
1845
|
onSelect(card.key)
|
|
1846
|
+
if (typeof onChat === 'function') onChat(card)
|
|
1679
1847
|
}
|
|
1680
1848
|
},
|
|
1681
1849
|
},
|
|
@@ -1772,7 +1940,24 @@ window.__ModuleLoader__.load({
|
|
|
1772
1940
|
}
|
|
1773
1941
|
|
|
1774
1942
|
/** One collapsed card folder: compact, with member labels and an unpack action. */
|
|
1775
|
-
function CanvasFolderCard({
|
|
1943
|
+
function CanvasFolderCard({
|
|
1944
|
+
card,
|
|
1945
|
+
t,
|
|
1946
|
+
onDragStart,
|
|
1947
|
+
onUnpackFolder,
|
|
1948
|
+
dropTargetKey,
|
|
1949
|
+
folding,
|
|
1950
|
+
expanded,
|
|
1951
|
+
onToggleFolder,
|
|
1952
|
+
onMemberDragStart,
|
|
1953
|
+
suppressClickRef,
|
|
1954
|
+
renaming,
|
|
1955
|
+
renameDraft,
|
|
1956
|
+
onRenameStart,
|
|
1957
|
+
onRenameChange,
|
|
1958
|
+
onRenameCommit,
|
|
1959
|
+
onRenameCancel,
|
|
1960
|
+
}) {
|
|
1776
1961
|
const members = card.members ?? []
|
|
1777
1962
|
return h(
|
|
1778
1963
|
'article',
|
|
@@ -1799,8 +1984,40 @@ window.__ModuleLoader__.load({
|
|
|
1799
1984
|
'div',
|
|
1800
1985
|
{ className: 'tb-card-head' },
|
|
1801
1986
|
h('span', { className: 'tb-card-badge' }, '📁'),
|
|
1802
|
-
|
|
1987
|
+
renaming
|
|
1988
|
+
? h('input', {
|
|
1989
|
+
className: 'tb-folder-name-input',
|
|
1990
|
+
value: renameDraft ?? '',
|
|
1991
|
+
placeholder: t('tree.folderNamePlaceholder'),
|
|
1992
|
+
autoFocus: true,
|
|
1993
|
+
'aria-label': t('tree.folderRename'),
|
|
1994
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1995
|
+
onChange: (event) => onRenameChange?.(event.target.value),
|
|
1996
|
+
onKeyDown: (event) => {
|
|
1997
|
+
event.stopPropagation()
|
|
1998
|
+
if (event.key === 'Enter') onRenameCommit?.()
|
|
1999
|
+
else if (event.key === 'Escape') onRenameCancel?.()
|
|
2000
|
+
},
|
|
2001
|
+
onBlur: () => onRenameCommit?.(),
|
|
2002
|
+
})
|
|
2003
|
+
: h('span', { className: 'tb-folder-name', title: card.folderName || '卡片夹' }, card.folderName || '卡片夹'),
|
|
1803
2004
|
h('span', { className: 'tb-card-spacer' }),
|
|
2005
|
+
!renaming && typeof onRenameStart === 'function'
|
|
2006
|
+
? h(
|
|
2007
|
+
'button',
|
|
2008
|
+
{
|
|
2009
|
+
type: 'button',
|
|
2010
|
+
className: 'tb-folder-rename',
|
|
2011
|
+
title: t('tree.folderRename'),
|
|
2012
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
2013
|
+
onClick: (event) => {
|
|
2014
|
+
event.stopPropagation()
|
|
2015
|
+
onRenameStart(card.folderId)
|
|
2016
|
+
},
|
|
2017
|
+
},
|
|
2018
|
+
'✎',
|
|
2019
|
+
)
|
|
2020
|
+
: null,
|
|
1804
2021
|
card.createdAt ? h('span', { className: 'tb-card-time' }, clock(card.createdAt)) : null,
|
|
1805
2022
|
),
|
|
1806
2023
|
expanded
|
|
@@ -1876,6 +2093,7 @@ window.__ModuleLoader__.load({
|
|
|
1876
2093
|
t,
|
|
1877
2094
|
selectedKey,
|
|
1878
2095
|
onSelect,
|
|
2096
|
+
onChat,
|
|
1879
2097
|
onOpen,
|
|
1880
2098
|
onBranch,
|
|
1881
2099
|
onNote,
|
|
@@ -1887,6 +2105,17 @@ window.__ModuleLoader__.load({
|
|
|
1887
2105
|
expandedFolderId,
|
|
1888
2106
|
onToggleFolder,
|
|
1889
2107
|
onMemberDragStart,
|
|
2108
|
+
renamingFolderId,
|
|
2109
|
+
folderNameDraft,
|
|
2110
|
+
doodleMode,
|
|
2111
|
+
doodles,
|
|
2112
|
+
onToggleDoodle,
|
|
2113
|
+
onClearDoodles,
|
|
2114
|
+
onDoodlePointerDown,
|
|
2115
|
+
onRenameStart,
|
|
2116
|
+
onRenameChange,
|
|
2117
|
+
onRenameCommit,
|
|
2118
|
+
onRenameCancel,
|
|
1890
2119
|
onResetLayout,
|
|
1891
2120
|
autoPan,
|
|
1892
2121
|
panSpeed,
|
|
@@ -1938,6 +2167,20 @@ window.__ModuleLoader__.load({
|
|
|
1938
2167
|
},
|
|
1939
2168
|
panSpeed === 'slow' ? t('tree.panSpeedSlow') : panSpeed === 'fast' ? t('tree.panSpeedFast') : t('tree.panSpeedNormal'),
|
|
1940
2169
|
),
|
|
2170
|
+
h(
|
|
2171
|
+
'button',
|
|
2172
|
+
{
|
|
2173
|
+
type: 'button',
|
|
2174
|
+
className: `tb-canvas-btn${doodleMode ? ' on' : ''}`,
|
|
2175
|
+
title: t('tree.doodleHint'),
|
|
2176
|
+
'aria-pressed': doodleMode === true,
|
|
2177
|
+
onClick: onToggleDoodle,
|
|
2178
|
+
},
|
|
2179
|
+
doodleMode ? `✏️ ${t('tree.doodleOn')}` : `✏️ ${t('tree.doodleOff')}`,
|
|
2180
|
+
),
|
|
2181
|
+
doodleMode
|
|
2182
|
+
? h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.doodleClear'), onClick: onClearDoodles }, `🧽 ${t('tree.doodleClear')}`)
|
|
2183
|
+
: null,
|
|
1941
2184
|
h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.resetLayoutHint'), onClick: onResetLayout }, t('tree.resetLayout')),
|
|
1942
2185
|
h('button', { type: 'button', className: 'tb-canvas-btn', title: t('tree.expandHint'), onClick: onToggleExpand }, expanded ? '⤡' : '⤢'),
|
|
1943
2186
|
h('span', { className: 'tb-canvas-hint' }, t('tree.folderHint')),
|
|
@@ -1979,6 +2222,33 @@ window.__ModuleLoader__.load({
|
|
|
1979
2222
|
h('span', null, t('tree.folderDropHint')),
|
|
1980
2223
|
)
|
|
1981
2224
|
})(),
|
|
2225
|
+
h(
|
|
2226
|
+
'svg',
|
|
2227
|
+
{
|
|
2228
|
+
className: `tb-tree-doodles${doodleMode ? ' active' : ''}`,
|
|
2229
|
+
width: layout.width,
|
|
2230
|
+
height: layout.height,
|
|
2231
|
+
style: { pointerEvents: doodleMode ? 'auto' : 'none', cursor: doodleMode ? 'crosshair' : 'default' },
|
|
2232
|
+
onPointerDown: (event) => {
|
|
2233
|
+
if (!doodleMode) return
|
|
2234
|
+
event.stopPropagation()
|
|
2235
|
+
onDoodlePointerDown?.(event)
|
|
2236
|
+
},
|
|
2237
|
+
},
|
|
2238
|
+
...(doodles ?? []).map((stroke, index) =>
|
|
2239
|
+
h('path', {
|
|
2240
|
+
key: `doodle-${index}`,
|
|
2241
|
+
d: smoothStrokePath(stroke.points),
|
|
2242
|
+
fill: 'none',
|
|
2243
|
+
stroke: stroke.color || '#ff5f56',
|
|
2244
|
+
strokeWidth: stroke.width || 3,
|
|
2245
|
+
strokeLinecap: 'round',
|
|
2246
|
+
strokeLinejoin: 'round',
|
|
2247
|
+
opacity: 0.9,
|
|
2248
|
+
}),
|
|
2249
|
+
),
|
|
2250
|
+
doodleMode ? h('rect', { x: 0, y: 0, width: layout.width, height: layout.height, fill: 'transparent' }) : null,
|
|
2251
|
+
),
|
|
1982
2252
|
...layout.cards.map((card) =>
|
|
1983
2253
|
card.kind === 'folder'
|
|
1984
2254
|
? CanvasFolderCard({
|
|
@@ -1992,8 +2262,14 @@ window.__ModuleLoader__.load({
|
|
|
1992
2262
|
onToggleFolder,
|
|
1993
2263
|
onMemberDragStart,
|
|
1994
2264
|
suppressClickRef,
|
|
2265
|
+
renaming: renamingFolderId === card.folderId,
|
|
2266
|
+
renameDraft: folderNameDraft,
|
|
2267
|
+
onRenameStart,
|
|
2268
|
+
onRenameChange,
|
|
2269
|
+
onRenameCommit,
|
|
2270
|
+
onRenameCancel,
|
|
1995
2271
|
})
|
|
1996
|
-
: CanvasCard({ card, t, selectedKey, onSelect, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }),
|
|
2272
|
+
: CanvasCard({ card, t, selectedKey, onSelect, onChat, onOpen, onBranch, onPrune, onNote, onDragStart, suppressClickRef, dropTargetKey, folding, onRewind }),
|
|
1997
2273
|
),
|
|
1998
2274
|
),
|
|
1999
2275
|
)
|
|
@@ -2136,6 +2412,69 @@ window.__ModuleLoader__.load({
|
|
|
2136
2412
|
)
|
|
2137
2413
|
}
|
|
2138
2414
|
|
|
2415
|
+
/** Extract text from one model/user message's content blocks. */
|
|
2416
|
+
function messageTextOf(message) {
|
|
2417
|
+
const blocks = Array.isArray(message?.content) ? message.content : []
|
|
2418
|
+
const parts = []
|
|
2419
|
+
for (const block of blocks) {
|
|
2420
|
+
if (!block || typeof block !== 'object') continue
|
|
2421
|
+
if (block.type === 'text' && typeof block.text === 'string') parts.push(block.text)
|
|
2422
|
+
else if (block.type === 'image') parts.push('[image]')
|
|
2423
|
+
else if (block.type === 'file') parts.push('[file]')
|
|
2424
|
+
}
|
|
2425
|
+
return parts.join('\n\n').trim()
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
/** Durable Session events from an event-window snapshot. */
|
|
2429
|
+
function durableSessionEvents(entries) {
|
|
2430
|
+
return (Array.isArray(entries) ? entries : [])
|
|
2431
|
+
.map((entry) => (entry?.type === 'event' ? entry.event : null))
|
|
2432
|
+
.filter(Boolean)
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
/** Messages belonging to one turn number, in conversation order. */
|
|
2436
|
+
function turnConversation(events, turn) {
|
|
2437
|
+
if (!Number.isInteger(turn)) return []
|
|
2438
|
+
const start = events.find((event) => event.type === 'turn/start' && event.data?.turn === turn)
|
|
2439
|
+
if (!start) return []
|
|
2440
|
+
const later = events.find((event) => event.type === 'turn/start' && event.seq > start.seq)
|
|
2441
|
+
const endSeq = later?.seq ?? Infinity
|
|
2442
|
+
const messages = []
|
|
2443
|
+
for (const event of events) {
|
|
2444
|
+
if (!Number.isInteger(event.seq) || event.seq < start.seq || event.seq >= endSeq) continue
|
|
2445
|
+
if (event.type === 'user/message' && event.data?.source?.kind === 'user') {
|
|
2446
|
+
const text = messageTextOf(event.data)
|
|
2447
|
+
if (text !== '') messages.push({ role: 'user', text, seq: event.seq })
|
|
2448
|
+
} else if (event.type === 'assistant/message') {
|
|
2449
|
+
const text = messageTextOf(event.data?.message)
|
|
2450
|
+
if (text !== '') messages.push({ role: 'assistant', text, seq: event.seq })
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
return messages
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
/** Best turn number for a card without an explicit turn (manual/start cards). */
|
|
2457
|
+
function turnForCheckpoint(events, checkpoint) {
|
|
2458
|
+
if (!checkpoint) return null
|
|
2459
|
+
const seq = Number.isInteger(checkpoint.seq) ? checkpoint.seq : Infinity
|
|
2460
|
+
let best = null
|
|
2461
|
+
for (const event of events) {
|
|
2462
|
+
if (event.type !== 'turn/start' || !Number.isInteger(event.data?.turn)) continue
|
|
2463
|
+
if (event.seq <= seq) best = event.data.turn
|
|
2464
|
+
else break
|
|
2465
|
+
}
|
|
2466
|
+
return best
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
/** Whether a card is the last card of the current session's branch. */
|
|
2470
|
+
function cardIsTail(card, layout, data) {
|
|
2471
|
+
if (!card || card.kind === 'folder' || !layout || !data) return false
|
|
2472
|
+
if (String(card.sessionId) !== String(data.currentSessionId)) return false
|
|
2473
|
+
const cards = (layout.cards ?? []).filter((entry) => entry.kind !== 'folder' && String(entry.sessionId) === String(card.sessionId))
|
|
2474
|
+
const last = cards[cards.length - 1]
|
|
2475
|
+
return Boolean(last && last.key === card.key)
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2139
2478
|
/* ---------------------------------------------------------------- */
|
|
2140
2479
|
/* panel */
|
|
2141
2480
|
/* ---------------------------------------------------------------- */
|
|
@@ -2161,6 +2500,11 @@ window.__ModuleLoader__.load({
|
|
|
2161
2500
|
}, [feedback])
|
|
2162
2501
|
const [view, setView] = React.useState('tree')
|
|
2163
2502
|
const [workspaceOpen, setWorkspaceOpen] = React.useState(false)
|
|
2503
|
+
const [renamingFolderId, setRenamingFolderId] = React.useState(null)
|
|
2504
|
+
const [folderNameDraft, setFolderNameDraft] = React.useState('')
|
|
2505
|
+
const [doodleMode, setDoodleMode] = React.useState(false)
|
|
2506
|
+
const [doodles, setDoodles] = React.useState([])
|
|
2507
|
+
const doodlesRef = React.useRef([])
|
|
2164
2508
|
const [selectedKey, setSelectedKey] = React.useState(null)
|
|
2165
2509
|
const [zoom, setZoom] = React.useState(1)
|
|
2166
2510
|
const [canvasExpanded, setCanvasExpanded] = React.useState(false)
|
|
@@ -2185,6 +2529,8 @@ window.__ModuleLoader__.load({
|
|
|
2185
2529
|
const panSpeedRef = React.useRef(panSpeed)
|
|
2186
2530
|
panSpeedRef.current = panSpeed
|
|
2187
2531
|
const [noteEditor, setNoteEditor] = React.useState(null)
|
|
2532
|
+
const [chat, setChat] = React.useState(null)
|
|
2533
|
+
const [branchPrompt, setBranchPrompt] = React.useState(null)
|
|
2188
2534
|
const viewportRef = React.useRef(null)
|
|
2189
2535
|
const worldRef = React.useRef(null)
|
|
2190
2536
|
const cameraRef = React.useRef({ x: 0, y: 0, scale: 1 })
|
|
@@ -2212,6 +2558,10 @@ window.__ModuleLoader__.load({
|
|
|
2212
2558
|
setFeedback(null)
|
|
2213
2559
|
setBusy('')
|
|
2214
2560
|
setSelectedKey(null)
|
|
2561
|
+
setChat(null)
|
|
2562
|
+
setBranchPrompt(null)
|
|
2563
|
+
setInsertMenu(false)
|
|
2564
|
+
setClearMenu(false)
|
|
2215
2565
|
busyRef.current = ''
|
|
2216
2566
|
cameraRef.current = { x: 0, y: 0, scale: 1 }
|
|
2217
2567
|
fittedRef.current = ''
|
|
@@ -2276,18 +2626,10 @@ window.__ModuleLoader__.load({
|
|
|
2276
2626
|
return ''
|
|
2277
2627
|
}
|
|
2278
2628
|
|
|
2279
|
-
const
|
|
2629
|
+
const runAct = async (action, checkpoint, mode, targetSessionId, existingChildSessionId, branchName = '') => {
|
|
2280
2630
|
const data = state.data
|
|
2281
2631
|
if (!data || data.currentSessionId !== sessionId) return
|
|
2282
2632
|
const actionSessionId = targetSessionId || sessionId
|
|
2283
|
-
const who = checkpoint ? checkpointName(checkpoint, t) : ''
|
|
2284
|
-
let message
|
|
2285
|
-
if (action === 'checkpoint') message = t('panel.confirmCheckpoint')
|
|
2286
|
-
else if (action === 'prune') message = format(t('panel.confirmPrune'), { who })
|
|
2287
|
-
else if (mode === 'branch-only') message = format(t('panel.confirmBranchOnly'), { who })
|
|
2288
|
-
else if (action === 'restore-files') message = format(t('panel.confirmFiles'), { who, warning: t('panel.deleteWarning') })
|
|
2289
|
-
else message = format(t('panel.confirmRewind'), { who, warning: t('panel.deleteWarning') })
|
|
2290
|
-
if (!window.confirm(message)) return
|
|
2291
2633
|
const busyKey = checkpoint ? checkpoint.id : action
|
|
2292
2634
|
setBusy(busyKey)
|
|
2293
2635
|
busyRef.current = busyKey
|
|
@@ -2310,6 +2652,7 @@ window.__ModuleLoader__.load({
|
|
|
2310
2652
|
const isFileAction = action === 'restore-files' || mode === 'files-only'
|
|
2311
2653
|
body = { action: isFileAction ? 'restore-files' : 'rewind', sessionId: actionSessionId, checkpointId: checkpoint.id }
|
|
2312
2654
|
if (mode) body.mode = mode
|
|
2655
|
+
if (branchName) body.name = branchName
|
|
2313
2656
|
}
|
|
2314
2657
|
const result = await request('action', { method: 'POST', body })
|
|
2315
2658
|
let tone = 'ok'
|
|
@@ -2365,6 +2708,47 @@ window.__ModuleLoader__.load({
|
|
|
2365
2708
|
}
|
|
2366
2709
|
}
|
|
2367
2710
|
|
|
2711
|
+
const act = async (action, checkpoint, mode, targetSessionId, existingChildSessionId) => {
|
|
2712
|
+
const data = state.data
|
|
2713
|
+
if (!data || data.currentSessionId !== sessionId) return
|
|
2714
|
+
const actionSessionId = targetSessionId || sessionId
|
|
2715
|
+
const who = checkpoint ? checkpointName(checkpoint, t) : ''
|
|
2716
|
+
let message
|
|
2717
|
+
if (action === 'checkpoint') message = t('panel.confirmCheckpoint')
|
|
2718
|
+
else if (action === 'prune') message = format(t('panel.confirmPrune'), { who })
|
|
2719
|
+
else if (mode === 'branch-only') message = format(t('panel.confirmBranchOnly'), { who })
|
|
2720
|
+
else if (action === 'restore-files') message = format(t('panel.confirmFiles'), { who, warning: t('panel.deleteWarning') })
|
|
2721
|
+
else message = format(t('panel.confirmRewind'), { who, warning: t('panel.deleteWarning') })
|
|
2722
|
+
if (action === 'rewind' && mode !== 'files-only') {
|
|
2723
|
+
// One dialog for both the warning and the branch name: desktop webviews
|
|
2724
|
+
// do not support window.prompt and a second modal is easy to miss.
|
|
2725
|
+
const source = (data.sessions ?? []).find((entry) => entry.sessionId === actionSessionId)
|
|
2726
|
+
const suffix = Number.isInteger(checkpoint?.turn) ? ` · T${checkpoint.turn}` : ''
|
|
2727
|
+
const fallbackName = `${source?.title || t('panel.branch')} · ${t('panel.branch')}${suffix}`
|
|
2728
|
+
setBranchPrompt({
|
|
2729
|
+
action,
|
|
2730
|
+
checkpoint,
|
|
2731
|
+
mode,
|
|
2732
|
+
targetSessionId,
|
|
2733
|
+
existingChildSessionId,
|
|
2734
|
+
defaultName: fallbackName,
|
|
2735
|
+
name: fallbackName,
|
|
2736
|
+
message,
|
|
2737
|
+
})
|
|
2738
|
+
return
|
|
2739
|
+
}
|
|
2740
|
+
if (!window.confirm(message)) return
|
|
2741
|
+
await runAct(action, checkpoint, mode, targetSessionId, existingChildSessionId, '')
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
const confirmBranchPrompt = async () => {
|
|
2745
|
+
const prompt = branchPrompt
|
|
2746
|
+
if (!prompt) return
|
|
2747
|
+
setBranchPrompt(null)
|
|
2748
|
+
const name = String(prompt.name ?? '').trim() || prompt.defaultName
|
|
2749
|
+
await runAct(prompt.action, prompt.checkpoint, prompt.mode, prompt.targetSessionId, prompt.existingChildSessionId, name)
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2368
2752
|
const toggleWorkspace = async (enabled, explicitCwd) => {
|
|
2369
2753
|
if (busyRef.current !== '') return
|
|
2370
2754
|
const data = state.data
|
|
@@ -2546,30 +2930,70 @@ window.__ModuleLoader__.load({
|
|
|
2546
2930
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2547
2931
|
}, [view, data?.currentSessionId, layoutReady])
|
|
2548
2932
|
|
|
2549
|
-
|
|
2550
|
-
|
|
2933
|
+
// Canvas layout belongs to the workspace, not one branch-family root:
|
|
2934
|
+
// pruning a branch replaces rootSessionId and used to make positions,
|
|
2935
|
+
// folder names and doodles disappear. Keep old root-scoped keys as
|
|
2936
|
+
// one-time migration sources.
|
|
2937
|
+
const layoutScope = data?.workspace?.cwd
|
|
2938
|
+
? `ws:${data.workspace.cwd}`
|
|
2939
|
+
: data?.rootSessionId
|
|
2940
|
+
? `root:${data.rootSessionId}`
|
|
2941
|
+
: null
|
|
2942
|
+
const scopeKey = (kind) => (layoutScope ? `dsh-timeback:${kind}:${layoutScope}` : null)
|
|
2943
|
+
// Pre-0.7.9 layout keys were scoped by the bare root session id.
|
|
2944
|
+
const legacyScopeKey = (kind) => (data?.rootSessionId ? `dsh-timeback:${kind}:${data.rootSessionId}` : null)
|
|
2945
|
+
const positionsKey = scopeKey('card-positions')
|
|
2946
|
+
const foldersKey = scopeKey('card-folders')
|
|
2947
|
+
const doodlesKey = scopeKey('tree-doodles')
|
|
2948
|
+
const legacyPositionsKey = legacyScopeKey('card-positions')
|
|
2949
|
+
const legacyFoldersKey = legacyScopeKey('card-folders')
|
|
2950
|
+
const legacyDoodlesKey = legacyScopeKey('tree-doodles')
|
|
2551
2951
|
|
|
2552
2952
|
// Restore dragged card positions and folders for this branch family.
|
|
2553
2953
|
React.useEffect(() => {
|
|
2554
2954
|
if (!positionsKey) return
|
|
2555
2955
|
let saved = {}
|
|
2556
2956
|
let savedFolders = []
|
|
2957
|
+
let savedDoodles = []
|
|
2958
|
+
const readScope = (key, legacyKey) => {
|
|
2959
|
+
let raw = key ? window.localStorage.getItem(key) : null
|
|
2960
|
+
if (!raw && legacyKey && legacyKey !== key) {
|
|
2961
|
+
raw = window.localStorage.getItem(legacyKey)
|
|
2962
|
+
if (raw && key) window.localStorage.setItem(key, raw)
|
|
2963
|
+
}
|
|
2964
|
+
return raw
|
|
2965
|
+
}
|
|
2557
2966
|
try {
|
|
2558
|
-
const raw =
|
|
2967
|
+
const raw = readScope(positionsKey, legacyPositionsKey)
|
|
2559
2968
|
if (raw) saved = JSON.parse(raw)
|
|
2560
|
-
const rawFolders =
|
|
2969
|
+
const rawFolders = readScope(foldersKey, legacyFoldersKey)
|
|
2561
2970
|
if (rawFolders) savedFolders = JSON.parse(rawFolders)
|
|
2971
|
+
const rawDoodles = readScope(doodlesKey, legacyDoodlesKey)
|
|
2972
|
+
if (rawDoodles) savedDoodles = JSON.parse(rawDoodles)
|
|
2562
2973
|
} catch {
|
|
2563
2974
|
saved = {}
|
|
2564
2975
|
savedFolders = []
|
|
2976
|
+
savedDoodles = []
|
|
2565
2977
|
}
|
|
2566
2978
|
if (saved === null || typeof saved !== 'object' || Array.isArray(saved)) saved = {}
|
|
2567
2979
|
if (!Array.isArray(savedFolders)) savedFolders = []
|
|
2980
|
+
if (!Array.isArray(savedDoodles)) savedDoodles = []
|
|
2981
|
+
savedDoodles = savedDoodles
|
|
2982
|
+
.filter((stroke) => stroke && Array.isArray(stroke.points) && stroke.points.length > 1)
|
|
2983
|
+
.slice(-200)
|
|
2984
|
+
.map((stroke) => ({
|
|
2985
|
+
color: /^#[0-9a-f]{6}$/i.test(String(stroke.color || '')) ? String(stroke.color) : '#ff5f56',
|
|
2986
|
+
width: Math.min(12, Math.max(1, Number(stroke.width) || 3)),
|
|
2987
|
+
points: stroke.points.filter((point) => Array.isArray(point) && point.length >= 2 && Number.isFinite(point[0]) && Number.isFinite(point[1])).slice(0, 2000),
|
|
2988
|
+
}))
|
|
2989
|
+
.filter((stroke) => stroke.points.length > 1)
|
|
2568
2990
|
positionsRef.current = saved
|
|
2569
2991
|
setPositions(saved)
|
|
2570
2992
|
foldersRef.current = savedFolders
|
|
2571
2993
|
setFolders(savedFolders)
|
|
2572
|
-
|
|
2994
|
+
doodlesRef.current = savedDoodles
|
|
2995
|
+
setDoodles(savedDoodles)
|
|
2996
|
+
}, [positionsKey, foldersKey, doodlesKey, legacyPositionsKey, legacyFoldersKey, legacyDoodlesKey])
|
|
2573
2997
|
|
|
2574
2998
|
// Wheel zoom must be non-passive, so it is bound directly to the viewport.
|
|
2575
2999
|
React.useEffect(() => {
|
|
@@ -2616,6 +3040,10 @@ window.__ModuleLoader__.load({
|
|
|
2616
3040
|
const unpackFolder = (folderId) => {
|
|
2617
3041
|
const next = foldersRef.current.filter((folder) => folder.id !== folderId)
|
|
2618
3042
|
storeFolders(next, true)
|
|
3043
|
+
if (renamingFolderId === folderId) {
|
|
3044
|
+
setRenamingFolderId(null)
|
|
3045
|
+
setFolderNameDraft('')
|
|
3046
|
+
}
|
|
2619
3047
|
}
|
|
2620
3048
|
|
|
2621
3049
|
/** Expand/collapse one folder's full member list. */
|
|
@@ -2623,6 +3051,92 @@ window.__ModuleLoader__.load({
|
|
|
2623
3051
|
setExpandedFolderId((current) => (current === folderId ? null : folderId))
|
|
2624
3052
|
}
|
|
2625
3053
|
|
|
3054
|
+
/** Start inline renaming for one folder card. */
|
|
3055
|
+
const startFolderRename = (folderId) => {
|
|
3056
|
+
const folder = foldersRef.current.find((entry) => entry.id === folderId)
|
|
3057
|
+
if (!folder) return
|
|
3058
|
+
setRenamingFolderId(folderId)
|
|
3059
|
+
setFolderNameDraft(folder.name || '卡片夹')
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
const commitFolderRename = () => {
|
|
3063
|
+
if (!renamingFolderId) return
|
|
3064
|
+
const next = renameCardFolder(foldersRef.current, renamingFolderId, folderNameDraft)
|
|
3065
|
+
storeFolders(next, true)
|
|
3066
|
+
setRenamingFolderId(null)
|
|
3067
|
+
setFolderNameDraft('')
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
const cancelFolderRename = () => {
|
|
3071
|
+
setRenamingFolderId(null)
|
|
3072
|
+
setFolderNameDraft('')
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
/** Persist freehand doodles over the conversation canvas. */
|
|
3076
|
+
const storeDoodles = (next, persist) => {
|
|
3077
|
+
doodlesRef.current = next
|
|
3078
|
+
setDoodles(next)
|
|
3079
|
+
if (persist !== true) return
|
|
3080
|
+
try {
|
|
3081
|
+
if (doodlesKey) window.localStorage.setItem(doodlesKey, JSON.stringify(next))
|
|
3082
|
+
} catch {
|
|
3083
|
+
// Storage can be disabled; doodles still work in memory.
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
const beginDoodle = (event) => {
|
|
3088
|
+
if (event.button !== 0) return
|
|
3089
|
+
const viewport = viewportRef.current
|
|
3090
|
+
if (!viewport) return
|
|
3091
|
+
event.preventDefault()
|
|
3092
|
+
const rect = viewport.getBoundingClientRect()
|
|
3093
|
+
const toWorld = (next) => {
|
|
3094
|
+
const camera = cameraRef.current
|
|
3095
|
+
return [
|
|
3096
|
+
Math.round((next.clientX - rect.left - camera.x) / camera.scale),
|
|
3097
|
+
Math.round((next.clientY - rect.top - camera.y) / camera.scale),
|
|
3098
|
+
]
|
|
3099
|
+
}
|
|
3100
|
+
const startPoint = toWorld(event)
|
|
3101
|
+
const stroke = { color: '#ff5f56', width: 3, points: [startPoint] }
|
|
3102
|
+
let frame = 0
|
|
3103
|
+
setDoodles([...doodlesRef.current, stroke])
|
|
3104
|
+
const move = (next) => {
|
|
3105
|
+
const samples = typeof next.getCoalescedEvents === 'function' ? next.getCoalescedEvents() : [next]
|
|
3106
|
+
for (const sample of samples.length > 0 ? samples : [next]) {
|
|
3107
|
+
if (stroke.points.length >= 2000) break
|
|
3108
|
+
const point = toWorld(sample)
|
|
3109
|
+
const last = stroke.points[stroke.points.length - 1]
|
|
3110
|
+
if (last && last[0] === point[0] && last[1] === point[1]) continue
|
|
3111
|
+
stroke.points.push(point)
|
|
3112
|
+
}
|
|
3113
|
+
if (!frame) {
|
|
3114
|
+
frame = window.requestAnimationFrame(() => {
|
|
3115
|
+
frame = 0
|
|
3116
|
+
setDoodles([...doodlesRef.current, stroke])
|
|
3117
|
+
})
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
const finish = () => {
|
|
3121
|
+
window.removeEventListener('pointermove', move)
|
|
3122
|
+
window.removeEventListener('pointerup', finish)
|
|
3123
|
+
window.removeEventListener('pointercancel', finish)
|
|
3124
|
+
if (frame) {
|
|
3125
|
+
window.cancelAnimationFrame(frame)
|
|
3126
|
+
frame = 0
|
|
3127
|
+
}
|
|
3128
|
+
doodlesRef.current = [...doodlesRef.current.filter((item) => item !== stroke), stroke].slice(-200)
|
|
3129
|
+
storeDoodles(doodlesRef.current, true)
|
|
3130
|
+
}
|
|
3131
|
+
window.addEventListener('pointermove', move)
|
|
3132
|
+
window.addEventListener('pointerup', finish)
|
|
3133
|
+
window.addEventListener('pointercancel', finish)
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
const clearDoodles = () => {
|
|
3137
|
+
storeDoodles([], true)
|
|
3138
|
+
}
|
|
3139
|
+
|
|
2626
3140
|
/** Remove one card from a folder; a folder with <2 members dissolves. */
|
|
2627
3141
|
const detachFolderMember = (folderId, memberKey, position) => {
|
|
2628
3142
|
const next = removeFolderMember(foldersRef.current, folderId, memberKey)
|
|
@@ -2882,6 +3396,118 @@ window.__ModuleLoader__.load({
|
|
|
2882
3396
|
})
|
|
2883
3397
|
}
|
|
2884
3398
|
|
|
3399
|
+
/** Read the turn behind one card and open its conversation/composer. */
|
|
3400
|
+
const openCardConversation = async (card) => {
|
|
3401
|
+
if (!card || card.kind === 'folder') return
|
|
3402
|
+
const base = { card, loading: true, messages: [], error: null, input: '', sending: false, branchedTo: null }
|
|
3403
|
+
setChat(base)
|
|
3404
|
+
if (!sessionApi) {
|
|
3405
|
+
setChat({ ...base, loading: false, error: t('chat.unavailable') })
|
|
3406
|
+
return
|
|
3407
|
+
}
|
|
3408
|
+
try {
|
|
3409
|
+
const checkpoint = [...(card.checkpoints ?? [])].reverse().find((entry) => Number.isInteger(entry.seq))
|
|
3410
|
+
const entries = await sessionApi.using(card.sessionId, { source: 'gateway' }, async (reference) => {
|
|
3411
|
+
const binding = await reference.ready
|
|
3412
|
+
if (checkpoint) {
|
|
3413
|
+
try {
|
|
3414
|
+
await binding.session.loadThrough(checkpoint.seq)
|
|
3415
|
+
} catch {
|
|
3416
|
+
// The visible window may already cover the turn.
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
const source = binding.eventSource
|
|
3420
|
+
const window = typeof source?.getSnapshot === 'function' ? source.getSnapshot() : source?.snapshot
|
|
3421
|
+
return window?.entries ?? []
|
|
3422
|
+
})
|
|
3423
|
+
const events = durableSessionEvents(entries)
|
|
3424
|
+
const turn = Number.isInteger(card.turn) ? card.turn : turnForCheckpoint(events, checkpoint)
|
|
3425
|
+
let messages = turnConversation(events, turn)
|
|
3426
|
+
if (messages.length === 0 && card.prompt) messages = [{ role: 'user', text: card.prompt }]
|
|
3427
|
+
setChat((current) =>
|
|
3428
|
+
current && current.card.key === card.key
|
|
3429
|
+
? { ...current, loading: false, messages, error: null }
|
|
3430
|
+
: current,
|
|
3431
|
+
)
|
|
3432
|
+
} catch (error) {
|
|
3433
|
+
setChat((current) =>
|
|
3434
|
+
current && current.card.key === card.key
|
|
3435
|
+
? { ...current, loading: false, error: error?.message || String(error) }
|
|
3436
|
+
: current,
|
|
3437
|
+
)
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
/** Send the composer text: continue the tail session or branch then send. */
|
|
3442
|
+
const sendChatMessage = async () => {
|
|
3443
|
+
const current = chat
|
|
3444
|
+
if (!current || current.sending) return
|
|
3445
|
+
const text = String(current.input ?? '').trim()
|
|
3446
|
+
if (text === '') return
|
|
3447
|
+
if (!sessionApi) {
|
|
3448
|
+
setChat({ ...current, error: t('chat.unavailable') })
|
|
3449
|
+
return
|
|
3450
|
+
}
|
|
3451
|
+
setChat({ ...current, sending: true, error: null })
|
|
3452
|
+
try {
|
|
3453
|
+
const data = state.data
|
|
3454
|
+
const layout = data ? layoutTree(data.sessions ?? [], data.currentSessionId, positionsRef.current, foldersRef.current) : null
|
|
3455
|
+
const tail = cardIsTail(current.card, layout, data)
|
|
3456
|
+
let targetSessionId = current.branchedTo || current.card.sessionId
|
|
3457
|
+
let branched = Boolean(current.branchedTo)
|
|
3458
|
+
if (!tail && !current.branchedTo) {
|
|
3459
|
+
const checkpoints = current.card.checkpoints ?? []
|
|
3460
|
+
const checkpoint =
|
|
3461
|
+
[...checkpoints].reverse().find((entry) => Number.isInteger(entry.seq) && entry.phase !== 'before') ??
|
|
3462
|
+
[...checkpoints].reverse().find((entry) => Number.isInteger(entry.seq))
|
|
3463
|
+
if (!checkpoint) throw new Error(t('chat.noCheckpoint'))
|
|
3464
|
+
const result = await request('action', {
|
|
3465
|
+
method: 'POST',
|
|
3466
|
+
body: {
|
|
3467
|
+
action: 'rewind',
|
|
3468
|
+
sessionId: current.card.sessionId,
|
|
3469
|
+
checkpointId: checkpoint.id,
|
|
3470
|
+
mode: 'branch-only',
|
|
3471
|
+
name: text.replace(/\s+/g, ' ').trim().slice(0, 120),
|
|
3472
|
+
},
|
|
3473
|
+
})
|
|
3474
|
+
if (!result?.childSessionId) throw new Error(t('chat.noCheckpoint'))
|
|
3475
|
+
targetSessionId = result.childSessionId
|
|
3476
|
+
branched = true
|
|
3477
|
+
// Keep the created branch on the draft so a failed prompt can be
|
|
3478
|
+
// retried without creating a second branch. Do not switch the UI
|
|
3479
|
+
// session yet: that would reset the chat drawer and hide a prompt
|
|
3480
|
+
// error; the catalog refresh below makes the new branch resolvable.
|
|
3481
|
+
setChat((previous) => (previous ? { ...previous, branchedTo: targetSessionId } : previous))
|
|
3482
|
+
}
|
|
3483
|
+
const promptOnce = () =>
|
|
3484
|
+
sessionApi.using(targetSessionId, { source: 'gateway' }, async (reference) => {
|
|
3485
|
+
const binding = await reference.ready
|
|
3486
|
+
return binding.session.prompt([{ type: 'text', text }], 'queue')
|
|
3487
|
+
})
|
|
3488
|
+
let result
|
|
3489
|
+
try {
|
|
3490
|
+
result = await promptOnce()
|
|
3491
|
+
} catch (error) {
|
|
3492
|
+
await sessionApi.refresh().catch(() => {})
|
|
3493
|
+
result = await promptOnce()
|
|
3494
|
+
}
|
|
3495
|
+
if (result && result.ok === false) {
|
|
3496
|
+
throw new Error(result.error?.message ? String(result.error.message) : JSON.stringify(result.error))
|
|
3497
|
+
}
|
|
3498
|
+
if (branched) openChild(targetSessionId)
|
|
3499
|
+
setChat(null)
|
|
3500
|
+
setFeedback({ tone: 'ok', text: branched ? t('chat.branched') : t('chat.sent') })
|
|
3501
|
+
setTick((value) => value + 1)
|
|
3502
|
+
} catch (error) {
|
|
3503
|
+
setChat((previous) =>
|
|
3504
|
+
previous
|
|
3505
|
+
? { ...previous, sending: false, error: format(t('chat.failed'), { error: error?.message || String(error) }) }
|
|
3506
|
+
: previous,
|
|
3507
|
+
)
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
|
|
2885
3511
|
/** Saving close for the card-note sheet: outside clicks never discard text. */
|
|
2886
3512
|
const dismissCardNoteSaving = async () => {
|
|
2887
3513
|
const editor = noteEditor
|
|
@@ -2919,17 +3545,14 @@ window.__ModuleLoader__.load({
|
|
|
2919
3545
|
/** Clear dragged positions and return to the automatic layout. */
|
|
2920
3546
|
const resetCardPositions = () => {
|
|
2921
3547
|
try {
|
|
2922
|
-
|
|
3548
|
+
for (const key of [positionsKey, legacyPositionsKey, foldersKey, legacyFoldersKey]) {
|
|
3549
|
+
if (key) window.localStorage.removeItem(key)
|
|
3550
|
+
}
|
|
2923
3551
|
} catch {
|
|
2924
3552
|
// Storage can be disabled.
|
|
2925
3553
|
}
|
|
2926
3554
|
positionsRef.current = {}
|
|
2927
3555
|
setPositions({})
|
|
2928
|
-
try {
|
|
2929
|
-
if (foldersKey) window.localStorage.removeItem(foldersKey)
|
|
2930
|
-
} catch {
|
|
2931
|
-
// Storage can be disabled.
|
|
2932
|
-
}
|
|
2933
3556
|
foldersRef.current = []
|
|
2934
3557
|
setFolders([])
|
|
2935
3558
|
}
|
|
@@ -2954,7 +3577,6 @@ window.__ModuleLoader__.load({
|
|
|
2954
3577
|
{ className: 'tb-muted tb-small', title: `timeback client ${BUILD}` },
|
|
2955
3578
|
format(t('panel.branchCount'), { sessions: sessions.length, checkpoints: checkpointTotal }),
|
|
2956
3579
|
),
|
|
2957
|
-
h('span', { className: 'tb-muted tb-small', title: 'timeback client build' }, BUILD),
|
|
2958
3580
|
h('span', { style: { flex: 1 } }),
|
|
2959
3581
|
h(
|
|
2960
3582
|
'button',
|
|
@@ -3086,6 +3708,7 @@ window.__ModuleLoader__.load({
|
|
|
3086
3708
|
t,
|
|
3087
3709
|
selectedKey: effectiveSelectedKey,
|
|
3088
3710
|
onSelect: setSelectedKey,
|
|
3711
|
+
onChat: openCardConversation,
|
|
3089
3712
|
onOpen: openSessionByCard,
|
|
3090
3713
|
onBranch: branchFromCard,
|
|
3091
3714
|
onPrune: pruneFromCard,
|
|
@@ -3100,6 +3723,17 @@ window.__ModuleLoader__.load({
|
|
|
3100
3723
|
expandedFolderId,
|
|
3101
3724
|
onToggleFolder: toggleFolder,
|
|
3102
3725
|
onMemberDragStart: startFolderMemberDrag,
|
|
3726
|
+
renamingFolderId,
|
|
3727
|
+
folderNameDraft,
|
|
3728
|
+
onRenameStart: startFolderRename,
|
|
3729
|
+
onRenameChange: setFolderNameDraft,
|
|
3730
|
+
onRenameCommit: commitFolderRename,
|
|
3731
|
+
onRenameCancel: cancelFolderRename,
|
|
3732
|
+
doodleMode,
|
|
3733
|
+
doodles,
|
|
3734
|
+
onToggleDoodle: () => setDoodleMode((value) => !value),
|
|
3735
|
+
onClearDoodles: clearDoodles,
|
|
3736
|
+
onDoodlePointerDown: beginDoodle,
|
|
3103
3737
|
onResetLayout: resetCardPositions,
|
|
3104
3738
|
autoPan,
|
|
3105
3739
|
panSpeed,
|
|
@@ -3177,89 +3811,238 @@ window.__ModuleLoader__.load({
|
|
|
3177
3811
|
),
|
|
3178
3812
|
)
|
|
3179
3813
|
: null,
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3814
|
+
chat
|
|
3815
|
+
? h(
|
|
3816
|
+
'div',
|
|
3817
|
+
{ className: 'tb-overlay', onClick: () => { if (!chat.sending) setChat(null) } },
|
|
3818
|
+
h(
|
|
3819
|
+
'div',
|
|
3820
|
+
{
|
|
3821
|
+
className: 'tb-note-dialog tb-chat-dialog',
|
|
3822
|
+
role: 'dialog',
|
|
3823
|
+
'aria-modal': true,
|
|
3824
|
+
onClick: (event) => event.stopPropagation(),
|
|
3825
|
+
},
|
|
3826
|
+
h(
|
|
3827
|
+
'div',
|
|
3828
|
+
{ className: 'tb-detail-head' },
|
|
3829
|
+
h(
|
|
3830
|
+
'span',
|
|
3831
|
+
{ className: 'tb-detail-title' },
|
|
3832
|
+
`${t('chat.title')} · ${chat.card.label}${chat.card.sessionTitle ? ` · ${chat.card.sessionTitle}` : ''}`,
|
|
3833
|
+
),
|
|
3834
|
+
h('span', { style: { flex: 1 } }),
|
|
3835
|
+
h(
|
|
3836
|
+
'button',
|
|
3837
|
+
{
|
|
3838
|
+
type: 'button',
|
|
3839
|
+
className: 'tb-btn',
|
|
3840
|
+
onClick: () => setChat(null),
|
|
3841
|
+
},
|
|
3842
|
+
t('chat.close'),
|
|
3843
|
+
),
|
|
3844
|
+
),
|
|
3845
|
+
h(
|
|
3846
|
+
'div',
|
|
3847
|
+
{ className: 'tb-ws-hint' },
|
|
3848
|
+
cardIsTail(chat.card, layout, state.data) ? t('chat.tailHint') : t('chat.branchHint'),
|
|
3849
|
+
),
|
|
3850
|
+
h(
|
|
3851
|
+
'div',
|
|
3852
|
+
{ className: 'tb-chat-messages' },
|
|
3853
|
+
chat.loading
|
|
3854
|
+
? h('div', { className: 'tb-empty tb-small' }, t('chat.loading'))
|
|
3855
|
+
: chat.messages.length > 0
|
|
3856
|
+
? chat.messages.map((message, index) =>
|
|
3857
|
+
h(
|
|
3858
|
+
'div',
|
|
3859
|
+
{ key: `msg-${index}`, className: `tb-chat-msg ${message.role}` },
|
|
3860
|
+
h('div', { className: 'tb-chat-role' }, message.role === 'user' ? t('chat.user') : t('chat.assistant')),
|
|
3861
|
+
message.role === 'assistant'
|
|
3862
|
+
? h('div', { className: 'tb-md' }, ...renderMarkdown(message.text, `chat-${index}`))
|
|
3863
|
+
: h('div', { className: 'tb-chat-text' }, message.text),
|
|
3864
|
+
),
|
|
3865
|
+
)
|
|
3866
|
+
: h('div', { className: 'tb-empty tb-small' }, t('chat.empty')),
|
|
3867
|
+
),
|
|
3868
|
+
chat.error && !chat.loading
|
|
3869
|
+
? h('div', { className: 'tb-feedback err' }, chat.error)
|
|
3870
|
+
: null,
|
|
3871
|
+
h(
|
|
3872
|
+
'div',
|
|
3873
|
+
{ className: 'tb-chat-composer' },
|
|
3874
|
+
h('textarea', {
|
|
3875
|
+
value: chat.input,
|
|
3876
|
+
placeholder: t('chat.placeholder'),
|
|
3877
|
+
disabled: chat.sending,
|
|
3878
|
+
onChange: (event) => setChat((current) => (current ? { ...current, input: event.target.value } : current)),
|
|
3879
|
+
onKeyDown: (event) => {
|
|
3880
|
+
if (event.nativeEvent?.isComposing) return
|
|
3881
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
3882
|
+
event.preventDefault()
|
|
3883
|
+
sendChatMessage()
|
|
3884
|
+
}
|
|
3885
|
+
},
|
|
3886
|
+
}),
|
|
3887
|
+
h(
|
|
3888
|
+
'div',
|
|
3889
|
+
{ className: 'tb-chat-actions' },
|
|
3890
|
+
h(
|
|
3891
|
+
'button',
|
|
3892
|
+
{
|
|
3893
|
+
type: 'button',
|
|
3894
|
+
className: 'tb-btn',
|
|
3895
|
+
onClick: () => openSessionByCard(chat.branchedTo || chat.card.sessionId),
|
|
3896
|
+
},
|
|
3897
|
+
t('chat.openSession'),
|
|
3898
|
+
),
|
|
3899
|
+
h('span', { style: { flex: 1 } }),
|
|
3900
|
+
h(
|
|
3901
|
+
'button',
|
|
3902
|
+
{
|
|
3903
|
+
type: 'button',
|
|
3904
|
+
className: 'tb-btn primary',
|
|
3905
|
+
disabled: chat.sending || String(chat.input ?? '').trim() === '',
|
|
3906
|
+
onClick: sendChatMessage,
|
|
3907
|
+
},
|
|
3908
|
+
chat.sending ? t('panel.acting') : t('chat.send'),
|
|
3909
|
+
),
|
|
3910
|
+
),
|
|
3911
|
+
),
|
|
3912
|
+
),
|
|
3913
|
+
)
|
|
3914
|
+
: null,
|
|
3915
|
+
branchPrompt
|
|
3916
|
+
? h(
|
|
3917
|
+
'div',
|
|
3918
|
+
{ className: 'tb-overlay center', onClick: () => setBranchPrompt(null) },
|
|
3919
|
+
h(
|
|
3920
|
+
'div',
|
|
3921
|
+
{
|
|
3922
|
+
className: 'tb-board-dialog tb-branch-dialog',
|
|
3923
|
+
role: 'dialog',
|
|
3924
|
+
'aria-modal': true,
|
|
3925
|
+
onClick: (event) => event.stopPropagation(),
|
|
3926
|
+
},
|
|
3927
|
+
h(
|
|
3928
|
+
'div',
|
|
3929
|
+
{ className: 'tb-detail-head' },
|
|
3930
|
+
h('span', { className: 'tb-detail-title' }, t('panel.branchNameTitle')),
|
|
3931
|
+
h('span', { style: { flex: 1 } }),
|
|
3932
|
+
),
|
|
3933
|
+
branchPrompt.message ? h('div', { className: 'tb-branch-message' }, branchPrompt.message) : null,
|
|
3934
|
+
h('div', { className: 'tb-ws-hint' }, t('panel.branchNameHint')),
|
|
3935
|
+
h('input', {
|
|
3936
|
+
value: branchPrompt.name ?? '',
|
|
3937
|
+
autoFocus: true,
|
|
3938
|
+
placeholder: branchPrompt.defaultName,
|
|
3939
|
+
onFocus: (event) => event.target.select(),
|
|
3940
|
+
onChange: (event) =>
|
|
3941
|
+
setBranchPrompt((current) => (current ? { ...current, name: event.target.value } : current)),
|
|
3942
|
+
onKeyDown: (event) => {
|
|
3943
|
+
event.stopPropagation()
|
|
3944
|
+
if (event.nativeEvent?.isComposing) return
|
|
3945
|
+
if (event.key === 'Enter') {
|
|
3946
|
+
event.preventDefault()
|
|
3947
|
+
confirmBranchPrompt()
|
|
3948
|
+
} else if (event.key === 'Escape') {
|
|
3949
|
+
event.preventDefault()
|
|
3950
|
+
setBranchPrompt(null)
|
|
3951
|
+
}
|
|
3952
|
+
},
|
|
3953
|
+
}),
|
|
3954
|
+
h(
|
|
3955
|
+
'div',
|
|
3956
|
+
{ className: 'tb-note-actions' },
|
|
3957
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => setBranchPrompt(null) }, t('panel.cancel')),
|
|
3958
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: confirmBranchPrompt }, t('panel.createBranch')),
|
|
3959
|
+
),
|
|
3960
|
+
),
|
|
3961
|
+
)
|
|
3962
|
+
: null,
|
|
3963
|
+
)
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
/** 全选 + folder/file checkbox selector for per-workspace snapshots. */
|
|
3967
|
+
function WorkspacePathSelector(props) {
|
|
3968
|
+
const t = typeof props?.t === 'function' ? props.t : (key) => key
|
|
3969
|
+
const sessionId = typeof props?.sessionId === 'string' ? props.sessionId : ''
|
|
3970
|
+
const workspace = props?.workspace || null
|
|
3971
|
+
const cwd = workspace?.cwd || ''
|
|
3972
|
+
const [state, setState] = React.useState({ loading: true, entries: [], excludePaths: [], error: '', saving: false })
|
|
3973
|
+
const [expanded, setExpanded] = React.useState({})
|
|
3974
|
+
const masterRef = React.useRef(null)
|
|
3975
|
+
const workspaceEnabled = workspace?.enabled === true
|
|
3976
|
+
const selectable = workspace?.mode === 'workspace' && workspace?.exists !== false && Boolean(cwd)
|
|
3977
|
+
|
|
3978
|
+
const load = async () => {
|
|
3979
|
+
if (!sessionId && !cwd) return
|
|
3980
|
+
setState((previous) => ({ ...previous, loading: true, error: '' }))
|
|
3981
|
+
try {
|
|
3982
|
+
const body = await request('action', {
|
|
3983
|
+
method: 'POST',
|
|
3984
|
+
body: { action: 'workspace-tree', ...(sessionId ? { sessionId } : {}), ...(cwd ? { cwd } : {}) },
|
|
3985
|
+
})
|
|
3986
|
+
setState({
|
|
3987
|
+
loading: false,
|
|
3988
|
+
entries: Array.isArray(body.entries) ? body.entries : [],
|
|
3989
|
+
excludePaths: Array.isArray(body.excludePaths) ? body.excludePaths : [],
|
|
3990
|
+
error: '',
|
|
3991
|
+
saving: false,
|
|
3992
|
+
})
|
|
3993
|
+
} catch (error) {
|
|
3994
|
+
setState((previous) => ({ ...previous, loading: false, error: error?.message || String(error) }))
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
React.useEffect(() => {
|
|
3999
|
+
load()
|
|
4000
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4001
|
+
}, [sessionId, cwd, workspaceEnabled])
|
|
4002
|
+
|
|
4003
|
+
React.useEffect(() => {
|
|
4004
|
+
if (!masterRef.current) return
|
|
4005
|
+
const excluded = (entry) => state.excludePaths.some((value) => entry.path === value || entry.path.startsWith(`${value}/`))
|
|
4006
|
+
const selected = state.entries.filter((entry) => !excluded(entry)).length
|
|
4007
|
+
masterRef.current.indeterminate = workspaceEnabled && state.excludePaths.length > 0 && selected > 0
|
|
4008
|
+
}, [state.excludePaths, state.entries, workspaceEnabled])
|
|
4009
|
+
|
|
4010
|
+
const savePaths = async (excludePaths) => {
|
|
4011
|
+
if (state.saving) return
|
|
4012
|
+
setState((previous) => ({ ...previous, saving: true, error: '' }))
|
|
4013
|
+
try {
|
|
4014
|
+
const body = await request('action', {
|
|
4015
|
+
method: 'POST',
|
|
4016
|
+
body: {
|
|
4017
|
+
action: 'set-workspace-paths',
|
|
4018
|
+
...(sessionId ? { sessionId } : {}),
|
|
4019
|
+
...(cwd ? { cwd } : {}),
|
|
4020
|
+
excludePaths,
|
|
4021
|
+
},
|
|
4022
|
+
})
|
|
4023
|
+
const nextExcludes = Array.isArray(body.workspace?.excludePaths) ? body.workspace.excludePaths : excludePaths
|
|
4024
|
+
setState((previous) => ({ ...previous, excludePaths: nextExcludes, saving: false }))
|
|
4025
|
+
if (typeof props?.onChanged === 'function') props.onChanged(body.workspace)
|
|
4026
|
+
} catch (error) {
|
|
4027
|
+
setState((previous) => ({ ...previous, saving: false, error: error?.message || String(error) }))
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
const setEnabled = async (enabled) => {
|
|
4032
|
+
if (state.saving) return
|
|
4033
|
+
setState((previous) => ({ ...previous, saving: true, error: '' }))
|
|
4034
|
+
try {
|
|
4035
|
+
await request('action', {
|
|
4036
|
+
method: 'POST',
|
|
4037
|
+
body: {
|
|
4038
|
+
action: 'set-workspace',
|
|
4039
|
+
...(sessionId ? { sessionId } : {}),
|
|
4040
|
+
...(cwd ? { cwd } : {}),
|
|
4041
|
+
enabled,
|
|
4042
|
+
},
|
|
4043
|
+
})
|
|
4044
|
+
if (enabled) {
|
|
4045
|
+
await savePaths([])
|
|
3263
4046
|
} else {
|
|
3264
4047
|
setState((previous) => ({ ...previous, saving: false }))
|
|
3265
4048
|
if (typeof props?.onChanged === 'function') props.onChanged(null)
|
|
@@ -3801,7 +4584,66 @@ window.__ModuleLoader__.load({
|
|
|
3801
4584
|
const BOARD_ANCHORS = ['top', 'right', 'bottom', 'left']
|
|
3802
4585
|
|
|
3803
4586
|
function emptyBoardCanvas() {
|
|
3804
|
-
return { notes: {}, background: [], drawings: {}, edges: [] }
|
|
4587
|
+
return { notes: {}, background: [], drawings: {}, edges: [], texts: [], windows: [] }
|
|
4588
|
+
}
|
|
4589
|
+
|
|
4590
|
+
/** Parse CSV/TSV/Markdown-table text into a rectangular cell grid. */
|
|
4591
|
+
function parseTableText(text) {
|
|
4592
|
+
const lines = String(text ?? '')
|
|
4593
|
+
.replace(/\r\n?/g, '\n')
|
|
4594
|
+
.split('\n')
|
|
4595
|
+
while (lines.length > 0 && lines[lines.length - 1] === '') lines.pop()
|
|
4596
|
+
if (lines.length === 0) return [['']]
|
|
4597
|
+
if (lines.filter((line) => line.includes('|')).length >= 2) {
|
|
4598
|
+
const rows = []
|
|
4599
|
+
for (const line of lines) {
|
|
4600
|
+
const trimmed = line.trim()
|
|
4601
|
+
if (!trimmed.includes('|')) continue
|
|
4602
|
+
if (/^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?$/.test(trimmed)) continue
|
|
4603
|
+
let cells = trimmed.split('|').map((cell) => cell.trim())
|
|
4604
|
+
if (cells.length > 0 && cells[0] === '') cells = cells.slice(1)
|
|
4605
|
+
if (cells.length > 0 && cells[cells.length - 1] === '') cells = cells.slice(0, -1)
|
|
4606
|
+
rows.push(cells)
|
|
4607
|
+
}
|
|
4608
|
+
if (rows.length > 0) return rows.slice(0, 50).map((row) => row.slice(0, 20))
|
|
4609
|
+
}
|
|
4610
|
+
const delimiter = lines.some((line) => line.includes('\t')) ? '\t' : ','
|
|
4611
|
+
const rows = []
|
|
4612
|
+
let row = []
|
|
4613
|
+
let cell = ''
|
|
4614
|
+
let quoted = false
|
|
4615
|
+
const pushCell = () => {
|
|
4616
|
+
row.push(cell)
|
|
4617
|
+
cell = ''
|
|
4618
|
+
}
|
|
4619
|
+
const pushRow = () => {
|
|
4620
|
+
pushCell()
|
|
4621
|
+
rows.push(row)
|
|
4622
|
+
row = []
|
|
4623
|
+
}
|
|
4624
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
4625
|
+
const char = text[index]
|
|
4626
|
+
if (quoted) {
|
|
4627
|
+
if (char === '"' && text[index + 1] === '"') {
|
|
4628
|
+
cell += '"'
|
|
4629
|
+
index += 1
|
|
4630
|
+
} else if (char === '"') quoted = false
|
|
4631
|
+
else cell += char
|
|
4632
|
+
continue
|
|
4633
|
+
}
|
|
4634
|
+
if (char === '"') quoted = true
|
|
4635
|
+
else if (char === delimiter) pushCell()
|
|
4636
|
+
else if (char === '\n') pushRow()
|
|
4637
|
+
else if (char !== '\r') cell += char
|
|
4638
|
+
}
|
|
4639
|
+
if (cell !== '' || row.length > 0) pushRow()
|
|
4640
|
+
if (rows.length === 0) return [['']]
|
|
4641
|
+
return rows.slice(0, 50).map((entry) => entry.slice(0, 20).map((value) => value.slice(0, 500)))
|
|
4642
|
+
}
|
|
4643
|
+
|
|
4644
|
+
/** Serialize a table grid back to editable TSV text. */
|
|
4645
|
+
function tableRowsToText(rows) {
|
|
4646
|
+
return (Array.isArray(rows) ? rows : []).map((row) => (Array.isArray(row) ? row : []).join('\t')).join('\n')
|
|
3805
4647
|
}
|
|
3806
4648
|
|
|
3807
4649
|
/** Deep-copy the sticky canvas so React sees new references. */
|
|
@@ -3820,6 +4662,11 @@ window.__ModuleLoader__.load({
|
|
|
3820
4662
|
drawings: Object.fromEntries(
|
|
3821
4663
|
Object.entries(canvas.drawings && typeof canvas.drawings === 'object' ? canvas.drawings : {}).map(([id, strokes]) => [id, copyStrokes(strokes)]),
|
|
3822
4664
|
),
|
|
4665
|
+
texts: (Array.isArray(canvas.texts) ? canvas.texts : []).map((text) => ({ ...text })),
|
|
4666
|
+
windows: (Array.isArray(canvas.windows) ? canvas.windows : []).map((window) => ({
|
|
4667
|
+
...window,
|
|
4668
|
+
...(Array.isArray(window.rows) ? { rows: window.rows.map((row) => [...row]) } : {}),
|
|
4669
|
+
})),
|
|
3823
4670
|
edges: (Array.isArray(canvas.edges) ? canvas.edges : []).map((edge) => ({
|
|
3824
4671
|
...edge,
|
|
3825
4672
|
from: { ...(edge.from ?? {}) },
|
|
@@ -3886,6 +4733,27 @@ window.__ModuleLoader__.load({
|
|
|
3886
4733
|
}
|
|
3887
4734
|
|
|
3888
4735
|
/** Render pen strokes and common shapes for one stroke layer. */
|
|
4736
|
+
/** Smooth a freehand point list with Catmull-Rom -> cubic Bezier. */
|
|
4737
|
+
function smoothStrokePath(points) {
|
|
4738
|
+
const list = Array.isArray(points) ? points : []
|
|
4739
|
+
if (list.length === 0) return ''
|
|
4740
|
+
if (list.length === 1) return `M ${list[0][0]} ${list[0][1]} L ${list[0][0] + 0.1} ${list[0][1] + 0.1}`
|
|
4741
|
+
if (list.length === 2) return `M ${list[0][0]} ${list[0][1]} L ${list[1][0]} ${list[1][1]}`
|
|
4742
|
+
let d = `M ${list[0][0]} ${list[0][1]}`
|
|
4743
|
+
for (let index = 0; index < list.length - 1; index += 1) {
|
|
4744
|
+
const p0 = list[index - 1] ?? list[index]
|
|
4745
|
+
const p1 = list[index]
|
|
4746
|
+
const p2 = list[index + 1]
|
|
4747
|
+
const p3 = list[index + 2] ?? p2
|
|
4748
|
+
const cp1x = p1[0] + (p2[0] - p0[0]) / 6
|
|
4749
|
+
const cp1y = p1[1] + (p2[1] - p0[1]) / 6
|
|
4750
|
+
const cp2x = p2[0] - (p3[0] - p1[0]) / 6
|
|
4751
|
+
const cp2y = p2[1] - (p3[1] - p1[1]) / 6
|
|
4752
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)} ${cp2x.toFixed(2)} ${cp2y.toFixed(2)} ${p2[0]} ${p2[1]}`
|
|
4753
|
+
}
|
|
4754
|
+
return d
|
|
4755
|
+
}
|
|
4756
|
+
|
|
3889
4757
|
function boardStrokeElements(strokes, keyPrefix) {
|
|
3890
4758
|
return (strokes ?? []).map((stroke, index) => {
|
|
3891
4759
|
const key = `${keyPrefix}-${index}`
|
|
@@ -3894,9 +4762,9 @@ window.__ModuleLoader__.load({
|
|
|
3894
4762
|
const color = stroke.color
|
|
3895
4763
|
const width = stroke.width
|
|
3896
4764
|
if (kind === 'pen' || points.length < 2) {
|
|
3897
|
-
return h('
|
|
4765
|
+
return h('path', {
|
|
3898
4766
|
key,
|
|
3899
|
-
|
|
4767
|
+
d: smoothStrokePath(points),
|
|
3900
4768
|
fill: 'none',
|
|
3901
4769
|
stroke: color,
|
|
3902
4770
|
strokeWidth: width,
|
|
@@ -3937,13 +4805,14 @@ window.__ModuleLoader__.load({
|
|
|
3937
4805
|
h('polygon', { points: boardArrowHead(a, b, width), fill: color, stroke: 'none' }),
|
|
3938
4806
|
)
|
|
3939
4807
|
}
|
|
3940
|
-
return h('
|
|
4808
|
+
return h('path', {
|
|
3941
4809
|
key,
|
|
3942
|
-
|
|
4810
|
+
d: smoothStrokePath(points),
|
|
3943
4811
|
fill: 'none',
|
|
3944
4812
|
stroke: color,
|
|
3945
4813
|
strokeWidth: width,
|
|
3946
4814
|
strokeLinecap: 'round',
|
|
4815
|
+
strokeLinejoin: 'round',
|
|
3947
4816
|
})
|
|
3948
4817
|
})
|
|
3949
4818
|
}
|
|
@@ -3973,6 +4842,7 @@ window.__ModuleLoader__.load({
|
|
|
3973
4842
|
width: BOARD_NOTE_W,
|
|
3974
4843
|
height: BOARD_NOTE_H,
|
|
3975
4844
|
z: index,
|
|
4845
|
+
kind: 'sticky',
|
|
3976
4846
|
color: '#ffffff',
|
|
3977
4847
|
}
|
|
3978
4848
|
}
|
|
@@ -4175,6 +5045,7 @@ window.__ModuleLoader__.load({
|
|
|
4175
5045
|
const onChange = typeof props?.onChange === 'function' ? props.onChange : () => {}
|
|
4176
5046
|
const disabled = props?.disabled === true
|
|
4177
5047
|
const [mode, setMode] = React.useState('rich')
|
|
5048
|
+
const [linkEditor, setLinkEditor] = React.useState(null)
|
|
4178
5049
|
const sourceRef = React.useRef(null)
|
|
4179
5050
|
const richRef = React.useRef(null)
|
|
4180
5051
|
const richRangeRef = React.useRef(null)
|
|
@@ -4224,6 +5095,7 @@ window.__ModuleLoader__.load({
|
|
|
4224
5095
|
const exec = (command, argument = null) => {
|
|
4225
5096
|
const element = richRef.current
|
|
4226
5097
|
if (!element) return
|
|
5098
|
+
let applied = false
|
|
4227
5099
|
try {
|
|
4228
5100
|
element.focus({ preventScroll: true })
|
|
4229
5101
|
const range = richRangeRef.current
|
|
@@ -4232,10 +5104,26 @@ window.__ModuleLoader__.load({
|
|
|
4232
5104
|
selection.removeAllRanges()
|
|
4233
5105
|
selection.addRange(range)
|
|
4234
5106
|
}
|
|
4235
|
-
document.execCommand(command, false, argument)
|
|
5107
|
+
applied = document.execCommand(command, false, argument)
|
|
4236
5108
|
} catch {
|
|
4237
5109
|
// execCommand can be unavailable; the source tab still works.
|
|
4238
5110
|
}
|
|
5111
|
+
// Some desktop WebViews disable execCommand but still expose the DOM
|
|
5112
|
+
// Range API; keep the text-colour button working there.
|
|
5113
|
+
if (!applied && command === 'foreColor' && typeof document !== 'undefined') {
|
|
5114
|
+
try {
|
|
5115
|
+
const selection = window.getSelection()
|
|
5116
|
+
const range = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null
|
|
5117
|
+
if (range && !range.collapsed) {
|
|
5118
|
+
const span = document.createElement('span')
|
|
5119
|
+
span.style.color = argument
|
|
5120
|
+
span.appendChild(range.extractContents())
|
|
5121
|
+
range.insertNode(span)
|
|
5122
|
+
}
|
|
5123
|
+
} catch {
|
|
5124
|
+
// Leave the document unchanged if the selection cannot be wrapped.
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
4239
5127
|
rememberRichSelection()
|
|
4240
5128
|
syncRich()
|
|
4241
5129
|
}
|
|
@@ -4295,6 +5183,14 @@ window.__ModuleLoader__.load({
|
|
|
4295
5183
|
else if (mode === 'source') sourceSurround(`<span style="color:${color}">`, '</span>')
|
|
4296
5184
|
}
|
|
4297
5185
|
|
|
5186
|
+
const submitLink = () => {
|
|
5187
|
+
const href = String(linkEditor?.href ?? '').trim()
|
|
5188
|
+
setLinkEditor(null)
|
|
5189
|
+
if (href === '') return
|
|
5190
|
+
if (mode === 'rich') exec('createLink', href)
|
|
5191
|
+
else sourceSurround('[', `](${href})`)
|
|
5192
|
+
}
|
|
5193
|
+
|
|
4298
5194
|
const richTools = [
|
|
4299
5195
|
{ key: 'h1', label: 'H1', title: t('md.heading'), run: () => exec('formatBlock', '<h1>') },
|
|
4300
5196
|
{ key: 'h2', label: 'H2', title: t('md.heading'), run: () => exec('formatBlock', '<h2>') },
|
|
@@ -4308,15 +5204,7 @@ window.__ModuleLoader__.load({
|
|
|
4308
5204
|
{ key: 'numbered', label: '1.', title: t('md.numbered'), run: () => exec('insertOrderedList') },
|
|
4309
5205
|
{ key: 'task', label: '☐', title: t('md.task'), run: () => insertHtml('<div>- [ ] {selection}</div>') },
|
|
4310
5206
|
{ key: 'quote', label: '❝', title: t('md.quote'), run: () => exec('formatBlock', '<blockquote>') },
|
|
4311
|
-
{ key: 'link', label: '🔗', title: t('md.link'), run: () => {
|
|
4312
|
-
let href = 'https://'
|
|
4313
|
-
try {
|
|
4314
|
-
href = window.prompt(t('md.linkPrompt'), 'https://') || ''
|
|
4315
|
-
} catch {
|
|
4316
|
-
href = ''
|
|
4317
|
-
}
|
|
4318
|
-
if (href) exec('createLink', href)
|
|
4319
|
-
} },
|
|
5207
|
+
{ key: 'link', label: '🔗', title: t('md.link'), run: () => setLinkEditor({ href: 'https://' }) },
|
|
4320
5208
|
{ key: 'hr', label: '—', title: t('md.hr'), run: () => exec('insertHorizontalRule') },
|
|
4321
5209
|
]
|
|
4322
5210
|
const sourceTools = [
|
|
@@ -4404,6 +5292,32 @@ window.__ModuleLoader__.load({
|
|
|
4404
5292
|
}),
|
|
4405
5293
|
),
|
|
4406
5294
|
),
|
|
5295
|
+
linkEditor
|
|
5296
|
+
? h(
|
|
5297
|
+
'div',
|
|
5298
|
+
{ className: 'tb-md-linkbar' },
|
|
5299
|
+
h('span', { className: 'tb-md-color-label' }, t('md.linkPrompt')),
|
|
5300
|
+
h('input', {
|
|
5301
|
+
className: 'tb-md-link-input',
|
|
5302
|
+
value: linkEditor.href ?? '',
|
|
5303
|
+
autoFocus: true,
|
|
5304
|
+
placeholder: 'https://',
|
|
5305
|
+
onChange: (event) => setLinkEditor({ href: event.target.value }),
|
|
5306
|
+
onKeyDown: (event) => {
|
|
5307
|
+
if (event.nativeEvent?.isComposing) return
|
|
5308
|
+
if (event.key === 'Enter') {
|
|
5309
|
+
event.preventDefault()
|
|
5310
|
+
submitLink()
|
|
5311
|
+
} else if (event.key === 'Escape') {
|
|
5312
|
+
event.preventDefault()
|
|
5313
|
+
setLinkEditor(null)
|
|
5314
|
+
}
|
|
5315
|
+
},
|
|
5316
|
+
}),
|
|
5317
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => setLinkEditor(null) }, t('panel.cancel')),
|
|
5318
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: submitLink }, t('panel.confirm')),
|
|
5319
|
+
)
|
|
5320
|
+
: null,
|
|
4407
5321
|
h('div', { className: 'tb-ws-hint', style: { fontSize: '10.5px' } }, t('md.hint')),
|
|
4408
5322
|
h(
|
|
4409
5323
|
'div',
|
|
@@ -4544,6 +5458,11 @@ window.__ModuleLoader__.load({
|
|
|
4544
5458
|
const selectedRef = React.useRef(selected)
|
|
4545
5459
|
selectedRef.current = selected
|
|
4546
5460
|
const [readerId, setReaderId] = React.useState('')
|
|
5461
|
+
const [textEditor, setTextEditor] = React.useState(null)
|
|
5462
|
+
const [windowEditor, setWindowEditor] = React.useState(null)
|
|
5463
|
+
const [insertMenu, setInsertMenu] = React.useState(false)
|
|
5464
|
+
const [clearMenu, setClearMenu] = React.useState(false)
|
|
5465
|
+
const [notice, setNotice] = React.useState(null)
|
|
4547
5466
|
const [linkPreview, setLinkPreview] = React.useState(null)
|
|
4548
5467
|
const [zoom, setZoom] = React.useState(1)
|
|
4549
5468
|
const zoomRef = React.useRef(zoom)
|
|
@@ -4691,6 +5610,17 @@ window.__ModuleLoader__.load({
|
|
|
4691
5610
|
}
|
|
4692
5611
|
addStrokes(canvasRef.current.background)
|
|
4693
5612
|
for (const strokes of Object.values(canvasRef.current.drawings ?? {})) addStrokes(strokes)
|
|
5613
|
+
for (const item of canvasRef.current.windows ?? []) {
|
|
5614
|
+
include(Number(item.x) || 0, Number(item.y) || 0)
|
|
5615
|
+
include((Number(item.x) || 0) + (Number(item.width) || 480), (Number(item.y) || 0) + (Number(item.height) || 260))
|
|
5616
|
+
}
|
|
5617
|
+
for (const item of canvasRef.current.texts ?? []) {
|
|
5618
|
+
const width = Math.min(1200, Math.max(80, Number(item.width) || 320))
|
|
5619
|
+
const lines = String(item.text || '').split(String.fromCharCode(10)).length
|
|
5620
|
+
const height = Math.max(24, lines * (Number(item.fontSize) || 18) * 1.45)
|
|
5621
|
+
include(Number(item.x) || 0, Number(item.y) || 0)
|
|
5622
|
+
include((Number(item.x) || 0) + width, (Number(item.y) || 0) + height)
|
|
5623
|
+
}
|
|
4694
5624
|
if (!Number.isFinite(minX)) {
|
|
4695
5625
|
minX = BOARD_STAGE_W / 2 - 300
|
|
4696
5626
|
maxX = BOARD_STAGE_W / 2 + 300
|
|
@@ -4803,11 +5733,32 @@ window.__ModuleLoader__.load({
|
|
|
4803
5733
|
const entries = state.board?.entries ?? []
|
|
4804
5734
|
const sortedEntries = [...entries].sort((left, right) => (right.updatedAt ?? 0) - (left.updatedAt ?? 0))
|
|
4805
5735
|
const boardVersion = state.board?.version ?? 0
|
|
4806
|
-
const
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
5736
|
+
const withDocLayout = (entry, base) => {
|
|
5737
|
+
if (entry?.kind !== 'doc' || base?.kind === 'doc') return base
|
|
5738
|
+
return {
|
|
5739
|
+
...base,
|
|
5740
|
+
kind: 'doc',
|
|
5741
|
+
width: Math.max(560, Number(base.width) || 0),
|
|
5742
|
+
height: Math.max(420, Number(base.height) || 0),
|
|
5743
|
+
}
|
|
5744
|
+
}
|
|
5745
|
+
const layoutFor = (entry, index) => withDocLayout(entry, canvas.notes[entry.id] ?? autoBoardLayout(index))
|
|
5746
|
+
const layoutForNote = (noteId) => {
|
|
5747
|
+
const entry = entries.find((candidate) => candidate.id === noteId)
|
|
5748
|
+
const index = Math.max(0, entries.findIndex((candidate) => candidate.id === noteId))
|
|
5749
|
+
return withDocLayout(entry, canvasRef.current.notes[noteId] ?? autoBoardLayout(index))
|
|
5750
|
+
}
|
|
5751
|
+
const noteSize = (layout) => {
|
|
5752
|
+
const doc = layout?.kind === 'doc'
|
|
5753
|
+
return {
|
|
5754
|
+
width: doc
|
|
5755
|
+
? Math.min(1200, Math.max(320, Number(layout?.width) || 560))
|
|
5756
|
+
: Math.min(640, Math.max(160, Number(layout?.width) || BOARD_NOTE_W)),
|
|
5757
|
+
height: doc
|
|
5758
|
+
? Math.min(900, Math.max(200, Number(layout?.height) || 420))
|
|
5759
|
+
: Math.min(560, Math.max(120, Number(layout?.height) || BOARD_NOTE_H)),
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
4811
5762
|
/** Viewport client point -> unscaled stage coordinates. */
|
|
4812
5763
|
const stagePoint = (event) => {
|
|
4813
5764
|
const stage = stageRef.current
|
|
@@ -4855,7 +5806,7 @@ window.__ModuleLoader__.load({
|
|
|
4855
5806
|
const stage = stageRef.current
|
|
4856
5807
|
return stage ? { layer: 'background', noteId: '', rect: stage.getBoundingClientRect() } : null
|
|
4857
5808
|
}
|
|
4858
|
-
const startCreate = () => setDraft({ id: '', title: '', body: '', preview: false, busy: false, error: null, color: '#ffffff' })
|
|
5809
|
+
const startCreate = (kind = 'sticky') => setDraft({ id: '', title: '', body: '', preview: false, busy: false, error: null, color: '#ffffff', kind })
|
|
4859
5810
|
const startEdit = (entry) =>
|
|
4860
5811
|
setDraft({
|
|
4861
5812
|
id: entry.id,
|
|
@@ -4865,6 +5816,7 @@ window.__ModuleLoader__.load({
|
|
|
4865
5816
|
busy: false,
|
|
4866
5817
|
error: null,
|
|
4867
5818
|
color: canvasRef.current.notes[entry.id]?.color || '#ffffff',
|
|
5819
|
+
kind: entry.kind === 'doc' ? 'doc' : 'sticky',
|
|
4868
5820
|
})
|
|
4869
5821
|
const closeDraft = () => {
|
|
4870
5822
|
if (draft && !draft.busy) setDraft(null)
|
|
@@ -4892,7 +5844,7 @@ window.__ModuleLoader__.load({
|
|
|
4892
5844
|
try {
|
|
4893
5845
|
const body = await request('action', {
|
|
4894
5846
|
method: 'POST',
|
|
4895
|
-
body: boardScope({ action: 'note-save', ...(draft.id ? { id: draft.id } : {}), title: draft.title, body: draft.body }),
|
|
5847
|
+
body: boardScope({ action: 'note-save', ...(draft.id ? { id: draft.id } : {}), title: draft.title, body: draft.body, kind: draft.kind === 'doc' ? 'doc' : 'sticky' }),
|
|
4896
5848
|
})
|
|
4897
5849
|
let board = body.board ?? state.board
|
|
4898
5850
|
setState({ loading: false, board, error: null })
|
|
@@ -4901,11 +5853,15 @@ window.__ModuleLoader__.load({
|
|
|
4901
5853
|
// the visible sticky and the stored layout can never disagree.
|
|
4902
5854
|
if (!draft.id && body.entry?.id && board && !canvasRef.current.notes[body.entry.id]) {
|
|
4903
5855
|
const index = Math.max(0, (board.entries?.length ?? 1) - 1)
|
|
5856
|
+
const isDoc = draft.kind === 'doc' || body.entry?.kind === 'doc'
|
|
5857
|
+
const base = autoBoardLayout(index)
|
|
4904
5858
|
const layoutBody = await saveCanvasNow({
|
|
4905
5859
|
...canvasRef.current,
|
|
4906
5860
|
notes: {
|
|
4907
5861
|
...canvasRef.current.notes,
|
|
4908
|
-
[body.entry.id]:
|
|
5862
|
+
[body.entry.id]: isDoc
|
|
5863
|
+
? { ...base, kind: 'doc', width: 560, height: 420, color: draft.color || '#ffffff' }
|
|
5864
|
+
: { ...base, kind: 'sticky', color: draft.color || '#ffffff' },
|
|
4909
5865
|
},
|
|
4910
5866
|
})
|
|
4911
5867
|
board = layoutBody?.board ?? board
|
|
@@ -4914,7 +5870,11 @@ window.__ModuleLoader__.load({
|
|
|
4914
5870
|
...canvasRef.current,
|
|
4915
5871
|
notes: {
|
|
4916
5872
|
...canvasRef.current.notes,
|
|
4917
|
-
[draft.id]: {
|
|
5873
|
+
[draft.id]: {
|
|
5874
|
+
...canvasRef.current.notes[draft.id],
|
|
5875
|
+
kind: draft.kind === 'doc' ? 'doc' : 'sticky',
|
|
5876
|
+
color: draft.color || '#ffffff',
|
|
5877
|
+
},
|
|
4918
5878
|
},
|
|
4919
5879
|
})
|
|
4920
5880
|
board = layoutBody?.board ?? board
|
|
@@ -4925,35 +5885,299 @@ window.__ModuleLoader__.load({
|
|
|
4925
5885
|
setDraft({ ...draft, busy: false, error: error?.message || String(error) })
|
|
4926
5886
|
}
|
|
4927
5887
|
}
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
5888
|
+
/** Stage point at the centre of the current viewport (used for new text). */
|
|
5889
|
+
const viewportStageCenter = () => {
|
|
5890
|
+
const viewport = viewportRef.current
|
|
5891
|
+
const stage = stageRef.current
|
|
5892
|
+
if (!viewport || !stage) return [180, 160]
|
|
5893
|
+
const rect = stage.getBoundingClientRect()
|
|
5894
|
+
return [
|
|
5895
|
+
Math.round((viewport.scrollLeft + viewport.clientWidth / 2 - rect.left) / zoomScale()),
|
|
5896
|
+
Math.round((viewport.scrollTop + viewport.clientHeight / 2 - rect.top) / zoomScale()),
|
|
5897
|
+
]
|
|
5898
|
+
}
|
|
5899
|
+
|
|
5900
|
+
const startAddText = () => {
|
|
5901
|
+
const [cx, cy] = viewportStageCenter()
|
|
5902
|
+
setTextEditor({ id: '', text: '', color: '#e6e6e6', fontSize: 18, x: Math.max(0, cx - 160), y: Math.max(0, cy - 24), width: 320, busy: false, error: null })
|
|
5903
|
+
}
|
|
5904
|
+
|
|
5905
|
+
const startEditText = (item) => {
|
|
5906
|
+
if (!item) return
|
|
5907
|
+
setTextEditor({ ...item, busy: false, error: null })
|
|
5908
|
+
}
|
|
5909
|
+
|
|
5910
|
+
const saveText = async () => {
|
|
5911
|
+
const editor = textEditor
|
|
5912
|
+
if (!editor || editor.busy) return
|
|
5913
|
+
setTextEditor((current) => (current ? { ...current, busy: true, error: null } : current))
|
|
5914
|
+
const text = String(editor.text ?? '').trim()
|
|
5915
|
+
if (text === '') {
|
|
5916
|
+
if (editor.id) await deleteText(editor.id)
|
|
5917
|
+
else setTextEditor(null)
|
|
5918
|
+
return
|
|
4935
5919
|
}
|
|
4936
|
-
|
|
4937
|
-
|
|
5920
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
5921
|
+
let id = editor.id
|
|
5922
|
+
if (!id) id = `tx-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`
|
|
5923
|
+
const item = {
|
|
5924
|
+
id,
|
|
5925
|
+
text,
|
|
5926
|
+
x: Math.max(0, Number(editor.x) || 0),
|
|
5927
|
+
y: Math.max(0, Number(editor.y) || 0),
|
|
5928
|
+
width: Math.min(1200, Math.max(80, Number(editor.width) || 320)),
|
|
5929
|
+
color: /^#[0-9a-f]{6}$/i.test(String(editor.color || '')) ? String(editor.color).toLowerCase() : '#e6e6e6',
|
|
5930
|
+
fontSize: Math.min(96, Math.max(8, Number(editor.fontSize) || 18)),
|
|
5931
|
+
}
|
|
5932
|
+
next.texts = [...(next.texts ?? []).filter((entry) => entry.id !== id), item]
|
|
4938
5933
|
try {
|
|
4939
|
-
|
|
4940
|
-
setState({ loading: false, board: body.board ?? state.board, error: null })
|
|
4941
|
-
const next = cloneBoardCanvas(canvasRef.current)
|
|
4942
|
-
delete next.notes[id]
|
|
4943
|
-
delete next.drawings[id]
|
|
4944
|
-
saveCanvasSoon(next)
|
|
5934
|
+
await saveCanvasNow(next)
|
|
4945
5935
|
} catch (error) {
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
setBusy('')
|
|
5936
|
+
setTextEditor({ ...editor, busy: false, error: error?.message || String(error) })
|
|
5937
|
+
return
|
|
4949
5938
|
}
|
|
5939
|
+
setSelected(id)
|
|
5940
|
+
setTextEditor(null)
|
|
4950
5941
|
}
|
|
4951
5942
|
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
5943
|
+
/** Outside-click close for the text editor: save non-empty text like stickies. */
|
|
5944
|
+
const dismissTextSaving = () => {
|
|
5945
|
+
const editor = textEditor
|
|
5946
|
+
if (!editor || editor.busy) return
|
|
5947
|
+
if (String(editor.text ?? '').trim() === '') {
|
|
5948
|
+
setTextEditor(null)
|
|
5949
|
+
return
|
|
5950
|
+
}
|
|
5951
|
+
saveText()
|
|
5952
|
+
}
|
|
4955
5953
|
|
|
4956
|
-
|
|
5954
|
+
const deleteText = async (id) => {
|
|
5955
|
+
if (!id) return
|
|
5956
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
5957
|
+
next.texts = (next.texts ?? []).filter((entry) => entry.id !== id)
|
|
5958
|
+
try {
|
|
5959
|
+
await saveCanvasNow(next)
|
|
5960
|
+
} catch {
|
|
5961
|
+
// The text stays visible if the save fails.
|
|
5962
|
+
return
|
|
5963
|
+
}
|
|
5964
|
+
if (selectedRef.current === id) setSelected('')
|
|
5965
|
+
setTextEditor(null)
|
|
5966
|
+
}
|
|
5967
|
+
|
|
5968
|
+
const emptyTableRows = (rows = 3, cols = 3) =>
|
|
5969
|
+
Array.from({ length: Math.max(1, rows) }, () => Array.from({ length: Math.max(1, cols) }, () => ''))
|
|
5970
|
+
|
|
5971
|
+
const startAddTable = (rows = 3, cols = 3) => {
|
|
5972
|
+
const [cx, cy] = viewportStageCenter()
|
|
5973
|
+
setInsertMenu(false)
|
|
5974
|
+
setWindowEditor({
|
|
5975
|
+
id: '',
|
|
5976
|
+
kind: 'table',
|
|
5977
|
+
title: '表格',
|
|
5978
|
+
rows: emptyTableRows(rows, cols),
|
|
5979
|
+
width: 500,
|
|
5980
|
+
height: 300,
|
|
5981
|
+
x: Math.max(0, cx - 250),
|
|
5982
|
+
y: Math.max(0, cy - 150),
|
|
5983
|
+
busy: false,
|
|
5984
|
+
error: null,
|
|
5985
|
+
})
|
|
5986
|
+
}
|
|
5987
|
+
|
|
5988
|
+
const pickFile = (accept, onFile) => {
|
|
5989
|
+
try {
|
|
5990
|
+
const input = document.createElement('input')
|
|
5991
|
+
input.type = 'file'
|
|
5992
|
+
input.accept = accept
|
|
5993
|
+
input.style.position = 'fixed'
|
|
5994
|
+
input.style.left = '-10000px'
|
|
5995
|
+
input.style.top = '0'
|
|
5996
|
+
input.style.opacity = '0'
|
|
5997
|
+
input.style.pointerEvents = 'none'
|
|
5998
|
+
// Some desktop WebViews only open the picker for an input attached to
|
|
5999
|
+
// the document, unlike Chromium's detached-input path.
|
|
6000
|
+
document.body.appendChild(input)
|
|
6001
|
+
const cleanup = () => input.remove()
|
|
6002
|
+
input.addEventListener('change', () => {
|
|
6003
|
+
const file = input.files?.[0]
|
|
6004
|
+
if (file) onFile(file)
|
|
6005
|
+
cleanup()
|
|
6006
|
+
})
|
|
6007
|
+
input.addEventListener('cancel', cleanup)
|
|
6008
|
+
input.click()
|
|
6009
|
+
window.setTimeout(() => {
|
|
6010
|
+
if (input.isConnected) cleanup()
|
|
6011
|
+
}, 60_000)
|
|
6012
|
+
} catch (error) {
|
|
6013
|
+
setState((previous) => ({ ...previous, error: error?.message || String(error) }))
|
|
6014
|
+
}
|
|
6015
|
+
}
|
|
6016
|
+
|
|
6017
|
+
const startImportTable = () => {
|
|
6018
|
+
setInsertMenu(false)
|
|
6019
|
+
pickFile('.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/plain,text/markdown', (file) => {
|
|
6020
|
+
if (file.size > 2_000_000) {
|
|
6021
|
+
setState((previous) => ({ ...previous, error: t('board.tableTooLarge') }))
|
|
6022
|
+
return
|
|
6023
|
+
}
|
|
6024
|
+
const reader = new FileReader()
|
|
6025
|
+
reader.onload = () => {
|
|
6026
|
+
const rows = parseTableText(String(reader.result ?? ''))
|
|
6027
|
+
const [cx, cy] = viewportStageCenter()
|
|
6028
|
+
setWindowEditor({
|
|
6029
|
+
id: '',
|
|
6030
|
+
kind: 'table',
|
|
6031
|
+
title: file.name.replace(/\.[^.]+$/, '') || '导入表格',
|
|
6032
|
+
rows,
|
|
6033
|
+
width: Math.min(900, Math.max(420, (rows[0]?.length ?? 3) * 120)),
|
|
6034
|
+
height: Math.min(700, Math.max(220, rows.length * 34 + 44)),
|
|
6035
|
+
x: Math.max(0, cx - 250),
|
|
6036
|
+
y: Math.max(0, cy - 150),
|
|
6037
|
+
busy: false,
|
|
6038
|
+
error: null,
|
|
6039
|
+
})
|
|
6040
|
+
}
|
|
6041
|
+
reader.onerror = () => setState((previous) => ({ ...previous, error: t('board.tableReadFailed') }))
|
|
6042
|
+
reader.readAsText(file)
|
|
6043
|
+
})
|
|
6044
|
+
}
|
|
6045
|
+
|
|
6046
|
+
const startImportImage = () => {
|
|
6047
|
+
setInsertMenu(false)
|
|
6048
|
+
pickFile('image/*', (file) => {
|
|
6049
|
+
if (!/^image\//i.test(file.type) && !/\.(png|jpe?g|gif|webp|bmp|svg|avif)$/i.test(file.name)) {
|
|
6050
|
+
setState((previous) => ({ ...previous, error: t('board.imageType') }))
|
|
6051
|
+
return
|
|
6052
|
+
}
|
|
6053
|
+
if (file.size > 1_500_000) {
|
|
6054
|
+
setState((previous) => ({ ...previous, error: t('board.imageTooLarge') }))
|
|
6055
|
+
return
|
|
6056
|
+
}
|
|
6057
|
+
const reader = new FileReader()
|
|
6058
|
+
reader.onload = () => {
|
|
6059
|
+
const [cx, cy] = viewportStageCenter()
|
|
6060
|
+
setWindowEditor({
|
|
6061
|
+
id: '',
|
|
6062
|
+
kind: 'image',
|
|
6063
|
+
title: file.name.replace(/\.[^.]+$/, '') || '图片',
|
|
6064
|
+
src: String(reader.result ?? ''),
|
|
6065
|
+
alt: file.name,
|
|
6066
|
+
width: 380,
|
|
6067
|
+
height: 280,
|
|
6068
|
+
x: Math.max(0, cx - 190),
|
|
6069
|
+
y: Math.max(0, cy - 140),
|
|
6070
|
+
busy: false,
|
|
6071
|
+
error: null,
|
|
6072
|
+
})
|
|
6073
|
+
}
|
|
6074
|
+
reader.onerror = () => setState((previous) => ({ ...previous, error: t('board.imageReadFailed') }))
|
|
6075
|
+
reader.readAsDataURL(file)
|
|
6076
|
+
})
|
|
6077
|
+
}
|
|
6078
|
+
|
|
6079
|
+
const startEditWindow = (item) => {
|
|
6080
|
+
if (!item) return
|
|
6081
|
+
setWindowEditor({
|
|
6082
|
+
...item,
|
|
6083
|
+
rows: Array.isArray(item.rows) ? item.rows.map((row) => [...row]) : item.rows,
|
|
6084
|
+
busy: false,
|
|
6085
|
+
error: null,
|
|
6086
|
+
})
|
|
6087
|
+
}
|
|
6088
|
+
|
|
6089
|
+
const saveWindow = async () => {
|
|
6090
|
+
const editor = windowEditor
|
|
6091
|
+
if (!editor || editor.busy) return
|
|
6092
|
+
setWindowEditor((current) => (current ? { ...current, busy: true, error: null } : current))
|
|
6093
|
+
const title = String(editor.title ?? '').trim() || (editor.kind === 'table' ? '表格' : '图片')
|
|
6094
|
+
if (editor.kind === 'image' && !editor.src) {
|
|
6095
|
+
setWindowEditor({ ...editor, busy: false, error: '请先选择图片' })
|
|
6096
|
+
return
|
|
6097
|
+
}
|
|
6098
|
+
let rows = editor.rows
|
|
6099
|
+
if (editor.kind === 'table') {
|
|
6100
|
+
rows = (Array.isArray(editor.rows) ? editor.rows : [[]]).slice(0, 50).map((row) =>
|
|
6101
|
+
(Array.isArray(row) ? row : []).slice(0, 20).map((cell) => String(cell ?? '').slice(0, 500)),
|
|
6102
|
+
)
|
|
6103
|
+
if (rows.length === 0) rows = [['']]
|
|
6104
|
+
}
|
|
6105
|
+
const id = editor.id || `win-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`
|
|
6106
|
+
const item = {
|
|
6107
|
+
id,
|
|
6108
|
+
kind: editor.kind,
|
|
6109
|
+
title,
|
|
6110
|
+
x: Math.max(0, Number(editor.x) || 0),
|
|
6111
|
+
y: Math.max(0, Number(editor.y) || 0),
|
|
6112
|
+
width: Math.min(1600, Math.max(160, Number(editor.width) || (editor.kind === 'image' ? 380 : 500))),
|
|
6113
|
+
height: Math.min(1200, Math.max(120, Number(editor.height) || 280)),
|
|
6114
|
+
...(editor.kind === 'table' ? { rows } : { src: editor.src, alt: editor.alt || title }),
|
|
6115
|
+
}
|
|
6116
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6117
|
+
next.windows = [...(next.windows ?? []).filter((entry) => entry.id !== id), item]
|
|
6118
|
+
try {
|
|
6119
|
+
await saveCanvasNow(next)
|
|
6120
|
+
} catch (error) {
|
|
6121
|
+
setWindowEditor({ ...editor, busy: false, error: error?.message || String(error) })
|
|
6122
|
+
return
|
|
6123
|
+
}
|
|
6124
|
+
setSelected(id)
|
|
6125
|
+
setWindowEditor(null)
|
|
6126
|
+
}
|
|
6127
|
+
|
|
6128
|
+
/** Outside-click close for the window editor: save valid content. */
|
|
6129
|
+
const dismissWindowSaving = () => {
|
|
6130
|
+
const editor = windowEditor
|
|
6131
|
+
if (!editor || editor.busy) return
|
|
6132
|
+
if (editor.kind === 'image' && !editor.src) {
|
|
6133
|
+
setWindowEditor(null)
|
|
6134
|
+
return
|
|
6135
|
+
}
|
|
6136
|
+
saveWindow()
|
|
6137
|
+
}
|
|
6138
|
+
|
|
6139
|
+
const deleteWindow = async (id) => {
|
|
6140
|
+
if (!id) return
|
|
6141
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6142
|
+
next.windows = (next.windows ?? []).filter((entry) => entry.id !== id)
|
|
6143
|
+
try {
|
|
6144
|
+
await saveCanvasNow(next)
|
|
6145
|
+
} catch {
|
|
6146
|
+
return
|
|
6147
|
+
}
|
|
6148
|
+
if (selectedRef.current === id) setSelected('')
|
|
6149
|
+
setWindowEditor(null)
|
|
6150
|
+
}
|
|
6151
|
+
|
|
6152
|
+
const removeEntry = async (id) => {
|
|
6153
|
+
if (!id || busy !== '') return
|
|
6154
|
+
let confirmed = true
|
|
6155
|
+
try {
|
|
6156
|
+
confirmed = typeof window.confirm === 'function' ? window.confirm(t('board.deleteConfirm')) : true
|
|
6157
|
+
} catch {
|
|
6158
|
+
confirmed = true
|
|
6159
|
+
}
|
|
6160
|
+
if (!confirmed) return
|
|
6161
|
+
setBusy(id)
|
|
6162
|
+
try {
|
|
6163
|
+
const body = await request('action', { method: 'POST', body: boardScope({ action: 'note-delete', id }) })
|
|
6164
|
+
setState({ loading: false, board: body.board ?? state.board, error: null })
|
|
6165
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6166
|
+
delete next.notes[id]
|
|
6167
|
+
delete next.drawings[id]
|
|
6168
|
+
saveCanvasSoon(next)
|
|
6169
|
+
} catch (error) {
|
|
6170
|
+
setState((previous) => ({ ...previous, error: error?.message || String(error) }))
|
|
6171
|
+
} finally {
|
|
6172
|
+
setBusy('')
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
|
|
6176
|
+
/* -------------------------------------------------------------- */
|
|
6177
|
+
/* sticky canvas: drag notes and draw strokes */
|
|
6178
|
+
/* -------------------------------------------------------------- */
|
|
6179
|
+
|
|
6180
|
+
/** Ctrl/Shift snapping: shapes stay square/circular, lines/arrows snap to 45°. */
|
|
4957
6181
|
const snapShapeEnd = (gesture, world) => {
|
|
4958
6182
|
const [sx, sy] = gesture.startWorld
|
|
4959
6183
|
const dx = world[0] - sx
|
|
@@ -5040,14 +6264,53 @@ window.__ModuleLoader__.load({
|
|
|
5040
6264
|
}
|
|
5041
6265
|
return
|
|
5042
6266
|
}
|
|
6267
|
+
if (current.type === 'window-drag') {
|
|
6268
|
+
const scale = zoomScale()
|
|
6269
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6270
|
+
const item = (next.windows ?? []).find((entry) => entry.id === current.windowId)
|
|
6271
|
+
if (item) {
|
|
6272
|
+
item.x = Math.max(0, Math.min(BOARD_STAGE_W - (Number(item.width) || 480), current.originX + (event.clientX - current.startX) / scale))
|
|
6273
|
+
item.y = Math.max(0, Math.min(BOARD_STAGE_H - 80, current.originY + (event.clientY - current.startY) / scale))
|
|
6274
|
+
next.windows = (next.windows ?? []).map((entry) => (entry.id === item.id ? item : entry))
|
|
6275
|
+
canvasRef.current = next
|
|
6276
|
+
setCanvas(next)
|
|
6277
|
+
}
|
|
6278
|
+
return
|
|
6279
|
+
}
|
|
6280
|
+
if (current.type === 'window-resize') {
|
|
6281
|
+
const scale = zoomScale()
|
|
6282
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6283
|
+
const item = (next.windows ?? []).find((entry) => entry.id === current.windowId)
|
|
6284
|
+
if (item) {
|
|
6285
|
+
item.width = Math.min(1600, Math.max(160, Math.round(current.startW + (event.clientX - current.startX) / scale)))
|
|
6286
|
+
item.height = Math.min(1200, Math.max(120, Math.round(current.startH + (event.clientY - current.startY) / scale)))
|
|
6287
|
+
next.windows = (next.windows ?? []).map((entry) => (entry.id === item.id ? item : entry))
|
|
6288
|
+
canvasRef.current = next
|
|
6289
|
+
setCanvas(next)
|
|
6290
|
+
}
|
|
6291
|
+
return
|
|
6292
|
+
}
|
|
6293
|
+
if (current.type === 'text-drag') {
|
|
6294
|
+
const scale = zoomScale()
|
|
6295
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
6296
|
+
const item = (next.texts ?? []).find((entry) => entry.id === current.textId)
|
|
6297
|
+
if (item) {
|
|
6298
|
+
item.x = Math.max(0, Math.min(BOARD_STAGE_W - (Number(item.width) || 320), current.originX + (event.clientX - current.startX) / scale))
|
|
6299
|
+
item.y = Math.max(0, Math.min(BOARD_STAGE_H - 40, current.originY + (event.clientY - current.startY) / scale))
|
|
6300
|
+
next.texts = (next.texts ?? []).map((entry) => (entry.id === item.id ? item : entry))
|
|
6301
|
+
canvasRef.current = next
|
|
6302
|
+
setCanvas(next)
|
|
6303
|
+
}
|
|
6304
|
+
return
|
|
6305
|
+
}
|
|
5043
6306
|
if (current.type === 'resize') {
|
|
5044
6307
|
const scale = zoomScale()
|
|
5045
|
-
const
|
|
5046
|
-
const
|
|
6308
|
+
const currentLayout = layoutForNote(current.noteId)
|
|
6309
|
+
const doc = currentLayout.kind === 'doc'
|
|
6310
|
+
const width = Math.min(doc ? 1200 : 640, Math.max(doc ? 320 : 160, Math.round(current.startW + (event.clientX - current.startX) / scale)))
|
|
6311
|
+
const height = Math.min(doc ? 900 : 560, Math.max(doc ? 200 : 120, Math.round(current.startH + (event.clientY - current.startY) / scale)))
|
|
5047
6312
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
5048
|
-
const layout =
|
|
5049
|
-
layout.width = width
|
|
5050
|
-
layout.height = height
|
|
6313
|
+
const layout = { ...currentLayout, width, height }
|
|
5051
6314
|
next.notes[current.noteId] = layout
|
|
5052
6315
|
canvasRef.current = next
|
|
5053
6316
|
setCanvas(next)
|
|
@@ -5073,8 +6336,7 @@ window.__ModuleLoader__.load({
|
|
|
5073
6336
|
const under = layerAt(event)
|
|
5074
6337
|
const changed =
|
|
5075
6338
|
under &&
|
|
5076
|
-
(under.layer !== current.layer || (under.layer === 'note' && under.noteId !== current.noteId))
|
|
5077
|
-
!(under.layer === 'note' && !drawOnStickyRef.current)
|
|
6339
|
+
(under.layer !== current.layer || (under.layer === 'note' && under.noteId !== current.noteId))
|
|
5078
6340
|
if (changed) {
|
|
5079
6341
|
const previous = current.lastWorld ?? [event.clientX, event.clientY]
|
|
5080
6342
|
const crossScale = zoomScale()
|
|
@@ -5134,8 +6396,7 @@ window.__ModuleLoader__.load({
|
|
|
5134
6396
|
const underShape = layerAt(event)
|
|
5135
6397
|
const shapeChanged =
|
|
5136
6398
|
underShape &&
|
|
5137
|
-
(underShape.layer !== current.layer || (underShape.layer === 'note' && underShape.noteId !== current.noteId))
|
|
5138
|
-
!(underShape.layer === 'note' && !drawOnStickyRef.current)
|
|
6399
|
+
(underShape.layer !== current.layer || (underShape.layer === 'note' && underShape.noteId !== current.noteId))
|
|
5139
6400
|
if (shapeChanged) {
|
|
5140
6401
|
const startWorld = current.startWorld ?? [event.clientX, event.clientY]
|
|
5141
6402
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
@@ -5184,11 +6445,30 @@ window.__ModuleLoader__.load({
|
|
|
5184
6445
|
stroke.points[1] = point
|
|
5185
6446
|
}
|
|
5186
6447
|
} else {
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
6448
|
+
// Use every coalesced pointer sample and render at most once per
|
|
6449
|
+
// animation frame. Cloning the whole board on every pointermove
|
|
6450
|
+
// made fast strokes visibly chunky.
|
|
6451
|
+
const scale = zoomScale()
|
|
6452
|
+
const samples =
|
|
6453
|
+
typeof event.getCoalescedEvents === 'function' ? event.getCoalescedEvents() : [event]
|
|
6454
|
+
for (const sample of samples.length > 0 ? samples : [event]) {
|
|
6455
|
+
if (stroke.points.length >= 800) break
|
|
6456
|
+
const samplePoint = [
|
|
6457
|
+
Math.round((sample.clientX - current.rect.left) / scale),
|
|
6458
|
+
Math.round((sample.clientY - current.rect.top) / scale),
|
|
6459
|
+
]
|
|
6460
|
+
const last = stroke.points[stroke.points.length - 1]
|
|
6461
|
+
if (last && last[0] === samplePoint[0] && last[1] === samplePoint[1]) continue
|
|
6462
|
+
stroke.points.push(samplePoint)
|
|
6463
|
+
}
|
|
5191
6464
|
current.lastWorld = [event.clientX, event.clientY]
|
|
6465
|
+
if (!current.renderFrame) {
|
|
6466
|
+
current.renderFrame = window.requestAnimationFrame(() => {
|
|
6467
|
+
current.renderFrame = 0
|
|
6468
|
+
setCanvas({ ...canvasRef.current })
|
|
6469
|
+
})
|
|
6470
|
+
}
|
|
6471
|
+
return
|
|
5192
6472
|
}
|
|
5193
6473
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
5194
6474
|
if (current.layer === 'background') {
|
|
@@ -5211,6 +6491,10 @@ window.__ModuleLoader__.load({
|
|
|
5211
6491
|
window.removeEventListener('pointercancel', finish)
|
|
5212
6492
|
const current = gestureRef.current
|
|
5213
6493
|
gestureRef.current = null
|
|
6494
|
+
if (current && current.renderFrame) {
|
|
6495
|
+
window.cancelAnimationFrame(current.renderFrame)
|
|
6496
|
+
current.renderFrame = 0
|
|
6497
|
+
}
|
|
5214
6498
|
if (current && current.type === 'link') {
|
|
5215
6499
|
setLinkPreview(null)
|
|
5216
6500
|
const under = event ? layerAt(event) : null
|
|
@@ -5249,16 +6533,72 @@ window.__ModuleLoader__.load({
|
|
|
5249
6533
|
|
|
5250
6534
|
const beginPointer = (event) => {
|
|
5251
6535
|
if (event.button !== 0) return
|
|
6536
|
+
if (insertMenu) setInsertMenu(false)
|
|
6537
|
+
if (clearMenu) setClearMenu(false)
|
|
6538
|
+
if (shapeMenu) setShapeMenu(false)
|
|
5252
6539
|
if (event.target?.closest?.('button') || event.target?.closest?.('.tb-sticky-linkline') || event.target?.closest?.('.tb-sticky-actions')) return
|
|
5253
6540
|
const stage = stageRef.current
|
|
5254
6541
|
if (!stage) return
|
|
6542
|
+
const windowElement = event.target?.closest?.('.tb-board-window')
|
|
6543
|
+
const windowId = windowElement?.getAttribute?.('data-window-id') || ''
|
|
6544
|
+
if (windowId) {
|
|
6545
|
+
if (toolRef.current !== 'select') return
|
|
6546
|
+
if (event.target?.closest?.('.tb-board-window-body')) {
|
|
6547
|
+
setSelected(windowId)
|
|
6548
|
+
return
|
|
6549
|
+
}
|
|
6550
|
+
event.preventDefault()
|
|
6551
|
+
setSelected(windowId)
|
|
6552
|
+
const item = (canvasRef.current.windows ?? []).find((entry) => entry.id === windowId)
|
|
6553
|
+
if (item) {
|
|
6554
|
+
if (event.target?.closest?.('.tb-board-window-resize')) {
|
|
6555
|
+
setGesture({
|
|
6556
|
+
type: 'window-resize',
|
|
6557
|
+
windowId,
|
|
6558
|
+
startX: event.clientX,
|
|
6559
|
+
startY: event.clientY,
|
|
6560
|
+
startW: Number(item.width) || 480,
|
|
6561
|
+
startH: Number(item.height) || 260,
|
|
6562
|
+
})
|
|
6563
|
+
} else {
|
|
6564
|
+
setGesture({
|
|
6565
|
+
type: 'window-drag',
|
|
6566
|
+
windowId,
|
|
6567
|
+
startX: event.clientX,
|
|
6568
|
+
startY: event.clientY,
|
|
6569
|
+
originX: Number(item.x) || 0,
|
|
6570
|
+
originY: Number(item.y) || 0,
|
|
6571
|
+
})
|
|
6572
|
+
}
|
|
6573
|
+
}
|
|
6574
|
+
return
|
|
6575
|
+
}
|
|
6576
|
+
const textElement = event.target?.closest?.('.tb-board-text')
|
|
6577
|
+
const textId = textElement?.getAttribute?.('data-text-id') || ''
|
|
6578
|
+
if (textId && toolRef.current === 'select') {
|
|
6579
|
+
event.preventDefault()
|
|
6580
|
+
setSelected(textId)
|
|
6581
|
+
const item = (canvasRef.current.texts ?? []).find((entry) => entry.id === textId)
|
|
6582
|
+
if (item) {
|
|
6583
|
+
setGesture({
|
|
6584
|
+
type: 'text-drag',
|
|
6585
|
+
textId,
|
|
6586
|
+
startX: event.clientX,
|
|
6587
|
+
startY: event.clientY,
|
|
6588
|
+
originX: Number(item.x) || 0,
|
|
6589
|
+
originY: Number(item.y) || 0,
|
|
6590
|
+
})
|
|
6591
|
+
}
|
|
6592
|
+
return
|
|
6593
|
+
}
|
|
6594
|
+
if (event.target?.closest?.('.tb-doc-body') && toolRef.current === 'select') return
|
|
5255
6595
|
const noteElement = event.target?.closest?.('.tb-sticky')
|
|
5256
6596
|
const noteId = noteElement?.getAttribute?.('data-note-id') || ''
|
|
5257
6597
|
if (toolRef.current === 'link') {
|
|
5258
6598
|
event.preventDefault()
|
|
5259
6599
|
if (!noteId) return
|
|
5260
6600
|
const localPoint = stagePoint(event)
|
|
5261
|
-
const layout =
|
|
6601
|
+
const layout = layoutForNote(noteId)
|
|
5262
6602
|
const anchorElement = event.target?.closest?.('.tb-anchor')
|
|
5263
6603
|
const anchor = anchorElement?.getAttribute?.('data-anchor') || nearestBoardAnchor(layout, localPoint)
|
|
5264
6604
|
setLinkPreview({ fromNoteId: noteId, fromAnchor: anchor, pointer: localPoint, targetNoteId: '', targetAnchor: '' })
|
|
@@ -5269,7 +6609,7 @@ window.__ModuleLoader__.load({
|
|
|
5269
6609
|
event.preventDefault()
|
|
5270
6610
|
event.stopPropagation()
|
|
5271
6611
|
setSelected(noteId)
|
|
5272
|
-
const layout =
|
|
6612
|
+
const layout = layoutForNote(noteId)
|
|
5273
6613
|
const size = noteSize(layout)
|
|
5274
6614
|
setGesture({
|
|
5275
6615
|
type: 'resize',
|
|
@@ -5297,7 +6637,7 @@ window.__ModuleLoader__.load({
|
|
|
5297
6637
|
}
|
|
5298
6638
|
event.preventDefault()
|
|
5299
6639
|
setSelected(noteId)
|
|
5300
|
-
const layout =
|
|
6640
|
+
const layout = layoutForNote(noteId)
|
|
5301
6641
|
setGesture({
|
|
5302
6642
|
type: 'drag',
|
|
5303
6643
|
noteId,
|
|
@@ -5309,10 +6649,13 @@ window.__ModuleLoader__.load({
|
|
|
5309
6649
|
return
|
|
5310
6650
|
}
|
|
5311
6651
|
if (noteId && !drawOnStickyRef.current) {
|
|
5312
|
-
//
|
|
5313
|
-
//
|
|
6652
|
+
// Keep the user's "draw on stickies" choice off; explain why the
|
|
6653
|
+
// stroke did not start with a small light toast instead.
|
|
5314
6654
|
event.preventDefault()
|
|
5315
6655
|
setSelected(noteId)
|
|
6656
|
+
const message = t('board.drawOnStickyNotice')
|
|
6657
|
+
setNotice(message)
|
|
6658
|
+
window.setTimeout(() => setNotice((current) => (current === message ? null : current)), 3600)
|
|
5316
6659
|
return
|
|
5317
6660
|
}
|
|
5318
6661
|
event.preventDefault()
|
|
@@ -5514,11 +6857,12 @@ window.__ModuleLoader__.load({
|
|
|
5514
6857
|
const layout = layoutFor(entry, index)
|
|
5515
6858
|
const size = noteSize(layout)
|
|
5516
6859
|
const agent = entry.source === 'agent'
|
|
6860
|
+
const isDoc = entry.kind === 'doc' || layout.kind === 'doc'
|
|
5517
6861
|
return h(
|
|
5518
6862
|
'article',
|
|
5519
6863
|
{
|
|
5520
6864
|
key: entry.id,
|
|
5521
|
-
className: `tb-sticky${agent ? ' link' : ''}${selected === entry.id ? ' selected' : ''}`,
|
|
6865
|
+
className: `tb-sticky${isDoc ? ' tb-doc' : ''}${agent && !isDoc ? ' link' : ''}${selected === entry.id ? ' selected' : ''}`,
|
|
5522
6866
|
'data-note-id': entry.id,
|
|
5523
6867
|
style: {
|
|
5524
6868
|
left: Number(layout.x) || 0,
|
|
@@ -5536,16 +6880,25 @@ window.__ModuleLoader__.load({
|
|
|
5536
6880
|
h(
|
|
5537
6881
|
'div',
|
|
5538
6882
|
{ 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 || '未命名便签'),
|
|
6883
|
+
h('span', { className: 'tb-sticky-src' }, isDoc ? '📄' : agent ? '🔗' : t('board.sourceUser')),
|
|
6884
|
+
h('span', { className: 'tb-sticky-title', title: entry.title }, entry.title || (isDoc ? '未命名文档' : '未命名便签')),
|
|
5541
6885
|
h(
|
|
5542
6886
|
'div',
|
|
5543
6887
|
{ className: 'tb-sticky-actions' },
|
|
6888
|
+
h('button', { type: 'button', title: t('board.openMd'), onClick: (event) => { event.stopPropagation(); openReader(entry.id) } }, '📖'),
|
|
5544
6889
|
h('button', { type: 'button', title: t('board.edit'), onClick: (event) => { event.stopPropagation(); startEdit(entry) } }, '✎'),
|
|
5545
6890
|
h('button', { type: 'button', title: t('board.delete'), disabled: busy !== '', onClick: (event) => { event.stopPropagation(); removeEntry(entry.id) } }, '✕'),
|
|
5546
6891
|
),
|
|
5547
6892
|
),
|
|
5548
|
-
|
|
6893
|
+
isDoc
|
|
6894
|
+
? h(
|
|
6895
|
+
'div',
|
|
6896
|
+
{ className: 'tb-doc-body' },
|
|
6897
|
+
...(entry.body.trim()
|
|
6898
|
+
? [h('div', { key: 'md', className: 'tb-md' }, ...renderMarkdown(entry.body, `doc-${entry.id}`))]
|
|
6899
|
+
: [h('span', { key: 'empty' }, t('board.empty'))]),
|
|
6900
|
+
)
|
|
6901
|
+
: agent
|
|
5549
6902
|
? h(
|
|
5550
6903
|
'div',
|
|
5551
6904
|
{ className: 'tb-sticky-body' },
|
|
@@ -5628,6 +6981,37 @@ window.__ModuleLoader__.load({
|
|
|
5628
6981
|
)
|
|
5629
6982
|
: null,
|
|
5630
6983
|
),
|
|
6984
|
+
h(
|
|
6985
|
+
'button',
|
|
6986
|
+
{ type: 'button', className: 'tb-tool', title: t('board.newText'), onClick: startAddText },
|
|
6987
|
+
`T ${t('board.addText')}`,
|
|
6988
|
+
),
|
|
6989
|
+
h(
|
|
6990
|
+
'div',
|
|
6991
|
+
{ className: 'tb-window-insert' },
|
|
6992
|
+
h(
|
|
6993
|
+
'button',
|
|
6994
|
+
{
|
|
6995
|
+
type: 'button',
|
|
6996
|
+
className: `tb-tool${insertMenu ? ' on' : ''}`,
|
|
6997
|
+
title: t('board.insertHint'),
|
|
6998
|
+
onClick: () => {
|
|
6999
|
+
setClearMenu(false)
|
|
7000
|
+
setInsertMenu((value) => !value)
|
|
7001
|
+
},
|
|
7002
|
+
},
|
|
7003
|
+
`+ ${t('board.insert')}`,
|
|
7004
|
+
),
|
|
7005
|
+
insertMenu
|
|
7006
|
+
? h(
|
|
7007
|
+
'div',
|
|
7008
|
+
{ className: 'tb-shape-menu tb-insert-menu', role: 'menu' },
|
|
7009
|
+
h('button', { type: 'button', role: 'menuitem', onClick: () => startAddTable(3, 3) }, `▦ ${t('board.table')}`),
|
|
7010
|
+
h('button', { type: 'button', role: 'menuitem', onClick: startImportTable }, `⇥ ${t('board.importTable')}`),
|
|
7011
|
+
h('button', { type: 'button', role: 'menuitem', onClick: startImportImage }, `🖼 ${t('board.importImage')}`),
|
|
7012
|
+
)
|
|
7013
|
+
: null,
|
|
7014
|
+
),
|
|
5631
7015
|
h('span', { className: 'tb-board-meta' }, t('board.brushSize')),
|
|
5632
7016
|
h('input', {
|
|
5633
7017
|
type: 'range',
|
|
@@ -5774,9 +7158,59 @@ window.__ModuleLoader__.load({
|
|
|
5774
7158
|
),
|
|
5775
7159
|
h('span', { style: { flex: 1 } }),
|
|
5776
7160
|
h('button', { type: 'button', className: 'tb-btn', onClick: autoFit }, t('board.center')),
|
|
5777
|
-
h(
|
|
5778
|
-
|
|
5779
|
-
|
|
7161
|
+
h(
|
|
7162
|
+
'div',
|
|
7163
|
+
{ className: 'tb-window-insert' },
|
|
7164
|
+
h(
|
|
7165
|
+
'button',
|
|
7166
|
+
{
|
|
7167
|
+
type: 'button',
|
|
7168
|
+
className: `tb-btn${clearMenu ? ' on' : ''}`,
|
|
7169
|
+
title: t('board.clearHint'),
|
|
7170
|
+
onClick: () => {
|
|
7171
|
+
setInsertMenu(false)
|
|
7172
|
+
setClearMenu((value) => !value)
|
|
7173
|
+
},
|
|
7174
|
+
},
|
|
7175
|
+
`🧹 ${t('board.clear')}`,
|
|
7176
|
+
),
|
|
7177
|
+
clearMenu
|
|
7178
|
+
? h(
|
|
7179
|
+
'div',
|
|
7180
|
+
{ className: 'tb-shape-menu tb-clear-menu', role: 'menu' },
|
|
7181
|
+
h(
|
|
7182
|
+
'button',
|
|
7183
|
+
{ type: 'button', role: 'menuitem', disabled: canvas.background.length === 0, onClick: () => { setClearMenu(false); clearBackground() } },
|
|
7184
|
+
t('board.clearBg'),
|
|
7185
|
+
),
|
|
7186
|
+
h(
|
|
7187
|
+
'button',
|
|
7188
|
+
{
|
|
7189
|
+
type: 'button',
|
|
7190
|
+
role: 'menuitem',
|
|
7191
|
+
disabled: (canvas.edges ?? []).length === 0,
|
|
7192
|
+
onClick: () => {
|
|
7193
|
+
setClearMenu(false)
|
|
7194
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
7195
|
+
next.edges = []
|
|
7196
|
+
saveCanvasSoon(next)
|
|
7197
|
+
},
|
|
7198
|
+
},
|
|
7199
|
+
t('board.clearEdges'),
|
|
7200
|
+
),
|
|
7201
|
+
h(
|
|
7202
|
+
'button',
|
|
7203
|
+
{
|
|
7204
|
+
type: 'button',
|
|
7205
|
+
role: 'menuitem',
|
|
7206
|
+
disabled: !selected || !(canvas.drawings[selected]?.length > 0),
|
|
7207
|
+
onClick: () => { setClearMenu(false); clearSelectedDrawing() },
|
|
7208
|
+
},
|
|
7209
|
+
t('board.clearNote'),
|
|
7210
|
+
),
|
|
7211
|
+
)
|
|
7212
|
+
: null,
|
|
7213
|
+
),
|
|
5780
7214
|
)
|
|
5781
7215
|
|
|
5782
7216
|
return h(
|
|
@@ -5789,14 +7223,15 @@ window.__ModuleLoader__.load({
|
|
|
5789
7223
|
h('span', { className: 'tb-board-sub' }, t('board.subtitle')),
|
|
5790
7224
|
h('span', { style: { flex: 1 } }),
|
|
5791
7225
|
h('span', { className: 'tb-muted tb-small' }, format(t('board.count'), { count: entries.length, version: boardVersion })),
|
|
5792
|
-
h('span', { className: 'tb-muted tb-small' }, format(t('board.canvasVersion'), { version: boardVersion })),
|
|
5793
7226
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomOut'), onClick: () => zoomBy(1 / 1.2) }, '−'),
|
|
5794
7227
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomReset'), onClick: () => zoomBy(1 / zoomRef.current) }, `${Math.round(zoom * 100)}%`),
|
|
5795
7228
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomIn'), onClick: () => zoomBy(1.2) }, '+'),
|
|
5796
7229
|
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')}`),
|
|
7230
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: () => startCreate('sticky') }, `+ ${t('board.newSticky')}`),
|
|
7231
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => startCreate('doc') }, `+ ${t('board.newDoc')}`),
|
|
5798
7232
|
),
|
|
5799
7233
|
toolbar,
|
|
7234
|
+
notice ? h('div', { className: 'tb-board-toast', role: 'status' }, notice) : null,
|
|
5800
7235
|
h('div', { className: 'tb-board-hint-wrap' }, h('span', { className: 'tb-ws-hint' }, `${t('board.stickyHint')} · ${t('board.panHint')}`)),
|
|
5801
7236
|
state.error ? h('div', { className: 'tb-feedback err' }, format(t('board.error'), { error: state.error })) : null,
|
|
5802
7237
|
h(
|
|
@@ -5815,10 +7250,160 @@ window.__ModuleLoader__.load({
|
|
|
5815
7250
|
drawingLayer(canvas.background, 'bg'),
|
|
5816
7251
|
edgeLayer(),
|
|
5817
7252
|
...entries.map((entry, index) => stickyFor(entry, index)),
|
|
7253
|
+
...(canvas.texts ?? []).map((item) =>
|
|
7254
|
+
h(
|
|
7255
|
+
'div',
|
|
7256
|
+
{
|
|
7257
|
+
key: item.id,
|
|
7258
|
+
className: `tb-board-text${selected === item.id ? ' selected' : ''}`,
|
|
7259
|
+
'data-text-id': item.id,
|
|
7260
|
+
style: {
|
|
7261
|
+
left: Number(item.x) || 0,
|
|
7262
|
+
top: Number(item.y) || 0,
|
|
7263
|
+
width: Math.min(1200, Math.max(80, Number(item.width) || 320)),
|
|
7264
|
+
color: item.color || '#e6e6e6',
|
|
7265
|
+
fontSize: Math.min(96, Math.max(8, Number(item.fontSize) || 18)),
|
|
7266
|
+
zIndex: 260,
|
|
7267
|
+
},
|
|
7268
|
+
onDoubleClick: (event) => {
|
|
7269
|
+
event.stopPropagation()
|
|
7270
|
+
startEditText(item)
|
|
7271
|
+
},
|
|
7272
|
+
},
|
|
7273
|
+
h('div', { className: 'tb-board-text-content' }, item.text || ''),
|
|
7274
|
+
h(
|
|
7275
|
+
'div',
|
|
7276
|
+
{ className: 'tb-board-text-actions' },
|
|
7277
|
+
h(
|
|
7278
|
+
'button',
|
|
7279
|
+
{
|
|
7280
|
+
type: 'button',
|
|
7281
|
+
title: t('board.editText'),
|
|
7282
|
+
onClick: (event) => {
|
|
7283
|
+
event.stopPropagation()
|
|
7284
|
+
startEditText(item)
|
|
7285
|
+
},
|
|
7286
|
+
},
|
|
7287
|
+
'✎',
|
|
7288
|
+
),
|
|
7289
|
+
h(
|
|
7290
|
+
'button',
|
|
7291
|
+
{
|
|
7292
|
+
type: 'button',
|
|
7293
|
+
title: t('board.deleteText'),
|
|
7294
|
+
onClick: (event) => {
|
|
7295
|
+
event.stopPropagation()
|
|
7296
|
+
deleteText(item.id)
|
|
7297
|
+
},
|
|
7298
|
+
},
|
|
7299
|
+
'✕',
|
|
7300
|
+
),
|
|
7301
|
+
),
|
|
7302
|
+
),
|
|
7303
|
+
),
|
|
7304
|
+
...(canvas.windows ?? []).map((item) =>
|
|
7305
|
+
h(
|
|
7306
|
+
'div',
|
|
7307
|
+
{
|
|
7308
|
+
key: item.id,
|
|
7309
|
+
className: `tb-board-window${selected === item.id ? ' selected' : ''}`,
|
|
7310
|
+
'data-window-id': item.id,
|
|
7311
|
+
style: {
|
|
7312
|
+
left: Number(item.x) || 0,
|
|
7313
|
+
top: Number(item.y) || 0,
|
|
7314
|
+
width: Math.min(1600, Math.max(160, Number(item.width) || 480)),
|
|
7315
|
+
height: Math.min(1200, Math.max(120, Number(item.height) || 260)),
|
|
7316
|
+
zIndex: 280,
|
|
7317
|
+
},
|
|
7318
|
+
onDoubleClick: (event) => {
|
|
7319
|
+
if (event.target?.closest?.('.tb-board-window-body')) return
|
|
7320
|
+
event.stopPropagation()
|
|
7321
|
+
startEditWindow(item)
|
|
7322
|
+
},
|
|
7323
|
+
},
|
|
7324
|
+
h(
|
|
7325
|
+
'div',
|
|
7326
|
+
{ className: 'tb-board-window-head' },
|
|
7327
|
+
h('span', { className: 'tb-board-window-title', title: item.title }, item.title || (item.kind === 'table' ? t('board.table') : t('board.importImage'))),
|
|
7328
|
+
h(
|
|
7329
|
+
'div',
|
|
7330
|
+
{ className: 'tb-board-window-actions' },
|
|
7331
|
+
h(
|
|
7332
|
+
'button',
|
|
7333
|
+
{
|
|
7334
|
+
type: 'button',
|
|
7335
|
+
title: t('board.edit'),
|
|
7336
|
+
onClick: (event) => {
|
|
7337
|
+
event.stopPropagation()
|
|
7338
|
+
startEditWindow(item)
|
|
7339
|
+
},
|
|
7340
|
+
},
|
|
7341
|
+
'✎',
|
|
7342
|
+
),
|
|
7343
|
+
h(
|
|
7344
|
+
'button',
|
|
7345
|
+
{
|
|
7346
|
+
type: 'button',
|
|
7347
|
+
title: t('board.delete'),
|
|
7348
|
+
onClick: (event) => {
|
|
7349
|
+
event.stopPropagation()
|
|
7350
|
+
deleteWindow(item.id)
|
|
7351
|
+
},
|
|
7352
|
+
},
|
|
7353
|
+
'✕',
|
|
7354
|
+
),
|
|
7355
|
+
),
|
|
7356
|
+
),
|
|
7357
|
+
h(
|
|
7358
|
+
'div',
|
|
7359
|
+
{ className: 'tb-board-window-body' },
|
|
7360
|
+
item.kind === 'table'
|
|
7361
|
+
? h(
|
|
7362
|
+
'table',
|
|
7363
|
+
null,
|
|
7364
|
+
...(item.rows ?? [['']]).map((row, rowIndex) =>
|
|
7365
|
+
h(
|
|
7366
|
+
'tr',
|
|
7367
|
+
{ key: `row-${rowIndex}` },
|
|
7368
|
+
...(row ?? []).map((cell, cellIndex) =>
|
|
7369
|
+
h(
|
|
7370
|
+
'td',
|
|
7371
|
+
{
|
|
7372
|
+
key: `cell-${rowIndex}-${cellIndex}`,
|
|
7373
|
+
contentEditable: true,
|
|
7374
|
+
suppressContentEditableWarning: true,
|
|
7375
|
+
onBlur: (event) => {
|
|
7376
|
+
const text = String(event.currentTarget?.textContent ?? '').replace(/\u00a0/g, '')
|
|
7377
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
7378
|
+
const target = (next.windows ?? []).find((entry) => entry.id === item.id)
|
|
7379
|
+
if (!target || !Array.isArray(target.rows)) return
|
|
7380
|
+
target.rows[rowIndex] = [...(target.rows[rowIndex] ?? [])]
|
|
7381
|
+
target.rows[rowIndex][cellIndex] = text
|
|
7382
|
+
next.windows = (next.windows ?? []).map((entry) => (entry.id === item.id ? target : entry))
|
|
7383
|
+
saveCanvasSoon(next)
|
|
7384
|
+
},
|
|
7385
|
+
},
|
|
7386
|
+
String(cell ?? '') === '' ? '\u00a0' : String(cell),
|
|
7387
|
+
),
|
|
7388
|
+
),
|
|
7389
|
+
),
|
|
7390
|
+
),
|
|
7391
|
+
)
|
|
7392
|
+
: h('img', { src: item.src, alt: item.alt || item.title || '', draggable: false }),
|
|
7393
|
+
),
|
|
7394
|
+
h('div', { className: 'tb-board-window-resize', title: t('board.resizeNote') }),
|
|
7395
|
+
),
|
|
7396
|
+
),
|
|
5818
7397
|
),
|
|
5819
7398
|
),
|
|
5820
7399
|
state.loading && !state.board ? h('p', { className: 'tb-board-md-empty' }, t('panel.loading')) : null,
|
|
5821
|
-
!state.loading &&
|
|
7400
|
+
!state.loading &&
|
|
7401
|
+
entries.length === 0 &&
|
|
7402
|
+
(canvas.texts ?? []).length === 0 &&
|
|
7403
|
+
(canvas.windows ?? []).length === 0 &&
|
|
7404
|
+
(canvas.background ?? []).length === 0
|
|
7405
|
+
? h('p', { className: 'tb-board-md-empty' }, t('board.empty'))
|
|
7406
|
+
: null,
|
|
5822
7407
|
),
|
|
5823
7408
|
h(
|
|
5824
7409
|
'div',
|
|
@@ -5897,7 +7482,7 @@ window.__ModuleLoader__.load({
|
|
|
5897
7482
|
h(
|
|
5898
7483
|
'div',
|
|
5899
7484
|
{ className: 'tb-detail-head' },
|
|
5900
|
-
h('span', { className: 'tb-detail-title' }, draft.id ? t('board.edit') : t('board.newSticky')),
|
|
7485
|
+
h('span', { className: 'tb-detail-title' }, draft.id ? t('board.edit') : draft.kind === 'doc' ? t('board.newDoc') : t('board.newSticky')),
|
|
5901
7486
|
h('span', { style: { flex: 1 } }),
|
|
5902
7487
|
h('button', { type: 'button', className: 'tb-btn', title: t('board.resizeHint'), onClick: resetDialogSize }, t('board.resetSize')),
|
|
5903
7488
|
),
|
|
@@ -5946,7 +7531,7 @@ window.__ModuleLoader__.load({
|
|
|
5946
7531
|
disabled: draft.busy,
|
|
5947
7532
|
placeholder: t('board.bodyPlaceholder'),
|
|
5948
7533
|
}),
|
|
5949
|
-
h('div', { className: 'tb-ws-hint' }, `${t('board.resizeHint')} · ${t('board.autosaveHint')}`),
|
|
7534
|
+
h('div', { className: 'tb-ws-hint' }, `${t('board.resizeHint')} · ${t('board.autosaveHint')}${draft.kind === 'doc' ? ` · ${t('board.docHint')}` : ''}`),
|
|
5950
7535
|
draft.error ? h('div', { className: 'tb-feedback err' }, format(t('board.error'), { error: draft.error })) : null,
|
|
5951
7536
|
h(
|
|
5952
7537
|
'div',
|
|
@@ -5960,14 +7545,275 @@ window.__ModuleLoader__.load({
|
|
|
5960
7545
|
),
|
|
5961
7546
|
)
|
|
5962
7547
|
: null,
|
|
7548
|
+
textEditor
|
|
7549
|
+
? h(
|
|
7550
|
+
'div',
|
|
7551
|
+
{ className: 'tb-overlay center', onClick: dismissTextSaving },
|
|
7552
|
+
h(
|
|
7553
|
+
'div',
|
|
7554
|
+
{
|
|
7555
|
+
className: 'tb-board-dialog tb-text-dialog',
|
|
7556
|
+
role: 'dialog',
|
|
7557
|
+
'aria-modal': true,
|
|
7558
|
+
onClick: (event) => event.stopPropagation(),
|
|
7559
|
+
},
|
|
7560
|
+
h(
|
|
7561
|
+
'div',
|
|
7562
|
+
{ className: 'tb-detail-head' },
|
|
7563
|
+
h('span', { className: 'tb-detail-title' }, textEditor.id ? t('board.editText') : t('board.newText')),
|
|
7564
|
+
h('span', { style: { flex: 1 } }),
|
|
7565
|
+
textEditor.id
|
|
7566
|
+
? h(
|
|
7567
|
+
'button',
|
|
7568
|
+
{
|
|
7569
|
+
type: 'button',
|
|
7570
|
+
className: 'tb-btn danger',
|
|
7571
|
+
onClick: () => deleteText(textEditor.id),
|
|
7572
|
+
},
|
|
7573
|
+
t('board.deleteText'),
|
|
7574
|
+
)
|
|
7575
|
+
: null,
|
|
7576
|
+
),
|
|
7577
|
+
h('textarea', {
|
|
7578
|
+
className: 'tb-text-input',
|
|
7579
|
+
value: textEditor.text ?? '',
|
|
7580
|
+
placeholder: t('board.textPlaceholder'),
|
|
7581
|
+
autoFocus: true,
|
|
7582
|
+
onChange: (event) => setTextEditor((current) => (current ? { ...current, text: event.target.value } : current)),
|
|
7583
|
+
}),
|
|
7584
|
+
h(
|
|
7585
|
+
'div',
|
|
7586
|
+
{ className: 'tb-text-row' },
|
|
7587
|
+
h('span', { className: 'tb-color-label' }, t('board.fontColor')),
|
|
7588
|
+
...['#e6e6e6', '#2a2418', '#ffffff', '#ff5f56', '#f0b23e', '#3ecf8e', '#38bdf8', '#c084fc', '#f472b6', '#1c4d8f'].map((value) =>
|
|
7589
|
+
h('button', {
|
|
7590
|
+
key: `text-${value}`,
|
|
7591
|
+
type: 'button',
|
|
7592
|
+
className: `tb-text-swatch${String(textEditor.color || '').toLowerCase() === value ? ' on' : ''}`,
|
|
7593
|
+
style: { background: value },
|
|
7594
|
+
title: value,
|
|
7595
|
+
'aria-label': value,
|
|
7596
|
+
onClick: () => setTextEditor((current) => (current ? { ...current, color: value } : current)),
|
|
7597
|
+
}),
|
|
7598
|
+
),
|
|
7599
|
+
h('input', {
|
|
7600
|
+
type: 'color',
|
|
7601
|
+
value: textEditor.color || '#e6e6e6',
|
|
7602
|
+
title: t('md.customColor'),
|
|
7603
|
+
style: { width: 30, height: 24, padding: 0, border: 0, background: 'transparent' },
|
|
7604
|
+
onChange: (event) => setTextEditor((current) => (current ? { ...current, color: event.target.value } : current)),
|
|
7605
|
+
}),
|
|
7606
|
+
),
|
|
7607
|
+
h(
|
|
7608
|
+
'div',
|
|
7609
|
+
{ className: 'tb-text-row' },
|
|
7610
|
+
h('span', { className: 'tb-color-label' }, t('board.fontSize')),
|
|
7611
|
+
h('input', {
|
|
7612
|
+
type: 'range',
|
|
7613
|
+
min: 8,
|
|
7614
|
+
max: 72,
|
|
7615
|
+
step: 1,
|
|
7616
|
+
value: Number(textEditor.fontSize) || 18,
|
|
7617
|
+
style: { width: 220 },
|
|
7618
|
+
onChange: (event) => setTextEditor((current) => (current ? { ...current, fontSize: Number(event.target.value) || 18 } : current)),
|
|
7619
|
+
}),
|
|
7620
|
+
h('span', { className: 'tb-board-meta' }, `${Number(textEditor.fontSize) || 18}px`),
|
|
7621
|
+
),
|
|
7622
|
+
h(
|
|
7623
|
+
'div',
|
|
7624
|
+
{
|
|
7625
|
+
className: 'tb-text-preview',
|
|
7626
|
+
style: { color: textEditor.color || '#e6e6e6', fontSize: Number(textEditor.fontSize) || 18 },
|
|
7627
|
+
},
|
|
7628
|
+
textEditor.text || t('board.textPlaceholder'),
|
|
7629
|
+
),
|
|
7630
|
+
textEditor.error ? h('div', { className: 'tb-feedback err' }, textEditor.error) : null,
|
|
7631
|
+
h(
|
|
7632
|
+
'div',
|
|
7633
|
+
{ className: 'tb-note-actions' },
|
|
7634
|
+
h('button', { type: 'button', className: 'tb-btn', disabled: textEditor.busy === true, onClick: () => setTextEditor(null) }, t('board.cancel')),
|
|
7635
|
+
h('button', { type: 'button', className: 'tb-btn primary', disabled: textEditor.busy === true, onClick: saveText }, t('board.save')),
|
|
7636
|
+
),
|
|
7637
|
+
),
|
|
7638
|
+
)
|
|
7639
|
+
: null,
|
|
7640
|
+
windowEditor
|
|
7641
|
+
? h(
|
|
7642
|
+
'div',
|
|
7643
|
+
{ className: 'tb-overlay center', onClick: dismissWindowSaving },
|
|
7644
|
+
h(
|
|
7645
|
+
'div',
|
|
7646
|
+
{
|
|
7647
|
+
className: 'tb-board-dialog tb-window-editor-dialog',
|
|
7648
|
+
role: 'dialog',
|
|
7649
|
+
'aria-modal': true,
|
|
7650
|
+
onClick: (event) => event.stopPropagation(),
|
|
7651
|
+
},
|
|
7652
|
+
h(
|
|
7653
|
+
'div',
|
|
7654
|
+
{ className: 'tb-detail-head' },
|
|
7655
|
+
h(
|
|
7656
|
+
'span',
|
|
7657
|
+
{ className: 'tb-detail-title' },
|
|
7658
|
+
`${windowEditor.kind === 'table' ? '▦' : '🖼'} ${
|
|
7659
|
+
windowEditor.id ? t('board.edit') : windowEditor.kind === 'table' ? t('board.table') : t('board.importImage')
|
|
7660
|
+
}`,
|
|
7661
|
+
),
|
|
7662
|
+
h('span', { style: { flex: 1 } }),
|
|
7663
|
+
windowEditor.id
|
|
7664
|
+
? h(
|
|
7665
|
+
'button',
|
|
7666
|
+
{ type: 'button', className: 'tb-btn danger', onClick: () => deleteWindow(windowEditor.id) },
|
|
7667
|
+
t('board.delete'),
|
|
7668
|
+
)
|
|
7669
|
+
: null,
|
|
7670
|
+
),
|
|
7671
|
+
h('input', {
|
|
7672
|
+
value: windowEditor.title ?? '',
|
|
7673
|
+
placeholder: t('board.windowTitle'),
|
|
7674
|
+
onChange: (event) => setWindowEditor((current) => (current ? { ...current, title: event.target.value } : current)),
|
|
7675
|
+
}),
|
|
7676
|
+
windowEditor.kind === 'table'
|
|
7677
|
+
? h(
|
|
7678
|
+
'div',
|
|
7679
|
+
{ className: 'tb-window-editor-body' },
|
|
7680
|
+
h(
|
|
7681
|
+
'div',
|
|
7682
|
+
{ className: 'tb-text-row' },
|
|
7683
|
+
h('button', {
|
|
7684
|
+
type: 'button',
|
|
7685
|
+
className: 'tb-btn',
|
|
7686
|
+
onClick: () =>
|
|
7687
|
+
setWindowEditor((current) => {
|
|
7688
|
+
if (!current) return current
|
|
7689
|
+
const rows = (current.rows ?? [[]]).map((row) => [...row])
|
|
7690
|
+
const cols = Math.max(1, ...rows.map((row) => row.length))
|
|
7691
|
+
rows.push(Array.from({ length: cols }, () => ''))
|
|
7692
|
+
return { ...current, rows }
|
|
7693
|
+
}),
|
|
7694
|
+
}, `+ ${t('board.addRow')}`),
|
|
7695
|
+
h('button', {
|
|
7696
|
+
type: 'button',
|
|
7697
|
+
className: 'tb-btn',
|
|
7698
|
+
onClick: () =>
|
|
7699
|
+
setWindowEditor((current) => {
|
|
7700
|
+
if (!current) return current
|
|
7701
|
+
const rows = (current.rows ?? [[]]).map((row) => [...row, ''])
|
|
7702
|
+
return { ...current, rows }
|
|
7703
|
+
}),
|
|
7704
|
+
}, `+ ${t('board.addCol')}`),
|
|
7705
|
+
h('button', {
|
|
7706
|
+
type: 'button',
|
|
7707
|
+
className: 'tb-btn',
|
|
7708
|
+
onClick: () => {
|
|
7709
|
+
const applyRows = (text, name) => {
|
|
7710
|
+
const rows = parseTableText(text)
|
|
7711
|
+
setWindowEditor((current) =>
|
|
7712
|
+
current
|
|
7713
|
+
? {
|
|
7714
|
+
...current,
|
|
7715
|
+
rows,
|
|
7716
|
+
...(name ? { title: name.replace(/\.[^.]+$/, '') || current.title } : {}),
|
|
7717
|
+
width: Math.min(900, Math.max(420, (rows[0]?.length ?? 3) * 120)),
|
|
7718
|
+
height: Math.min(700, Math.max(220, rows.length * 34 + 44)),
|
|
7719
|
+
}
|
|
7720
|
+
: current,
|
|
7721
|
+
)
|
|
7722
|
+
}
|
|
7723
|
+
pickFile('.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/plain,text/markdown', (file) => {
|
|
7724
|
+
if (file.size > 2_000_000) {
|
|
7725
|
+
setWindowEditor((current) => (current ? { ...current, error: t('board.tableTooLarge') } : current))
|
|
7726
|
+
return
|
|
7727
|
+
}
|
|
7728
|
+
const reader = new FileReader()
|
|
7729
|
+
reader.onload = () => applyRows(String(reader.result ?? ''), file.name)
|
|
7730
|
+
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: t('board.tableReadFailed') } : current))
|
|
7731
|
+
reader.readAsText(file)
|
|
7732
|
+
})
|
|
7733
|
+
},
|
|
7734
|
+
}, `⇥ ${t('board.fromFile')}`),
|
|
7735
|
+
),
|
|
7736
|
+
h('textarea', {
|
|
7737
|
+
className: 'tb-text-input',
|
|
7738
|
+
value: tableRowsToText(windowEditor.rows),
|
|
7739
|
+
placeholder: t('board.tableHint'),
|
|
7740
|
+
onChange: (event) => {
|
|
7741
|
+
const rows = parseTableText(event.target.value)
|
|
7742
|
+
setWindowEditor((current) => (current ? { ...current, rows } : current))
|
|
7743
|
+
},
|
|
7744
|
+
}),
|
|
7745
|
+
h(
|
|
7746
|
+
'div',
|
|
7747
|
+
{ className: 'tb-table-editor-preview' },
|
|
7748
|
+
h(
|
|
7749
|
+
'table',
|
|
7750
|
+
null,
|
|
7751
|
+
...(windowEditor.rows ?? [['']]).slice(0, 10).map((row, rowIndex) =>
|
|
7752
|
+
h(
|
|
7753
|
+
'tr',
|
|
7754
|
+
{ key: `preview-row-${rowIndex}` },
|
|
7755
|
+
...(row ?? []).slice(0, 8).map((cell, cellIndex) =>
|
|
7756
|
+
h('td', { key: `preview-cell-${rowIndex}-${cellIndex}` }, String(cell ?? '') === '' ? '\u00a0' : String(cell)),
|
|
7757
|
+
),
|
|
7758
|
+
),
|
|
7759
|
+
),
|
|
7760
|
+
),
|
|
7761
|
+
),
|
|
7762
|
+
)
|
|
7763
|
+
: h(
|
|
7764
|
+
'div',
|
|
7765
|
+
{ className: 'tb-window-editor-body' },
|
|
7766
|
+
h('div', { className: 'tb-table-editor-preview' }, h('img', { src: windowEditor.src, alt: windowEditor.alt || '' })),
|
|
7767
|
+
h(
|
|
7768
|
+
'div',
|
|
7769
|
+
{ className: 'tb-text-row' },
|
|
7770
|
+
h('button', {
|
|
7771
|
+
type: 'button',
|
|
7772
|
+
className: 'tb-btn',
|
|
7773
|
+
onClick: () => {
|
|
7774
|
+
pickFile('image/*', (file) => {
|
|
7775
|
+
const imageType = /^image\//i.test(file.type) || /\.(png|jpe?g|gif|webp|bmp|svg|avif)$/i.test(file.name)
|
|
7776
|
+
if (!imageType || file.size > 1_500_000) {
|
|
7777
|
+
setWindowEditor((current) =>
|
|
7778
|
+
current ? { ...current, error: imageType ? t('board.imageTooLarge') : t('board.imageType') } : current,
|
|
7779
|
+
)
|
|
7780
|
+
return
|
|
7781
|
+
}
|
|
7782
|
+
const reader = new FileReader()
|
|
7783
|
+
reader.onload = () =>
|
|
7784
|
+
setWindowEditor((current) =>
|
|
7785
|
+
current ? { ...current, src: String(reader.result ?? ''), alt: file.name } : current,
|
|
7786
|
+
)
|
|
7787
|
+
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: t('board.imageReadFailed') } : current))
|
|
7788
|
+
reader.readAsDataURL(file)
|
|
7789
|
+
})
|
|
7790
|
+
},
|
|
7791
|
+
}, `🖼 ${t('board.chooseImage')}`),
|
|
7792
|
+
),
|
|
7793
|
+
h('div', { className: 'tb-ws-hint' }, t('board.imageHint')),
|
|
7794
|
+
),
|
|
7795
|
+
h('div', { className: 'tb-ws-hint' }, windowEditor.kind === 'table' ? t('board.tableHint') : t('board.imageHint')),
|
|
7796
|
+
windowEditor.error ? h('div', { className: 'tb-feedback err' }, windowEditor.error) : null,
|
|
7797
|
+
h(
|
|
7798
|
+
'div',
|
|
7799
|
+
{ className: 'tb-note-actions' },
|
|
7800
|
+
h('button', { type: 'button', className: 'tb-btn', disabled: windowEditor.busy === true, onClick: () => setWindowEditor(null) }, t('board.cancel')),
|
|
7801
|
+
h('button', { type: 'button', className: 'tb-btn primary', disabled: windowEditor.busy === true, onClick: saveWindow }, t('board.save')),
|
|
7802
|
+
),
|
|
7803
|
+
),
|
|
7804
|
+
)
|
|
7805
|
+
: null,
|
|
5963
7806
|
)
|
|
5964
7807
|
}
|
|
5965
7808
|
|
|
5966
7809
|
if (typeof window !== 'undefined' && window.__TIMEBACK_TEST__) {
|
|
7810
|
+
window.__TIMEBACK_TEST__.parseTableText = parseTableText
|
|
7811
|
+
window.__TIMEBACK_TEST__.tableRowsToText = tableRowsToText
|
|
5967
7812
|
window.__TIMEBACK_TEST__.edgePanVector = edgePanVector
|
|
5968
7813
|
window.__TIMEBACK_TEST__.renderMarkdown = renderMarkdown
|
|
5969
7814
|
window.__TIMEBACK_TEST__.stripMarkdown = stripMarkdown
|
|
5970
7815
|
window.__TIMEBACK_TEST__.boardEdgePath = boardEdgePath
|
|
7816
|
+
window.__TIMEBACK_TEST__.smoothStrokePath = smoothStrokePath
|
|
5971
7817
|
window.__TIMEBACK_TEST__.MarkdownEditor = MarkdownEditor
|
|
5972
7818
|
window.__TIMEBACK_TEST__.WorkspacePathSelector = WorkspacePathSelector
|
|
5973
7819
|
window.__TIMEBACK_TEST__.markdownToEditorHtml = markdownToEditorHtml
|
|
@@ -5976,15 +7822,19 @@ window.__ModuleLoader__.load({
|
|
|
5976
7822
|
window.__TIMEBACK_TEST__.mergeCardFolder = mergeCardFolder
|
|
5977
7823
|
window.__TIMEBACK_TEST__.stableSessionColor = stableSessionColor
|
|
5978
7824
|
window.__TIMEBACK_TEST__.removeFolderMember = removeFolderMember
|
|
7825
|
+
window.__TIMEBACK_TEST__.renameCardFolder = renameCardFolder
|
|
5979
7826
|
window.__TIMEBACK_TEST__.layoutTree = layoutTree
|
|
7827
|
+
window.__TIMEBACK_TEST__.turnConversation = turnConversation
|
|
7828
|
+
window.__TIMEBACK_TEST__.messageTextOf = messageTextOf
|
|
5980
7829
|
window.__TIMEBACK_TEST__.CanvasFolderCard = CanvasFolderCard
|
|
5981
7830
|
window.__TIMEBACK_TEST__.TreeCanvas = TreeCanvas
|
|
5982
7831
|
}
|
|
5983
7832
|
|
|
5984
7833
|
return {
|
|
5985
|
-
inject: ['slots', 'locale', 'sidebarRight', 'sidebarRightTabs', 'uiWorkspace', 'uiSession', 'contextMenus'],
|
|
7834
|
+
inject: ['slots', 'locale', 'sidebarRight', 'sidebarRightTabs', 'uiWorkspace', 'uiSession', 'sessions', 'contextMenus'],
|
|
5986
7835
|
apply(ctx) {
|
|
5987
7836
|
const t = ctx.locale.bind(NS)
|
|
7837
|
+
sessionApi = ctx.sessions ?? null
|
|
5988
7838
|
console.log(`[timeback] client ${BUILD} loaded`)
|
|
5989
7839
|
openSessionBridge = (sessionId) => {
|
|
5990
7840
|
try {
|