Commit 7260b8a1 by pangchong

feat: 优化表格渲染样式

parent 16e14a6e
...@@ -27,6 +27,7 @@ export interface AttrDef { ...@@ -27,6 +27,7 @@ export interface AttrDef {
export interface FlatNode { export interface FlatNode {
id: string id: string
tagName: string tagName: string
attrSummary?: string
subtitle: string subtitle: string
fullSubtitle?: string fullSubtitle?: string
depth: number depth: number
......
...@@ -139,17 +139,32 @@ ...@@ -139,17 +139,32 @@
</n-icon> </n-icon>
</div> </div>
<!-- Label & Subtitle --> <!-- Label & Subtitle & AttrSummary -->
<div <div
class="flex-1 min-w-0 flex items-center space-x-2 z-10" class="flex-1 min-w-0 flex items-center space-x-1.5 z-10"
:title="item.fullSubtitle || item.subtitle ? `${item.tagName} ${item.fullSubtitle || item.subtitle}` : item.tagName" :title="
item.fullSubtitle || item.subtitle || item.attrSummary
? `${item.tagName} ${item.attrSummary ? '[' + item.attrSummary + '] ' : ''}${item.fullSubtitle || item.subtitle}`
: item.tagName
"
> >
<!-- 节点名称高亮 --> <!-- 节点名称高亮 -->
<span class="font-bold text-sm flex-shrink-0" v-html="highlightText(item.tagName, pattern)"></span> <span class="font-bold text-sm flex-shrink-0" v-html="highlightText(item.tagName, pattern)"></span>
<!-- 子标题高亮 --> <!-- 属性摘要 Badge (包含淡色背景与框线,与文本预览彻底区分) -->
<span
v-if="item.attrSummary"
class="text-[10px] font-mono px-1.5 py-0.5 rounded shrink-0 leading-none font-medium border"
:class="[
effectiveSelectedId === item.id
? 'bg-white/20 text-white border-white/30'
: 'bg-primary/10 text-primary border-primary/20 dark:bg-primary/20 dark:border-primary/30'
]"
v-html="highlightText(item.attrSummary, pattern)"
></span>
<!-- 节点文本内容预览高亮 -->
<span <span
v-if="item.subtitle" v-if="item.subtitle"
class="text-xs truncate" class="text-xs truncate font-normal"
:title="item.fullSubtitle || item.subtitle" :title="item.fullSubtitle || item.subtitle"
:class="[ :class="[
effectiveSelectedId === item.id effectiveSelectedId === item.id
......
...@@ -1753,6 +1753,41 @@ export function useTableEditor(props: { node: XmlNode }) { ...@@ -1753,6 +1753,41 @@ export function useTableEditor(props: { node: XmlNode }) {
} }
} }
// 3. ENTRY 节点 MERGED 属性:单元格显示黄色背景(与 PDF 规范一致)
if ((cell.attributes?.MERGED || cell.rawNode?.attributes?.MERGED) === 'TRUE') {
styles['background-color'] = 'yellow'
}
// 4. COLSPEC MERGED:该列的列规范被标记为合并,对应列的所有单元格显示黄色
if (!styles['background-color']) {
const tgroupNode = store.nodeMap.get(structure.value.tgroupId)?.node
if (tgroupNode) {
const colSpecs = tgroupNode.children.filter((c) => c.tagName === 'COLSPEC')
const colSpec = colSpecs[cell.colIdx ?? 0]
if (colSpec?.attributes?.MERGED === 'TRUE') {
styles['background-color'] = 'yellow'
}
}
}
// 5. SPANSPEC MERGED:单元格引用的跨列规范被标记为合并,显示黄色
if (!styles['background-color']) {
const spanName = (cell.attributes?.SPANNAME || cell.rawNode?.attributes?.SPANNAME || '').toLowerCase()
if (spanName) {
const tgroupNode = store.nodeMap.get(structure.value.tgroupId)?.node
if (tgroupNode) {
const spanSpec = tgroupNode.children
.filter((c) => c.tagName === 'SPANSPEC')
.find((c) =>
(c.attributes?.SPANNAME || c.attributes?.spanname || '').toLowerCase() === spanName
)
if (spanSpec?.attributes?.MERGED === 'TRUE') {
styles['background-color'] = 'yellow'
}
}
}
}
return styles return styles
} }
......
...@@ -6,15 +6,27 @@ ...@@ -6,15 +6,27 @@
<span class="text-xs text-color3">{{ CELL_EDIT_TIP }}</span> <span class="text-xs text-color3">{{ CELL_EDIT_TIP }}</span>
<span v-if="!isDiffMode" class="text-xs text-color3 select-none">· 右键单元格可快速操作</span> <span v-if="!isDiffMode" class="text-xs text-color3 select-none">· 右键单元格可快速操作</span>
<span v-else class="text-xs text-color3 select-none">· 比对只读模式</span> <span v-else class="text-xs text-color3 select-none">· 比对只读模式</span>
<!-- TABLE 节点 MERGED 状态提示 -->
<span
v-if="node.attributes?.MERGED === 'TRUE'"
class="inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-bold select-none"
style="background: yellow; color: #78350f; border: 1px solid #ca8a04"
>
MERGED
</span>
</div> </div>
<!-- 可视化二维表格视图 --> <!-- 可视化二维表格视图 -->
<div class="flex-1 overflow-auto border border-divider rounded-lg shadow-inner bg-fill-2 p-2"> <div
class="flex-1 overflow-auto border rounded-lg shadow-inner p-2"
:style="node.attributes?.MERGED === 'TRUE' ? { backgroundColor: 'yellow', borderColor: '#ca8a04' } : {}"
>
<table <table
class="w-full border-collapse text-sm table-fixed min-w-[600px] transition-all" class="w-full border-collapse text-sm table-fixed min-w-[600px] transition-all"
:data-node-id="structure.tgroupId" :data-node-id="structure.tgroupId"
data-tag-name="TGROUP" data-tag-name="TGROUP"
:class="[isNodeSelected(structure.tgroupId) ? 'ring-2 ring-primary ring-offset-2 rounded' : '', tableFrameClass]" :class="[isNodeSelected(structure.tgroupId) ? 'ring-2 ring-primary ring-offset-2 rounded' : '', tableFrameClass]"
:style="editorStore.nodeMap.get(structure.tgroupId)?.node.attributes?.MERGED === 'TRUE' ? { backgroundColor: 'yellow' } : {}"
> >
<colgroup> <colgroup>
<col class="w-12" /> <col class="w-12" />
...@@ -30,6 +42,7 @@ ...@@ -30,6 +42,7 @@
@click.stop="editorStore.setSelectedNodeId(structure.theadId)" @click.stop="editorStore.setSelectedNodeId(structure.theadId)"
class="transition-all" class="transition-all"
:class="[isNodeSelected(structure.theadId) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/5' : '']" :class="[isNodeSelected(structure.theadId) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/5' : '']"
:style="editorStore.nodeMap.get(structure.theadId)?.node.attributes?.MERGED === 'TRUE' ? { backgroundColor: 'yellow' } : {}"
> >
<template v-for="(row, rIdx) in structure.theadRows" :key="row.id"> <template v-for="(row, rIdx) in structure.theadRows" :key="row.id">
<!-- 如果 ROW 拥有非 ENTRY 子节点 (如 EFFECT, CONEFFECT, REVST, REVEND) --> <!-- 如果 ROW 拥有非 ENTRY 子节点 (如 EFFECT, CONEFFECT, REVST, REVEND) -->
...@@ -56,6 +69,7 @@ ...@@ -56,6 +69,7 @@
isNodeSelected(row.id) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/10' : '', isNodeSelected(row.id) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/10' : '',
insertedRowIds.has(row.id) ? 'inserted-row-highlight' : '' insertedRowIds.has(row.id) ? 'inserted-row-highlight' : ''
]" ]"
:style="editorStore.nodeMap.get(row.id)?.node.attributes?.MERGED === 'TRUE' ? { backgroundColor: 'yellow' } : {}"
@click.stop="editorStore.setSelectedNodeId(row.id)" @click.stop="editorStore.setSelectedNodeId(row.id)"
> >
<!-- 表头行选择号 --> <!-- 表头行选择号 -->
...@@ -174,6 +188,7 @@ ...@@ -174,6 +188,7 @@
@click.stop="editorStore.setSelectedNodeId(structure.tbodyId)" @click.stop="editorStore.setSelectedNodeId(structure.tbodyId)"
class="transition-all" class="transition-all"
:class="[isNodeSelected(structure.tbodyId) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/5' : '']" :class="[isNodeSelected(structure.tbodyId) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/5' : '']"
:style="editorStore.nodeMap.get(structure.tbodyId)?.node.attributes?.MERGED === 'TRUE' ? { backgroundColor: 'yellow' } : {}"
> >
<template v-for="(row, rIdx) in structure.tbodyRows" :key="row.id"> <template v-for="(row, rIdx) in structure.tbodyRows" :key="row.id">
<!-- 如果 ROW 拥有非 ENTRY 子节点 (如 EFFECT, CONEFFECT, REVST, REVEND) --> <!-- 如果 ROW 拥有非 ENTRY 子节点 (如 EFFECT, CONEFFECT, REVST, REVEND) -->
...@@ -200,6 +215,7 @@ ...@@ -200,6 +215,7 @@
isNodeSelected(row.id) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/10' : '', isNodeSelected(row.id) ? 'outline outline-2 outline-primary outline-offset-[-2px] bg-primary/10' : '',
insertedRowIds.has(row.id) ? 'inserted-row-highlight' : '' insertedRowIds.has(row.id) ? 'inserted-row-highlight' : ''
]" ]"
:style="editorStore.nodeMap.get(row.id)?.node.attributes?.MERGED === 'TRUE' ? { backgroundColor: 'yellow' } : {}"
@click.stop="editorStore.setSelectedNodeId(row.id)" @click.stop="editorStore.setSelectedNodeId(row.id)"
> >
<!-- 行号选择单元格 --> <!-- 行号选择单元格 -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment