feat(asset): add AssetID to ContentChunk and update image handling in HTML content

This commit is contained in:
mlogclub
2026-04-17 13:35:00 +08:00
parent f4761d768c
commit 0037b97f29
5 changed files with 18 additions and 108 deletions
+4 -1
View File
@@ -16,6 +16,7 @@ const (
type ContentChunk struct {
Type ContentChunkType //
Content string // text content or image url
AssetID string // image asset id
}
func SplitHTMLContentChunks(content string) ([]ContentChunk, error) {
@@ -57,12 +58,14 @@ func SplitHTMLContentChunks(content string) ([]ContentChunk, error) {
case "img":
flushText()
src := strings.TrimSpace(findContentChunkHTMLAttr(node, "src"))
if src == "" {
assetID := strings.TrimSpace(findContentChunkHTMLAttr(node, "data-asset-id"))
if src == "" && assetID == "" {
return
}
chunks = append(chunks, ContentChunk{
Type: ContentChunkTypeImage,
Content: src,
AssetID: assetID,
})
return
}