Fixes #3965 - Can not start a row in a knowledge base article with a linked answer
This commit is contained in:
parent
a2ed9a767e
commit
20015da4d3
4 changed files with 29 additions and 7 deletions
|
@ -30,11 +30,12 @@ class App.UiElement.richtext.additions.RichTextToolButton
|
|||
html: true
|
||||
animation: false
|
||||
delay: 0
|
||||
placement: 'auto'
|
||||
placement: 'top'
|
||||
theme: 'dark'
|
||||
content: content
|
||||
container: 'body'
|
||||
template: '<div class="popover popover--has-horizontal-form" role="tooltip"><div class="arrow"></div><h2 class="popover-title"></h2><div class="popover-content"></div></div>'
|
||||
container: '.page-content .main'
|
||||
viewport: { selector: '.page-content .main', padding: 10 }
|
||||
template: '<div class="popover popover--has-horizontal-form popover--richtextpopover" role="tooltip"><div class="arrow"></div><h2 class="popover-title"></h2><div class="popover-content"></div></div>'
|
||||
|
||||
hash
|
||||
|
||||
|
|
|
@ -40,6 +40,16 @@ class App.UiElement.richtext.additions.RichTextToolPopup extends App.ControllerF
|
|||
|
||||
$(@event.currentTarget).on('hidden.bs.popover', (e) => @willClose(e))
|
||||
|
||||
$(document).on('click', @onClickingBackround)
|
||||
|
||||
onClickingBackround: (e) =>
|
||||
return true if @el[0].contains(e.target)
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
$(@event.currentTarget).popover('destroy')
|
||||
|
||||
getAjaxAttributes: (field, attributes) ->
|
||||
@delegate?.getAjaxAttributes?(field, attributes)
|
||||
|
||||
|
@ -152,5 +162,5 @@ class App.UiElement.richtext.additions.RichTextToolPopup extends App.ControllerF
|
|||
textEditor = $(@event.currentTarget).closest('.richtext.form-control').find('[contenteditable]')
|
||||
textEditor.find('span.highlight-emulator').contents().unwrap()
|
||||
|
||||
$(document).off('click', @onClickingBackround)
|
||||
$(@event.currentTarget).off('hidden.bs.popover')
|
||||
$(e.currentTarget).popover('destroy')
|
||||
|
|
|
@ -21,6 +21,10 @@ class App.UiElement.richtext.additions.RichTextToolPopupAnswer extends App.UiEle
|
|||
apply: (callback) ->
|
||||
id = @el.find('input').val()
|
||||
object = App.KnowledgeBaseAnswerTranslation.find(id)
|
||||
|
||||
if !object
|
||||
return
|
||||
|
||||
textEditor = $(@event.currentTarget).closest('.richtext.form-control').find('[contenteditable]')
|
||||
|
||||
switch @selection.type
|
||||
|
@ -33,8 +37,15 @@ class App.UiElement.richtext.additions.RichTextToolPopupAnswer extends App.UiEle
|
|||
when 'caret'
|
||||
newElem = $('<a>')
|
||||
@applyOnto(newElem, object, object.title)
|
||||
|
||||
selectionElem = @selection.dom[0]
|
||||
|
||||
if selectionElem.splitText
|
||||
@selection.dom[0].splitText(@selection.offset)
|
||||
newElem.insertAfter(@selection.dom)
|
||||
else
|
||||
newElem.prependTo(@selection.dom)
|
||||
|
||||
when 'range'
|
||||
placeholder = textEditor.find('span.highlight-emulator')
|
||||
newElem = $('<a>')
|
||||
|
|
|
@ -50,7 +50,7 @@ App.PopoverProvidable =
|
|||
|
||||
anyPopoversDestroy: ->
|
||||
# do not remove permanent .popover--notifications widget
|
||||
$('.popover:not(.popover--notifications)').remove()
|
||||
$('.popover:not(.popover--notifications,.popover--richtextpopover)').remove()
|
||||
|
||||
extended: ->
|
||||
@include InstanceMethods
|
||||
|
|
Loading…
Reference in a new issue