feat(电子公文): 支持标引解析与原文定位
build.yaml / build (push) Successful in 49s

This commit is contained in:
xiaoqidun committed 2026-10-13 00:30:27 +08:00
1 parent 3780a25140
commit e86fc6a4e0
10 files changed
+823 -8

No files matched your search

+14
View File
@@ -207,6 +207,7 @@ func RunWASM() {
registerCallback("ofdgoVerifySignatures", verifySignatures)
registerCallback("ofdgoRenderPage", renderPage)
registerCallback("ofdgoOutlineLinks", outlineLinks)
registerCallback("ofdgoStructureTargets", structureTargets)
registerCallback("ofdgoOpenLinks", openLinks)
registerCallback("ofdgoRenderBackends", renderBackends)
registerCallback("ofdgoSVGFontData", svgFontData)
@@ -922,6 +923,19 @@ func outlineLinks(args []js.Value) (any, error) {
return linkResults(links)
}
// structureTargets 查询当前文档标引节点的原文与定位范围
// 入参: args 标引清单索引和节点路径
// 返回: any 标引目标, error 参数或解析错误
func structureTargets(args []js.Value) (any, error) {
if currentSession == nil {
return nil, fmt.Errorf("ofd document is not opened")
}
if len(args) != 2 {
return nil, fmt.Errorf("missing structure path")
}
return currentSession.Renderer.StructureTargets(args[0].Int(), indexesFromJS(args[1]))
}
// linkResults 将库层动作目标转换为浏览器数据
// 入参: source 动作目标
// 返回: []any 浏览器动作数据, error 附件读取错误
+19 -8
View File
@@ -97,6 +97,8 @@ type DocumentInfo struct {
Signatures []SignatureInfo `json:"signatures"`
Pages []PageInfo `json:"pages"`
Outlines []OutlineInfo `json:"outlines,omitempty"`
Structures []ofdgo.Structure `json:"structures,omitempty"`
StructureError string `json:"structureError,omitempty"`
DetailsPending bool `json:"detailsPending,omitempty"`
}
@@ -122,13 +124,15 @@ type DocumentEntry struct {
// DocumentDetails 不含页面数组的文档补充信息
type DocumentDetails struct {
FontCount int `json:"fontCount"`
SignatureCount int `json:"signatureCount"`
SignatureError string `json:"signatureError,omitempty"`
AttachmentError string `json:"attachmentError,omitempty"`
Attachments []AttachmentInfo `json:"attachments,omitempty"`
Fonts []FontInfo `json:"fonts"`
Signatures []SignatureInfo `json:"signatures"`
Structures []ofdgo.Structure `json:"structures,omitempty"`
StructureError string `json:"structureError,omitempty"`
FontCount int `json:"fontCount"`
SignatureCount int `json:"signatureCount"`
SignatureError string `json:"signatureError,omitempty"`
AttachmentError string `json:"attachmentError,omitempty"`
Attachments []AttachmentInfo `json:"attachments,omitempty"`
Fonts []FontInfo `json:"fonts"`
Signatures []SignatureInfo `json:"signatures"`
}
// OutlineInfo 目录节点信息
@@ -513,10 +517,15 @@ func (s *Session) Summary() DocumentInfo {
return info
}
// Details 获取无需逐页扫描的附件、签名及字体匹配结果
// Details 获取无需逐页扫描的标引、附件、签名及字体匹配结果
// 返回: DocumentDetails 文档补充信息
func (s *Session) Details() DocumentDetails {
info := DocumentDetails{}
if structures, err := s.Reader.Structure(); err == nil {
info.Structures = structures
} else {
info.StructureError = err.Error()
}
if attachments, err := s.Reader.Attachments(); err == nil {
for _, attachment := range attachments {
if attachment.Visible || s.editing {
@@ -551,6 +560,8 @@ func (s *Session) Details() DocumentDetails {
func (s *Session) Info() DocumentInfo {
info := s.Summary()
details := s.Details()
info.Structures = details.Structures
info.StructureError = details.StructureError
info.Attachments = details.Attachments
info.AttachmentError = details.AttachmentError
info.Signatures = details.Signatures