Adds v-pre to code blocks in comments

Closes #22911
This commit is contained in:
Phil Hughes 2016-10-04 14:06:44 +01:00
parent 796f531f2b
commit 138e26b1fa
4 changed files with 17 additions and 3 deletions

View file

@ -14,6 +14,7 @@ v 8.13.0 (unreleased)
- Simplify Mentionable concern instance methods - Simplify Mentionable concern instance methods
- Fix permission for setting an issue's due date - Fix permission for setting an issue's due date
- Expose expires_at field when sharing project on API - Expose expires_at field when sharing project on API
- Fix VueJS template tags being rendered in code comments
- Fix issue with page scrolling to top when closing or pinning sidebar (lukehowell) - Fix issue with page scrolling to top when closing or pinning sidebar (lukehowell)
- Allow the Koding integration to be configured through the API - Allow the Koding integration to be configured through the API
- Added soft wrap button to repository file/blob editor - Added soft wrap button to repository file/blob editor

View file

@ -25,7 +25,7 @@ module Banzai
return if customized?(whitelist[:transformers]) return if customized?(whitelist[:transformers])
# Allow code highlighting # Allow code highlighting
whitelist[:attributes]['pre'] = %w(class) whitelist[:attributes]['pre'] = %w(class v-pre)
whitelist[:attributes]['span'] = %w(class) whitelist[:attributes]['span'] = %w(class)
# Allow table alignment # Allow table alignment

View file

@ -30,7 +30,8 @@ module Banzai
# users can still access an issue/comment/etc. # users can still access an issue/comment/etc.
end end
highlighted = %(<pre class="#{css_classes}"><code>#{code}</code></pre>) highlighted = %(<pre class="#{css_classes}" v-pre="true"><code>#{code}</code></pre>)
puts highlighted
# Extracted to a method to measure it # Extracted to a method to measure it
replace_parent_pre_element(node, highlighted) replace_parent_pre_element(node, highlighted)

View file

@ -240,6 +240,18 @@ describe 'Comments', feature: true do
is_expected.to have_css('.notes_holder .note', count: 1) is_expected.to have_css('.notes_holder .note', count: 1)
is_expected.to have_button('Reply...') is_expected.to have_button('Reply...')
end end
it 'adds code to discussion' do
click_button 'Reply...'
page.within(first('.js-discussion-note-form')) do
fill_in 'note[note]', with: '```{{ test }}```'
click_button('Comment')
end
expect(page).to have_content('{{ test }}')
end
end end
end end
end end