Ticket #3582: 3582.patch
File 3582.patch, 5.8 KB (added by , 13 years ago) |
---|
-
_source/plugins/link/dialogs/anchor.js
26 26 { 27 27 // Always create a new anchor, because of IE BUG. 28 28 var name = this.getValueOf( 'info', 'txtName' ), 29 element = CKEDITOR.env.ie ? 30 editor.document.createElement( '<a name="' + CKEDITOR.tools.htmlEncode( name ) + '">' ) : 31 editor.document.createElement( 'a' ); 29 element = CKEDITOR.env.ie6Compat ? 30 editor.document.createElement( '<a name="' + CKEDITOR.tools.htmlEncode( name ) + '">' ) : 31 editor.document.createElement( 'a' ), 32 fakeElement, 33 selection, 34 ranges, 35 tmpId, 36 style, 37 created; 32 38 33 39 // Move contents and attributes of old anchor to new anchor. 34 40 if ( this.editMode ) … … 36 42 this.editObj.copyAttributes( element, { name : 1 } ); 37 43 this.editObj.moveChildren( element ); 38 44 } 45 else 46 { 47 // Put selected text inside the anchor 48 selection = editor.getSelection(); 49 ranges = selection.getRanges( true ); 50 if ( ranges.length == 1 && !ranges[0].collapsed ) 51 { 52 tmpId = 'tmp' + CKEDITOR.tools.getNextNumber(); 53 style = new CKEDITOR.style( { element : 'a', attributes : {'id': tmpId} } ); 54 style.type = CKEDITOR.STYLE_INLINE; 55 style.apply( editor.document ); 56 created = editor.document.getById( tmpId ); 57 created.moveChildren( element ); 39 58 59 selection.selectElement( created ); 60 } 61 } 62 40 63 // Set name. 41 64 element.removeAttribute( '_cke_saved_name' ); 42 65 element.setAttribute( 'name', name ); 43 66 44 // Insert a new anchor. 45 var fakeElement = editor.createFakeElement( element, 'cke_anchor', 'anchor' ); 46 if ( !this.editMode ) 47 editor.insertElement( fakeElement ); 67 if ( element.$.childNodes.length==0 && ( !CKEDITOR.env.gecko ) ) 68 { 69 fakeElement = editor.createFakeElement( element, 'cke_anchor', 'anchor' ); 70 // Insert a new anchor. 71 if ( !this.editMode ) 72 editor.insertElement( fakeElement ); 73 else 74 { 75 fakeElement.replace( this.fakeObj ); 76 editor.getSelection().selectElement( fakeElement ); 77 } 78 } 48 79 else 49 80 { 50 fakeElement.replace( this.fakeObj ); 51 editor.getSelection().selectElement( fakeElement ); 81 element.addClass( 'cke_anchor' ); 82 if ( !this.editMode ) 83 editor.insertElement( element ); 84 else 85 { 86 element.replace( this.editObj ); 87 editor.getSelection().selectElement( element ); 88 } 52 89 } 53 90 54 91 return true; 55 92 }, 56 93 onShow : function() 57 94 { 58 this.editObj = false; 59 this.fakeObj = false; 60 this.editMode = false; 95 this.editObj = this.fakeObj = this.editMode = false; 61 96 62 var selection = editor.getSelection(); 63 var element = selection.getSelectedElement(); 97 var selection = editor.getSelection(), 98 element = selection.getSelectedElement(), 99 link; 100 64 101 if ( element && element.getAttribute( '_cke_real_element_type' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' ) 65 102 { 66 103 this.fakeObj = element; … … 68 105 loadElements.apply( this, [ editor, selection, element ] ); 69 106 selection.selectElement( this.fakeObj ); 70 107 } 108 else 109 { 110 link = CKEDITOR.plugins.link.getSelectedLink( editor ); 111 if ( link ) 112 { 113 element = link; 114 loadElements.apply( this, [ editor, selection, element ] ); 115 selection.selectElement( link ); 116 } 117 } 71 118 this.getContentElement( 'info', 'txtName' ).focus(); 72 119 }, 73 120 contents : [ -
_source/plugins/link/plugin.js
30 30 CKEDITOR.dialog.add( 'anchor', this.path + 'dialogs/anchor.js' ); 31 31 32 32 // Add the CSS styles for anchor placeholders. 33 var background = 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ');' + 34 'background-repeat: no-repeat;' + 35 'border: 1px solid #a9a9a9;', 36 anchorCss = '{' + 37 background + 38 'background-position: 0 center;' + 39 'padding-left: 18px;' + 40 '}'; 41 33 42 editor.addCss( 34 43 'img.cke_anchor' + 35 44 '{' + 36 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ');'+45 background + 37 46 'background-position: center center;' + 38 'background-repeat: no-repeat;' +39 'border: 1px solid #a9a9a9;' +40 47 'width: 18px !important;' + 41 48 'height: 18px !important;' + 42 49 '}\n' + 43 50 'a.cke_anchor' + 44 '{' + 45 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ');' + 46 'background-position: 0 center;' + 47 'background-repeat: no-repeat;' + 48 'border: 1px solid #a9a9a9;' + 49 'padding-left: 18px;' + 50 '}' 51 anchorCss + 52 'a[name]' + 53 anchorCss 51 54 ); 52 55 53 56 // Register selection change handler for the unlink button. … … 137 140 var dataProcessor = editor.dataProcessor, 138 141 dataFilter = dataProcessor && dataProcessor.dataFilter; 139 142 140 if ( dataFilter )143 if ( dataFilter && ( !CKEDITOR.env.gecko ) ) 141 144 { 142 145 dataFilter.addRules( 143 146 { … … 147 150 { 148 151 var attributes = element.attributes; 149 152 if ( attributes.name && !attributes.href ) 150 return editor.createFakeParserElement( element, 'cke_anchor', 'anchor' ); 153 { 154 if (element.children.length==0) 155 return editor.createFakeParserElement( element, 'cke_anchor', 'anchor' ); 156 attributes['class'] = (attributes['class'] || '') + ' cke_anchor'; 157 } 151 158 } 152 159 } 153 160 });