Skip to content

Commit

Permalink
🎨 Protyle Improve continuous soft newline split block parsing siyuan-…
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jan 7, 2024
1 parent cc7390f commit 86795b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (t *Tree) finalParseBlockIAL() {

if t.Context.ParseOption.ProtyleWYSIWYG && t.Context.ParseOption.Spin &&
ast.NodeDocument != n.Type && nil != n.Next && ast.NodeKramdownBlockIAL != n.Next.Type && "" != n.Next.ID {
// 这个节点是 spin 后新生成的,将 n.Next 的 ID 和属性赋予它,并认为 n.Next 是新节点
// 这个节点是 spin 后新生成的,将 n.Next 的 ID 和属性赋予它,并认为 n.Next 是新节点 https://github.com/siyuan-note/siyuan/issues/5723
n.ID = n.Next.ID
n.KramdownIAL = n.Next.KramdownIAL
if "" == n.IALAttr("updated") {
Expand Down Expand Up @@ -400,9 +400,11 @@ type Options struct {
// 这个开关主要用于兼容 Markdown 输入 API 上 https://github.com/siyuan-note/siyuan/issues/6039
// 不用于 Protyle 自旋过程 https://github.com/siyuan-note/siyuan/issues/5877
HTMLTag2TextMark bool
// Spin 设置是否打开自旋解析支持,该选项仅用于 Spin 内部过程,外部请勿设置或使用。
// Spin 设置是否打开自旋解析支持,该选项仅用于 Spin 内部过程,设置时请注意使用场景。
//
// 该选项的引入主要为了解决 finalParseBlockIAL 过程中是否需要移动 IAL 节点的问题,只有处于自旋过程中才需要移动 IAL 节点
// 其他情况(比如 API 输入 markdown https://github.com/siyuan-note/siyuan/issues/6725)无需移动处理
// 其他情况,比如标题块软换行分块 https://github.com/siyuan-note/siyuan/issues/5723 以及软换行空行分块 https://ld246.com/article/1703839312585
// 的场景需要移动 IAL 节点,但是 API 输入 markdown https://github.com/siyuan-note/siyuan/issues/6725)无需移动
Spin bool
}

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{

{"213", "<div data-node-id=\"20240107150436-5y8mdyj\" data-node-index=\"4\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20240107153500\" style=\"background-color: var(--b3-card-error-background); color: var(--b3-card-error-color);\"><div contenteditable=\"true\" spellcheck=\"false\">foo\n\nb<wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20240107150436-5y8mdyj\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" style=\"background-color: var(--b3-card-error-background); color: var(--b3-card-error-color);\" updated=\"20240107153500\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"2\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">b<wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"212", "<div data-node-id=\"20231202195719-0j1mozn\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20231202213354\"><div contenteditable=\"true\" spellcheck=\"false\">`<span data-type=\"strong\">foo`<wbr></span></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20231202195719-0j1mozn\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20231202213354\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span data-type=\"code\">\u200bfoo</span>\u200b<wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"211", "<div data-node-id=\"20231202195719-0j1mozn\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20231202205111\"><div contenteditable=\"true\" spellcheck=\"false\">`<span data-type=\"code\">​&lt;div&gt;foo&lt;/div&gt;</span>​`<wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20231202195719-0j1mozn\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20231202205111\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span data-type=\"code\">\u200b&lt;div&gt;foo&lt;/div&gt;</span>\u200b<wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"210", "<div data-node-id=\"20231202195719-0j1mozn\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20231202195907\"><div contenteditable=\"true\" spellcheck=\"false\">​​`1<wbr>​<span data-type=\"code\">​foo</span>​`</div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20231202195719-0j1mozn\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20231202195907\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span data-type=\"code\">\u200b1<wbr>foo</span>\u200b</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit 86795b7

Please sign in to comment.