Fixes #3094, fixes #2334 - When quoting, no breakout from div container possible.

(cherry picked from commit e338309791)
This commit is contained in:
Dominik Klein 2021-10-22 14:23:31 +02:00
parent 49759f0be8
commit e54158c0a8
2 changed files with 41 additions and 5 deletions

View file

@ -114,11 +114,22 @@
sel = window.getSelection()
if (sel) {
node = $(sel.anchorNode)
if (node && node.parent() && node.parent().is('blockquote')) {
e.preventDefault()
document.execCommand('Insertparagraph')
document.execCommand('Outdent')
return
if (node.closest('blockquote').length > 0) {
// Special handling when the line is not wrapped inside of a html element.
if (!node.is('div') && node.parent().is('blockquote') && node.text()) {
e.preventDefault()
document.execCommand('formatBlock', false, 'div')
document.execCommand('insertParagraph')
return
}
if (!e.shiftKey && node && (node.is('blockquote') || (node.parent() && node.parent().is('blockquote')) || !node.text())) {
e.preventDefault()
document.execCommand('insertParagraph')
document.execCommand('outdent')
return
}
}
}

View file

@ -178,6 +178,31 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr
end
end
context 'when full quote header setting is enabled' do
let(:full_quote_header_setting) { true }
it 'can breakout with enter from quote block' do
within(:active_content) do
highlight_and_click_reply
within(:richtext) do
blockquote_empty_line = first('blockquote br:nth-child(2)', visible: :all)
page.driver.browser.action.move_to_location(blockquote_empty_line.native.location.x, blockquote_empty_line.native.location.y).click.perform
end
# Special handling for firefox, because the cursor is at the wrong location after the move to with click.
if Capybara.current_driver == :zammad_firefox
find(:richtext).send_keys(:down)
end
find(:richtext).send_keys(:enter)
within(:richtext) do
expect(page).to have_css('blockquote', count: 2)
end
end
end
end
end
def click_forward