Commit d0c3ebe 1 parent 462fff0 commit d0c3ebe Copy full SHA for d0c3ebe
File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1149
1149
this . importSelection ( exportedSelection ) ;
1150
1150
} else {
1151
1151
this . options . ownerDocument . execCommand ( 'createLink' , false , targetUrl ) ;
1152
+ MediumEditor . util . ensureHref ( MediumEditor . selection . getSelectionStart ( this . options . ownerDocument ) , targetUrl ) ;
1152
1153
}
1153
1154
1154
1155
if ( this . options . targetBlank || opts . target === '_blank' ) {
Original file line number Diff line number Diff line change 572
572
return doc . execCommand ( 'formatBlock' , false , tagName ) ;
573
573
} ,
574
574
575
+ /*
576
+ * this function is called to ensure href is set correctly as FF does "encodeURI" on href value when execCommand createLink.
577
+ * see also https://bugzilla.mozilla.org/show_bug.cgi?id=451142
578
+ */
579
+ ensureHref : function ( el , anchorUrl ) {
580
+ var i , url = anchorUrl ;
581
+ if ( el . nodeName . toLowerCase ( ) === 'a' ) {
582
+ el . attributes . href . value = url ;
583
+ } else {
584
+ el = el . getElementsByTagName ( 'a' ) ;
585
+
586
+ for ( i = 0 ; i < el . length ; i += 1 ) {
587
+ if ( encodeURI ( url ) === el [ i ] . attributes . href . value ) {
588
+ el [ i ] . attributes . href . value = url ;
589
+ }
590
+ }
591
+ }
592
+ } ,
593
+
575
594
/**
576
595
* Set target to blank on the given el element
577
596
*
You can’t perform that action at this time.
0 commit comments