Commit c9002bb4 by pangchong

refactor(editor): 优化分页符相关代码结构和样式

- 调整分页符渲染部分的代码格式,提升代码可读性
- 增加分页符说明文字,提示导出和打印预览时分页效果
- 优化节点删除逻辑的代码缩进和换行,增强代码清晰度
- 微调部分静态常量导入格式,统一代码风格
parent 84c44c7d
...@@ -222,4 +222,3 @@ export const TRANSLATE_TARGET_TAGS = ['PARAC', 'TITLEC'] ...@@ -222,4 +222,3 @@ export const TRANSLATE_TARGET_TAGS = ['PARAC', 'TITLEC']
// 虚拟辅助排版标签集(不参与 DTD 规则约束,如打印换页符) // 虚拟辅助排版标签集(不参与 DTD 规则约束,如打印换页符)
export const VIRTUAL_LAYOUT_TAGS = ['PAGEBREAK'] export const VIRTUAL_LAYOUT_TAGS = ['PAGEBREAK']
import { ImageOutline, GridOutline, DocumentTextOutline, CreateOutline, RemoveOutline, ListOutline, ReturnDownForwardOutline } from '@vicons/ionicons5' import {
ImageOutline,
GridOutline,
DocumentTextOutline,
CreateOutline,
RemoveOutline,
ListOutline,
ReturnDownForwardOutline
} from '@vicons/ionicons5'
/** /**
* EditorToolbar 组件级静态常量 * EditorToolbar 组件级静态常量
......
...@@ -221,7 +221,10 @@ ...@@ -221,7 +221,10 @@
<span class="text-[8px] bg-primary-1 text-primary px-1 rounded font-bold scale-[0.9]">PAGEBREAK</span> <span class="text-[8px] bg-primary-1 text-primary px-1 rounded font-bold scale-[0.9]">PAGEBREAK</span>
</div> </div>
<div class="flex items-center select-none w-full scale-[0.9] origin-left my-1.5"> <div class="flex items-center select-none w-full scale-[0.9] origin-left my-1.5">
<div class="flex-1 border-t border-dashed" style="border-color: color-mix(in srgb, var(--primary-color) 40%, transparent)"></div> <div
class="flex-1 border-t border-dashed"
style="border-color: color-mix(in srgb, var(--primary-color) 40%, transparent)"
></div>
<span <span
class="mx-1 text-[8px] px-1 py-0.5 rounded border border-dashed flex-shrink-0" class="mx-1 text-[8px] px-1 py-0.5 rounded border border-dashed flex-shrink-0"
style=" style="
...@@ -232,10 +235,15 @@ ...@@ -232,10 +235,15 @@
> >
分页符 [Page Break] 分页符 [Page Break]
</span> </span>
<div class="flex-1 border-t border-dashed" style="border-color: color-mix(in srgb, var(--primary-color) 40%, transparent)"></div> <div
class="flex-1 border-t border-dashed"
style="border-color: color-mix(in srgb, var(--primary-color) 40%, transparent)"
></div>
</div> </div>
</div> </div>
<div class="text-[10px] text-color3 mt-2 text-center leading-relaxed">在选定节点下方插入分页标记,导出和打印预览时在该处换页。</div> <div class="text-[10px] text-color3 mt-2 text-center leading-relaxed">
在选定节点下方插入分页标记,导出和打印预览时在该处换页。
</div>
</template> </template>
</div> </div>
</div> </div>
......
...@@ -855,16 +855,17 @@ export function useNodeTree( ...@@ -855,16 +855,17 @@ export function useNodeTree(
// 删除节点(受 DTD 约束,文本节点和分页符节点永远允许删除) // 删除节点(受 DTD 约束,文本节点和分页符节点永远允许删除)
if (parent) { if (parent) {
const deletable = (isVirtual || VIRTUAL_LAYOUT_TAGS.includes(node.tagName)) const deletable =
? true isVirtual || VIRTUAL_LAYOUT_TAGS.includes(node.tagName)
: (() => { ? true
const existingTags = parent.children.filter((c) => !VIRTUAL_LAYOUT_TAGS.includes(c.tagName)).map((c) => c.tagName) : (() => {
// 位置特许规则:父级中最后一个子节点(按位置)允许删除 const existingTags = parent.children.filter((c) => !VIRTUAL_LAYOUT_TAGS.includes(c.tagName)).map((c) => c.tagName)
if (existingTags.length > 0 && existingTags[existingTags.length - 1] === node.tagName) { // 位置特许规则:父级中最后一个子节点(按位置)允许删除
return true if (existingTags.length > 0 && existingTags[existingTags.length - 1] === node.tagName) {
} return true
return canDeleteChild(parent.tagName, node.tagName, existingTags) }
})() return canDeleteChild(parent.tagName, node.tagName, existingTags)
})()
options.push({ options.push({
label: '删除节点', label: '删除节点',
key: 'deleteNode', key: 'deleteNode',
......
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