Ticket #3582: 3582_5.patch
File 3582_5.patch, 14.0 KB (added by , 13 years ago) |
---|
-
_source/plugins/dialog/plugin.js
927 927 var editor = this._.editor; 928 928 editor.focus(); 929 929 930 if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie)930 if ( editor.mode == 'wysiwyg' ) 931 931 { 932 932 var selection = editor.getSelection(); 933 933 selection && selection.unlock( true ); … … 2988 2988 */ 2989 2989 openDialog : function( dialogName, callback ) 2990 2990 { 2991 if ( this.mode == 'wysiwyg' && CKEDITOR.env.ie)2991 if ( this.mode == 'wysiwyg' ) 2992 2992 { 2993 2993 var selection = this.getSelection(); 2994 2994 selection && selection.lock(); -
_source/plugins/link/dialogs/anchor.js
6 6 CKEDITOR.dialog.add( 'anchor', function( editor ) 7 7 { 8 8 // Function called in onShow to load selected element. 9 var loadElements = function( e ditor, selection, element )9 var loadElements = function( element ) 10 10 { 11 this.editMode = true; 12 this.editObj = element; 11 this._.selectedElement = element; 13 12 14 var attributeValue = this.editObj.getAttribute( 'name' ); 15 if ( attributeValue ) 16 this.setValueOf( 'info','txtName', attributeValue ); 17 else 18 this.setValueOf( 'info','txtName', "" ); 13 var attributeValue = element.data( 'cke-saved-name' ); 14 this.setValueOf( 'info','txtName', attributeValue || '' ); 19 15 }; 20 16 21 17 return { … … 24 20 minHeight : 60, 25 21 onOk : function() 26 22 { 27 // Always create a new anchor, because of IE BUG. 28 var name = this.getValueOf( 'info', 'txtName' ), 29 element = CKEDITOR.env.ie && !( CKEDITOR.document.$.documentMode >= 8 ) ? 30 editor.document.createElement( '<a name="' + CKEDITOR.tools.htmlEncode( name ) + '">' ) : 31 editor.document.createElement( 'a' ); 32 33 // Move contents and attributes of old anchor to new anchor. 34 if ( this.editMode ) 23 var name = this.getValueOf( 'info', 'txtName' ); 24 var attributes = 35 25 { 36 this.editObj.copyAttributes( element, { name : 1 } );37 this.editObj.moveChildren( element );38 } 26 name : name, 27 'data-cke-saved-name' : name 28 }; 39 29 40 // Set name. 41 element.data( 'cke-saved-name', false ); 42 element.setAttribute( 'name', name ); 43 44 // Insert a new anchor. 45 var fakeElement = editor.createFakeElement( element, 'cke_anchor', 'anchor' ); 46 if ( !this.editMode ) 47 editor.insertElement( fakeElement ); 30 if ( this._.selectedElement ) 31 this._.selectedElement.setAttributes( attributes ); 48 32 else 49 33 { 50 fakeElement.replace( this.fakeObj ); 51 editor.getSelection().selectElement( fakeElement ); 34 // Apply style. 35 var style = new CKEDITOR.style( { element : 'a', attributes : attributes } ); 36 style.type = CKEDITOR.STYLE_INLINE; 37 style.apply( editor.document ); 52 38 } 39 }, 53 40 54 return true; 41 onHide : function() 42 { 43 delete this._.selectedElement; 55 44 }, 45 56 46 onShow : function() 57 47 { 58 this.editObj = false;59 this.fakeObj = false;60 this.editMode = false;48 var selection = editor.getSelection(), 49 fullySelected = selection.getSelectedElement(), 50 partialSelected; 61 51 62 var selection = editor.getSelection(); 63 var element = selection.getSelectedElement(); 64 if ( element && element.data( 'cke-real-element-type' ) && element.data( 'cke-real-element-type' ) == 'anchor' ) 52 // Detect the anchor under selection. 53 if ( fullySelected && fullySelected.is( 'a' ) && fullySelected.hasAttribute( 'name' ) ) 54 loadElements.call( this, fullySelected ); 55 else 65 56 { 66 this.fakeObj = element; 67 element = editor.restoreRealElement( this.fakeObj ); 68 loadElements.apply( this, [ editor, selection, element ] ); 69 selection.selectElement( this.fakeObj ); 70 } 57 partialSelected = CKEDITOR.plugins.link.getSelectedLink( editor ); 58 if ( partialSelected ) 59 { 60 loadElements.call( this, partialSelected ); 61 selection.selectElement( partialSelected ); 62 } 63 } 64 71 65 this.getContentElement( 'info', 'txtName' ).focus(); 72 66 }, 73 67 contents : [ -
_source/plugins/wysiwygarea/plugin.js
62 62 if ( range.checkReadOnly() ) 63 63 return; 64 64 65 if ( CKEDITOR.env.ie ) 66 { 67 var selIsLocked = selection.isLocked; 65 var selIsLocked = selection.isLocked; 66 selIsLocked && selection.unlock(); 68 67 69 if ( selIsLocked ) 70 selection.unlock(); 71 68 if ( CKEDITOR.env.ie ) 69 { 72 70 var $sel = selection.getNative(); 73 71 74 72 // Delete control selections to avoid IE bugs on pasteHTML. … … 99 97 } 100 98 catch (e) {} 101 99 102 if ( selIsLocked )103 this.getSelection().lock();104 100 } 105 101 else 106 102 this.document.$.execCommand( 'inserthtml', false, data ); 107 103 104 selIsLocked && this.getSelection().lock(); 105 108 106 // Webkit does not scroll to the cursor position after pasting (#5558) 109 107 if ( CKEDITOR.env.webkit ) 110 108 { … … 635 633 var element = evt.data.getTarget(), 636 634 data = { element : element, dialog : '' }; 637 635 editor.fire( 'doubleclick', data ); 638 data.dialog && editor.openDialog( data.dialog ); 639 }); 636 data.dialog && editor.openDialog( data.dialog, function() 637 { 638 // Fully embrace the element under click in the to-be-locked selection. 639 element && editor.getSelection().selectElement( element ) 640 }); 641 }); 640 642 641 643 // Prevent automatic submission in IE #6336 642 644 CKEDITOR.env.ie && domDocument.on( 'click', function( evt ) -
_source/plugins/htmldataprocessor/plugin.js
95 95 delete blockLikeTags.pre; 96 96 var defaultDataFilterRules = 97 97 { 98 elements : { 99 a : function( element ) 100 { 101 var attrs = element.attributes; 102 if ( attrs && attrs[ 'data-cke-saved-name' ] ) 103 attrs[ 'class' ] = ( attrs[ 'class' ] ? attrs[ 'class' ] + ' ' : '' ) + 'cke_anchor'; 104 } 105 }, 98 elements : {}, 106 99 attributeNames : 107 100 [ 108 101 // Event attributes (onXYZ) must not be directly set. They can become -
_source/plugins/link/dialogs/link.js
242 242 } 243 243 244 244 // Find out whether we have any anchors in the editor. 245 // Get all IMG elements in CK document. 246 var elements = editor.document.getElementsByTag( 'img' ), 247 realAnchors = new CKEDITOR.dom.nodeList( editor.document.$.anchors ), 248 anchors = retval.anchors = []; 245 var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors ), 246 anchors = retval.anchors = [], 247 item; 249 248 250 for ( var i = 0 ; i < elements.count(); i++ )249 for ( var i = 0, count = anchorList.count(); i < count; i++ ) 251 250 { 252 var item = elements.getItem( i ); 253 if ( item.data( 'cke-realelement' ) && item.data( 'cke-real-element-type' ) == 'anchor' ) 254 anchors.push( editor.restoreRealElement( item ) ); 255 } 256 257 for ( i = 0 ; i < realAnchors.count() ; i++ ) 258 anchors.push( realAnchors.getItem( i ) ); 259 260 for ( i = 0 ; i < anchors.length ; i++ ) 261 { 262 item = anchors[ i ]; 251 item = anchorList.getItem( i ); 263 252 anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) }; 264 253 } 265 254 266 255 // Record down the selected element in the dialog. 267 256 this._.selectedElement = element; 268 269 257 return retval; 270 258 }; 271 259 … … 1151 1139 ], 1152 1140 onShow : function() 1153 1141 { 1154 this.fakeObj = false;1155 1156 1142 var editor = this.getParentEditor(), 1157 1143 selection = editor.getSelection(), 1158 1144 element = null; … … 1160 1146 // Fill in all the relevant fields if there's already one link selected. 1161 1147 if ( ( element = plugin.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) ) 1162 1148 selection.selectElement( element ); 1163 else if ( ( element = selection.getSelectedElement() ) && element.is( 'img' )1164 && element.data( 'cke-real-element-type' )1165 && element.data( 'cke-real-element-type' ) == 'anchor' )1166 {1167 this.fakeObj = element;1168 element = editor.restoreRealElement( this.fakeObj );1169 selection.selectElement( this.fakeObj );1170 }1171 1149 else 1172 1150 element = null; 1173 1151 … … 1302 1280 advAttr( 'advAccessKey', 'accessKey' ); 1303 1281 1304 1282 if ( data.adv[ 'advName' ] ) 1305 {1306 1283 attributes[ 'name' ] = attributes[ 'data-cke-saved-name' ] = data.adv[ 'advName' ]; 1307 attributes[ 'class' ] = ( attributes[ 'class' ] ? attributes[ 'class' ] + ' ' : '' ) + 'cke_anchor';1308 }1309 1284 else 1310 1285 removeAttributes = removeAttributes.concat( [ 'data-cke-saved-name', 'name' ] ); 1311 1286 … … 1350 1325 href = element.data( 'cke-saved-href' ), 1351 1326 textView = element.getHtml(); 1352 1327 1353 // IE BUG: Setting the name attribute to an existing link doesn't work.1354 // Must re-create the link from weired syntax to workaround.1355 if ( CKEDITOR.env.ie && !( CKEDITOR.document.$.documentMode >= 8 ) && attributes.name != element.getAttribute( 'name' ) )1356 {1357 var newElement = new CKEDITOR.dom.element( '<a name="' + CKEDITOR.tools.htmlEncode( attributes.name ) + '">',1358 editor.document );1359 1360 selection = editor.getSelection();1361 1362 element.copyAttributes( newElement, { name : 1 } );1363 element.moveChildren( newElement );1364 newElement.replace( element );1365 element = newElement;1366 1367 selection.selectElement( element );1368 }1369 1370 1328 element.setAttributes( attributes ); 1371 1329 element.removeAttributes( removeAttributes ); 1372 1330 // Update text view when user changes protocol (#4612). … … 1376 1334 element.setHtml( data.type == 'email' ? 1377 1335 data.email.address : attributes[ 'data-cke-saved-href' ] ); 1378 1336 } 1379 // Make the element display as an anchor if a name has been set.1380 if ( element.getAttribute( 'name' ) )1381 element.addClass( 'cke_anchor' );1382 else1383 element.removeClass( 'cke_anchor' );1384 1337 1385 if ( this.fakeObj )1386 editor.createFakeElement( element, 'cke_anchor', 'anchor' ).replace( this.fakeObj );1387 1388 1338 delete this._.selectedElement; 1389 1339 } 1390 1340 }, -
_source/plugins/link/plugin.js
31 31 32 32 // Add the CSS styles for anchor placeholders. 33 33 var side = editor.lang.dir == 'rtl' ? 'right' : 'left'; 34 editor.addCss( 35 'img.cke_anchor' + 34 var anchorCss = 36 35 '{' + 37 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ');' + 38 'background-position: center center;' + 39 'background-repeat: no-repeat;' + 36 'background: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ') no-repeat ' + side + ' center;' + 40 37 'border: 1px solid #a9a9a9;' + 41 'width: 18px !important;' +42 'height: 18px !important;' +43 '}\n' +44 'a.cke_anchor' +45 '{' +46 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ');' +47 'background-position: ' + side + ' center;' +48 'background-repeat: no-repeat;' +49 'border: 1px solid #a9a9a9;' +50 38 'padding-' + side + ': 18px;' + 51 '}' 52 ); 39 '}'; 53 40 41 var emptyAnchorCss = '{display:inline-block;height:18px;}'; 42 43 editor.addCss( ( CKEDITOR.env.ie6Compat ? 'a.cke_anchor' : 'a[name]' ) + anchorCss ); 44 editor.addCss( ( CKEDITOR.env.ie6Compat ? 'a.cke_anchor' : CKEDITOR.env.ie7Compat? 'a[name]' : 'a[name]:empty' )+ emptyAnchorCss ); 45 54 46 // Register selection change handler for the unlink button. 55 47 editor.on( 'selectionChange', function( evt ) 56 48 { … … 141 133 var dataProcessor = editor.dataProcessor, 142 134 dataFilter = dataProcessor && dataProcessor.dataFilter; 143 135 144 if ( dataFilter )136 if ( dataFilter && CKEDITOR.env.ie6Compat ) 145 137 { 146 138 dataFilter.addRules( 147 139 { … … 149 141 { 150 142 a : function( element ) 151 143 { 152 var attributes = element.attributes; 153 if ( attributes.name && !attributes.href ) 154 return editor.createFakeParserElement( element, 'cke_anchor', 'anchor' ); 144 var attributes = element.attributes, 145 cls = attributes[ 'class' ]; 146 if ( attributes.name && ( !cls || cls.indexOf( 'cke_anchor' ) < 0 ) ) 147 attributes[ 'class' ] = ( cls || '' ) + ' cke_anchor'; 155 148 } 156 149 } 157 150 }); … … 240 233 linkShowAdvancedTab : true, 241 234 linkShowTargetTab : true 242 235 } ); 236 237 // Present a[name] as "cke_anchor" in IE6. 238 CKEDITOR.env.ie6Compat && ( function() 239 { 240 function markAnchor( org ) 241 { 242 var attrGet = org == elementProto.getAttribute; 243 244 return function( name, val ) 245 { 246 if ( this.getDocument().equals( CKEDITOR.document ) ) 247 return org.apply( this, arguments ); 248 249 var retval = org.apply( this, arguments ); 250 if ( this.is( 'a' ) ) 251 { 252 if ( name == 'name' ) 253 this[ val ? 'addClass' : 'removeClass' ]( 'cke_anchor' ); 254 else if ( name == 'class' && this.$.getAttribute( 'name' ) ) 255 attrGet ? retval = retval.replace( /\s*cke_anchor\s*/, '' ) : this.addClass( 'cke_anchor' ); 256 } 257 return retval; 258 }; 259 } 260 261 var elementProto = CKEDITOR.dom.element.prototype, 262 methods = [ 'getAttribute','setAttribute', 'removeAttribute' ]; 263 for ( var i = 0; i < methods.length; i++ ) 264 elementProto[ methods[ i ] ] = CKEDITOR.tools.override( elementProto[ methods [ i ] ], markAnchor ); 265 266 } )();