[28350] Fix bound element to pre block to avoid recursive insertion

When the outer pre element is not bound to the model code block, it is
not consumed for insertion and is thus treated as a container node where
we continue to insert _within_. This results in multiple code blocks
being nested into one another.

https://community.openproject.com/wp/28350
pull/6569/head
Oliver Günther 6 years ago
parent 8fbd3b367b
commit f39acbce2b
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 2
      app/assets/javascripts/vendor/ckeditor/ckeditor.js
  2. 2
      app/assets/javascripts/vendor/ckeditor/ckeditor.js.map
  3. 31
      spec/features/wysiwyg/macros/code_block_macro_spec.rb

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -59,6 +59,37 @@ describe 'Wysiwyg code block macro', type: :feature, js: true do
visit project_wiki_path(project, :wiki)
end
it 'can add and save multiple code blocks (Regression #28350)' do
editor.in_editor do |container,|
editor.set_markdown expected
# Expect first macro saved to editor
expect(container).to have_selector('.op-ckeditor--code-block', text: snippet)
expect(container).to have_selector('.op-ckeditor--code-block-language', text: 'ruby')
editor.set_markdown "#{expected}\n#{expected}"
expect(container).to have_selector('.op-ckeditor--code-block', text: snippet, count: 2)
expect(container).to have_selector('.op-ckeditor--code-block-language', text: 'ruby', count: 2)
end
click_on 'Save'
expect(page).to have_selector('.flash.notice')
# Expect output widget
within('#content') do
expect(page).to have_selector('pre.highlight-ruby', count: 2)
end
# Edit page again, expect widget
click_on 'Edit'
editor.in_editor do |container,|
expect(container).to have_selector('.op-ckeditor--code-block', text: snippet, count: 2)
expect(container).to have_selector('.op-ckeditor--code-block-language', text: 'ruby', count: 2)
end
end
it 'can add and edit a code block widget' do
editor.in_editor do |container,|
editor.click_toolbar_button 'Insert code snippet'

Loading…
Cancel
Save