Skip to content

Commit

Permalink
🎨 Protyle Improve img link dest siyuan-note/siyuan#13497
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 16, 2024
1 parent 8647e47 commit 8ec5512
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion protyle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ func (lute *Lute) genASTContenteditable(n *html.Node, tree *parse.Tree) {
node.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: util.StrToBytes(alt)})
node.AppendChild(&ast.Node{Type: ast.NodeCloseBracket})
node.AppendChild(&ast.Node{Type: ast.NodeOpenParen})
src := util.DomAttrValue(img, "data-src")
src := strings.TrimSpace(util.DomAttrValue(img, "data-src"))
node.AppendChild(&ast.Node{Type: ast.NodeLinkDest, Tokens: util.StrToBytes(src)})
if title := util.DomAttrValue(img, "title"); "" != title {
node.AppendChild(&ast.Node{Type: ast.NodeLinkSpace})
Expand Down
1 change: 1 addition & 0 deletions test/spin_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var spinBlockDOMTests = []*parseTest{

{"239", "<div data-node-id=\"20241216215356-8csb7bj\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241216215405\"><div contenteditable=\"true\" spellcheck=\"false\">​<span contenteditable=\"false\" data-type=\"img\" class=\"img\"><span> </span><span><span class=\"protyle-action protyle-icons\"><span class=\"protyle-icon protyle-icon--only\"><svg class=\"svg\"><use xlink:href=\"#iconMore\"></use></svg></span></span><img src=\" assets/image-20241216215356-kcrpglk.png\" data-src=\" assets/image-20241216215356-kcrpglk.png\" loading=\"lazy\" alt=\"image\"><span class=\"protyle-action__drag\"></span><span class=\"img__net\"><svg><use xlink:href=\"#iconLanguage\"></use></svg></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>​</div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241216215356-8csb7bj\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241216215405\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span contenteditable=\"false\" data-type=\"img\" class=\"img\"><span> </span><span><span class=\"protyle-action protyle-icons\"><span class=\"protyle-icon protyle-icon--only\"><svg class=\"svg\"><use xlink:href=\"#iconMore\"></use></svg></span></span><img src=\"assets/image-20241216215356-kcrpglk.png\" data-src=\"assets/image-20241216215356-kcrpglk.png\" loading=\"lazy\" alt=\"image\" /><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>\u200b</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"238", "<div data-node-id=\"20241211073144-72jsrs1\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073144\"><div contenteditable=\"true\" spellcheck=\"true\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt;着重符号&lt;span&gt; <span data-type=\"block-ref\" data-subtype=\"s\" data-id=\"20241210194444-oqwwntf\">*</span></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241211073144-72jsrs1\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073144\"><div contenteditable=\"true\" spellcheck=\"false\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt; 着重符号 &lt;span&gt; <span data-type=\"block-ref\" data-subtype=\"s\" data-id=\"20241210194444-oqwwntf\">*</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"237", "<div data-node-id=\"20241211073030-vjzgigb\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073030\"><div contenteditable=\"true\" spellcheck=\"true\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt;着重符号&lt;span&gt;</div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241211073030-vjzgigb\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073030\"><div contenteditable=\"true\" spellcheck=\"false\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt; 着重符号 &lt;span&gt;</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"236", "<div data-node-id=\"20241201123502-sm8drny\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241201173738\"><div contenteditable=\"true\" spellcheck=\"false\">​<span contenteditable=\"false\" data-type=\"img\" class=\"img\" style=\"min-width: calc(100% - 0.1em);\"><span> </span><span style=\" width: 469px;\"><span class=\"protyle-action protyle-icons\"><span class=\"protyle-icon protyle-icon--only\"><svg class=\"svg\"><use xlink:href=\"#iconMore\"></use></svg></span></span><img src=\"assets/image-20241201123502-bou3n94.png\" data-src=\"assets/image-20241201123502-bou3n94.png\" loading=\"lazy\" alt=\"image\" style=\"height: 67vh;\"><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>1<wbr><br></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241201123502-sm8drny\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241201173738\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span contenteditable=\"false\" data-type=\"img\" class=\"img\" style=\"min-width: calc(100% - 0.1em);\"><span> </span><span style=\"width: 469px;\"><span class=\"protyle-action protyle-icons\"><span class=\"protyle-icon protyle-icon--only\"><svg class=\"svg\"><use xlink:href=\"#iconMore\"></use></svg></span></span><img src=\"assets/image-20241201123502-bou3n94.png\" data-src=\"assets/image-20241201123502-bou3n94.png\" loading=\"lazy\" alt=\"image\" style=\"height: 67vh;\" /><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>1<wbr><br /></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit 8ec5512

Please sign in to comment.