dsh-timeback 0.7.8 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/client.js +459 -112
- package/docs/MARKET.md +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ desktop app):
|
|
|
113
113
|
```bash
|
|
114
114
|
# From npm (published: https://www.npmjs.com/package/dsh-timeback)
|
|
115
115
|
dsh plugin --profile web add dsh-timeback
|
|
116
|
-
dsh plugin --profile web add dsh-timeback@0.7.
|
|
116
|
+
dsh plugin --profile web add dsh-timeback@0.7.10 # pin a release
|
|
117
117
|
|
|
118
118
|
# Straight from GitHub (no npm release needed)
|
|
119
119
|
dsh plugin --profile web add github:<owner>/dsh-timeback
|
package/client.js
CHANGED
|
@@ -23,7 +23,7 @@ window.__ModuleLoader__.load({
|
|
|
23
23
|
const REFRESH_MS = 3000
|
|
24
24
|
const MAX_ROWS = 240
|
|
25
25
|
/** Bump together with package.json so a stale browser bundle is obvious. */
|
|
26
|
-
const BUILD = '0.7.
|
|
26
|
+
const BUILD = '0.7.10+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. */
|
|
@@ -62,6 +62,12 @@ window.__ModuleLoader__.load({
|
|
|
62
62
|
'panel.confirmRewind': '将创建新分支并恢复工作区到:{who}\n\n{warning}\n\n确定继续?',
|
|
63
63
|
'panel.confirmFiles': '将把工作区文件恢复为:{who}\n\n{warning}\n\n确定继续?',
|
|
64
64
|
'panel.branchNamePrompt': '输入新分支会话的名称:',
|
|
65
|
+
'panel.branchNameTitle': '新分支名称',
|
|
66
|
+
'panel.confirm': '确定',
|
|
67
|
+
'panel.cancel': '取消',
|
|
68
|
+
'panel.close': '关闭',
|
|
69
|
+
'panel.branchNameHint': '输入新分支会话的名称;留空则使用默认名称。',
|
|
70
|
+
'panel.createBranch': '创建分支',
|
|
65
71
|
'panel.confirmBranchOnly': '将在该检查点创建新分支,不修改工作区文件:{who}\n\n确定继续?',
|
|
66
72
|
'panel.confirmCheckpoint': '将记录当前对话位置与工作区快照。确定继续?',
|
|
67
73
|
'panel.deleteWarning': '快照之后新增的文件会被删除,之后修改的文件会被覆盖。回退前会自动保存安全快照,可用它撤销本次恢复。',
|
|
@@ -130,7 +136,9 @@ window.__ModuleLoader__.load({
|
|
|
130
136
|
'board.fontSize': '字号',
|
|
131
137
|
'board.deleteText': '删除文本',
|
|
132
138
|
'board.insert': '插入',
|
|
139
|
+
'board.clear': '清理',
|
|
133
140
|
'board.insertHint': '添加表格、导入表格或导入图片窗口',
|
|
141
|
+
'board.clearHint': '清理背景笔迹、路径或选中便签的笔迹',
|
|
134
142
|
'board.table': '表格',
|
|
135
143
|
'board.importTable': '导入表格',
|
|
136
144
|
'board.importImage': '导入图片',
|
|
@@ -142,6 +150,11 @@ window.__ModuleLoader__.load({
|
|
|
142
150
|
'board.chooseImage': '选择图片',
|
|
143
151
|
'board.imageHint': '图片窗口可拖动,右下角可缩放;大小上限约 1.5MB。',
|
|
144
152
|
'board.windowTitle': '窗口标题',
|
|
153
|
+
'board.tableTooLarge': '表格文件过大(上限约 2MB)',
|
|
154
|
+
'board.tableReadFailed': '表格读取失败',
|
|
155
|
+
'board.imageType': '请选择图片文件',
|
|
156
|
+
'board.imageTooLarge': '图片过大(上限约 1.5MB)',
|
|
157
|
+
'board.imageReadFailed': '图片读取失败',
|
|
145
158
|
'board.docHint': '完整 Markdown 文档页:默认展开预览,可拖动右下角调整大小。',
|
|
146
159
|
'board.stickyColor': '便签颜色',
|
|
147
160
|
'board.stickyHint': '便签可拖动;画笔可在方格纸背景或便签上绘制,橡皮擦除笔画。',
|
|
@@ -339,6 +352,12 @@ window.__ModuleLoader__.load({
|
|
|
339
352
|
'panel.confirmRewind': 'Create a new branch and restore the workspace to: {who}\n\n{warning}\n\nContinue?',
|
|
340
353
|
'panel.confirmFiles': 'Restore workspace files to: {who}\n\n{warning}\n\nContinue?',
|
|
341
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',
|
|
342
361
|
'panel.confirmBranchOnly': 'Create a new branch at this checkpoint without touching files: {who}\n\nContinue?',
|
|
343
362
|
'panel.confirmCheckpoint': 'Record the current conversation position and a workspace snapshot?',
|
|
344
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.',
|
|
@@ -407,7 +426,9 @@ window.__ModuleLoader__.load({
|
|
|
407
426
|
'board.fontSize': 'Font size',
|
|
408
427
|
'board.deleteText': 'Delete text',
|
|
409
428
|
'board.insert': 'Insert',
|
|
429
|
+
'board.clear': 'Clear',
|
|
410
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',
|
|
411
432
|
'board.table': 'Table',
|
|
412
433
|
'board.importTable': 'Import table',
|
|
413
434
|
'board.importImage': 'Import image',
|
|
@@ -419,6 +440,11 @@ window.__ModuleLoader__.load({
|
|
|
419
440
|
'board.chooseImage': 'Choose image',
|
|
420
441
|
'board.imageHint': 'Image windows can be dragged and resized from the bottom-right; max about 1.5MB.',
|
|
421
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',
|
|
422
448
|
'board.docHint': 'Full Markdown document page: expanded preview by default, resize from the bottom-right corner.',
|
|
423
449
|
'board.stickyColor': 'Sticky colour',
|
|
424
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.',
|
|
@@ -615,6 +641,7 @@ window.__ModuleLoader__.load({
|
|
|
615
641
|
.tb-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1))}
|
|
616
642
|
.tb-btn:disabled{opacity:.5;cursor:default}
|
|
617
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)}
|
|
618
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)}
|
|
619
646
|
.tb-body{flex:1;min-height:120px;overflow:auto;padding:10px 12px 28px;display:flex;flex-direction:column;gap:8px}
|
|
620
647
|
.tb-ws-select{display:flex;flex-direction:column;gap:5px;margin:3px 0 4px}
|
|
@@ -674,7 +701,7 @@ window.__ModuleLoader__.load({
|
|
|
674
701
|
.tb-canvas-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
675
702
|
.tb-world{position:absolute;left:0;top:0;transform-origin:0 0}
|
|
676
703
|
.tb-tree-doodles{position:absolute;left:0;top:0;overflow:visible;z-index:50}
|
|
677
|
-
.tb-tree-doodles polyline{fill:none;stroke-linecap:round;stroke-linejoin:round}
|
|
704
|
+
.tb-tree-doodles polyline,.tb-tree-doodles path{fill:none;stroke-linecap:round;stroke-linejoin:round}
|
|
678
705
|
.tb-world-links{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
|
|
679
706
|
.tb-link{fill:none;stroke-width:1.6;opacity:.55}
|
|
680
707
|
.tb-link.fork{stroke-width:2;opacity:.75}
|
|
@@ -745,7 +772,11 @@ window.__ModuleLoader__.load({
|
|
|
745
772
|
.tb-card-editnote.has{color:var(--tb-color,#4d7cfe);border-color:color-mix(in srgb, var(--tb-color,#4d7cfe) 50%, transparent)}
|
|
746
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}
|
|
747
774
|
.tb-overlay.center{justify-content:center;align-items:center;padding:16px}
|
|
748
|
-
.tb-
|
|
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}
|
|
749
780
|
.tb-chat-messages{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:8px;padding:2px 2px 4px}
|
|
750
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)}
|
|
751
782
|
.tb-chat-msg.user{background:rgba(77,124,254,.13);border-color:rgba(77,124,254,.4)}
|
|
@@ -810,6 +841,8 @@ window.__ModuleLoader__.load({
|
|
|
810
841
|
.tb-board-bgdraw{position:absolute;left:0;top:0;pointer-events:none;overflow:visible}
|
|
811
842
|
.tb-window-insert{position:relative;display:inline-flex}
|
|
812
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}
|
|
813
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)}
|
|
814
847
|
.tb-board-window.selected{outline:2px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff);outline-offset:1px}
|
|
815
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}
|
|
@@ -824,6 +857,7 @@ window.__ModuleLoader__.load({
|
|
|
824
857
|
.tb-board-window-body img{display:block;width:100%;height:100%;object-fit:contain;background:rgba(0,0,0,.14)}
|
|
825
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%)}
|
|
826
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}
|
|
827
861
|
.tb-window-editor-body{display:flex;flex-direction:column;gap:6px;min-height:0}
|
|
828
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)}
|
|
829
863
|
.tb-table-editor-preview table{border-collapse:collapse;width:100%;font-size:12px}
|
|
@@ -840,6 +874,8 @@ window.__ModuleLoader__.load({
|
|
|
840
874
|
.tb-board-text-actions button:hover{background:rgba(255,255,255,.12);color:#fff}
|
|
841
875
|
.tb-text-dialog{width:min(700px,94vw);height:auto;max-height:90vh;display:flex;flex-direction:column;gap:8px}
|
|
842
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}
|
|
843
879
|
.tb-text-input:focus{border-color:var(--dsw-alias-brand-primary-new-colorprimary-new-color,#7aa2ff)}
|
|
844
880
|
.tb-text-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
845
881
|
.tb-text-swatches{display:flex;gap:4px;flex-wrap:wrap}
|
|
@@ -921,6 +957,8 @@ window.__ModuleLoader__.load({
|
|
|
921
957
|
.tb-md-tool:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
922
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)}
|
|
923
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}
|
|
924
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))}
|
|
925
963
|
.tb-md-color-label{font-size:12px;color:var(--dsw-alias-label-secondary,#9aa0a6);margin-right:1px}
|
|
926
964
|
.tb-md-body{display:flex;gap:8px;flex:1;min-height:0;overflow:hidden}
|
|
@@ -2198,11 +2236,14 @@ window.__ModuleLoader__.load({
|
|
|
2198
2236
|
},
|
|
2199
2237
|
},
|
|
2200
2238
|
...(doodles ?? []).map((stroke, index) =>
|
|
2201
|
-
h('
|
|
2239
|
+
h('path', {
|
|
2202
2240
|
key: `doodle-${index}`,
|
|
2203
|
-
|
|
2241
|
+
d: smoothStrokePath(stroke.points),
|
|
2242
|
+
fill: 'none',
|
|
2204
2243
|
stroke: stroke.color || '#ff5f56',
|
|
2205
2244
|
strokeWidth: stroke.width || 3,
|
|
2245
|
+
strokeLinecap: 'round',
|
|
2246
|
+
strokeLinejoin: 'round',
|
|
2206
2247
|
opacity: 0.9,
|
|
2207
2248
|
}),
|
|
2208
2249
|
),
|
|
@@ -2489,6 +2530,7 @@ window.__ModuleLoader__.load({
|
|
|
2489
2530
|
panSpeedRef.current = panSpeed
|
|
2490
2531
|
const [noteEditor, setNoteEditor] = React.useState(null)
|
|
2491
2532
|
const [chat, setChat] = React.useState(null)
|
|
2533
|
+
const [branchPrompt, setBranchPrompt] = React.useState(null)
|
|
2492
2534
|
const viewportRef = React.useRef(null)
|
|
2493
2535
|
const worldRef = React.useRef(null)
|
|
2494
2536
|
const cameraRef = React.useRef({ x: 0, y: 0, scale: 1 })
|
|
@@ -2516,6 +2558,8 @@ window.__ModuleLoader__.load({
|
|
|
2516
2558
|
setFeedback(null)
|
|
2517
2559
|
setBusy('')
|
|
2518
2560
|
setSelectedKey(null)
|
|
2561
|
+
setChat(null)
|
|
2562
|
+
setBranchPrompt(null)
|
|
2519
2563
|
busyRef.current = ''
|
|
2520
2564
|
cameraRef.current = { x: 0, y: 0, scale: 1 }
|
|
2521
2565
|
fittedRef.current = ''
|
|
@@ -2580,27 +2624,10 @@ window.__ModuleLoader__.load({
|
|
|
2580
2624
|
return ''
|
|
2581
2625
|
}
|
|
2582
2626
|
|
|
2583
|
-
const
|
|
2627
|
+
const runAct = async (action, checkpoint, mode, targetSessionId, existingChildSessionId, branchName = '') => {
|
|
2584
2628
|
const data = state.data
|
|
2585
2629
|
if (!data || data.currentSessionId !== sessionId) return
|
|
2586
2630
|
const actionSessionId = targetSessionId || sessionId
|
|
2587
|
-
const who = checkpoint ? checkpointName(checkpoint, t) : ''
|
|
2588
|
-
let message
|
|
2589
|
-
if (action === 'checkpoint') message = t('panel.confirmCheckpoint')
|
|
2590
|
-
else if (action === 'prune') message = format(t('panel.confirmPrune'), { who })
|
|
2591
|
-
else if (mode === 'branch-only') message = format(t('panel.confirmBranchOnly'), { who })
|
|
2592
|
-
else if (action === 'restore-files') message = format(t('panel.confirmFiles'), { who, warning: t('panel.deleteWarning') })
|
|
2593
|
-
else message = format(t('panel.confirmRewind'), { who, warning: t('panel.deleteWarning') })
|
|
2594
|
-
if (!window.confirm(message)) return
|
|
2595
|
-
let branchName = ''
|
|
2596
|
-
if (action === 'rewind' && mode !== 'files-only') {
|
|
2597
|
-
const source = (data.sessions ?? []).find((entry) => entry.sessionId === actionSessionId)
|
|
2598
|
-
const suffix = Number.isInteger(checkpoint?.turn) ? ` · T${checkpoint.turn}` : ''
|
|
2599
|
-
const fallbackName = `${source?.title || t('panel.branch')} · ${t('panel.branch')}${suffix}`
|
|
2600
|
-
const entered = window.prompt(t('panel.branchNamePrompt'), fallbackName)
|
|
2601
|
-
if (entered === null) return
|
|
2602
|
-
branchName = (entered || '').trim() || fallbackName
|
|
2603
|
-
}
|
|
2604
2631
|
const busyKey = checkpoint ? checkpoint.id : action
|
|
2605
2632
|
setBusy(busyKey)
|
|
2606
2633
|
busyRef.current = busyKey
|
|
@@ -2679,6 +2706,47 @@ window.__ModuleLoader__.load({
|
|
|
2679
2706
|
}
|
|
2680
2707
|
}
|
|
2681
2708
|
|
|
2709
|
+
const act = async (action, checkpoint, mode, targetSessionId, existingChildSessionId) => {
|
|
2710
|
+
const data = state.data
|
|
2711
|
+
if (!data || data.currentSessionId !== sessionId) return
|
|
2712
|
+
const actionSessionId = targetSessionId || sessionId
|
|
2713
|
+
const who = checkpoint ? checkpointName(checkpoint, t) : ''
|
|
2714
|
+
let message
|
|
2715
|
+
if (action === 'checkpoint') message = t('panel.confirmCheckpoint')
|
|
2716
|
+
else if (action === 'prune') message = format(t('panel.confirmPrune'), { who })
|
|
2717
|
+
else if (mode === 'branch-only') message = format(t('panel.confirmBranchOnly'), { who })
|
|
2718
|
+
else if (action === 'restore-files') message = format(t('panel.confirmFiles'), { who, warning: t('panel.deleteWarning') })
|
|
2719
|
+
else message = format(t('panel.confirmRewind'), { who, warning: t('panel.deleteWarning') })
|
|
2720
|
+
if (action === 'rewind' && mode !== 'files-only') {
|
|
2721
|
+
// One dialog for both the warning and the branch name: desktop webviews
|
|
2722
|
+
// do not support window.prompt and a second modal is easy to miss.
|
|
2723
|
+
const source = (data.sessions ?? []).find((entry) => entry.sessionId === actionSessionId)
|
|
2724
|
+
const suffix = Number.isInteger(checkpoint?.turn) ? ` · T${checkpoint.turn}` : ''
|
|
2725
|
+
const fallbackName = `${source?.title || t('panel.branch')} · ${t('panel.branch')}${suffix}`
|
|
2726
|
+
setBranchPrompt({
|
|
2727
|
+
action,
|
|
2728
|
+
checkpoint,
|
|
2729
|
+
mode,
|
|
2730
|
+
targetSessionId,
|
|
2731
|
+
existingChildSessionId,
|
|
2732
|
+
defaultName: fallbackName,
|
|
2733
|
+
name: fallbackName,
|
|
2734
|
+
message,
|
|
2735
|
+
})
|
|
2736
|
+
return
|
|
2737
|
+
}
|
|
2738
|
+
if (!window.confirm(message)) return
|
|
2739
|
+
await runAct(action, checkpoint, mode, targetSessionId, existingChildSessionId, '')
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
const confirmBranchPrompt = async () => {
|
|
2743
|
+
const prompt = branchPrompt
|
|
2744
|
+
if (!prompt) return
|
|
2745
|
+
setBranchPrompt(null)
|
|
2746
|
+
const name = String(prompt.name ?? '').trim() || prompt.defaultName
|
|
2747
|
+
await runAct(prompt.action, prompt.checkpoint, prompt.mode, prompt.targetSessionId, prompt.existingChildSessionId, name)
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2682
2750
|
const toggleWorkspace = async (enabled, explicitCwd) => {
|
|
2683
2751
|
if (busyRef.current !== '') return
|
|
2684
2752
|
const data = state.data
|
|
@@ -2860,9 +2928,24 @@ window.__ModuleLoader__.load({
|
|
|
2860
2928
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2861
2929
|
}, [view, data?.currentSessionId, layoutReady])
|
|
2862
2930
|
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2931
|
+
// Canvas layout belongs to the workspace, not one branch-family root:
|
|
2932
|
+
// pruning a branch replaces rootSessionId and used to make positions,
|
|
2933
|
+
// folder names and doodles disappear. Keep old root-scoped keys as
|
|
2934
|
+
// one-time migration sources.
|
|
2935
|
+
const layoutScope = data?.workspace?.cwd
|
|
2936
|
+
? `ws:${data.workspace.cwd}`
|
|
2937
|
+
: data?.rootSessionId
|
|
2938
|
+
? `root:${data.rootSessionId}`
|
|
2939
|
+
: null
|
|
2940
|
+
const scopeKey = (kind) => (layoutScope ? `dsh-timeback:${kind}:${layoutScope}` : null)
|
|
2941
|
+
// Pre-0.7.9 layout keys were scoped by the bare root session id.
|
|
2942
|
+
const legacyScopeKey = (kind) => (data?.rootSessionId ? `dsh-timeback:${kind}:${data.rootSessionId}` : null)
|
|
2943
|
+
const positionsKey = scopeKey('card-positions')
|
|
2944
|
+
const foldersKey = scopeKey('card-folders')
|
|
2945
|
+
const doodlesKey = scopeKey('tree-doodles')
|
|
2946
|
+
const legacyPositionsKey = legacyScopeKey('card-positions')
|
|
2947
|
+
const legacyFoldersKey = legacyScopeKey('card-folders')
|
|
2948
|
+
const legacyDoodlesKey = legacyScopeKey('tree-doodles')
|
|
2866
2949
|
|
|
2867
2950
|
// Restore dragged card positions and folders for this branch family.
|
|
2868
2951
|
React.useEffect(() => {
|
|
@@ -2870,12 +2953,20 @@ window.__ModuleLoader__.load({
|
|
|
2870
2953
|
let saved = {}
|
|
2871
2954
|
let savedFolders = []
|
|
2872
2955
|
let savedDoodles = []
|
|
2956
|
+
const readScope = (key, legacyKey) => {
|
|
2957
|
+
let raw = key ? window.localStorage.getItem(key) : null
|
|
2958
|
+
if (!raw && legacyKey && legacyKey !== key) {
|
|
2959
|
+
raw = window.localStorage.getItem(legacyKey)
|
|
2960
|
+
if (raw && key) window.localStorage.setItem(key, raw)
|
|
2961
|
+
}
|
|
2962
|
+
return raw
|
|
2963
|
+
}
|
|
2873
2964
|
try {
|
|
2874
|
-
const raw =
|
|
2965
|
+
const raw = readScope(positionsKey, legacyPositionsKey)
|
|
2875
2966
|
if (raw) saved = JSON.parse(raw)
|
|
2876
|
-
const rawFolders =
|
|
2967
|
+
const rawFolders = readScope(foldersKey, legacyFoldersKey)
|
|
2877
2968
|
if (rawFolders) savedFolders = JSON.parse(rawFolders)
|
|
2878
|
-
const rawDoodles =
|
|
2969
|
+
const rawDoodles = readScope(doodlesKey, legacyDoodlesKey)
|
|
2879
2970
|
if (rawDoodles) savedDoodles = JSON.parse(rawDoodles)
|
|
2880
2971
|
} catch {
|
|
2881
2972
|
saved = {}
|
|
@@ -2900,7 +2991,7 @@ window.__ModuleLoader__.load({
|
|
|
2900
2991
|
setFolders(savedFolders)
|
|
2901
2992
|
doodlesRef.current = savedDoodles
|
|
2902
2993
|
setDoodles(savedDoodles)
|
|
2903
|
-
}, [positionsKey, foldersKey, doodlesKey])
|
|
2994
|
+
}, [positionsKey, foldersKey, doodlesKey, legacyPositionsKey, legacyFoldersKey, legacyDoodlesKey])
|
|
2904
2995
|
|
|
2905
2996
|
// Wheel zoom must be non-passive, so it is bound directly to the viewport.
|
|
2906
2997
|
React.useEffect(() => {
|
|
@@ -3006,21 +3097,32 @@ window.__ModuleLoader__.load({
|
|
|
3006
3097
|
}
|
|
3007
3098
|
const startPoint = toWorld(event)
|
|
3008
3099
|
const stroke = { color: '#ff5f56', width: 3, points: [startPoint] }
|
|
3009
|
-
let
|
|
3010
|
-
setDoodles(
|
|
3100
|
+
let frame = 0
|
|
3101
|
+
setDoodles([...doodlesRef.current, stroke])
|
|
3011
3102
|
const move = (next) => {
|
|
3012
|
-
const
|
|
3013
|
-
const
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3103
|
+
const samples = typeof next.getCoalescedEvents === 'function' ? next.getCoalescedEvents() : [next]
|
|
3104
|
+
for (const sample of samples.length > 0 ? samples : [next]) {
|
|
3105
|
+
if (stroke.points.length >= 2000) break
|
|
3106
|
+
const point = toWorld(sample)
|
|
3107
|
+
const last = stroke.points[stroke.points.length - 1]
|
|
3108
|
+
if (last && last[0] === point[0] && last[1] === point[1]) continue
|
|
3109
|
+
stroke.points.push(point)
|
|
3110
|
+
}
|
|
3111
|
+
if (!frame) {
|
|
3112
|
+
frame = window.requestAnimationFrame(() => {
|
|
3113
|
+
frame = 0
|
|
3114
|
+
setDoodles([...doodlesRef.current, stroke])
|
|
3115
|
+
})
|
|
3116
|
+
}
|
|
3019
3117
|
}
|
|
3020
3118
|
const finish = () => {
|
|
3021
3119
|
window.removeEventListener('pointermove', move)
|
|
3022
3120
|
window.removeEventListener('pointerup', finish)
|
|
3023
3121
|
window.removeEventListener('pointercancel', finish)
|
|
3122
|
+
if (frame) {
|
|
3123
|
+
window.cancelAnimationFrame(frame)
|
|
3124
|
+
frame = 0
|
|
3125
|
+
}
|
|
3024
3126
|
doodlesRef.current = [...doodlesRef.current.filter((item) => item !== stroke), stroke].slice(-200)
|
|
3025
3127
|
storeDoodles(doodlesRef.current, true)
|
|
3026
3128
|
}
|
|
@@ -3295,7 +3397,7 @@ window.__ModuleLoader__.load({
|
|
|
3295
3397
|
/** Read the turn behind one card and open its conversation/composer. */
|
|
3296
3398
|
const openCardConversation = async (card) => {
|
|
3297
3399
|
if (!card || card.kind === 'folder') return
|
|
3298
|
-
const base = { card, loading: true, messages: [], error: null, input: '', sending: false }
|
|
3400
|
+
const base = { card, loading: true, messages: [], error: null, input: '', sending: false, branchedTo: null }
|
|
3299
3401
|
setChat(base)
|
|
3300
3402
|
if (!sessionApi) {
|
|
3301
3403
|
setChat({ ...base, loading: false, error: t('chat.unavailable') })
|
|
@@ -3349,9 +3451,9 @@ window.__ModuleLoader__.load({
|
|
|
3349
3451
|
const data = state.data
|
|
3350
3452
|
const layout = data ? layoutTree(data.sessions ?? [], data.currentSessionId, positionsRef.current, foldersRef.current) : null
|
|
3351
3453
|
const tail = cardIsTail(current.card, layout, data)
|
|
3352
|
-
let targetSessionId = current.card.sessionId
|
|
3353
|
-
let branched =
|
|
3354
|
-
if (!tail) {
|
|
3454
|
+
let targetSessionId = current.branchedTo || current.card.sessionId
|
|
3455
|
+
let branched = Boolean(current.branchedTo)
|
|
3456
|
+
if (!tail && !current.branchedTo) {
|
|
3355
3457
|
const checkpoints = current.card.checkpoints ?? []
|
|
3356
3458
|
const checkpoint =
|
|
3357
3459
|
[...checkpoints].reverse().find((entry) => Number.isInteger(entry.seq) && entry.phase !== 'before') ??
|
|
@@ -3364,15 +3466,17 @@ window.__ModuleLoader__.load({
|
|
|
3364
3466
|
sessionId: current.card.sessionId,
|
|
3365
3467
|
checkpointId: checkpoint.id,
|
|
3366
3468
|
mode: 'branch-only',
|
|
3367
|
-
name: text.slice(0, 120),
|
|
3469
|
+
name: text.replace(/\s+/g, ' ').trim().slice(0, 120),
|
|
3368
3470
|
},
|
|
3369
3471
|
})
|
|
3370
3472
|
if (!result?.childSessionId) throw new Error(t('chat.noCheckpoint'))
|
|
3371
3473
|
targetSessionId = result.childSessionId
|
|
3372
3474
|
branched = true
|
|
3373
|
-
//
|
|
3374
|
-
//
|
|
3375
|
-
|
|
3475
|
+
// Keep the created branch on the draft so a failed prompt can be
|
|
3476
|
+
// retried without creating a second branch. Do not switch the UI
|
|
3477
|
+
// session yet: that would reset the chat drawer and hide a prompt
|
|
3478
|
+
// error; the catalog refresh below makes the new branch resolvable.
|
|
3479
|
+
setChat((previous) => (previous ? { ...previous, branchedTo: targetSessionId } : previous))
|
|
3376
3480
|
}
|
|
3377
3481
|
const promptOnce = () =>
|
|
3378
3482
|
sessionApi.using(targetSessionId, { source: 'gateway' }, async (reference) => {
|
|
@@ -3389,6 +3493,7 @@ window.__ModuleLoader__.load({
|
|
|
3389
3493
|
if (result && result.ok === false) {
|
|
3390
3494
|
throw new Error(result.error?.message ? String(result.error.message) : JSON.stringify(result.error))
|
|
3391
3495
|
}
|
|
3496
|
+
if (branched) openChild(targetSessionId)
|
|
3392
3497
|
setChat(null)
|
|
3393
3498
|
setFeedback({ tone: 'ok', text: branched ? t('chat.branched') : t('chat.sent') })
|
|
3394
3499
|
setTick((value) => value + 1)
|
|
@@ -3438,17 +3543,14 @@ window.__ModuleLoader__.load({
|
|
|
3438
3543
|
/** Clear dragged positions and return to the automatic layout. */
|
|
3439
3544
|
const resetCardPositions = () => {
|
|
3440
3545
|
try {
|
|
3441
|
-
|
|
3546
|
+
for (const key of [positionsKey, legacyPositionsKey, foldersKey, legacyFoldersKey]) {
|
|
3547
|
+
if (key) window.localStorage.removeItem(key)
|
|
3548
|
+
}
|
|
3442
3549
|
} catch {
|
|
3443
3550
|
// Storage can be disabled.
|
|
3444
3551
|
}
|
|
3445
3552
|
positionsRef.current = {}
|
|
3446
3553
|
setPositions({})
|
|
3447
|
-
try {
|
|
3448
|
-
if (foldersKey) window.localStorage.removeItem(foldersKey)
|
|
3449
|
-
} catch {
|
|
3450
|
-
// Storage can be disabled.
|
|
3451
|
-
}
|
|
3452
3554
|
foldersRef.current = []
|
|
3453
3555
|
setFolders([])
|
|
3454
3556
|
}
|
|
@@ -3473,7 +3575,6 @@ window.__ModuleLoader__.load({
|
|
|
3473
3575
|
{ className: 'tb-muted tb-small', title: `timeback client ${BUILD}` },
|
|
3474
3576
|
format(t('panel.branchCount'), { sessions: sessions.length, checkpoints: checkpointTotal }),
|
|
3475
3577
|
),
|
|
3476
|
-
h('span', { className: 'tb-muted tb-small', title: 'timeback client build' }, BUILD),
|
|
3477
3578
|
h('span', { style: { flex: 1 } }),
|
|
3478
3579
|
h(
|
|
3479
3580
|
'button',
|
|
@@ -3760,7 +3861,7 @@ window.__ModuleLoader__.load({
|
|
|
3760
3861
|
: h('div', { className: 'tb-chat-text' }, message.text),
|
|
3761
3862
|
),
|
|
3762
3863
|
)
|
|
3763
|
-
: h('div', { className: 'tb-empty tb-small' },
|
|
3864
|
+
: h('div', { className: 'tb-empty tb-small' }, t('chat.empty')),
|
|
3764
3865
|
),
|
|
3765
3866
|
chat.error && !chat.loading
|
|
3766
3867
|
? h('div', { className: 'tb-feedback err' }, chat.error)
|
|
@@ -3774,6 +3875,7 @@ window.__ModuleLoader__.load({
|
|
|
3774
3875
|
disabled: chat.sending,
|
|
3775
3876
|
onChange: (event) => setChat((current) => (current ? { ...current, input: event.target.value } : current)),
|
|
3776
3877
|
onKeyDown: (event) => {
|
|
3878
|
+
if (event.nativeEvent?.isComposing) return
|
|
3777
3879
|
if (event.key === 'Enter' && !event.shiftKey) {
|
|
3778
3880
|
event.preventDefault()
|
|
3779
3881
|
sendChatMessage()
|
|
@@ -3788,7 +3890,7 @@ window.__ModuleLoader__.load({
|
|
|
3788
3890
|
{
|
|
3789
3891
|
type: 'button',
|
|
3790
3892
|
className: 'tb-btn',
|
|
3791
|
-
onClick: () => openSessionByCard(chat.card.sessionId),
|
|
3893
|
+
onClick: () => openSessionByCard(chat.branchedTo || chat.card.sessionId),
|
|
3792
3894
|
},
|
|
3793
3895
|
t('chat.openSession'),
|
|
3794
3896
|
),
|
|
@@ -3808,6 +3910,54 @@ window.__ModuleLoader__.load({
|
|
|
3808
3910
|
),
|
|
3809
3911
|
)
|
|
3810
3912
|
: null,
|
|
3913
|
+
branchPrompt
|
|
3914
|
+
? h(
|
|
3915
|
+
'div',
|
|
3916
|
+
{ className: 'tb-overlay center', onClick: () => setBranchPrompt(null) },
|
|
3917
|
+
h(
|
|
3918
|
+
'div',
|
|
3919
|
+
{
|
|
3920
|
+
className: 'tb-board-dialog tb-branch-dialog',
|
|
3921
|
+
role: 'dialog',
|
|
3922
|
+
'aria-modal': true,
|
|
3923
|
+
onClick: (event) => event.stopPropagation(),
|
|
3924
|
+
},
|
|
3925
|
+
h(
|
|
3926
|
+
'div',
|
|
3927
|
+
{ className: 'tb-detail-head' },
|
|
3928
|
+
h('span', { className: 'tb-detail-title' }, t('panel.branchNameTitle')),
|
|
3929
|
+
h('span', { style: { flex: 1 } }),
|
|
3930
|
+
),
|
|
3931
|
+
branchPrompt.message ? h('div', { className: 'tb-branch-message' }, branchPrompt.message) : null,
|
|
3932
|
+
h('div', { className: 'tb-ws-hint' }, t('panel.branchNameHint')),
|
|
3933
|
+
h('input', {
|
|
3934
|
+
value: branchPrompt.name ?? '',
|
|
3935
|
+
autoFocus: true,
|
|
3936
|
+
placeholder: branchPrompt.defaultName,
|
|
3937
|
+
onFocus: (event) => event.target.select(),
|
|
3938
|
+
onChange: (event) =>
|
|
3939
|
+
setBranchPrompt((current) => (current ? { ...current, name: event.target.value } : current)),
|
|
3940
|
+
onKeyDown: (event) => {
|
|
3941
|
+
event.stopPropagation()
|
|
3942
|
+
if (event.nativeEvent?.isComposing) return
|
|
3943
|
+
if (event.key === 'Enter') {
|
|
3944
|
+
event.preventDefault()
|
|
3945
|
+
confirmBranchPrompt()
|
|
3946
|
+
} else if (event.key === 'Escape') {
|
|
3947
|
+
event.preventDefault()
|
|
3948
|
+
setBranchPrompt(null)
|
|
3949
|
+
}
|
|
3950
|
+
},
|
|
3951
|
+
}),
|
|
3952
|
+
h(
|
|
3953
|
+
'div',
|
|
3954
|
+
{ className: 'tb-note-actions' },
|
|
3955
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => setBranchPrompt(null) }, t('panel.cancel')),
|
|
3956
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: confirmBranchPrompt }, t('panel.createBranch')),
|
|
3957
|
+
),
|
|
3958
|
+
),
|
|
3959
|
+
)
|
|
3960
|
+
: null,
|
|
3811
3961
|
)
|
|
3812
3962
|
}
|
|
3813
3963
|
|
|
@@ -4581,6 +4731,27 @@ window.__ModuleLoader__.load({
|
|
|
4581
4731
|
}
|
|
4582
4732
|
|
|
4583
4733
|
/** Render pen strokes and common shapes for one stroke layer. */
|
|
4734
|
+
/** Smooth a freehand point list with Catmull-Rom -> cubic Bezier. */
|
|
4735
|
+
function smoothStrokePath(points) {
|
|
4736
|
+
const list = Array.isArray(points) ? points : []
|
|
4737
|
+
if (list.length === 0) return ''
|
|
4738
|
+
if (list.length === 1) return `M ${list[0][0]} ${list[0][1]} L ${list[0][0] + 0.1} ${list[0][1] + 0.1}`
|
|
4739
|
+
if (list.length === 2) return `M ${list[0][0]} ${list[0][1]} L ${list[1][0]} ${list[1][1]}`
|
|
4740
|
+
let d = `M ${list[0][0]} ${list[0][1]}`
|
|
4741
|
+
for (let index = 0; index < list.length - 1; index += 1) {
|
|
4742
|
+
const p0 = list[index - 1] ?? list[index]
|
|
4743
|
+
const p1 = list[index]
|
|
4744
|
+
const p2 = list[index + 1]
|
|
4745
|
+
const p3 = list[index + 2] ?? p2
|
|
4746
|
+
const cp1x = p1[0] + (p2[0] - p0[0]) / 6
|
|
4747
|
+
const cp1y = p1[1] + (p2[1] - p0[1]) / 6
|
|
4748
|
+
const cp2x = p2[0] - (p3[0] - p1[0]) / 6
|
|
4749
|
+
const cp2y = p2[1] - (p3[1] - p1[1]) / 6
|
|
4750
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)} ${cp2x.toFixed(2)} ${cp2y.toFixed(2)} ${p2[0]} ${p2[1]}`
|
|
4751
|
+
}
|
|
4752
|
+
return d
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4584
4755
|
function boardStrokeElements(strokes, keyPrefix) {
|
|
4585
4756
|
return (strokes ?? []).map((stroke, index) => {
|
|
4586
4757
|
const key = `${keyPrefix}-${index}`
|
|
@@ -4589,9 +4760,9 @@ window.__ModuleLoader__.load({
|
|
|
4589
4760
|
const color = stroke.color
|
|
4590
4761
|
const width = stroke.width
|
|
4591
4762
|
if (kind === 'pen' || points.length < 2) {
|
|
4592
|
-
return h('
|
|
4763
|
+
return h('path', {
|
|
4593
4764
|
key,
|
|
4594
|
-
|
|
4765
|
+
d: smoothStrokePath(points),
|
|
4595
4766
|
fill: 'none',
|
|
4596
4767
|
stroke: color,
|
|
4597
4768
|
strokeWidth: width,
|
|
@@ -4632,13 +4803,14 @@ window.__ModuleLoader__.load({
|
|
|
4632
4803
|
h('polygon', { points: boardArrowHead(a, b, width), fill: color, stroke: 'none' }),
|
|
4633
4804
|
)
|
|
4634
4805
|
}
|
|
4635
|
-
return h('
|
|
4806
|
+
return h('path', {
|
|
4636
4807
|
key,
|
|
4637
|
-
|
|
4808
|
+
d: smoothStrokePath(points),
|
|
4638
4809
|
fill: 'none',
|
|
4639
4810
|
stroke: color,
|
|
4640
4811
|
strokeWidth: width,
|
|
4641
4812
|
strokeLinecap: 'round',
|
|
4813
|
+
strokeLinejoin: 'round',
|
|
4642
4814
|
})
|
|
4643
4815
|
})
|
|
4644
4816
|
}
|
|
@@ -4871,6 +5043,7 @@ window.__ModuleLoader__.load({
|
|
|
4871
5043
|
const onChange = typeof props?.onChange === 'function' ? props.onChange : () => {}
|
|
4872
5044
|
const disabled = props?.disabled === true
|
|
4873
5045
|
const [mode, setMode] = React.useState('rich')
|
|
5046
|
+
const [linkEditor, setLinkEditor] = React.useState(null)
|
|
4874
5047
|
const sourceRef = React.useRef(null)
|
|
4875
5048
|
const richRef = React.useRef(null)
|
|
4876
5049
|
const richRangeRef = React.useRef(null)
|
|
@@ -4920,6 +5093,7 @@ window.__ModuleLoader__.load({
|
|
|
4920
5093
|
const exec = (command, argument = null) => {
|
|
4921
5094
|
const element = richRef.current
|
|
4922
5095
|
if (!element) return
|
|
5096
|
+
let applied = false
|
|
4923
5097
|
try {
|
|
4924
5098
|
element.focus({ preventScroll: true })
|
|
4925
5099
|
const range = richRangeRef.current
|
|
@@ -4928,10 +5102,26 @@ window.__ModuleLoader__.load({
|
|
|
4928
5102
|
selection.removeAllRanges()
|
|
4929
5103
|
selection.addRange(range)
|
|
4930
5104
|
}
|
|
4931
|
-
document.execCommand(command, false, argument)
|
|
5105
|
+
applied = document.execCommand(command, false, argument)
|
|
4932
5106
|
} catch {
|
|
4933
5107
|
// execCommand can be unavailable; the source tab still works.
|
|
4934
5108
|
}
|
|
5109
|
+
// Some desktop WebViews disable execCommand but still expose the DOM
|
|
5110
|
+
// Range API; keep the text-colour button working there.
|
|
5111
|
+
if (!applied && command === 'foreColor' && typeof document !== 'undefined') {
|
|
5112
|
+
try {
|
|
5113
|
+
const selection = window.getSelection()
|
|
5114
|
+
const range = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null
|
|
5115
|
+
if (range && !range.collapsed) {
|
|
5116
|
+
const span = document.createElement('span')
|
|
5117
|
+
span.style.color = argument
|
|
5118
|
+
span.appendChild(range.extractContents())
|
|
5119
|
+
range.insertNode(span)
|
|
5120
|
+
}
|
|
5121
|
+
} catch {
|
|
5122
|
+
// Leave the document unchanged if the selection cannot be wrapped.
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
4935
5125
|
rememberRichSelection()
|
|
4936
5126
|
syncRich()
|
|
4937
5127
|
}
|
|
@@ -4991,6 +5181,14 @@ window.__ModuleLoader__.load({
|
|
|
4991
5181
|
else if (mode === 'source') sourceSurround(`<span style="color:${color}">`, '</span>')
|
|
4992
5182
|
}
|
|
4993
5183
|
|
|
5184
|
+
const submitLink = () => {
|
|
5185
|
+
const href = String(linkEditor?.href ?? '').trim()
|
|
5186
|
+
setLinkEditor(null)
|
|
5187
|
+
if (href === '') return
|
|
5188
|
+
if (mode === 'rich') exec('createLink', href)
|
|
5189
|
+
else sourceSurround('[', `](${href})`)
|
|
5190
|
+
}
|
|
5191
|
+
|
|
4994
5192
|
const richTools = [
|
|
4995
5193
|
{ key: 'h1', label: 'H1', title: t('md.heading'), run: () => exec('formatBlock', '<h1>') },
|
|
4996
5194
|
{ key: 'h2', label: 'H2', title: t('md.heading'), run: () => exec('formatBlock', '<h2>') },
|
|
@@ -5004,15 +5202,7 @@ window.__ModuleLoader__.load({
|
|
|
5004
5202
|
{ key: 'numbered', label: '1.', title: t('md.numbered'), run: () => exec('insertOrderedList') },
|
|
5005
5203
|
{ key: 'task', label: '☐', title: t('md.task'), run: () => insertHtml('<div>- [ ] {selection}</div>') },
|
|
5006
5204
|
{ key: 'quote', label: '❝', title: t('md.quote'), run: () => exec('formatBlock', '<blockquote>') },
|
|
5007
|
-
{ key: 'link', label: '🔗', title: t('md.link'), run: () => {
|
|
5008
|
-
let href = 'https://'
|
|
5009
|
-
try {
|
|
5010
|
-
href = window.prompt(t('md.linkPrompt'), 'https://') || ''
|
|
5011
|
-
} catch {
|
|
5012
|
-
href = ''
|
|
5013
|
-
}
|
|
5014
|
-
if (href) exec('createLink', href)
|
|
5015
|
-
} },
|
|
5205
|
+
{ key: 'link', label: '🔗', title: t('md.link'), run: () => setLinkEditor({ href: 'https://' }) },
|
|
5016
5206
|
{ key: 'hr', label: '—', title: t('md.hr'), run: () => exec('insertHorizontalRule') },
|
|
5017
5207
|
]
|
|
5018
5208
|
const sourceTools = [
|
|
@@ -5100,6 +5290,32 @@ window.__ModuleLoader__.load({
|
|
|
5100
5290
|
}),
|
|
5101
5291
|
),
|
|
5102
5292
|
),
|
|
5293
|
+
linkEditor
|
|
5294
|
+
? h(
|
|
5295
|
+
'div',
|
|
5296
|
+
{ className: 'tb-md-linkbar' },
|
|
5297
|
+
h('span', { className: 'tb-md-color-label' }, t('md.linkPrompt')),
|
|
5298
|
+
h('input', {
|
|
5299
|
+
className: 'tb-md-link-input',
|
|
5300
|
+
value: linkEditor.href ?? '',
|
|
5301
|
+
autoFocus: true,
|
|
5302
|
+
placeholder: 'https://',
|
|
5303
|
+
onChange: (event) => setLinkEditor({ href: event.target.value }),
|
|
5304
|
+
onKeyDown: (event) => {
|
|
5305
|
+
if (event.nativeEvent?.isComposing) return
|
|
5306
|
+
if (event.key === 'Enter') {
|
|
5307
|
+
event.preventDefault()
|
|
5308
|
+
submitLink()
|
|
5309
|
+
} else if (event.key === 'Escape') {
|
|
5310
|
+
event.preventDefault()
|
|
5311
|
+
setLinkEditor(null)
|
|
5312
|
+
}
|
|
5313
|
+
},
|
|
5314
|
+
}),
|
|
5315
|
+
h('button', { type: 'button', className: 'tb-btn', onClick: () => setLinkEditor(null) }, t('panel.cancel')),
|
|
5316
|
+
h('button', { type: 'button', className: 'tb-btn primary', onClick: submitLink }, t('panel.confirm')),
|
|
5317
|
+
)
|
|
5318
|
+
: null,
|
|
5103
5319
|
h('div', { className: 'tb-ws-hint', style: { fontSize: '10.5px' } }, t('md.hint')),
|
|
5104
5320
|
h(
|
|
5105
5321
|
'div',
|
|
@@ -5243,6 +5459,7 @@ window.__ModuleLoader__.load({
|
|
|
5243
5459
|
const [textEditor, setTextEditor] = React.useState(null)
|
|
5244
5460
|
const [windowEditor, setWindowEditor] = React.useState(null)
|
|
5245
5461
|
const [insertMenu, setInsertMenu] = React.useState(false)
|
|
5462
|
+
const [clearMenu, setClearMenu] = React.useState(false)
|
|
5246
5463
|
const [notice, setNotice] = React.useState(null)
|
|
5247
5464
|
const [linkPreview, setLinkPreview] = React.useState(null)
|
|
5248
5465
|
const [zoom, setZoom] = React.useState(1)
|
|
@@ -5291,7 +5508,6 @@ window.__ModuleLoader__.load({
|
|
|
5291
5508
|
|
|
5292
5509
|
React.useEffect(() => () => {
|
|
5293
5510
|
if (saveTimerRef.current) clearTimeout(saveTimerRef.current)
|
|
5294
|
-
if (foldTimerRef.current) clearTimeout(foldTimerRef.current)
|
|
5295
5511
|
}, [])
|
|
5296
5512
|
|
|
5297
5513
|
/** Zoom around one viewport point while keeping that content anchored. */
|
|
@@ -5514,7 +5730,21 @@ window.__ModuleLoader__.load({
|
|
|
5514
5730
|
const entries = state.board?.entries ?? []
|
|
5515
5731
|
const sortedEntries = [...entries].sort((left, right) => (right.updatedAt ?? 0) - (left.updatedAt ?? 0))
|
|
5516
5732
|
const boardVersion = state.board?.version ?? 0
|
|
5517
|
-
const
|
|
5733
|
+
const withDocLayout = (entry, base) => {
|
|
5734
|
+
if (entry?.kind !== 'doc' || base?.kind === 'doc') return base
|
|
5735
|
+
return {
|
|
5736
|
+
...base,
|
|
5737
|
+
kind: 'doc',
|
|
5738
|
+
width: Math.max(560, Number(base.width) || 0),
|
|
5739
|
+
height: Math.max(420, Number(base.height) || 0),
|
|
5740
|
+
}
|
|
5741
|
+
}
|
|
5742
|
+
const layoutFor = (entry, index) => withDocLayout(entry, canvas.notes[entry.id] ?? autoBoardLayout(index))
|
|
5743
|
+
const layoutForNote = (noteId) => {
|
|
5744
|
+
const entry = entries.find((candidate) => candidate.id === noteId)
|
|
5745
|
+
const index = Math.max(0, entries.findIndex((candidate) => candidate.id === noteId))
|
|
5746
|
+
return withDocLayout(entry, canvasRef.current.notes[noteId] ?? autoBoardLayout(index))
|
|
5747
|
+
}
|
|
5518
5748
|
const noteSize = (layout) => {
|
|
5519
5749
|
const doc = layout?.kind === 'doc'
|
|
5520
5750
|
return {
|
|
@@ -5666,17 +5896,18 @@ window.__ModuleLoader__.load({
|
|
|
5666
5896
|
|
|
5667
5897
|
const startAddText = () => {
|
|
5668
5898
|
const [cx, cy] = viewportStageCenter()
|
|
5669
|
-
setTextEditor({ id: '', text: '', color: '#e6e6e6', fontSize: 18, x: Math.max(0, cx - 160), y: Math.max(0, cy - 24), width: 320 })
|
|
5899
|
+
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 })
|
|
5670
5900
|
}
|
|
5671
5901
|
|
|
5672
5902
|
const startEditText = (item) => {
|
|
5673
5903
|
if (!item) return
|
|
5674
|
-
setTextEditor({ ...item })
|
|
5904
|
+
setTextEditor({ ...item, busy: false, error: null })
|
|
5675
5905
|
}
|
|
5676
5906
|
|
|
5677
5907
|
const saveText = async () => {
|
|
5678
5908
|
const editor = textEditor
|
|
5679
|
-
if (!editor) return
|
|
5909
|
+
if (!editor || editor.busy) return
|
|
5910
|
+
setTextEditor((current) => (current ? { ...current, busy: true, error: null } : current))
|
|
5680
5911
|
const text = String(editor.text ?? '').trim()
|
|
5681
5912
|
if (text === '') {
|
|
5682
5913
|
if (editor.id) await deleteText(editor.id)
|
|
@@ -5699,13 +5930,24 @@ window.__ModuleLoader__.load({
|
|
|
5699
5930
|
try {
|
|
5700
5931
|
await saveCanvasNow(next)
|
|
5701
5932
|
} catch (error) {
|
|
5702
|
-
setTextEditor({ ...editor, error: error?.message || String(error) })
|
|
5933
|
+
setTextEditor({ ...editor, busy: false, error: error?.message || String(error) })
|
|
5703
5934
|
return
|
|
5704
5935
|
}
|
|
5705
5936
|
setSelected(id)
|
|
5706
5937
|
setTextEditor(null)
|
|
5707
5938
|
}
|
|
5708
5939
|
|
|
5940
|
+
/** Outside-click close for the text editor: save non-empty text like stickies. */
|
|
5941
|
+
const dismissTextSaving = () => {
|
|
5942
|
+
const editor = textEditor
|
|
5943
|
+
if (!editor || editor.busy) return
|
|
5944
|
+
if (String(editor.text ?? '').trim() === '') {
|
|
5945
|
+
setTextEditor(null)
|
|
5946
|
+
return
|
|
5947
|
+
}
|
|
5948
|
+
saveText()
|
|
5949
|
+
}
|
|
5950
|
+
|
|
5709
5951
|
const deleteText = async (id) => {
|
|
5710
5952
|
if (!id) return
|
|
5711
5953
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
@@ -5745,12 +5987,25 @@ window.__ModuleLoader__.load({
|
|
|
5745
5987
|
const input = document.createElement('input')
|
|
5746
5988
|
input.type = 'file'
|
|
5747
5989
|
input.accept = accept
|
|
5748
|
-
input.style.
|
|
5990
|
+
input.style.position = 'fixed'
|
|
5991
|
+
input.style.left = '-10000px'
|
|
5992
|
+
input.style.top = '0'
|
|
5993
|
+
input.style.opacity = '0'
|
|
5994
|
+
input.style.pointerEvents = 'none'
|
|
5995
|
+
// Some desktop WebViews only open the picker for an input attached to
|
|
5996
|
+
// the document, unlike Chromium's detached-input path.
|
|
5997
|
+
document.body.appendChild(input)
|
|
5998
|
+
const cleanup = () => input.remove()
|
|
5749
5999
|
input.addEventListener('change', () => {
|
|
5750
6000
|
const file = input.files?.[0]
|
|
5751
6001
|
if (file) onFile(file)
|
|
6002
|
+
cleanup()
|
|
5752
6003
|
})
|
|
6004
|
+
input.addEventListener('cancel', cleanup)
|
|
5753
6005
|
input.click()
|
|
6006
|
+
window.setTimeout(() => {
|
|
6007
|
+
if (input.isConnected) cleanup()
|
|
6008
|
+
}, 60_000)
|
|
5754
6009
|
} catch (error) {
|
|
5755
6010
|
setState((previous) => ({ ...previous, error: error?.message || String(error) }))
|
|
5756
6011
|
}
|
|
@@ -5760,7 +6015,7 @@ window.__ModuleLoader__.load({
|
|
|
5760
6015
|
setInsertMenu(false)
|
|
5761
6016
|
pickFile('.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/plain,text/markdown', (file) => {
|
|
5762
6017
|
if (file.size > 2_000_000) {
|
|
5763
|
-
setState((previous) => ({ ...previous, error: '
|
|
6018
|
+
setState((previous) => ({ ...previous, error: t('board.tableTooLarge') }))
|
|
5764
6019
|
return
|
|
5765
6020
|
}
|
|
5766
6021
|
const reader = new FileReader()
|
|
@@ -5780,7 +6035,7 @@ window.__ModuleLoader__.load({
|
|
|
5780
6035
|
error: null,
|
|
5781
6036
|
})
|
|
5782
6037
|
}
|
|
5783
|
-
reader.onerror = () => setState((previous) => ({ ...previous, error: '
|
|
6038
|
+
reader.onerror = () => setState((previous) => ({ ...previous, error: t('board.tableReadFailed') }))
|
|
5784
6039
|
reader.readAsText(file)
|
|
5785
6040
|
})
|
|
5786
6041
|
}
|
|
@@ -5788,12 +6043,12 @@ window.__ModuleLoader__.load({
|
|
|
5788
6043
|
const startImportImage = () => {
|
|
5789
6044
|
setInsertMenu(false)
|
|
5790
6045
|
pickFile('image/*', (file) => {
|
|
5791
|
-
if (!/^image\//i.test(file.type)) {
|
|
5792
|
-
setState((previous) => ({ ...previous, error: '
|
|
6046
|
+
if (!/^image\//i.test(file.type) && !/\.(png|jpe?g|gif|webp|bmp|svg|avif)$/i.test(file.name)) {
|
|
6047
|
+
setState((previous) => ({ ...previous, error: t('board.imageType') }))
|
|
5793
6048
|
return
|
|
5794
6049
|
}
|
|
5795
6050
|
if (file.size > 1_500_000) {
|
|
5796
|
-
setState((previous) => ({ ...previous, error: '
|
|
6051
|
+
setState((previous) => ({ ...previous, error: t('board.imageTooLarge') }))
|
|
5797
6052
|
return
|
|
5798
6053
|
}
|
|
5799
6054
|
const reader = new FileReader()
|
|
@@ -5813,7 +6068,7 @@ window.__ModuleLoader__.load({
|
|
|
5813
6068
|
error: null,
|
|
5814
6069
|
})
|
|
5815
6070
|
}
|
|
5816
|
-
reader.onerror = () => setState((previous) => ({ ...previous, error: '
|
|
6071
|
+
reader.onerror = () => setState((previous) => ({ ...previous, error: t('board.imageReadFailed') }))
|
|
5817
6072
|
reader.readAsDataURL(file)
|
|
5818
6073
|
})
|
|
5819
6074
|
}
|
|
@@ -5830,10 +6085,11 @@ window.__ModuleLoader__.load({
|
|
|
5830
6085
|
|
|
5831
6086
|
const saveWindow = async () => {
|
|
5832
6087
|
const editor = windowEditor
|
|
5833
|
-
if (!editor) return
|
|
6088
|
+
if (!editor || editor.busy) return
|
|
6089
|
+
setWindowEditor((current) => (current ? { ...current, busy: true, error: null } : current))
|
|
5834
6090
|
const title = String(editor.title ?? '').trim() || (editor.kind === 'table' ? '表格' : '图片')
|
|
5835
6091
|
if (editor.kind === 'image' && !editor.src) {
|
|
5836
|
-
setWindowEditor({ ...editor, error: '请先选择图片' })
|
|
6092
|
+
setWindowEditor({ ...editor, busy: false, error: '请先选择图片' })
|
|
5837
6093
|
return
|
|
5838
6094
|
}
|
|
5839
6095
|
let rows = editor.rows
|
|
@@ -5866,6 +6122,17 @@ window.__ModuleLoader__.load({
|
|
|
5866
6122
|
setWindowEditor(null)
|
|
5867
6123
|
}
|
|
5868
6124
|
|
|
6125
|
+
/** Outside-click close for the window editor: save valid content. */
|
|
6126
|
+
const dismissWindowSaving = () => {
|
|
6127
|
+
const editor = windowEditor
|
|
6128
|
+
if (!editor || editor.busy) return
|
|
6129
|
+
if (editor.kind === 'image' && !editor.src) {
|
|
6130
|
+
setWindowEditor(null)
|
|
6131
|
+
return
|
|
6132
|
+
}
|
|
6133
|
+
saveWindow()
|
|
6134
|
+
}
|
|
6135
|
+
|
|
5869
6136
|
const deleteWindow = async (id) => {
|
|
5870
6137
|
if (!id) return
|
|
5871
6138
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
@@ -6035,14 +6302,12 @@ window.__ModuleLoader__.load({
|
|
|
6035
6302
|
}
|
|
6036
6303
|
if (current.type === 'resize') {
|
|
6037
6304
|
const scale = zoomScale()
|
|
6038
|
-
const currentLayout =
|
|
6305
|
+
const currentLayout = layoutForNote(current.noteId)
|
|
6039
6306
|
const doc = currentLayout.kind === 'doc'
|
|
6040
6307
|
const width = Math.min(doc ? 1200 : 640, Math.max(doc ? 320 : 160, Math.round(current.startW + (event.clientX - current.startX) / scale)))
|
|
6041
6308
|
const height = Math.min(doc ? 900 : 560, Math.max(doc ? 200 : 120, Math.round(current.startH + (event.clientY - current.startY) / scale)))
|
|
6042
6309
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
6043
|
-
const layout =
|
|
6044
|
-
layout.width = width
|
|
6045
|
-
layout.height = height
|
|
6310
|
+
const layout = { ...currentLayout, width, height }
|
|
6046
6311
|
next.notes[current.noteId] = layout
|
|
6047
6312
|
canvasRef.current = next
|
|
6048
6313
|
setCanvas(next)
|
|
@@ -6177,11 +6442,30 @@ window.__ModuleLoader__.load({
|
|
|
6177
6442
|
stroke.points[1] = point
|
|
6178
6443
|
}
|
|
6179
6444
|
} else {
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6445
|
+
// Use every coalesced pointer sample and render at most once per
|
|
6446
|
+
// animation frame. Cloning the whole board on every pointermove
|
|
6447
|
+
// made fast strokes visibly chunky.
|
|
6448
|
+
const scale = zoomScale()
|
|
6449
|
+
const samples =
|
|
6450
|
+
typeof event.getCoalescedEvents === 'function' ? event.getCoalescedEvents() : [event]
|
|
6451
|
+
for (const sample of samples.length > 0 ? samples : [event]) {
|
|
6452
|
+
if (stroke.points.length >= 800) break
|
|
6453
|
+
const samplePoint = [
|
|
6454
|
+
Math.round((sample.clientX - current.rect.left) / scale),
|
|
6455
|
+
Math.round((sample.clientY - current.rect.top) / scale),
|
|
6456
|
+
]
|
|
6457
|
+
const last = stroke.points[stroke.points.length - 1]
|
|
6458
|
+
if (last && last[0] === samplePoint[0] && last[1] === samplePoint[1]) continue
|
|
6459
|
+
stroke.points.push(samplePoint)
|
|
6460
|
+
}
|
|
6184
6461
|
current.lastWorld = [event.clientX, event.clientY]
|
|
6462
|
+
if (!current.renderFrame) {
|
|
6463
|
+
current.renderFrame = window.requestAnimationFrame(() => {
|
|
6464
|
+
current.renderFrame = 0
|
|
6465
|
+
setCanvas({ ...canvasRef.current })
|
|
6466
|
+
})
|
|
6467
|
+
}
|
|
6468
|
+
return
|
|
6185
6469
|
}
|
|
6186
6470
|
const next = cloneBoardCanvas(canvasRef.current)
|
|
6187
6471
|
if (current.layer === 'background') {
|
|
@@ -6204,6 +6488,10 @@ window.__ModuleLoader__.load({
|
|
|
6204
6488
|
window.removeEventListener('pointercancel', finish)
|
|
6205
6489
|
const current = gestureRef.current
|
|
6206
6490
|
gestureRef.current = null
|
|
6491
|
+
if (current && current.renderFrame) {
|
|
6492
|
+
window.cancelAnimationFrame(current.renderFrame)
|
|
6493
|
+
current.renderFrame = 0
|
|
6494
|
+
}
|
|
6207
6495
|
if (current && current.type === 'link') {
|
|
6208
6496
|
setLinkPreview(null)
|
|
6209
6497
|
const under = event ? layerAt(event) : null
|
|
@@ -6242,6 +6530,9 @@ window.__ModuleLoader__.load({
|
|
|
6242
6530
|
|
|
6243
6531
|
const beginPointer = (event) => {
|
|
6244
6532
|
if (event.button !== 0) return
|
|
6533
|
+
if (insertMenu) setInsertMenu(false)
|
|
6534
|
+
if (clearMenu) setClearMenu(false)
|
|
6535
|
+
if (shapeMenu) setShapeMenu(false)
|
|
6245
6536
|
if (event.target?.closest?.('button') || event.target?.closest?.('.tb-sticky-linkline') || event.target?.closest?.('.tb-sticky-actions')) return
|
|
6246
6537
|
const stage = stageRef.current
|
|
6247
6538
|
if (!stage) return
|
|
@@ -6304,7 +6595,7 @@ window.__ModuleLoader__.load({
|
|
|
6304
6595
|
event.preventDefault()
|
|
6305
6596
|
if (!noteId) return
|
|
6306
6597
|
const localPoint = stagePoint(event)
|
|
6307
|
-
const layout =
|
|
6598
|
+
const layout = layoutForNote(noteId)
|
|
6308
6599
|
const anchorElement = event.target?.closest?.('.tb-anchor')
|
|
6309
6600
|
const anchor = anchorElement?.getAttribute?.('data-anchor') || nearestBoardAnchor(layout, localPoint)
|
|
6310
6601
|
setLinkPreview({ fromNoteId: noteId, fromAnchor: anchor, pointer: localPoint, targetNoteId: '', targetAnchor: '' })
|
|
@@ -6315,7 +6606,7 @@ window.__ModuleLoader__.load({
|
|
|
6315
6606
|
event.preventDefault()
|
|
6316
6607
|
event.stopPropagation()
|
|
6317
6608
|
setSelected(noteId)
|
|
6318
|
-
const layout =
|
|
6609
|
+
const layout = layoutForNote(noteId)
|
|
6319
6610
|
const size = noteSize(layout)
|
|
6320
6611
|
setGesture({
|
|
6321
6612
|
type: 'resize',
|
|
@@ -6343,7 +6634,7 @@ window.__ModuleLoader__.load({
|
|
|
6343
6634
|
}
|
|
6344
6635
|
event.preventDefault()
|
|
6345
6636
|
setSelected(noteId)
|
|
6346
|
-
const layout =
|
|
6637
|
+
const layout = layoutForNote(noteId)
|
|
6347
6638
|
setGesture({
|
|
6348
6639
|
type: 'drag',
|
|
6349
6640
|
noteId,
|
|
@@ -6701,7 +6992,10 @@ window.__ModuleLoader__.load({
|
|
|
6701
6992
|
type: 'button',
|
|
6702
6993
|
className: `tb-tool${insertMenu ? ' on' : ''}`,
|
|
6703
6994
|
title: t('board.insertHint'),
|
|
6704
|
-
onClick: () =>
|
|
6995
|
+
onClick: () => {
|
|
6996
|
+
setClearMenu(false)
|
|
6997
|
+
setInsertMenu((value) => !value)
|
|
6998
|
+
},
|
|
6705
6999
|
},
|
|
6706
7000
|
`+ ${t('board.insert')}`,
|
|
6707
7001
|
),
|
|
@@ -6861,9 +7155,59 @@ window.__ModuleLoader__.load({
|
|
|
6861
7155
|
),
|
|
6862
7156
|
h('span', { style: { flex: 1 } }),
|
|
6863
7157
|
h('button', { type: 'button', className: 'tb-btn', onClick: autoFit }, t('board.center')),
|
|
6864
|
-
h(
|
|
6865
|
-
|
|
6866
|
-
|
|
7158
|
+
h(
|
|
7159
|
+
'div',
|
|
7160
|
+
{ className: 'tb-window-insert' },
|
|
7161
|
+
h(
|
|
7162
|
+
'button',
|
|
7163
|
+
{
|
|
7164
|
+
type: 'button',
|
|
7165
|
+
className: `tb-btn${clearMenu ? ' on' : ''}`,
|
|
7166
|
+
title: t('board.clearHint'),
|
|
7167
|
+
onClick: () => {
|
|
7168
|
+
setInsertMenu(false)
|
|
7169
|
+
setClearMenu((value) => !value)
|
|
7170
|
+
},
|
|
7171
|
+
},
|
|
7172
|
+
`🧹 ${t('board.clear')}`,
|
|
7173
|
+
),
|
|
7174
|
+
clearMenu
|
|
7175
|
+
? h(
|
|
7176
|
+
'div',
|
|
7177
|
+
{ className: 'tb-shape-menu tb-clear-menu', role: 'menu' },
|
|
7178
|
+
h(
|
|
7179
|
+
'button',
|
|
7180
|
+
{ type: 'button', role: 'menuitem', disabled: canvas.background.length === 0, onClick: () => { setClearMenu(false); clearBackground() } },
|
|
7181
|
+
t('board.clearBg'),
|
|
7182
|
+
),
|
|
7183
|
+
h(
|
|
7184
|
+
'button',
|
|
7185
|
+
{
|
|
7186
|
+
type: 'button',
|
|
7187
|
+
role: 'menuitem',
|
|
7188
|
+
disabled: (canvas.edges ?? []).length === 0,
|
|
7189
|
+
onClick: () => {
|
|
7190
|
+
setClearMenu(false)
|
|
7191
|
+
const next = cloneBoardCanvas(canvasRef.current)
|
|
7192
|
+
next.edges = []
|
|
7193
|
+
saveCanvasSoon(next)
|
|
7194
|
+
},
|
|
7195
|
+
},
|
|
7196
|
+
t('board.clearEdges'),
|
|
7197
|
+
),
|
|
7198
|
+
h(
|
|
7199
|
+
'button',
|
|
7200
|
+
{
|
|
7201
|
+
type: 'button',
|
|
7202
|
+
role: 'menuitem',
|
|
7203
|
+
disabled: !selected || !(canvas.drawings[selected]?.length > 0),
|
|
7204
|
+
onClick: () => { setClearMenu(false); clearSelectedDrawing() },
|
|
7205
|
+
},
|
|
7206
|
+
t('board.clearNote'),
|
|
7207
|
+
),
|
|
7208
|
+
)
|
|
7209
|
+
: null,
|
|
7210
|
+
),
|
|
6867
7211
|
)
|
|
6868
7212
|
|
|
6869
7213
|
return h(
|
|
@@ -6876,7 +7220,6 @@ window.__ModuleLoader__.load({
|
|
|
6876
7220
|
h('span', { className: 'tb-board-sub' }, t('board.subtitle')),
|
|
6877
7221
|
h('span', { style: { flex: 1 } }),
|
|
6878
7222
|
h('span', { className: 'tb-muted tb-small' }, format(t('board.count'), { count: entries.length, version: boardVersion })),
|
|
6879
|
-
h('span', { className: 'tb-muted tb-small' }, format(t('board.canvasVersion'), { version: boardVersion })),
|
|
6880
7223
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomOut'), onClick: () => zoomBy(1 / 1.2) }, '−'),
|
|
6881
7224
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomReset'), onClick: () => zoomBy(1 / zoomRef.current) }, `${Math.round(zoom * 100)}%`),
|
|
6882
7225
|
h('button', { type: 'button', className: 'tb-tool', title: t('board.zoomIn'), onClick: () => zoomBy(1.2) }, '+'),
|
|
@@ -7202,7 +7545,7 @@ window.__ModuleLoader__.load({
|
|
|
7202
7545
|
textEditor
|
|
7203
7546
|
? h(
|
|
7204
7547
|
'div',
|
|
7205
|
-
{ className: 'tb-overlay center', onClick:
|
|
7548
|
+
{ className: 'tb-overlay center', onClick: dismissTextSaving },
|
|
7206
7549
|
h(
|
|
7207
7550
|
'div',
|
|
7208
7551
|
{
|
|
@@ -7285,8 +7628,8 @@ window.__ModuleLoader__.load({
|
|
|
7285
7628
|
h(
|
|
7286
7629
|
'div',
|
|
7287
7630
|
{ className: 'tb-note-actions' },
|
|
7288
|
-
h('button', { type: 'button', className: 'tb-btn', onClick: () => setTextEditor(null) }, t('board.cancel')),
|
|
7289
|
-
h('button', { type: 'button', className: 'tb-btn primary', onClick: saveText }, t('board.save')),
|
|
7631
|
+
h('button', { type: 'button', className: 'tb-btn', disabled: textEditor.busy === true, onClick: () => setTextEditor(null) }, t('board.cancel')),
|
|
7632
|
+
h('button', { type: 'button', className: 'tb-btn primary', disabled: textEditor.busy === true, onClick: saveText }, t('board.save')),
|
|
7290
7633
|
),
|
|
7291
7634
|
),
|
|
7292
7635
|
)
|
|
@@ -7294,7 +7637,7 @@ window.__ModuleLoader__.load({
|
|
|
7294
7637
|
windowEditor
|
|
7295
7638
|
? h(
|
|
7296
7639
|
'div',
|
|
7297
|
-
{ className: 'tb-overlay center', onClick:
|
|
7640
|
+
{ className: 'tb-overlay center', onClick: dismissWindowSaving },
|
|
7298
7641
|
h(
|
|
7299
7642
|
'div',
|
|
7300
7643
|
{
|
|
@@ -7376,12 +7719,12 @@ window.__ModuleLoader__.load({
|
|
|
7376
7719
|
}
|
|
7377
7720
|
pickFile('.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/plain,text/markdown', (file) => {
|
|
7378
7721
|
if (file.size > 2_000_000) {
|
|
7379
|
-
setWindowEditor((current) => (current ? { ...current, error: '
|
|
7722
|
+
setWindowEditor((current) => (current ? { ...current, error: t('board.tableTooLarge') } : current))
|
|
7380
7723
|
return
|
|
7381
7724
|
}
|
|
7382
7725
|
const reader = new FileReader()
|
|
7383
7726
|
reader.onload = () => applyRows(String(reader.result ?? ''), file.name)
|
|
7384
|
-
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: '
|
|
7727
|
+
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: t('board.tableReadFailed') } : current))
|
|
7385
7728
|
reader.readAsText(file)
|
|
7386
7729
|
})
|
|
7387
7730
|
},
|
|
@@ -7426,8 +7769,11 @@ window.__ModuleLoader__.load({
|
|
|
7426
7769
|
className: 'tb-btn',
|
|
7427
7770
|
onClick: () => {
|
|
7428
7771
|
pickFile('image/*', (file) => {
|
|
7429
|
-
|
|
7430
|
-
|
|
7772
|
+
const imageType = /^image\//i.test(file.type) || /\.(png|jpe?g|gif|webp|bmp|svg|avif)$/i.test(file.name)
|
|
7773
|
+
if (!imageType || file.size > 1_500_000) {
|
|
7774
|
+
setWindowEditor((current) =>
|
|
7775
|
+
current ? { ...current, error: imageType ? t('board.imageTooLarge') : t('board.imageType') } : current,
|
|
7776
|
+
)
|
|
7431
7777
|
return
|
|
7432
7778
|
}
|
|
7433
7779
|
const reader = new FileReader()
|
|
@@ -7435,7 +7781,7 @@ window.__ModuleLoader__.load({
|
|
|
7435
7781
|
setWindowEditor((current) =>
|
|
7436
7782
|
current ? { ...current, src: String(reader.result ?? ''), alt: file.name } : current,
|
|
7437
7783
|
)
|
|
7438
|
-
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: '
|
|
7784
|
+
reader.onerror = () => setWindowEditor((current) => (current ? { ...current, error: t('board.imageReadFailed') } : current))
|
|
7439
7785
|
reader.readAsDataURL(file)
|
|
7440
7786
|
})
|
|
7441
7787
|
},
|
|
@@ -7448,8 +7794,8 @@ window.__ModuleLoader__.load({
|
|
|
7448
7794
|
h(
|
|
7449
7795
|
'div',
|
|
7450
7796
|
{ className: 'tb-note-actions' },
|
|
7451
|
-
h('button', { type: 'button', className: 'tb-btn', onClick: () => setWindowEditor(null) }, t('board.cancel')),
|
|
7452
|
-
h('button', { type: 'button', className: 'tb-btn primary', onClick: saveWindow }, t('board.save')),
|
|
7797
|
+
h('button', { type: 'button', className: 'tb-btn', disabled: windowEditor.busy === true, onClick: () => setWindowEditor(null) }, t('board.cancel')),
|
|
7798
|
+
h('button', { type: 'button', className: 'tb-btn primary', disabled: windowEditor.busy === true, onClick: saveWindow }, t('board.save')),
|
|
7453
7799
|
),
|
|
7454
7800
|
),
|
|
7455
7801
|
)
|
|
@@ -7464,6 +7810,7 @@ window.__ModuleLoader__.load({
|
|
|
7464
7810
|
window.__TIMEBACK_TEST__.renderMarkdown = renderMarkdown
|
|
7465
7811
|
window.__TIMEBACK_TEST__.stripMarkdown = stripMarkdown
|
|
7466
7812
|
window.__TIMEBACK_TEST__.boardEdgePath = boardEdgePath
|
|
7813
|
+
window.__TIMEBACK_TEST__.smoothStrokePath = smoothStrokePath
|
|
7467
7814
|
window.__TIMEBACK_TEST__.MarkdownEditor = MarkdownEditor
|
|
7468
7815
|
window.__TIMEBACK_TEST__.WorkspacePathSelector = WorkspacePathSelector
|
|
7469
7816
|
window.__TIMEBACK_TEST__.markdownToEditorHtml = markdownToEditorHtml
|
package/docs/MARKET.md
CHANGED
|
@@ -78,12 +78,12 @@ dshmarket;要让所有人的 dshmarket 搜到,必须走下一节的公共目
|
|
|
78
78
|
|
|
79
79
|
## 4. npm(已发布 0.6.0)
|
|
80
80
|
|
|
81
|
-
`dsh-timeback@0.7.
|
|
81
|
+
`dsh-timeback@0.7.10` 已发布到官方 npm(<https://www.npmjs.com/package/dsh-timeback>),
|
|
82
82
|
用户可以直接安装/固定版本:
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
85
|
dsh plugin --profile web add dsh-timeback
|
|
86
|
-
dsh plugin --profile web add dsh-timeback@0.7.
|
|
86
|
+
dsh plugin --profile web add dsh-timeback@0.7.10
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
awesome 目录 CI 会从 npm 自动补充映射,之后市场安装和更新会走 registry。发布流程参考:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-timeback",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"description": "Conversation tree with per-turn workspace snapshots for DeepSeek Harness: branch at any checkpoint and restore the files that turn had.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|