@@ -731,6 +731,13 @@ angular.module('textAngularSetup', [])
731
731
var imageLink ;
732
732
imageLink = $window . prompt ( taTranslations . insertImage . dialogPrompt , 'http://' ) ;
733
733
if ( imageLink && imageLink !== '' && imageLink !== 'http://' ) {
734
+ /* istanbul ignore next: don't know how to test this... since it needs a dialogPrompt */
735
+ if ( taSelection . getSelectionElement ( ) . tagName . toLowerCase ( ) === 'a' ) {
736
+ // due to differences in implementation between FireFox and Chrome, we must move the
737
+ // insertion point past the <a> element, otherwise FireFox inserts inside the <a>
738
+ // With this change, both FireFox and Chrome behave the same way!
739
+ taSelection . setSelectionAfterElement ( taSelection . getSelectionElement ( ) ) ;
740
+ }
734
741
return this . $editor ( ) . wrapSelection ( 'insertImage' , imageLink , true ) ;
735
742
}
736
743
} ,
@@ -757,6 +764,13 @@ angular.module('textAngularSetup', [])
757
764
// for all options see: http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
758
765
// maxresdefault.jpg seems to be undefined on some.
759
766
var embed = '<img class="ta-insert-video" src="https://img.youtube.com/vi/' + videoId + '/hqdefault.jpg" ta-insert-video="' + urlLink + '" contenteditable="false" allowfullscreen="true" frameborder="0" />' ;
767
+ /* istanbul ignore next: don't know how to test this... since it needs a dialogPrompt */
768
+ if ( taSelection . getSelectionElement ( ) . tagName . toLowerCase ( ) === 'a' ) {
769
+ // due to differences in implementation between FireFox and Chrome, we must move the
770
+ // insertion point past the <a> element, otherwise FireFox inserts inside the <a>
771
+ // With this change, both FireFox and Chrome behave the same way!
772
+ taSelection . setSelectionAfterElement ( taSelection . getSelectionElement ( ) ) ;
773
+ }
760
774
// insert
761
775
return this . $editor ( ) . wrapSelection ( 'insertHTML' , embed , true ) ;
762
776
}
0 commit comments