✨ feat(vscode): 代码阅读预览界面
Vite 加 code-reader.html 第二入口;代码块树(层级竖线、折叠、种类标签配色)、译文 / 源码按词性着色、块内直接编辑(防抖回写整行、Esc 回预览)、翻译下拉、解析失败提示;看板与代码阅读共用带类型的 acquireVsCodeApi 包装和 ErrorBoundary。
This commit is contained in:
1 parent
cab5ac0ebc
commit
af56985d9a
16 files changed
+775
-74
No files matched your search
@@ -0,0 +1,22 @@
|
||||
/** 代码阅读预览与扩展之间的收发,以及按块 id 记的视图状态。 */
|
||||
|
||||
import type { ExtensionToWebview, WebviewToExtension } from './types'
|
||||
import { createVsCodeBridge } from '@/lib/vscodeBridge'
|
||||
|
||||
/** 哪些块停在「编辑」、哪些块折叠了。块 id 是它在树里的位置,文档刷新后照旧对得上。 */
|
||||
export interface ViewState {
|
||||
editing: string[]
|
||||
collapsed: string[]
|
||||
}
|
||||
|
||||
const bridge = createVsCodeBridge<ExtensionToWebview, WebviewToExtension, ViewState>()
|
||||
|
||||
export const { postMessage, onMessage } = bridge
|
||||
|
||||
export function loadViewState(): ViewState {
|
||||
return bridge.getState() ?? { editing: [], collapsed: [] }
|
||||
}
|
||||
|
||||
export function saveViewState(state: ViewState): void {
|
||||
bridge.setState(state)
|
||||
}
|
||||
Reference in new issue
Block a user