X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Flink%2Fdialogs%2Flink.js;h=a6596169d046d380e35028fedeefa790e7edfba1;hb=4e70ea24db840898be8cc21c950363a52a2a6aba;hp=56baa05b7291700c4a69ab86683429cc95a23335;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git diff --git a/_source/plugins/link/dialogs/link.js b/_source/plugins/link/dialogs/link.js index 56baa05..a659616 100644 --- a/_source/plugins/link/dialogs/link.js +++ b/_source/plugins/link/dialogs/link.js @@ -196,7 +196,8 @@ CKEDITOR.dialog.add( 'link', function( editor ) var featureMatch; while ( ( featureMatch = popupFeaturesRegex.exec( onclickMatch[2] ) ) ) { - if ( featureMatch[2] == 'yes' || featureMatch[2] == '1' ) + // Some values should remain numbers (#7300) + if ( ( featureMatch[2] == 'yes' || featureMatch[2] == '1' ) && !( featureMatch[1] in { height:1, width:1, top:1, left:1 } ) ) retval.target[ featureMatch[1] ] = true; else if ( isFinite( featureMatch[2] ) ) retval.target[ featureMatch[1] ] = featureMatch[2]; @@ -234,36 +235,27 @@ CKEDITOR.dialog.add( 'link', function( editor ) advAttr( 'advTabIndex', 'tabindex' ); advAttr( 'advTitle', 'title' ); advAttr( 'advContentType', 'type' ); - advAttr( 'advCSSClasses', 'class' ); + CKEDITOR.plugins.link.synAnchorSelector ? + retval.adv.advCSSClasses = getLinkClass( element ) + : advAttr( 'advCSSClasses', 'class' ); advAttr( 'advCharset', 'charset' ); advAttr( 'advStyles', 'style' ); + advAttr( 'advRel', 'rel' ); } // Find out whether we have any anchors in the editor. - // Get all IMG elements in CK document. - var elements = editor.document.getElementsByTag( 'img' ), - realAnchors = new CKEDITOR.dom.nodeList( editor.document.$.anchors ), - anchors = retval.anchors = []; + var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors ), + anchors = retval.anchors = [], + item; - for ( var i = 0; i < elements.count() ; i++ ) + for ( var i = 0, count = anchorList.count(); i < count; i++ ) { - var item = elements.getItem( i ); - if ( item.data( 'cke-realelement' ) && item.data( 'cke-real-element-type' ) == 'anchor' ) - anchors.push( editor.restoreRealElement( item ) ); - } - - for ( i = 0 ; i < realAnchors.count() ; i++ ) - anchors.push( realAnchors.getItem( i ) ); - - for ( i = 0 ; i < anchors.length ; i++ ) - { - item = anchors[ i ]; + item = anchorList.getItem( i ); anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) }; } // Record down the selected element in the dialog. this._.selectedElement = element; - return retval; }; @@ -367,6 +359,12 @@ CKEDITOR.dialog.add( 'link', function( editor ) return 'String.fromCharCode(' + encodedChars.join( ',' ) + ')'; } + function getLinkClass( ele ) + { + var className = ele.getAttribute( 'class' ); + return className ? className.replace( /\s*(?:cke_anchor_empty|cke_anchor)(?:\s*$)?/g, '' ) : ''; + } + var commonLang = editor.lang.common, linkLang = editor.lang.link; @@ -1121,16 +1119,24 @@ CKEDITOR.dialog.add( 'link', function( editor ) }, { type : 'hbox', + widths : [ '45%', '55%' ], children : [ { type : 'text', + label : linkLang.rel, + 'default' : '', + id : 'advRel', + setup : setupAdvParams, + commit : commitAdvParams + }, + { + type : 'text', label : linkLang.styles, 'default' : '', id : 'advStyles', setup : setupAdvParams, commit : commitAdvParams - } ] } @@ -1141,8 +1147,6 @@ CKEDITOR.dialog.add( 'link', function( editor ) ], onShow : function() { - this.fakeObj = false; - var editor = this.getParentEditor(), selection = editor.getSelection(), element = null; @@ -1150,14 +1154,6 @@ CKEDITOR.dialog.add( 'link', function( editor ) // Fill in all the relevant fields if there's already one link selected. if ( ( element = plugin.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) ) selection.selectElement( element ); - else if ( ( element = selection.getSelectedElement() ) && element.is( 'img' ) - && element.data( 'cke-real-element-type' ) - && element.data( 'cke-real-element-type' ) == 'anchor' ) - { - this.fakeObj = element; - element = editor.restoreRealElement( this.fakeObj ); - selection.selectElement( this.fakeObj ); - } else element = null; @@ -1292,10 +1288,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) advAttr( 'advAccessKey', 'accessKey' ); if ( data.adv[ 'advName' ] ) - { attributes[ 'name' ] = attributes[ 'data-cke-saved-name' ] = data.adv[ 'advName' ]; - attributes[ 'class' ] = ( attributes[ 'class' ] ? attributes[ 'class' ] + ' ' : '' ) + 'cke_anchor'; - } else removeAttributes = removeAttributes.concat( [ 'data-cke-saved-name', 'name' ] ); @@ -1306,6 +1299,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) advAttr( 'advCSSClasses', 'class' ); advAttr( 'advCharset', 'charset' ); advAttr( 'advStyles', 'style' ); + advAttr( 'advRel', 'rel' ); } @@ -1339,25 +1333,12 @@ CKEDITOR.dialog.add( 'link', function( editor ) 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 && attributes.name != element.getAttribute( 'name' ) ) - { - var newElement = new CKEDITOR.dom.element( '', - editor.document ); - - selection = editor.getSelection(); - - element.copyAttributes( newElement, { name : 1 } ); - element.moveChildren( newElement ); - newElement.replace( element ); - element = newElement; - - selection.selectElement( element ); - } - element.setAttributes( attributes ); element.removeAttributes( removeAttributes ); + + if ( data.adv && data.adv.advName && CKEDITOR.plugins.link.synAnchorSelector ) + element.addClass( element.getChildCount() ? 'cke_anchor' : 'cke_anchor_empty' ); + // Update text view when user changes protocol (#4612). if ( href == textView || data.type == 'email' && textView.indexOf( '@' ) != -1 ) { @@ -1365,14 +1346,6 @@ CKEDITOR.dialog.add( 'link', function( editor ) 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 ); delete this._.selectedElement; }