Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Parse `<img>` tags when pasting https://github.com/siyuan-note/siyuan/issues/15464

Danielaabb85d89562
diff --git a/kernel/model/import.go b/kernel/model/import.go
index 51c78876d1..e00aac8163 100644
--- a/kernel/model/import.go
+++ b/kernel/model/import.go
@@ -1374,6 +1374,15 @@ func htmlBlock2Inline(tree *parse.Tree) {
img.AppendChild(&ast.Node{Type: ast.NodeLinkTitle})
}
img.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
+ if width := domAttrValue(htmlImg, "width"); "" != width {
+ if util2.IsDigit(width) {
+ width += "px"
+ }
+ style := "width: " + width + ";"
+ ial := &ast.Node{Type: ast.NodeKramdownSpanIAL, Tokens: parse.IAL2Tokens([][]string{{"style", style}})}
+ img.SetIALAttr("style", style)
+ img.InsertAfter(ial)
+ }
if nil != n.Parent && ast.NodeText == n.Type {
// 行级 HTML 会被解析为文本,所以这里要在父级段落前面插入,避免形成段落嵌套 https://github.com/siyuan-note/siyuan/issues/13080