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
|
html: true
|
||||||
animation: false
|
animation: false
|
||||||
delay: 0
|
delay: 0
|
||||||
placement: 'auto'
|
placement: 'top'
|
||||||
theme: 'dark'
|
theme: 'dark'
|
||||||
content: content
|
content: content
|
||||||
container: 'body'
|
container: '.page-content .main'
|
||||||
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>'
|
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
|
hash
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,16 @@ class App.UiElement.richtext.additions.RichTextToolPopup extends App.ControllerF
|
||||||
|
|
||||||
$(@event.currentTarget).on('hidden.bs.popover', (e) => @willClose(e))
|
$(@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) ->
|
getAjaxAttributes: (field, attributes) ->
|
||||||
@delegate?.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 = $(@event.currentTarget).closest('.richtext.form-control').find('[contenteditable]')
|
||||||
textEditor.find('span.highlight-emulator').contents().unwrap()
|
textEditor.find('span.highlight-emulator').contents().unwrap()
|
||||||
|
|
||||||
|
$(document).off('click', @onClickingBackround)
|
||||||
$(@event.currentTarget).off('hidden.bs.popover')
|
$(@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) ->
|
apply: (callback) ->
|
||||||
id = @el.find('input').val()
|
id = @el.find('input').val()
|
||||||
object = App.KnowledgeBaseAnswerTranslation.find(id)
|
object = App.KnowledgeBaseAnswerTranslation.find(id)
|
||||||
|
|
||||||
|
if !object
|
||||||
|
return
|
||||||
|
|
||||||
textEditor = $(@event.currentTarget).closest('.richtext.form-control').find('[contenteditable]')
|
textEditor = $(@event.currentTarget).closest('.richtext.form-control').find('[contenteditable]')
|
||||||
|
|
||||||
switch @selection.type
|
switch @selection.type
|
||||||
|
@ -33,8 +37,15 @@ class App.UiElement.richtext.additions.RichTextToolPopupAnswer extends App.UiEle
|
||||||
when 'caret'
|
when 'caret'
|
||||||
newElem = $('<a>')
|
newElem = $('<a>')
|
||||||
@applyOnto(newElem, object, object.title)
|
@applyOnto(newElem, object, object.title)
|
||||||
|
|
||||||
|
selectionElem = @selection.dom[0]
|
||||||
|
|
||||||
|
if selectionElem.splitText
|
||||||
@selection.dom[0].splitText(@selection.offset)
|
@selection.dom[0].splitText(@selection.offset)
|
||||||
newElem.insertAfter(@selection.dom)
|
newElem.insertAfter(@selection.dom)
|
||||||
|
else
|
||||||
|
newElem.prependTo(@selection.dom)
|
||||||
|
|
||||||
when 'range'
|
when 'range'
|
||||||
placeholder = textEditor.find('span.highlight-emulator')
|
placeholder = textEditor.find('span.highlight-emulator')
|
||||||
newElem = $('<a>')
|
newElem = $('<a>')
|
||||||
|
|
|
@ -50,7 +50,7 @@ App.PopoverProvidable =
|
||||||
|
|
||||||
anyPopoversDestroy: ->
|
anyPopoversDestroy: ->
|
||||||
# do not remove permanent .popover--notifications widget
|
# do not remove permanent .popover--notifications widget
|
||||||
$('.popover:not(.popover--notifications)').remove()
|
$('.popover:not(.popover--notifications,.popover--richtextpopover)').remove()
|
||||||
|
|
||||||
extended: ->
|
extended: ->
|
||||||
@include InstanceMethods
|
@include InstanceMethods
|
||||||
|
|
Loading…
Reference in a new issue