feat(编辑能力): 完善外观与链接编辑,修复文字缩放
build.yaml / build (push) Successful in 40s

This commit is contained in:
xiaoqidun committed 2026-09-24 12:50:51 +08:00
1 parent d7cd3d03b5
commit 06b5df9173
13 files changed
+448 -142

No files matched your search

+35 -1
View File
@@ -16,6 +16,7 @@ package ofdgo
import (
"fmt"
"maps"
"strings"
)
@@ -24,7 +25,10 @@ import (
// 入参: parts 输出覆盖条目
// 返回: error 读取或解析错误
func (e *Editor) prunePageReferences(parts map[string][]byte) error {
removed := make(map[string]bool)
removed := maps.Clone(e.removedPages)
if removed == nil {
removed = make(map[string]bool)
}
for id := range e.source.pages {
removed[id] = true
}
@@ -154,6 +158,36 @@ func (e *Editor) prunePageReferences(parts map[string][]byte) error {
return nil
}
// pruneCreatedPageReferences 清理创作文档中被明确删除页面的直接跳转,不检查其他目标是否可达
// 入参: data 创作XML, removed 已删除页面标识
// 返回: []byte 更新后的XML, error 解析错误
func pruneCreatedPageReferences(data []byte, removed map[string]bool) ([]byte, error) {
root, err := parseEditorXML(data)
if err != nil {
return nil, err
}
var patches []editorXMLPatch
var walk func(*editorXML)
walk = func(node *editorXML) {
if node.name.Space != ofdNamespace {
return
}
if node.name.Local == "Action" {
if target := node.child("Goto"); target != nil {
if dest := target.child("Dest"); dest != nil && removed[dest.attr("PageID")] {
patches = append(patches, editorXMLPatch{start: node.start, end: node.end})
return
}
}
}
for _, child := range node.children {
walk(child)
}
}
walk(root)
return editorPatchXML(data, patches), nil
}
// editorPageLocation 解析标准XML引用,优先使用所在文件的相对路径
// 入参: reader 原包, parts 覆盖条目, name 所在XML, value 路径
// 返回: string 包内路径, error 路径不存在