🐛 fix(vscode): 代码阅读属性表的输入参数、导入项可以折叠

This commit is contained in:
cruldra committed 2026-09-25 12:20:37 +08:00
1 parent 846fba92e1
commit e8a6a795f5
5 files changed
+55 -15

No files matched your search

@@ -29,6 +29,7 @@ const KIND_LABEL: Record<BlockKind, string> = {
export interface BlockTreeState {
version: number
editing: ReadonlySet<string>
/** 折叠的块 id 和属性行 id(propertyRowId),默认全部展开 */
collapsed: ReadonlySet<string>
/** 刚点了「编辑」、要把光标放进去的块 */
focusId: string | null
@@ -62,9 +63,9 @@ export function BlockLevel({ blocks, kind, tree }: { blocks: BlockView[], kind?:
}
/** 预览状态的内容:函数、导入、常量、变量块是属性表,其余是一行译文。 */
function BlockPreview({ block }: { block: BlockView }): ReactElement {
function BlockPreview({ block, tree }: { block: BlockView, tree: BlockTreeState }): ReactElement {
if ('properties' in block)
return <PropertyGrid rows={block.properties} />
return <PropertyGrid blockId={block.id} rows={block.properties} collapsed={tree.collapsed} onToggleFold={tree.onToggleFold} />
return (
<p className="cr-code">
<SegmentText segments={block.translation} />
@@ -112,7 +113,7 @@ function BlockCard({ block, tree }: { block: BlockView, tree: BlockTreeState }):
onExit={() => tree.onToggleEdit(block.id)}
/>
)
: <BlockPreview block={block} />}
: <BlockPreview block={block} tree={tree} />}
</div>
<button
type="button"