Skip to content

Commit

Permalink
🐛 任务列表暴露 ID 问题 siyuan-note/siyuan#429
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Nov 6, 2020
1 parent eb532bf commit 436e5c7
Show file tree
Hide file tree
Showing 4 changed files with 8 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.

1 change: 1 addition & 0 deletions test/spinv_ir_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var spinVditorIRBlockDOMTests = []*parseTest{

{"57", "<ul data-marker=\"*\" data-block=\"0\" data-node-id=\"20201106094752-tw5u1zz\" data-type=\"ul\"><li data-marker=\"*\" class=\"vditor-task\" data-node-id=\"20201106094752-n0uvzjy\"><p data-block=\"0\" data-node-id=\"20201106094826-al3hi61\" data-type=\"p\"><input type=\"checkbox\"> foo</p></li><li data-marker=\"*\" class=\"vditor-task\" data-node-id=\"20201106094756-g8cgvth\"><p data-block=\"0\" data-node-id=\"20201106094826-5ztcccc\" data-type=\"p\"><input type=\"checkbox\"> bar</p><p data-block=\"0\" data-node-id=\"20201106094826-x1uij4r\" data-type=\"p\">ba<wbr></p></li></ul>", "<ul data-marker=\"*\" data-block=\"0\" data-node-id=\"20201106094752-tw5u1zz\" data-type=\"ul\"><li data-marker=\"*\" class=\"vditor-task\" data-node-id=\"20201106094752-n0uvzjy\"><p data-block=\"0\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"p\"><input type=\"checkbox\" /> foo</p></li><li data-marker=\"*\" class=\"vditor-task\" data-node-id=\"20201106094756-g8cgvth\"><p data-block=\"0\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"p\"><input type=\"checkbox\" /> bar</p><p data-block=\"0\" data-node-id=\"20201106094826-x1uij4r\" data-type=\"p\">ba<wbr></p></li></ul>"},
{"56", "<p data-block=\"0\" data-node-id=\"20201104222722-s61wm2l\" data-type=\"p\"><code><span data-type=\"html-inline\" class=\"vditor-ir__node\"><span class=\"vditor-ir__marker\">&lt;code<wbr></span></span></code></p>", "<p data-block=\"0\" data-node-id=\"20201104222722-s61wm2l\" data-type=\"p\">&lt;code<wbr></p>"},
{"55", "<p data-block=\"0\" data-node-id=\"20201104222722-s61wm2l\" data-type=\"p\"><code><span data-type=\"html-inline\" class=\"vditor-ir__node\"><span class=\"vditor-ir__marker\">&lt;code&gt;f<wbr></span></span></code></p>", "<p data-block=\"0\" data-node-id=\"20201104222722-s61wm2l\" data-type=\"p\"><code><span data-type=\"html-inline\" class=\"vditor-ir__node\"><span class=\"vditor-ir__marker\">&lt;code&gt;</span></span>f<wbr></p>"},
{"54", "<ul data-tight=\"true\" data-marker=\"-\" data-block=\"0\" data-node-id=\"20201104105438-4m9bt3x\" data-type=\"ul\"><li data-marker=\"-\" data-node-id=\"20201104105440-h85slm9\">foo\n-<wbr></li></ul>", "<ul data-tight=\"true\" data-marker=\"-\" data-block=\"0\" data-node-id=\"20201104105438-4m9bt3x\" data-type=\"ul\"><li data-marker=\"-\" data-node-id=\"20201104105440-h85slm9\"><h2 data-block=\"0\" class=\"vditor-ir__node vditor-ir__node--expand\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"h\" id=\"ir-foo\" data-marker=\"-\">foo<wbr><span class=\"vditor-ir__marker vditor-ir__marker--heading\" data-type=\"heading-marker\" data-render=\"2\">\n---</span></h2></li></ul>"},
Expand Down
6 changes: 5 additions & 1 deletion vditor_ir_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,11 @@ func (lute *Lute) genASTByVditorIRBlockDOM(n *html.Node, tree *parse.Tree) {
if lute.hasAttr(n, "checked") {
node.TaskListItemChecked = true
}
tree.Context.Tip.AppendChild(node)
if ast.NodeParagraph == tree.Context.Tip.Type { // 松散任务列表,task marker 挂在 li 下第一个子节点
tree.Context.Tip.Parent.PrependChild(node)
} else {
tree.Context.Tip.AppendChild(node)
}
if nil != node.Parent.Parent.Parent && nil != node.Parent.Parent.Parent.ListData { // ul.li.p.input
node.Parent.Parent.Parent.ListData.Typ = 3
node.Parent.Parent.ListData.Typ = 3
Expand Down

0 comments on commit 436e5c7

Please sign in to comment.