Commit 3c1eb907d0bf58b5197f7bae6f7c3a940ceb8ef9

Authored by Victor Costa
2 parents 23e94684 338114ff

Merge branch 'AI3205-comment-paragraph' into stable

plugins/comment_paragraph/lib/ext/article.rb
... ... @@ -24,14 +24,14 @@ class Article
24 24 if body && (body_changed? || setting_changed?(:comment_paragraph_plugin_activate))
25 25 updated = body_changed? ? body_change[1] : body
26 26 doc = Nokogiri::HTML(updated)
27   - doc.css('body > div, body > span, body > p, li').each do |paragraph|
  27 + doc.css('li, body > div, body > span, body > p').each do |paragraph|
28 28 next if paragraph.css('[data-macro="comment_paragraph_plugin/allow_comment"]').present? || paragraph.content.blank?
29 29  
30 30 commentable = Nokogiri::XML::Node.new("span", doc)
31 31 commentable['class'] = "macro article_comments paragraph_comment #{paragraph['class']}"
32 32 commentable['data-macro'] = 'comment_paragraph_plugin/allow_comment'
33 33 commentable['data-macro-paragraph_uuid'] = SecureRandom.uuid
34   - commentable.inner_html = paragraph.content
  34 + commentable.inner_html = paragraph.inner_html
35 35 paragraph.inner_html = commentable
36 36 end
37 37 self.body = doc.at('body').inner_html
... ...
plugins/comment_paragraph/test/unit/article_test.rb
... ... @@ -49,6 +49,14 @@ class ArticleTest < ActiveSupport::TestCase
49 49 assert_mark_paragraph article.body, 'li', 'item2'
50 50 end
51 51  
  52 + should 'parse inner html li when activate comment paragraph' do
  53 + article.body = '<div><ul><li class="custom_class">item1</li><li>item2</li></ul><div>'
  54 + article.comment_paragraph_plugin_activate = true
  55 + article.save!
  56 + assert_mark_paragraph article.body, 'li', 'item1'
  57 + assert_mark_paragraph article.body, 'li', 'item2'
  58 + end
  59 +
52 60 should 'do not remove macro div when disable comment paragraph' do
53 61 article.body = "<p>paragraph 1</p>"
54 62 article.comment_paragraph_plugin_activate = true
... ...