Skip to content

Commit

Permalink
🎨 Improve inline code markdown editing siyuan-note/siyuan#9805
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 2, 2023
1 parent e2e00a2 commit 1e21d61
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 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.

5 changes: 5 additions & 0 deletions protyle.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ func (lute *Lute) BlockDOM2Tree(htmlStr string) (ret *parse.Tree) {
htmlStr = strings.ReplaceAll(htmlStr, "\n<wbr>\n</s>", "</s>\n<wbr>\n")
htmlStr = strings.ReplaceAll(htmlStr, "\n<wbr>\n</u>", "</u>\n<wbr>\n")
htmlStr = strings.ReplaceAll(htmlStr, "\n<wbr>\n</span>", "</span>\n<wbr>\n")

// Improve `inline code` markdown editing https://github.com/siyuan-note/siyuan/issues/9805
// spinBlockDOMTests #212
htmlStr = strings.ReplaceAll(htmlStr, "`<wbr></span>", "</span>`<wbr>")

htmlStr = strings.ReplaceAll(htmlStr, "<wbr>", editor.Caret)

var startSpaces, endSpaces int
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{

{"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>"},
{"209", "<div data-node-id=\"20231109115518-48ngzmw\" data-node-index=\"1\" data-type=\"NodeHTMLBlock\" class=\"render-node\" updated=\"20231127225525\" data-subtype=\"block\"><div class=\"protyle-icons\"><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__edit\"><svg><use xlink:href=\"#iconEdit\"></use></svg></span><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-action__menu protyle-icon--last\"><svg><use xlink:href=\"#iconMore\"></use></svg></span></div><div><protyle-html data-content=\"&lt;div&gt;\ntest1\n&lt;/div&gt;\"></protyle-html><span style=\"position: absolute\">​</span></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20231109115518-48ngzmw\" data-node-index=\"1\" data-type=\"NodeHTMLBlock\" class=\"render-node\" updated=\"20231127225525\" data-subtype=\"block\"><div class=\"protyle-icons\"><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__edit\"><svg><use xlink:href=\"#iconEdit\"></use></svg></span><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-action__menu protyle-icon--last\"><svg><use xlink:href=\"#iconMore\"></use></svg></span></div><div><protyle-html data-content=\"&lt;div&gt;\ntest1\n&lt;/div&gt;\"></protyle-html><span style=\"position: absolute\">\u200b</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit 1e21d61

Please sign in to comment.