Ticket #3582: 3582_4.patch
File 3582_4.patch, 14.4 KB (added by , 13 years ago) |
---|
-
../3.6.x/_source/core/dom/element.js
1030 1030 this.$.tabIndex = value; 1031 1031 else if ( name == 'checked' ) 1032 1032 this.$.checked = value; 1033 else if ( name == 'name' ) 1034 { 1035 var replacement = this.getDocument().createElement( '<' + this.getName() +' name="' + value + '">' ); 1036 this.copyAttributes( replacement, { name : 1 } ); 1037 this.getParent() && replacement.replace( this ); 1038 this.moveChildren( replacement ); 1039 this.$ = replacement.$; 1040 if ( CKEDITOR.env.ie6Compat && this.is( 'a' ) && value ) 1041 this.addClass( 'cke_anchor' ); 1042 } 1033 1043 else 1034 1044 standard.apply( this, arguments ); 1035 1045 return this; … … 1092 1102 name = 'className'; 1093 1103 else if ( name == 'tabindex' ) 1094 1104 name = 'tabIndex'; 1105 else if ( name == 'name' ) 1106 { 1107 var replacement = this.getDocument().createElement( this.getName() ); 1108 this.copyAttributes( replacement ); 1109 this.getParent() && replacement.replace( this ); 1110 this.moveChildren( replacement ); 1111 this.$ = replacement.$; 1112 if ( CKEDITOR.env.ie6Compat && this.is( 'a' ) ) 1113 this.removeClass( 'cke_anchor' ); 1114 } 1095 1115 standard.call( this, name ); 1096 1116 }; 1097 1117 } -
../3.6.x/_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(); -
../3.6.x/_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 : [ -
../3.6.x/_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 ) -
../3.6.x/_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 -
../3.6.x/_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 }, -
../3.6.x/_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 0 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;' + 38 ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ? 'display:inline-block;' : '' ) + 50 39 'padding-' + side + ': 18px;' + 51 '}' 52 ); 40 '}'; 53 41 42 editor.addCss( ( CKEDITOR.env.ie6Compat ? 'a.cke_anchor' : 'a[name]' ) + anchorCss ); 43 54 44 // Register selection change handler for the unlink button. 55 45 editor.on( 'selectionChange', function( evt ) 56 46 { … … 141 131 var dataProcessor = editor.dataProcessor, 142 132 dataFilter = dataProcessor && dataProcessor.dataFilter; 143 133 144 if ( dataFilter )134 if ( dataFilter && CKEDITOR.env.ie6Compat ) 145 135 { 146 136 dataFilter.addRules( 147 137 { … … 149 139 { 150 140 a : function( element ) 151 141 { 152 var attributes = element.attributes; 153 if ( attributes.name && !attributes.href ) 154 return editor.createFakeParserElement( element, 'cke_anchor', 'anchor' ); 142 var attributes = element.attributes, 143 cls = attributes[ 'class' ]; 144 if ( attributes.name && ( !cls || cls.indexOf( 'cke_anchor' ) < 0 ) ) 145 attributes[ 'class' ] = ( cls || '' ) + ' cke_anchor'; 155 146 } 156 147 } 157 148 });