Skip to content

Commit

Permalink
✨ 所见即所得模式加入评论 Vanessa219/vditor#721
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 29, 2020
1 parent 0713453 commit 352823c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 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.

6 changes: 2 additions & 4 deletions parse/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ func (t *Tree) parseInline(block *ast.Node, ctx *InlineContext) {
case lex.ItemNewline:
n = t.parseNewline(block, ctx)
case lex.ItemLess:
n = t.parseAutolink(ctx)
if nil == n {
n = t.parseAutoEmailLink(ctx)
if nil == n {
if n = t.parseAutolink(ctx); nil == n {
if n = t.parseAutoEmailLink(ctx); nil == n {
n = t.parseInlineHTML(ctx)
}
}
Expand Down
5 changes: 5 additions & 0 deletions render/vditor_wysiwyg_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,11 @@ func (r *VditorRenderer) renderInlineHTML(node *ast.Node, entering bool) ast.Wal
return ast.WalkStop
}

if bytes.Contains(node.Tokens, []byte("<span comment-id-")) || bytes.Equal(node.Tokens, []byte("</span>")) {
r.Write(node.Tokens)
return ast.WalkStop
}

if entering {
previousNodeText := node.PreviousNodeText()
previousNodeText = strings.ReplaceAll(previousNodeText, util.Caret, "")
Expand Down
1 change: 1 addition & 0 deletions test/m2v_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var md2VditorDOMTests = []parseTest{

{"21", "f<span comment-id-1>oo</span>", "<p data-block=\"0\">f<span comment-id-1>oo</span></p>"},
{"20", "\n > foo", "<div class=\"vditor-wysiwyg__block\" data-type=\"code-block\" data-block=\"0\" data-marker=\"```\"><pre class=\"vditor-wysiwyg__pre\" style=\"display: none\"><code> &gt; foo\n</code></pre><pre class=\"vditor-wysiwyg__preview\" data-render=\"2\"><code> &gt; foo\n</code></pre></div>"},
{"19", "foo\n{: id=\"fooid\"}\nbar\n{: id=\"barid\"}", "<p data-block=\"0\" id=\"fooid\">foo</p><p data-block=\"0\" id=\"barid\">bar</p>"},
{"18", "![][foo]\n\n[foo]: bar", "<p data-block=\"0\">\u200b<img src=\"bar\" alt=\"\" data-type=\"link-ref\" data-link-label=\"foo\" /></p><div data-block=\"0\" data-type=\"link-ref-defs-block\">[foo]: bar\n</div>"},
Expand Down

0 comments on commit 352823c

Please sign in to comment.