dsh-vscode-mode 0.29.2 → 0.31.0
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 +120 -11
- package/lib/client.js +178 -51
- package/lib/client.js.map +1 -1
- package/lib/index.js +4860 -1576
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/dsh-vscodemode-html-plan/LICENSE +202 -0
- package/skills/dsh-vscodemode-html-plan/SKILL.md +147 -0
- package/skills/dsh-vscodemode-html-plan/examples/scheduled-send.html +298 -0
- package/skills/dsh-vscodemode-html-plan/references/blocks.md +227 -0
- package/skills/dsh-vscodemode-html-plan/references/subagent-brief.md +17 -0
- package/skills/dsh-vscodemode-html-plan/references/upstream-SKILL.md +174 -0
- package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.css +564 -0
- package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.js +1299 -0
- package/skills/dsh-vscodemode-html-plan/runtime/pack.mjs +300 -0
- package/src/ai/llmTask.ts +178 -0
- package/src/ai/llmTypes.ts +6 -0
- package/src/ai/svnCommitMsg.ts +107 -0
- package/src/ai/svnTriage.ts +34 -85
- package/src/client/aiCommit.ts +57 -0
- package/src/client/compatSummary.ts +15 -0
- package/src/client/editorFlush.ts +55 -0
- package/src/client/featurePrefs.ts +63 -0
- package/src/client/htmlPlan/HtmlPlanPanel.ts +261 -0
- package/src/client/htmlPlan/planActions.ts +347 -0
- package/src/client/htmlPlan/planPage.ts +333 -0
- package/src/client/htmlPreview.ts +218 -0
- package/src/client/index.ts +43 -0
- package/src/client/monaco/loader.ts +71 -9
- package/src/client/monaco/templateLanguages.ts +300 -0
- package/src/client/officialSidebar.ts +16 -4
- package/src/client/openPathRouter.ts +7 -0
- package/src/client/planState.ts +8 -2
- package/src/client/refCopy.ts +70 -0
- package/src/client/refIntake.ts +215 -0
- package/src/client/sidebar/menuItems.ts +11 -0
- package/src/client/sidebar/panels/FileExplorer.ts +11 -0
- package/src/client/sidebar/panels/SearchPanel.ts +214 -4
- package/src/client/sidebar/panels/SvnPanel.ts +17 -0
- package/src/client/sidebar/types.ts +2 -0
- package/src/client/styles/editor.css +112 -0
- package/src/client/svnActions.ts +7 -0
- package/src/client/svnCommit.ts +109 -0
- package/src/client/svnNotice.ts +1 -1
- package/src/client/svnStatus.ts +5 -2
- package/src/client/ui/DiffLauncher.ts +3 -1
- package/src/client/ui/EditorView.ts +221 -14
- package/src/client/ui/McpSettings.ts +108 -1
- package/src/client/ui/SvnAiPlanDialog.ts +24 -4
- package/src/client/ui/SvnCommitDialog.ts +458 -0
- package/src/client/ui/commandCatalog.ts +11 -0
- package/src/client/ui/svnCommitModel.ts +204 -0
- package/src/client/univer/UniverCacheSettings.ts +75 -0
- package/src/client/univer/UniverHost.ts +177 -0
- package/src/client/univer/api.ts +30 -0
- package/src/client/univer/routing.ts +32 -0
- package/src/client/univer/store.ts +111 -0
- package/src/fileOpenSettings.ts +118 -6
- package/src/htmlPlanCommand.ts +176 -0
- package/src/index.ts +4 -0
- package/src/paths.ts +5 -0
- package/src/refPointer.ts +193 -0
- package/src/rpc.ts +51 -0
- package/src/search/replacePlan.ts +144 -0
- package/src/search/replaceRun.ts +289 -0
- package/src/shared/keybindings.ts +11 -0
- package/src/shared/refSyntax.ts +106 -0
- package/src/shared/rpc.ts +28 -4
- package/src/shared/snippets.ts +17 -0
- package/src/shared/svn.ts +191 -10
- package/src/shared/svnActions.ts +16 -0
- package/src/shared/univer.ts +90 -0
- package/src/svn.ts +205 -47
- package/src/svnCommit.ts +348 -0
- package/src/svnCore.ts +254 -0
- package/src/svnToolJson.ts +73 -0
- package/src/svnTools.ts +566 -0
- package/src/univerBridge.ts +83 -0
- package/src/univerCache.ts +205 -0
- package/src/univerRpc.ts +144 -0
|
@@ -31,12 +31,21 @@ import { reviewRegions } from '../../shared/reviewRegions.js'
|
|
|
31
31
|
import { PENDING_PREFIX } from '../../shared/pendingReview.js'
|
|
32
32
|
import { coveredPathKeys, diffPathKey, diffSummary, reviewPathOf } from '../state/diffSummary.js'
|
|
33
33
|
import { emitFileChanged, emitRefresh } from '../events.js'
|
|
34
|
+
import { handleCopyAsRef } from '../refCopy.js'
|
|
35
|
+
import { attachRefIntake } from '../refIntake.js'
|
|
36
|
+
import { featurePrefs } from '../featurePrefs.js'
|
|
37
|
+
import { FLUSH_ALL_EVENT } from '../editorFlush.js'
|
|
34
38
|
import { langOf, loadMonaco, snippetLanguageOf } from '../monaco/loader.js'
|
|
35
39
|
import { bindEditActions, runEditAction } from '../monaco/editActions.js'
|
|
36
40
|
import { addReloadGuard } from '../pageReload.js'
|
|
37
41
|
import { clampZoom, clearZoomMem, dataUrlOf, isImagePath, isSvgPath, recallZoom, rememberZoom, zoomKeyOf, zoomStepOf } from '../imagePreview.js'
|
|
38
42
|
import { isMarkdownPath } from '../markdownPreview.js'
|
|
43
|
+
import { hasOfficialHtmlPreview, isHtmlPath } from '../htmlPreview.js'
|
|
44
|
+
import { HtmlPlanPanel } from '../htmlPlan/HtmlPlanPanel.js'
|
|
39
45
|
import { isExcelPath } from '../excel/model.js'
|
|
46
|
+
import { isUniverPath, isOfficePath } from '../../shared/univer.js'
|
|
47
|
+
import { routesUniver } from '../univer/routing.js'
|
|
48
|
+
import { UniverHost, useUniver } from '../univer/UniverHost.js'
|
|
40
49
|
import { excelState, loadExcel, allowClose, releaseExcel, renameExcel, unsafeExcel, notifyExcel } from '../excel/controller.js'
|
|
41
50
|
import { ExcelHost } from '../excel/ExcelHost.js'
|
|
42
51
|
import { setActiveEditorPath } from '../activePathStore.js'
|
|
@@ -120,6 +129,7 @@ import { promptName } from './PromptDialog.js'
|
|
|
120
129
|
import { openWithDialog } from '../openWithDialog.js'
|
|
121
130
|
import { copyText as copyClipText } from '../copyText.js'
|
|
122
131
|
import { SvnLogDialog } from './SvnLogDialog.js'
|
|
132
|
+
import { SvnCommitDialog } from './SvnCommitDialog.js'
|
|
123
133
|
import { SvnUpdateDialog } from './SvnUpdateDialog.js'
|
|
124
134
|
import { sameUpdateOwner, updateDone } from './svnUpdateModel.js'
|
|
125
135
|
import { IconRefreshOutline16 } from './icons.js'
|
|
@@ -378,6 +388,7 @@ export function EditorView(props) {
|
|
|
378
388
|
const [svnLogData, setSvnLogData] = React.useState(null) // 日志条目(null=未加载)
|
|
379
389
|
const [svnLogBusy, setSvnLogBusy] = React.useState(false) // 日志在途
|
|
380
390
|
const [svnLogError, setSvnLogError] = React.useState('') // 日志错误文案
|
|
391
|
+
const [commitSeed, setCommitSeed] = React.useState(null) // 提交对话框 { paths?, message? }(null=关闭)
|
|
381
392
|
const [svnLogWcRev, setSvnLogWcRev] = React.useState(null) // P1-9:文件目标的工作副本版号(null = 不加粗)
|
|
382
393
|
const [dlogOpen, setDlogOpen] = React.useState(false) // 诊断日志弹窗(自取数据,null 语义无需状态层)
|
|
383
394
|
const [svnUpdateDialog, setSvnUpdateDialog] = React.useState(null) // {path,sessionId,scope,resumeJobId?};窗口内自取增量
|
|
@@ -640,8 +651,18 @@ export function EditorView(props) {
|
|
|
640
651
|
const isImageActive = !!active && isImagePath(active) && !svgTextRef.current.has(active)
|
|
641
652
|
// 当前 tab 是否为 PDF 面板(与 loadContent 分派条件同源)
|
|
642
653
|
const isPdfActive = !!active && isPdfPath(active)
|
|
654
|
+
const univer = useUniver(sessionId ?? '')
|
|
655
|
+
const [officeFallback, setOfficeFallback] = React.useState(new Set())
|
|
656
|
+
const [officeExplicit, setOfficeExplicit] = React.useState(new Set())
|
|
657
|
+
/** @private @author ddj 2026年11月12号 @param path File identity. @returns Optional Office route without taking ownership of existing dirty Excel buffers. */
|
|
658
|
+
function useOffice(path) {
|
|
659
|
+
if (isUniverPath(path)) return true
|
|
660
|
+
const offered = routesUniver(path, univer.capability) || (officeExplicit.has(path) && univer.capability?.available)
|
|
661
|
+
return offered && !officeFallback.has(path) && !(isExcelPath(path) && excelState(JSON.stringify([scope, sessionId]), path).dirty)
|
|
662
|
+
}
|
|
663
|
+
const isUniverActive = !!active && useOffice(active)
|
|
643
664
|
const excelScope = JSON.stringify([scope, sessionId])
|
|
644
|
-
const isExcelActive = !!active && isExcelPath(active)
|
|
665
|
+
const isExcelActive = !!active && isExcelPath(active) && !isUniverActive
|
|
645
666
|
|
|
646
667
|
React.useEffect(() => {
|
|
647
668
|
/** @private @author ddj 2026年10月28号 @param event Browser exit. @sideEffects Warns on all retained sessions; never silently saves or discards. */
|
|
@@ -660,6 +681,7 @@ export function EditorView(props) {
|
|
|
660
681
|
}, [excelScope, active, isExcelActive])
|
|
661
682
|
// 当前 tab 是否为可预览的 Markdown,以及是否正处于预览态(预览态替换 Monaco host,只读)
|
|
662
683
|
const isMdActive = !!active && isMarkdownPath(active)
|
|
684
|
+
const isHtmlActive = !!active && isHtmlPath(active)
|
|
663
685
|
const mdPreviewing = isMdActive && mdPreviewRef.current.has(active)
|
|
664
686
|
const regions = React.useMemo(() => {
|
|
665
687
|
// #region debug log
|
|
@@ -1256,6 +1278,13 @@ export function EditorView(props) {
|
|
|
1256
1278
|
clearSync(scope, path)
|
|
1257
1279
|
if (markRead === true) clearReadVersion(scope, path)
|
|
1258
1280
|
}
|
|
1281
|
+
if (useOffice(path)) {
|
|
1282
|
+
setContent('')
|
|
1283
|
+
setContentPath(path)
|
|
1284
|
+
stampLoad(path, sid, seq)
|
|
1285
|
+
setStatus('Univer 文档 · 查看与审阅')
|
|
1286
|
+
return
|
|
1287
|
+
}
|
|
1259
1288
|
if (isExcelPath(path)) {
|
|
1260
1289
|
const state = excelState(excelScope, path)
|
|
1261
1290
|
void loadExcel(state, async () => {
|
|
@@ -1274,6 +1303,10 @@ export function EditorView(props) {
|
|
|
1274
1303
|
}).catch((error) => { if (loadCurrent(path, seq)) failLoad(path, sid, seq, String(error)) })
|
|
1275
1304
|
return
|
|
1276
1305
|
}
|
|
1306
|
+
if (isOfficePath(path)) {
|
|
1307
|
+
failLoad(path, sid, seq, 'Office 二进制文件不能作为文本读取;请使用其他打开方式')
|
|
1308
|
+
return
|
|
1309
|
+
}
|
|
1277
1310
|
// 图片文件走专用通道:base64 → data URL 预览,不建 Monaco model、不进文本/差异流程
|
|
1278
1311
|
if (isImagePath(path) && !svgTextRef.current.has(path)) {
|
|
1279
1312
|
loadImage(path, sid, seq, version)
|
|
@@ -1537,7 +1570,7 @@ export function EditorView(props) {
|
|
|
1537
1570
|
* @returns 比对结果;模型不可用/读失败 → null(按「需要重载」处理)
|
|
1538
1571
|
*/
|
|
1539
1572
|
function readDiskCompare(path) {
|
|
1540
|
-
if (isExcelPath(path)) return Promise.resolve({ equal: false })
|
|
1573
|
+
if (isExcelPath(path) || useOffice(path)) return Promise.resolve({ equal: false })
|
|
1541
1574
|
// A read-only page has no full Monaco buffer to compare. Acknowledge the observed
|
|
1542
1575
|
// version as changed so polling advances its baseline instead of invalidating every reread.
|
|
1543
1576
|
if (path === activeRef.current && (paging || pageChanged === pageIdentity)) return Promise.resolve({ equal: false })
|
|
@@ -1626,6 +1659,11 @@ export function EditorView(props) {
|
|
|
1626
1659
|
// G9:入口统一归一为工作区相对路径(差异栏/对话链接/LSP 跳转等都经此事件)
|
|
1627
1660
|
const normalized = tabPath(p)
|
|
1628
1661
|
if (!normalized) return
|
|
1662
|
+
if (e?.detail?.univer === true && (!e.detail.sessionId || e.detail.sessionId === sessionId)) {
|
|
1663
|
+
flushSave()
|
|
1664
|
+
setOfficeExplicit((previous) => new Set([...previous, normalized]))
|
|
1665
|
+
setOfficeFallback((previous) => { const next = new Set(previous); next.delete(normalized); return next })
|
|
1666
|
+
}
|
|
1629
1667
|
if (e?.detail?.focusDiff === true) {
|
|
1630
1668
|
recordNav()
|
|
1631
1669
|
pendingFocusRef.current = { path: normalized, region: null }
|
|
@@ -2049,6 +2087,7 @@ export function EditorView(props) {
|
|
|
2049
2087
|
if (!isMarkdownPath(path)) { setStatus('当前文件不是 Markdown'); return }
|
|
2050
2088
|
toggleMdPreviewRef.current?.(path)
|
|
2051
2089
|
}],
|
|
2090
|
+
['edrv.command.previewHtml', () => { previewHtmlOf(activeRef.current) }],
|
|
2052
2091
|
['edrv.command.navigateBack', () => navBackRef.current?.()],
|
|
2053
2092
|
['edrv.command.navigateForward', () => navForwardRef.current?.()],
|
|
2054
2093
|
['edrv.command.nextTab', () => cycleTabRef.current?.(1)],
|
|
@@ -2088,6 +2127,7 @@ export function EditorView(props) {
|
|
|
2088
2127
|
['edrv.command.svnDiffBase', () => runSvnDiffBase(activeRef.current)],
|
|
2089
2128
|
['edrv.command.svnAdd', () => runSvnAdd(activeRef.current)],
|
|
2090
2129
|
['edrv.command.svnRevertCli', () => runSvnRevertCli(activeRef.current)],
|
|
2130
|
+
['edrv.command.svnCommit', () => openSvnCommit({ paths: activeRef.current ? [activeRef.current] : [] })],
|
|
2091
2131
|
['edrv.command.svnLog', () => openSvnLog(activeRef.current || undefined)],
|
|
2092
2132
|
['edrv.command.svnCreatePatch', () => runSvnAction(SVN_ACTION_BY_ID['create-patch'], {
|
|
2093
2133
|
sessionId,
|
|
@@ -2183,7 +2223,7 @@ export function EditorView(props) {
|
|
|
2183
2223
|
setLoadStage({ progress: 10, message: '准备读取文件…' })
|
|
2184
2224
|
setStatus('加载中…')
|
|
2185
2225
|
loadContent(active, sessionId)
|
|
2186
|
-
}, [active, sessionId])
|
|
2226
|
+
}, [active, sessionId, isUniverActive])
|
|
2187
2227
|
|
|
2188
2228
|
/**
|
|
2189
2229
|
* 切换焦点分组时同步重置内容状态(与 setWorkbench 同批渲染)。
|
|
@@ -2314,6 +2354,7 @@ export function EditorView(props) {
|
|
|
2314
2354
|
openSvnDiff: (p) => runSvnDiffBase(p),
|
|
2315
2355
|
openSvnLocalPair: runSvnDiffLocalPair,
|
|
2316
2356
|
openSvnLog: (p) => openSvnLog(p ?? relPath),
|
|
2357
|
+
openCommitDialog: (seed) => openSvnCommit(seed),
|
|
2317
2358
|
refreshChanges: () => refreshSvnChanges(sessionId, scope),
|
|
2318
2359
|
})
|
|
2319
2360
|
},
|
|
@@ -2366,7 +2407,7 @@ export function EditorView(props) {
|
|
|
2366
2407
|
if (!path) return Promise.resolve(false)
|
|
2367
2408
|
if (modelsRef.current.get(path)) return Promise.resolve(true)
|
|
2368
2409
|
// 图片/PDF 不建文本 model(各自走预览控件),预热对它们没有意义
|
|
2369
|
-
if (isExcelPath(path) || isImagePath(path) || isPdfPath(path)) return Promise.resolve(false)
|
|
2410
|
+
if (useOffice(path) || isExcelPath(path) || isImagePath(path) || isPdfPath(path)) return Promise.resolve(false)
|
|
2370
2411
|
const sid = sessionId
|
|
2371
2412
|
if (!sid) return Promise.resolve(false)
|
|
2372
2413
|
|
|
@@ -2402,6 +2443,77 @@ export function EditorView(props) {
|
|
|
2402
2443
|
return true
|
|
2403
2444
|
}
|
|
2404
2445
|
|
|
2446
|
+
/**
|
|
2447
|
+
* 提交全部待保存内容(全局替换前置动作;见 editorFlush.ts 的成因说明)。
|
|
2448
|
+
* 不依赖 active:遍历所有文档存储各自 flush,再补一次活动页签的防抖槽。
|
|
2449
|
+
* @author ddj 2026年11月15号
|
|
2450
|
+
* @returns 全部落盘完成的 promise(单个文档失败不阻塞其他文档)
|
|
2451
|
+
*/
|
|
2452
|
+
const flushAllDocuments = () => {
|
|
2453
|
+
saveTimerRef.current?.flush()
|
|
2454
|
+
const tasks = []
|
|
2455
|
+
for (const store of docStores.current.values()) {
|
|
2456
|
+
try { tasks.push(Promise.resolve(store.flush?.()).catch(() => {})) } catch (error) { /* 单文档异常不阻塞 */ }
|
|
2457
|
+
}
|
|
2458
|
+
return Promise.all(tasks).then(() => undefined)
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
// 外部(搜索面板的全局替换)要求落盘时必须能等到真正写完,否则会用旧内容覆盖磁盘。
|
|
2462
|
+
React.useEffect(() => {
|
|
2463
|
+
/** @private @author ddj 2026年11月15号 @description 把本编辑器的落盘 promise 注册给请求方 */
|
|
2464
|
+
const onFlush = (event) => {
|
|
2465
|
+
const detail = event?.detail
|
|
2466
|
+
if (!detail || typeof detail.register !== 'function') return
|
|
2467
|
+
detail.register('editor:' + String(sessionId ?? ''), flushAllDocuments())
|
|
2468
|
+
}
|
|
2469
|
+
window.addEventListener(FLUSH_ALL_EVENT, onFlush)
|
|
2470
|
+
return () => window.removeEventListener(FLUSH_ALL_EVENT, onFlush)
|
|
2471
|
+
// flushAllDocuments 只读 ref,闭包无陈旧状态
|
|
2472
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2473
|
+
}, [])
|
|
2474
|
+
|
|
2475
|
+
// 引用接入:拖文件 / 粘贴文件 / 粘贴 @路径 落成对话引用 chip(composer 内才生效)。
|
|
2476
|
+
React.useEffect(() => {
|
|
2477
|
+
if (!addToConversation) return undefined
|
|
2478
|
+
let disposed = false
|
|
2479
|
+
/** @private @author ddj 2026年11月15号 @description 路径片段交给 host 解析成工作区相对路径 */
|
|
2480
|
+
const resolveRef = async (ref, activePathValue) => {
|
|
2481
|
+
try {
|
|
2482
|
+
const body = { sessionId, ref, ...(activePathValue ? { activePath: activePathValue } : {}) }
|
|
2483
|
+
const res = await rpc('edrv.resolveRef', body)
|
|
2484
|
+
if (disposed) return { ok: false }
|
|
2485
|
+
return res && typeof res === 'object' ? res : { ok: false }
|
|
2486
|
+
} catch (error) {
|
|
2487
|
+
return { ok: false, error: String(error) }
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
const detach = attachRefIntake({
|
|
2491
|
+
sessionId: () => sessionId,
|
|
2492
|
+
activePath: () => activeRef.current ?? null,
|
|
2493
|
+
appendReference: (targetSession, path, range) => addToConversation.appendReference(targetSession, path, range),
|
|
2494
|
+
appendText: (targetSession, text) => addToConversation.appendText(targetSession, text),
|
|
2495
|
+
resolve: resolveRef,
|
|
2496
|
+
notify: (text) => setStatus(text),
|
|
2497
|
+
})
|
|
2498
|
+
return () => { disposed = true; detach() }
|
|
2499
|
+
// 依赖 sessionId:换会话要重新绑定到新会话的输入框
|
|
2500
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2501
|
+
}, [sessionId])
|
|
2502
|
+
|
|
2503
|
+
// 复制选区 → 会话引用文本:只在编辑器根节点内拦截(终端/输入框/其他插件不受影响)。
|
|
2504
|
+
React.useEffect(() => {
|
|
2505
|
+
const host = viewRootRef.current ?? document
|
|
2506
|
+
/** @private @author ddj 2026年11月15号 @description 跨行或整行单行选区复制为 @路径 Lx-Ly */
|
|
2507
|
+
const onCopy = (event) => {
|
|
2508
|
+
if (!featurePrefs().refIntake) return
|
|
2509
|
+
handleCopyAsRef(event, editorRef.current, activeRef.current)
|
|
2510
|
+
}
|
|
2511
|
+
host.addEventListener('copy', onCopy, true)
|
|
2512
|
+
return () => host.removeEventListener('copy', onCopy, true)
|
|
2513
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2514
|
+
}, [])
|
|
2515
|
+
|
|
2516
|
+
|
|
2405
2517
|
/**
|
|
2406
2518
|
* Apply a save completion only to the unchanged model that supplied its text.
|
|
2407
2519
|
* @private @author ddj 2026年09月28号
|
|
@@ -2464,6 +2576,7 @@ export function EditorView(props) {
|
|
|
2464
2576
|
/** @private @author ddj 2026年10月14号 @param path Canonical path. @param manual Explicit save. @returns Guarded save, never another pane's content. */
|
|
2465
2577
|
function saveDocument(path, manual) {
|
|
2466
2578
|
if (isExcelPath(path)) return Promise.resolve({ ok: false })
|
|
2579
|
+
if (useOffice(path)) return Promise.resolve({ ok: false })
|
|
2467
2580
|
if (missingRef.current.has(path)) { setStatus('删除预览只读;请使用 Keep / Undo'); return Promise.resolve({ ok: false }) }
|
|
2468
2581
|
const model = modelsRef.current.get(path)
|
|
2469
2582
|
if (!model) return Promise.resolve({ ok: false })
|
|
@@ -2476,6 +2589,7 @@ export function EditorView(props) {
|
|
|
2476
2589
|
|
|
2477
2590
|
const doSave = (silent) => {
|
|
2478
2591
|
if (!active) return
|
|
2592
|
+
if (useOffice(active)) { if (!silent) setStatus('Univer 文档请在文档内编辑与审阅;不会作为文本保存'); return }
|
|
2479
2593
|
if (isExcelPath(active)) { if (!silent) setStatus('Excel 不写原件;请使用「基础 · 导出副本」'); return }
|
|
2480
2594
|
// 外部改动待处理:自动保存(silent)直接放弃,避免陈旧缓冲覆盖磁盘;
|
|
2481
2595
|
// 手工保存(Ctrl+S / 命令栏)继续走版本守卫,由 host 判定并给冲突提示。
|
|
@@ -2508,6 +2622,7 @@ export function EditorView(props) {
|
|
|
2508
2622
|
const persistDirty = (paths) => {
|
|
2509
2623
|
for (const path of paths) {
|
|
2510
2624
|
if (isExcelPath(path)) continue
|
|
2625
|
+
if (useOffice(path)) continue
|
|
2511
2626
|
if (!dirtyRef.current[path]) continue
|
|
2512
2627
|
// 外部改动未处理:不落盘(避免覆盖),脏内容仍保留在 model 中
|
|
2513
2628
|
if (readSync(scope, path)) { setStatus('未落盘(外部已修改):' + baseNameOf(path)); continue }
|
|
@@ -2547,7 +2662,7 @@ export function EditorView(props) {
|
|
|
2547
2662
|
// 切回源码时 ensureEditor 会**新建**编辑器实例,而 active/content 都没变;缺此依赖则本 effect
|
|
2548
2663
|
// 不重跑 → 空 model、行内差异标记消失。同款原因见下方差异自绘 effect。
|
|
2549
2664
|
React.useEffect(() => {
|
|
2550
|
-
if (!monaco || !editorRef.current || !active || !contentReady) return
|
|
2665
|
+
if (!monaco || !editorRef.current || !active || !contentReady || useOffice(active)) return
|
|
2551
2666
|
const ed = editorRef.current
|
|
2552
2667
|
const model = getModel(active, content)
|
|
2553
2668
|
viewKeeperRef.current?.bind(String(scope), active, model, findKeyOf(scope, focusedGroupOf(active)))
|
|
@@ -3156,6 +3271,24 @@ export function EditorView(props) {
|
|
|
3156
3271
|
}
|
|
3157
3272
|
toggleMdPreviewRef.current = toggleMdPreview
|
|
3158
3273
|
|
|
3274
|
+
/**
|
|
3275
|
+
* 用官方 HTML 渲染器预览当前网页(按钮/快捷键/命令栏同一动作)。
|
|
3276
|
+
*
|
|
3277
|
+
* 先 flushSave:官方预览读的是磁盘内容,防抖窗口内未落盘的改动必须先生效;
|
|
3278
|
+
* 再交给原生打开 handler(session 域 file 地址 → 官方 documentpreviews 的 html body)。
|
|
3279
|
+
* 旧版 DSH 无官方渲染器时只提示,不改动当前文本编辑态。
|
|
3280
|
+
* @author ddj 2026年11月21号
|
|
3281
|
+
* @param path 当前文件路径
|
|
3282
|
+
*/
|
|
3283
|
+
function previewHtmlOf(path) {
|
|
3284
|
+
if (!isHtmlPath(path)) { setStatus('当前文件不是 HTML'); return }
|
|
3285
|
+
if (!hasOfficialHtmlPreview()) { setStatus('当前 DSH 不支持 HTML 渲染预览'); return }
|
|
3286
|
+
|
|
3287
|
+
flushSave()
|
|
3288
|
+
saveViewState(path)
|
|
3289
|
+
if (!tryNativeOpen(path)) { setStatus('打开官方 HTML 预览失败,请在对话中打开该文件'); return }
|
|
3290
|
+
setStatus('已在官方查看器打开网页预览')
|
|
3291
|
+
}
|
|
3159
3292
|
/** 当前图片的会话+路径级缩放记忆键(页签切换回来保留同一缩放)。 */
|
|
3160
3293
|
const imgZoomKey = zoomKeyOf(sessionId, active)
|
|
3161
3294
|
|
|
@@ -3952,6 +4085,15 @@ export function EditorView(props) {
|
|
|
3952
4085
|
* @author ddj 2026年09月16号
|
|
3953
4086
|
* @param relPath 目标相对路径(缺省 = 工作区根)
|
|
3954
4087
|
*/
|
|
4088
|
+
/**
|
|
4089
|
+
* 打开原生提交对话框(种子 = 预选路径/预填信息;来自 AI 逐组提交或动作入口)。
|
|
4090
|
+
* @author ddj 2026年11月15号
|
|
4091
|
+
* @param seed 预填载荷(缺省 = 按面板默认勾选)
|
|
4092
|
+
*/
|
|
4093
|
+
const openSvnCommit = (seed) => {
|
|
4094
|
+
setCommitSeed(seed && typeof seed === 'object' ? seed : {})
|
|
4095
|
+
}
|
|
4096
|
+
|
|
3955
4097
|
const openSvnLog = (relPath) => {
|
|
3956
4098
|
const target = relPath || ''
|
|
3957
4099
|
dshTrace('svnLog.open', { target, scope, hasSession: Boolean(sessionId) })
|
|
@@ -4077,6 +4219,7 @@ export function EditorView(props) {
|
|
|
4077
4219
|
openSvnDiff: (p) => runSvnDiffBase(p),
|
|
4078
4220
|
openSvnLocalPair: runSvnDiffLocalPair,
|
|
4079
4221
|
openSvnLog: (p) => openSvnLog(p ?? path),
|
|
4222
|
+
openCommitDialog: (seed) => openSvnCommit(seed),
|
|
4080
4223
|
refreshChanges: () => refreshSvnChanges(sessionId, scope),
|
|
4081
4224
|
})
|
|
4082
4225
|
}
|
|
@@ -4184,7 +4327,7 @@ export function EditorView(props) {
|
|
|
4184
4327
|
// 原生打开范围(nativeOpenExts 设置):命中且非差异跳转 → 走官方渲染器
|
|
4185
4328
|
//(focusDiff=true 跳过:差异审查对象必为本插件编辑的文本文件,审查优先);
|
|
4186
4329
|
// handler 缺失/失败(旧版无 openResource / seat 未挂)→ 回退现状页签打开,不阻断
|
|
4187
|
-
if (!focusDiff && !isExcelPath(path) && inNativePath(path) && tryNativeOpen(path)) return
|
|
4330
|
+
if (!useOffice(path) && !focusDiff && !isExcelPath(path) && inNativePath(path) && tryNativeOpen(path)) return
|
|
4188
4331
|
// 对比浮窗独立保留,允许同时打开并编辑其他文件。
|
|
4189
4332
|
recordNav()
|
|
4190
4333
|
// G9:统一归一为页签规范形态(差异栏/启动器/树/命令栏等入口一致)
|
|
@@ -4303,6 +4446,10 @@ export function EditorView(props) {
|
|
|
4303
4446
|
|
|
4304
4447
|
/** @private @author ddj 2026年09月28号 @param request Claimed target. @returns Correlated actual readiness. */
|
|
4305
4448
|
function receiptReady(request) {
|
|
4449
|
+
if (request.path && useOffice(request.path)) {
|
|
4450
|
+
const host = viewRootRef.current?.querySelector('.edrv-uv-host')
|
|
4451
|
+
return request.sessionId === sessionId && sameFile(active, request.path) && host?.getAttribute('data-univer-path') === active
|
|
4452
|
+
}
|
|
4306
4453
|
if (request.plan) return request.sessionId === sessionId && planActive === request.plan.address
|
|
4307
4454
|
&& planTabs.some((item) => item.address === request.plan.address && item.markdown === request.plan.markdown)
|
|
4308
4455
|
&& planHostRef.current?.getAttribute('data-plan-address') === request.plan.address
|
|
@@ -4530,6 +4677,7 @@ export function EditorView(props) {
|
|
|
4530
4677
|
function openTextPages() {
|
|
4531
4678
|
if (largeCandidate !== pageIdentity || dirtyRef.current[active] || savingRef.current.has(active)) return
|
|
4532
4679
|
flushSave()
|
|
4680
|
+
if (useOffice(active)) return
|
|
4533
4681
|
if (dirtyRef.current[active] || savingRef.current.has(active)) return
|
|
4534
4682
|
setPageChanged(null)
|
|
4535
4683
|
setPagedFile(pageIdentity)
|
|
@@ -4539,6 +4687,10 @@ export function EditorView(props) {
|
|
|
4539
4687
|
let disposed = false, keeper = null, subscription = null, observer = null, unbindGutter = null, pageRoot = null
|
|
4540
4688
|
const focus = () => { const owner = ownerOf(benchRef.current, path); if (owner) selectGroup(owner.id, path) }
|
|
4541
4689
|
host.addEventListener('pointerdown', focus)
|
|
4690
|
+
if (useOffice(path)) {
|
|
4691
|
+
host.textContent = 'Univer · 点击此编辑组继续查看与审阅'
|
|
4692
|
+
return () => host.removeEventListener('pointerdown', focus)
|
|
4693
|
+
}
|
|
4542
4694
|
if (isExcelPath(path)) {
|
|
4543
4695
|
host.textContent = 'Excel · 点击此编辑组继续查看和编辑(同一文件共享编辑状态)'
|
|
4544
4696
|
return () => host.removeEventListener('pointerdown', focus)
|
|
@@ -4669,7 +4821,13 @@ export function EditorView(props) {
|
|
|
4669
4821
|
onClick: () => toggleMdPreview(active),
|
|
4670
4822
|
}, mdPreviewing ? '源码' : '预览') : null),
|
|
4671
4823
|
(mdPreviewing ? React.createElement('span', { className: 'edrv-pb-meta' }, '预览') : null),
|
|
4672
|
-
|
|
4824
|
+
// HTML 网页预览:交给官方 HTML 渲染器;按钮在渲染器不可用时禁用并说明原因。
|
|
4825
|
+
(isHtmlActive ? React.createElement('button', {
|
|
4826
|
+
className: 'edrv-pill edrv-pill-ghost edrv-pb-mdbtn',
|
|
4827
|
+
title: (hasOfficialHtmlPreview() ? '用官方渲染器预览网页' : '当前 DSH 不支持 HTML 渲染预览') + '(' + (chordOf('edrv.previewHtml') ?? '未绑定') + ')',
|
|
4828
|
+
disabled: !hasOfficialHtmlPreview(),
|
|
4829
|
+
onClick: () => previewHtmlOf(active),
|
|
4830
|
+
}, '预览网页') : null), (active && !isImageActive && langOf(active) ? React.createElement('span', { className: 'edrv-pb-meta' }, langOf(active)) : null),
|
|
4673
4831
|
(isImageActive && imgSize ? React.createElement('span', { className: 'edrv-pb-meta' }, imgSize.w + '×' + imgSize.h) : null),
|
|
4674
4832
|
(cursor ? React.createElement('span', { className: 'edrv-pb-meta' }, cursor) : null),
|
|
4675
4833
|
(status ? React.createElement('span', { className: 'edrv-pb-meta edrv-pb-status' }, status) : null))
|
|
@@ -4835,17 +4993,36 @@ export function EditorView(props) {
|
|
|
4835
4993
|
React.createElement('button', { className: 'edrv-pill edrv-pill-ghost', onClick: retry }, '重试'),
|
|
4836
4994
|
React.createElement('button', { className: 'edrv-pill edrv-pill-ghost', onClick: close }, '关闭标签页')))
|
|
4837
4995
|
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4996
|
+
/**
|
|
4997
|
+
* 计划页的 Markdown 渲染(HTML 计划页缺失/未声明时的回退)。
|
|
4998
|
+
* @author ddj 2026年11月21号
|
|
4999
|
+
* @param plan 计划文档
|
|
5000
|
+
* @returns 只读 Markdown 元素
|
|
5001
|
+
*/
|
|
5002
|
+
function planMarkdownBody(plan) {
|
|
5003
|
+
const text = plan.markdown
|
|
4842
5004
|
const render = isComponentType(MarkdownText)
|
|
4843
5005
|
? React.createElement(MarkdownDelegateProvider, {
|
|
4844
5006
|
openFile: (path, options) => options?.line != null ? openFileAt(path, options.line) : openFile(path, false),
|
|
4845
|
-
}, React.createElement(MarkdownText, { text, streaming: false, labels, variant: 'body' }))
|
|
5007
|
+
}, React.createElement(MarkdownText, { text, streaming: false, labels: PLAN_MD_LABELS, variant: 'body' }))
|
|
4846
5008
|
: React.createElement('pre', { className: 'edrv-mdview-pre' }, text)
|
|
5009
|
+
return React.createElement('div', { className: 'edrv-mdview-stage' }, React.createElement('div', { className: 'edrv-mdview-doc' }, render))
|
|
5010
|
+
}
|
|
5011
|
+
|
|
5012
|
+
let body
|
|
5013
|
+
if (activePlan) {
|
|
4847
5014
|
body = React.createElement('div', { className: 'edrv-mdview', ref: planHostRef, 'data-plan-address': activePlan.address },
|
|
4848
|
-
|
|
5015
|
+
activePlan.htmlPath
|
|
5016
|
+
? React.createElement(HtmlPlanPanel, {
|
|
5017
|
+
key: activePlan.address,
|
|
5018
|
+
sessionId,
|
|
5019
|
+
cwd,
|
|
5020
|
+
address: activePlan.address,
|
|
5021
|
+
title: activePlan.title,
|
|
5022
|
+
htmlPath: activePlan.htmlPath,
|
|
5023
|
+
markdown: activePlan.markdown,
|
|
5024
|
+
})
|
|
5025
|
+
: planMarkdownBody(activePlan))
|
|
4849
5026
|
} else if (pageChanged === pageIdentity && largeCandidate === pageIdentity) {
|
|
4850
5027
|
body = React.createElement('div', { className: 'edrv-empty', role: 'status' },
|
|
4851
5028
|
React.createElement('div', null, '文件已变化,请重新读取'),
|
|
@@ -4889,6 +5066,19 @@ export function EditorView(props) {
|
|
|
4889
5066
|
setLoadStage({ progress: 10, message: '重新读取文件…' })
|
|
4890
5067
|
loadContent(active, sessionId)
|
|
4891
5068
|
}), largeCandidate === pageIdentity && React.createElement('button', { className: 'edrv-pill edrv-pill-ghost', onClick: openTextPages }, '只读分段查看'))
|
|
5069
|
+
} else if (isUniverActive) {
|
|
5070
|
+
const cachedDocument = [...univer.documents.values()].find((document) => sameFile(document.file, active))
|
|
5071
|
+
body = React.createElement(UniverHost, { key: sessionId + active, path: active, sessionId,
|
|
5072
|
+
source: cachedDocument?.source,
|
|
5073
|
+
sourceChanged: cachedDocument?.sourceChanged,
|
|
5074
|
+
onOpen: (path) => openFile(path, false),
|
|
5075
|
+
onFallback: () => {
|
|
5076
|
+
if (isUniverPath(active)) { setStatus('Univer 容器不能作为文本打开'); return }
|
|
5077
|
+
flushSave()
|
|
5078
|
+
if (isExcelPath(active)) { setOfficeFallback((previous) => new Set([...previous, active])); return }
|
|
5079
|
+
if (props.fileOpeners) openWithDialog(props.fileOpeners, { sessionId, cwd: cwd ?? undefined }, active)
|
|
5080
|
+
else setStatus('没有可用的其他打开方式')
|
|
5081
|
+
} })
|
|
4892
5082
|
} else if (isExcelActive && contentPath === active && excelState(excelScope, active).document) {
|
|
4893
5083
|
body = React.createElement(ExcelHost, { key: excelScope + active, state: excelState(excelScope, active), path: active, cwd })
|
|
4894
5084
|
} else if (isExcelActive) {
|
|
@@ -5081,6 +5271,7 @@ export function EditorView(props) {
|
|
|
5081
5271
|
openSvnLocalPair: runSvnDiffLocalPair,
|
|
5082
5272
|
refreshSvnChanges: () => refreshSvnChanges(sessionId, scope),
|
|
5083
5273
|
openSvnLog: (p) => openSvnLog(p),
|
|
5274
|
+
openSvnCommit: (seed) => openSvnCommit(seed),
|
|
5084
5275
|
confirm: (message) => (typeof window === 'undefined' ? false : window.confirm(message)),
|
|
5085
5276
|
notify: (message) => setStatus(message),
|
|
5086
5277
|
// 名称输入弹窗(资源管理器右键的新建文件/新建文件夹/重命名)
|
|
@@ -5209,7 +5400,7 @@ export function EditorView(props) {
|
|
|
5209
5400
|
: null
|
|
5210
5401
|
|
|
5211
5402
|
// 侧栏差异栏悬浮在编辑区底部;中央页签仍使用对话 dock。
|
|
5212
|
-
const sideDock = dockInLayout(dockSnapshot, 'side')
|
|
5403
|
+
const sideDock = !isUniverActive && dockInLayout(dockSnapshot, 'side')
|
|
5213
5404
|
? React.createElement('div', {
|
|
5214
5405
|
className: 'edrv-side-diff-dock edrv-diff-dock-shell',
|
|
5215
5406
|
'data-edrv-diff-dock-shell': '1',
|
|
@@ -5344,6 +5535,20 @@ export function EditorView(props) {
|
|
|
5344
5535
|
},
|
|
5345
5536
|
})
|
|
5346
5537
|
: null
|
|
5538
|
+
// 原生提交对话框(22-agent-tools-and-commit):portal 到 body,与日志/更新弹窗同一挂载方式
|
|
5539
|
+
const svnCommitEl = commitSeed
|
|
5540
|
+
? React.createElement(SvnCommitDialog, {
|
|
5541
|
+
key: 'edrv-svn-commit',
|
|
5542
|
+
sessionId,
|
|
5543
|
+
seed: commitSeed,
|
|
5544
|
+
notify: (message) => setStatus(message),
|
|
5545
|
+
onClose: () => setCommitSeed(null),
|
|
5546
|
+
onCommitted: (result) => {
|
|
5547
|
+
refreshSvnChanges(sessionId, scope)
|
|
5548
|
+
setStatus(result?.revision !== undefined ? '提交成功:r' + result.revision : '提交完成')
|
|
5549
|
+
},
|
|
5550
|
+
})
|
|
5551
|
+
: null
|
|
5347
5552
|
/**
|
|
5348
5553
|
* 更新终态只刷新一次目录树与变更缓存,切到日志再返回不重复执行。
|
|
5349
5554
|
* @author ddj 2026年09月24号
|
|
@@ -5503,6 +5708,7 @@ export function EditorView(props) {
|
|
|
5503
5708
|
tabMenuEl,
|
|
5504
5709
|
paletteEl,
|
|
5505
5710
|
svnLogEl,
|
|
5711
|
+
svnCommitEl,
|
|
5506
5712
|
svnUpdateEl,
|
|
5507
5713
|
svnDiffEl,
|
|
5508
5714
|
patchDialogEl,
|
|
@@ -5516,6 +5722,7 @@ export function EditorView(props) {
|
|
|
5516
5722
|
tabMenuEl,
|
|
5517
5723
|
paletteEl,
|
|
5518
5724
|
svnLogEl,
|
|
5725
|
+
svnCommitEl,
|
|
5519
5726
|
svnUpdateEl,
|
|
5520
5727
|
svnDiffEl,
|
|
5521
5728
|
patchDialogEl,
|
|
@@ -27,6 +27,7 @@ import { LspSettings } from './LspSettings.js'
|
|
|
27
27
|
import { PerfSettings } from './PerfSettings.js'
|
|
28
28
|
import { IntegrationSettings } from './IntegrationSettings.js'
|
|
29
29
|
import { AiSettings } from './AiSettings.js'
|
|
30
|
+
import { UniverCacheSettings } from '../univer/UniverCacheSettings.js'
|
|
30
31
|
|
|
31
32
|
const EMPTY = { serverName: '', transport: 'stdio', command: '', args: '', cwd: '', url: '', headers: '', startup: 'on-demand', sharing: 'agent', startupTimeoutMs: 60000 }
|
|
32
33
|
|
|
@@ -148,6 +149,8 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
148
149
|
const [limitDraft, setLimitDraft] = React.useState(null) // 页签上限草稿(同上提交语义)
|
|
149
150
|
const [nativeSaved, setNativeSaved] = React.useState(DEFAULT_NATIVE_CSV) // 原生打开范围已保存值
|
|
150
151
|
const [nativeDraft, setNativeDraft] = React.useState(null) // 原生打开范围草稿(同上提交语义)
|
|
152
|
+
const [refIntakeOn, setRefIntakeOn] = React.useState(true) // 引用接入(拖拽/粘贴/复制 → 引用 chip)
|
|
153
|
+
const [searchReplaceOn, setSearchReplaceOn] = React.useState(true) // 搜索面板全局替换
|
|
151
154
|
const [kbMessage, setKbMessage] = React.useState('') // 打开官方快捷键弹窗的失败说明(空 = 未失败)
|
|
152
155
|
const settings = React.useContext(SettingsContext)
|
|
153
156
|
const snapshot = settings?.getSnapshot?.()
|
|
@@ -163,6 +166,8 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
163
166
|
setLimit(normalizeMaxOpenEditors(snap?.value?.maxOpenEditors))
|
|
164
167
|
const native = snap?.value?.nativeOpenExts
|
|
165
168
|
setNativeSaved(typeof native === 'string' && native.trim() ? native : DEFAULT_NATIVE_CSV)
|
|
169
|
+
setRefIntakeOn(snap?.value?.refIntake !== false)
|
|
170
|
+
setSearchReplaceOn(snap?.value?.searchReplace !== false)
|
|
166
171
|
}
|
|
167
172
|
onChange()
|
|
168
173
|
return settings?.subscribe?.(onChange)
|
|
@@ -215,6 +220,30 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
215
220
|
if (nativeDraft === null) return
|
|
216
221
|
saveNative(nativeDraft)
|
|
217
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* 提交布尔开关(引用接入 / 搜索替换)。
|
|
225
|
+
* @author ddj 2026年11月15号
|
|
226
|
+
* @param key 设置字段名
|
|
227
|
+
* @param value 新值(true/false)
|
|
228
|
+
* @param apply 乐观写入本地状态的函数(失败时用 !value 回滚)
|
|
229
|
+
* @returns 无(失败经 error 状态提示)
|
|
230
|
+
* @sideEffects 写设置文档;客户端特性读取由 index.ts 的设置桥同拍推送
|
|
231
|
+
*/
|
|
232
|
+
const saveToggle = (key, value, apply) => {
|
|
233
|
+
apply(value)
|
|
234
|
+
setBusy(true)
|
|
235
|
+
setError('')
|
|
236
|
+
if (!settings?.set) {
|
|
237
|
+
setError('设置服务不可用')
|
|
238
|
+
apply(!value)
|
|
239
|
+
setBusy(false)
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
settings.set(key, value).catch((e) => {
|
|
243
|
+
setError(String(e))
|
|
244
|
+
apply(!value)
|
|
245
|
+
}).finally(() => setBusy(false))
|
|
246
|
+
}
|
|
218
247
|
const closeDevForm = () => {
|
|
219
248
|
if (!window.confirm('关闭开发形态:插件将切换为正式版安装(版本依赖 + 删除工作区链接),pnpm 装配后需重启 DSH 生效。确认关闭?')) return
|
|
220
249
|
setDevBusy(true)
|
|
@@ -321,6 +350,23 @@ function GeneralSettings({ registry, getShortcuts }) {
|
|
|
321
350
|
})),
|
|
322
351
|
),
|
|
323
352
|
),
|
|
353
|
+
React.createElement('section', { className: 'vsm-panel' },
|
|
354
|
+
React.createElement('h3', { className: 'vsm-panel-title' }, '交互'),
|
|
355
|
+
React.createElement('div', { className: 'vsm-panel-body' },
|
|
356
|
+
React.createElement(SettingRow, { label: '引用接入', description: '资源管理器拖入的文件、编辑器里复制的行选区、粘贴的文件会落成对话引用 chip;关闭后完全走原生行为。' },
|
|
357
|
+
React.createElement('input', {
|
|
358
|
+
type: 'checkbox', checked: refIntakeOn,
|
|
359
|
+
disabled: loading || unavailable || notReady || busy || snapshot?.writable === false,
|
|
360
|
+
onChange: (event) => saveToggle('refIntake', event.target.checked, setRefIntakeOn),
|
|
361
|
+
})),
|
|
362
|
+
React.createElement(SettingRow, { label: '搜索替换', description: '搜索面板显示替换入口(先预览命中再确认写盘);关闭后只保留搜索。' },
|
|
363
|
+
React.createElement('input', {
|
|
364
|
+
type: 'checkbox', checked: searchReplaceOn,
|
|
365
|
+
disabled: loading || unavailable || notReady || busy || snapshot?.writable === false,
|
|
366
|
+
onChange: (event) => saveToggle('searchReplace', event.target.checked, setSearchReplaceOn),
|
|
367
|
+
})),
|
|
368
|
+
),
|
|
369
|
+
),
|
|
324
370
|
React.createElement('section', { className: 'vsm-panel' },
|
|
325
371
|
React.createElement('h3', { className: 'vsm-panel-title' }, '快捷键'),
|
|
326
372
|
React.createElement('div', { className: 'vsm-panel-body' },
|
|
@@ -364,6 +410,11 @@ function SvnSettingsSection() {
|
|
|
364
410
|
const [svnDraft, setSvnDraft] = React.useState(null)
|
|
365
411
|
const [tortoisePath, setTortoisePath] = React.useState('')
|
|
366
412
|
const [tortoiseDraft, setTortoiseDraft] = React.useState(null)
|
|
413
|
+
const [readOnly, setReadOnly] = React.useState(false)
|
|
414
|
+
const [scale, setScale] = React.useState(1)
|
|
415
|
+
const [autoAdd, setAutoAdd] = React.useState(true)
|
|
416
|
+
const [autoDelete, setAutoDelete] = React.useState(true)
|
|
417
|
+
const [commitStyle, setCommitStyle] = React.useState('plain')
|
|
367
418
|
const [svnInfo, setSvnInfo] = React.useState(null)
|
|
368
419
|
const [busy, setBusy] = React.useState(false)
|
|
369
420
|
const [error, setError] = React.useState('')
|
|
@@ -372,6 +423,11 @@ function SvnSettingsSection() {
|
|
|
372
423
|
const snap = settings?.getSnapshot?.()
|
|
373
424
|
setSvnPath(typeof snap?.value?.svnPath === 'string' ? snap.value.svnPath : '')
|
|
374
425
|
setTortoisePath(typeof snap?.value?.tortoisePath === 'string' ? snap.value.tortoisePath : '')
|
|
426
|
+
setReadOnly(snap?.value?.svnReadOnly === true)
|
|
427
|
+
setScale(typeof snap?.value?.svnCommandTimeoutScale === 'number' ? snap.value.svnCommandTimeoutScale : 1)
|
|
428
|
+
setAutoAdd(snap?.value?.svnAutoAddUnversioned !== false)
|
|
429
|
+
setAutoDelete(snap?.value?.svnAutoDeleteMissing !== false)
|
|
430
|
+
setCommitStyle(snap?.value?.aiCommitStyle === 'conventional' ? 'conventional' : 'plain')
|
|
375
431
|
}
|
|
376
432
|
onChange()
|
|
377
433
|
return settings?.subscribe?.(onChange)
|
|
@@ -406,6 +462,12 @@ function SvnSettingsSection() {
|
|
|
406
462
|
setTortoiseDraft(null)
|
|
407
463
|
savePath('tortoisePath', next, () => setTortoisePath(next))
|
|
408
464
|
}
|
|
465
|
+
/** 通用设置写入(布尔/数字/枚举;失败就地报错,不吞)。 */
|
|
466
|
+
const saveValue = (key, value, apply) => {
|
|
467
|
+
setBusy(true); setError('')
|
|
468
|
+
if (!settings?.set) { setError('设置服务不可用'); setBusy(false); return }
|
|
469
|
+
settings.set(key, value).then(() => { apply() }).catch((e) => setError(String(e))).finally(() => setBusy(false))
|
|
470
|
+
}
|
|
409
471
|
const disabled = loading || unavailable || notReady || busy || snapshot?.writable === false
|
|
410
472
|
return React.createElement('section', { className: 'vsm-panel' },
|
|
411
473
|
React.createElement('h3', { className: 'vsm-panel-title' }, 'SVN'),
|
|
@@ -431,6 +493,49 @@ function SvnSettingsSection() {
|
|
|
431
493
|
onBlur: commitTortoise,
|
|
432
494
|
onKeyDown: (event) => { if (event.key === 'Enter') commitTortoise() },
|
|
433
495
|
})),
|
|
496
|
+
React.createElement('label', { className: 'vsm-general-row' },
|
|
497
|
+
React.createElement('span', null, '超时倍数'),
|
|
498
|
+
React.createElement('input', {
|
|
499
|
+
value: String(scale), placeholder: '1', disabled, title: 'SVN 命令超时倍数(0.2–20;仓库慢或工作副本大时调到 2–3)',
|
|
500
|
+
onChange: (event) => {
|
|
501
|
+
const next = Number(event.target.value)
|
|
502
|
+
if (Number.isFinite(next)) setScale(next)
|
|
503
|
+
},
|
|
504
|
+
onBlur: () => saveValue('svnCommandTimeoutScale', Math.min(20, Math.max(0.2, scale)), () => {}),
|
|
505
|
+
})),
|
|
506
|
+
React.createElement('label', { className: 'vsm-general-row' },
|
|
507
|
+
React.createElement('span', null, '只读模式'),
|
|
508
|
+
React.createElement('input', {
|
|
509
|
+
type: 'checkbox', checked: readOnly, disabled,
|
|
510
|
+
title: '开启后拒绝全部写操作(提交/还原/更新/属性写入),只保留查看与比对',
|
|
511
|
+
onChange: () => saveValue('svnReadOnly', !readOnly, () => setReadOnly(!readOnly)),
|
|
512
|
+
})),
|
|
513
|
+
React.createElement('label', { className: 'vsm-general-row' },
|
|
514
|
+
React.createElement('span', null, '提交前自动加入'),
|
|
515
|
+
React.createElement('input', {
|
|
516
|
+
type: 'checkbox', checked: autoAdd, disabled,
|
|
517
|
+
title: '提交时对勾选的未版本控制文件自动 svn add(关闭后这些文件会被跳过并在结果里列出)',
|
|
518
|
+
onChange: () => saveValue('svnAutoAddUnversioned', !autoAdd, () => setAutoAdd(!autoAdd)),
|
|
519
|
+
})),
|
|
520
|
+
React.createElement('label', { className: 'vsm-general-row' },
|
|
521
|
+
React.createElement('span', null, '提交前自动删除'),
|
|
522
|
+
React.createElement('input', {
|
|
523
|
+
type: 'checkbox', checked: autoDelete, disabled,
|
|
524
|
+
title: '提交时对勾选的已删除文件自动 svn delete(关闭后这些文件会被跳过并在结果里列出)',
|
|
525
|
+
onChange: () => saveValue('svnAutoDeleteMissing', !autoDelete, () => setAutoDelete(!autoDelete)),
|
|
526
|
+
})),
|
|
527
|
+
React.createElement('label', { className: 'vsm-general-row' },
|
|
528
|
+
React.createElement('span', null, 'AI 提交信息风格'),
|
|
529
|
+
React.createElement('select', {
|
|
530
|
+
value: commitStyle, disabled,
|
|
531
|
+
title: 'plain = 中文「<模块>:<标题>」;conventional = type(scope): subject',
|
|
532
|
+
onChange: (event) => {
|
|
533
|
+
const next = event.target.value === 'conventional' ? 'conventional' : 'plain'
|
|
534
|
+
saveValue('aiCommitStyle', next, () => setCommitStyle(next))
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
React.createElement('option', { value: 'plain' }, '中文模板'),
|
|
538
|
+
React.createElement('option', { value: 'conventional' }, 'Conventional Commits'))),
|
|
434
539
|
),
|
|
435
540
|
)
|
|
436
541
|
}
|
|
@@ -687,7 +792,9 @@ export function McpSettings(props) {
|
|
|
687
792
|
const resetDraft = () => { if (!ref.current?.view.busy) setDraft(EMPTY) }
|
|
688
793
|
let body
|
|
689
794
|
if (tab === 'mcp' && loading) body = React.createElement('div', { className: 'vsm-mcp-empty' }, '正在读取 MCP 服务…')
|
|
690
|
-
else if (tab === 'general') body = React.createElement(
|
|
795
|
+
else if (tab === 'general') body = React.createElement(React.Fragment, null,
|
|
796
|
+
React.createElement(GeneralSettings, { registry: openerRegistry, getShortcuts }),
|
|
797
|
+
React.createElement(UniverCacheSettings, { getSession: props?.getMcpSession ?? (() => undefined) }))
|
|
691
798
|
else if (tab === 'mcp') body = React.createElement(McpManagePanel, { servers, projects, busy, draft, edit, resetDraft,
|
|
692
799
|
saveGlobal, saveProject, connectProject, policyProject,
|
|
693
800
|
refreshGlobal, toggleGlobal, removeGlobal, refreshProject, toggleProject, removeProject })
|