Page MenuHomeIn-Portal Phabricator

D259.diff
No OneTemporary

File Metadata

Created
Mon, Jan 6, 3:34 AM

D259.diff

Index: branches/5.2.x/core/ckeditor/plugins/my_link/plugin.js
===================================================================
--- branches/5.2.x/core/ckeditor/plugins/my_link/plugin.js
+++ branches/5.2.x/core/ckeditor/plugins/my_link/plugin.js
@@ -630,72 +630,48 @@
advAttr( 'advRel', 'rel' );
}
+ var selection = editor.getSelection();
// Browser need the "href" fro copy/paste link to work. (#6641)
- attributes.href = attributes[ 'data-cke-saved-href' ];
+ attributes.href = attributes['data-cke-saved-href'];
- if ( !this._.selectedElement )
- {
- // Create element if current selection is collapsed.
- var selection = editor.getSelection(),
- ranges = selection.getRanges( true );
- if ( ranges.length == 1 && ranges[0].collapsed )
- {
+ if ( !this._.selectedElement ) {
+ var range = selection.getRanges(1)[0];
+
+ // Use link URL as text with a collapsed cursor.
+ if ( range.collapsed ) {
// Short mailto link text view (#5736).
- var text = new CKEDITOR.dom.text( data.type == 'email' ?
- data.email.address : attributes[ 'data-cke-saved-href' ], editor.document );
- ranges[0].insertNode( text );
- ranges[0].selectNodeContents( text );
- selection.selectRanges( ranges );
+ var text = new CKEDITOR.dom.text(data.type == 'email' ? data.email.address : attributes['data-cke-saved-href'], editor.document);
+ range.insertNode(text);
+ range.selectNodeContents(text);
}
// Apply style.
- var style = new CKEDITOR.style( { element : 'a', attributes : attributes } );
- style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why.
- style.apply( editor.document );
+ var style = new CKEDITOR.style({element: 'a', attributes: attributes});
+ style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why.
+ style.applyToRange(range);
+ range.select();
}
- else
- {
+ else {
// We're only editing an existing link, so just overwrite the attributes.
var element = this._.selectedElement,
- href = element.data( 'cke-saved-href' ),
+ href = element.data('cke-saved-href'),
textView = element.getHtml();
- // IE BUG: Setting the name attribute to an existing link doesn't work.
- // Must re-create the link from weired syntax to workaround.
- if ( CKEDITOR.env.ie && !( CKEDITOR.document.$.documentMode >= 8 ) && attributes.name != element.getAttribute( 'name' ) )
- {
- var newElement = new CKEDITOR.dom.element( '<a name="' + CKEDITOR.tools.htmlEncode( attributes.name ) + '">',
- editor.document );
+ element.setAttributes(attributes);
+ element.removeAttributes(removeAttributes);
- selection = editor.getSelection();
-
- element.copyAttributes( newElement, { name : 1 } );
- element.moveChildren( newElement );
- newElement.replace( element );
- element = newElement;
-
- selection.selectElement( element );
+ if ( data.adv && data.adv.advName && CKEDITOR.plugins.link.synAnchorSelector ) {
+ element.addClass(element.getChildCount() ? 'cke_anchor' : 'cke_anchor_empty');
}
- element.setAttributes( attributes );
- element.removeAttributes( removeAttributes );
// Update text view when user changes protocol (#4612).
- if ( href == textView || data.type == 'email' && textView.indexOf( '@' ) != -1 )
- {
+ if ( href == textView || data.type == 'email' && textView.indexOf('@') != -1 ) {
// Short mailto link text view (#5736).
- element.setHtml( data.type == 'email' ?
- data.email.address : attributes[ 'data-cke-saved-href' ] );
+ element.setHtml(data.type == 'email' ? data.email.address : attributes['data-cke-saved-href']);
}
- // Make the element display as an anchor if a name has been set.
- if ( element.getAttribute( 'name' ) )
- element.addClass( 'cke_anchor' );
- else
- element.removeClass( 'cke_anchor' );
-
- if ( this.fakeObj )
- editor.createFakeElement( element, 'cke_anchor', 'anchor' ).replace( this.fakeObj );
+ selection.selectElement(element);
delete this._.selectedElement;
}
};

Event Timeline