Ticket #617: 617_2.patch
File 617_2.patch, 9.3 KB (added by , 16 years ago) |
---|
-
editor/_source/internals/fckxhtml.js
30 30 FCKDomTools.CheckAndRemovePaddingNode( node.ownerDocument, FCKConfig.EnterMode ) ; 31 31 FCKXHtmlEntities.Initialize() ; 32 32 33 // Random ID for protected attributes. 34 this._ProtectID = Math.random() ; 35 33 36 // Set the correct entity to use for empty blocks. 34 37 this._NbspEntity = ( FCKConfig.ProcessHTMLEntities? 'nbsp' : '#160' ) ; 35 38 … … 484 487 } ; 485 488 486 489 FCKXHtml.TagProcessors.ul = FCKXHtml.TagProcessors.ol ; 490 491 FCKXHtml.AttributeProcessors = 492 { 493 style : function( node, htmlNode, attrValue ) 494 { 495 var borderPattern = /border[a-zA-Z-]*\s*:[^;]+(;|$)\s*/g ; 496 497 if ( attrValue.match( borderPattern ) ) 498 { 499 // Remove all border attributes from the style string. 500 attrValue = attrValue.replace( borderPattern, '' ) ; 501 var oldAttrValue = attrValue ; 502 503 // Calculate the most compact border style representation. 504 // 1. Start from the 12 basic border-[DIRECTION]-[STYLE] values. 505 // 2. If [STYLE] has the same value for all [DIRECTION]s, compress to a single border-[STYLE] value, 506 // and eliminate the redundant values. 507 // 3. If any border-[DIRECTION] or border have all 3 [STYLE]s under it, compress the [STYLES]s to 508 // a single string and eliminate the redundant values. 509 var directions = ['top', 'right', 'bottom', 'left'] ; 510 var styles = ['width', 'style', 'color'] ; 511 var borderStyle = {} ; 512 for ( var i = 0 ; i < directions.length ; i++ ) 513 { 514 for ( var j = 0 ; j < styles.length ; j++ ) 515 { 516 var cssName = ['border', directions[i], styles[j]].join( '-' ) ; 517 var jsName = ['border', directions[i].charAt(0).toUpperCase() + directions[i].substr(1), 518 styles[j].charAt(0).toUpperCase() + styles[j].substr(1)].join( '' ) ; 519 borderStyle[cssName] = FCKDomTools.GetCurrentElementStyle( FCKTools.GetElementWindow( htmlNode ), 520 htmlNode, jsName ) ; 521 if ( styles[j] == 'color' ) 522 borderStyle[cssName] = FCKTools.RGBToHex( borderStyle[cssName] ) ; 523 } 524 } 525 526 for ( var i = 0 ; i < styles.length ; i++ ) 527 { 528 var isEqual = true ; 529 var lastValue = null ; 530 for ( var j = 0 ; j < directions.length ; j++ ) 531 { 532 var cssName = ['border', directions[j], styles[i]].join( '-' ) ; 533 if ( lastValue == null ) 534 lastValue = borderStyle[cssName] ; 535 if ( lastValue != borderStyle[cssName] ) 536 { 537 isEqual = false ; 538 break ; 539 } 540 } 541 if ( isEqual ) 542 { 543 borderStyle['border-' + styles[i]] = lastValue ; 544 for ( var j = 0 ; j < directions.length ; j++ ) 545 delete borderStyle[['border', directions[j], styles[i]].join( '-' )] ; 546 } 547 } 548 549 for ( var i = 0 ; i < directions.length ; i++ ) 550 { 551 if ( borderStyle['border-' + directions[i] + '-width'] && 552 borderStyle['border-' + directions[i] + '-style'] && 553 borderStyle['border-' + directions[i] + '-color']) 554 { 555 borderStyle['border-' + directions[i]] = borderStyle['border-' + directions[i] + '-width'] + ' ' 556 + borderStyle['border-' + directions[i] + '-style'] + ' ' 557 + borderStyle['border-' + directions[i] + '-color'] ; 558 delete borderStyle['border-' + directions[i] + '-width'] ; 559 delete borderStyle['border-' + directions[i] + '-style'] ; 560 delete borderStyle['border-' + directions[i] + '-color'] ; 561 } 562 } 563 564 if ( borderStyle['border-width'] && borderStyle['border-style'] && borderStyle['border-color'] ) 565 { 566 borderStyle['border'] = borderStyle['border-width'] + ' ' 567 + borderStyle['border-style'] + ' ' 568 + borderStyle['border-color'] ; 569 delete borderStyle['border-width'] ; 570 delete borderStyle['border-style'] ; 571 delete borderStyle['border-color'] ; 572 } 573 574 // Calculate the style string fragment according to the minimal representation and append it 575 // to the attrValue. 576 var fragment = [] ; 577 for ( var i in borderStyle ) 578 fragment.push( i + ': ' + borderStyle[i] ) ; 579 fragment = ' ' + fragment.join( '; ' ) + ';' ; 580 attrValue += fragment ; 581 attrValue = attrValue.Trim() ; 582 } 583 584 FCKXHtml._AppendAttribute( node, 'style_protected_' + FCKXHtml._ProtectID , attrValue ) ; 585 } 586 } ; -
editor/_source/internals/fcktools.js
619 619 { 620 620 return function() { obj[methodName].apply(obj, arguments); } ; 621 621 } 622 623 /** 624 * Convert a CSS rgb(R, G, B) color back to #RRGGBB format. 625 */ 626 FCKTools.RGBToHex = function( rgb ) 627 { 628 var matchResults = rgb.match( /(rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\))/i ) ; 629 if ( !matchResults ) 630 return rgb ; 631 632 var red = parseInt( matchResults[2], 10 ).toString( 16 ), 633 green = parseInt( matchResults[3], 10 ).toString( 16 ), 634 blue = parseInt( matchResults[4], 10 ).toString( 16 ) ; 635 var color = [red, green, blue] ; 636 637 // Add padding zeros if the hex value is less than 0x10. 638 for ( var i = 0 ; i < color.length ; i++ ) 639 color[i] = String( '0' + color[i] ).slice( -2 ) ; 640 641 return '#' + color.join( '' ) ; 642 } -
editor/_source/internals/fckxhtml_gecko.js
24 24 25 25 FCKXHtml._GetMainXmlString = function() 26 26 { 27 return '<xhtml>' + this.MainNode.innerHTML + '</xhtml>' ; 27 var html = this.MainNode.innerHTML.replace( new RegExp( '_protected_' + this._ProtectID, 'g' ), '' ) ; 28 return '<xhtml>' + html + '</xhtml>' ; 28 29 } 29 30 30 31 FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node ) … … 60 61 else 61 62 sAttValue = htmlNode.getAttribute( sAttName, 2 ) ; // We must use getAttribute to get it exactly as it is defined. 62 63 63 this._AppendAttribute( node, sAttName, sAttValue ) ; 64 if ( this.AttributeProcessors[sAttName] ) 65 this.AttributeProcessors[sAttName]( node, htmlNode, sAttValue ) ; 66 else 67 this._AppendAttribute( node, sAttName, sAttValue ) ; 64 68 } 65 69 } 66 70 } -
editor/_source/internals/fckxhtml_ie.js
24 24 25 25 FCKXHtml._GetMainXmlString = function() 26 26 { 27 return this.MainNode.xml ; 27 var html = this.MainNode.xml.replace( new RegExp( '_protected_' + this._ProtectID, 'g' ), '' ) ; 28 return html ; 28 29 } 29 30 30 31 FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node, nodeName ) … … 77 78 } 78 79 catch (e) {} 79 80 } 80 this._AppendAttribute( node, sAttName, sAttValue || oAttribute.nodeValue ) ; 81 if ( this.AttributeProcessors[sAttName] ) 82 this.AttributeProcessors[sAttName]( node, htmlNode, sAttValue) ; 83 else 84 this._AppendAttribute( node, sAttName, sAttValue || oAttribute.nodeValue ) ; 81 85 } 82 86 } 83 87 } … … 200 204 node = FCKXHtml._AppendChildNodes( node, htmlNode ) ; 201 205 202 206 return node ; 203 } 204 No newline at end of file 207 } -
editor/dialog/fck_tablecell.html
64 64 if ( oCell.attributes['noWrap'] != null && oCell.attributes['noWrap'].specified ) 65 65 GetE('selWordWrap').value = !oCell.noWrap ; 66 66 67 var sBorderColor = oCell.style.borderColor ; 68 var matchResults = null ; 69 sBorderColor = oEditor.FCKTools.RGBToHex( sBorderColor ) ; 70 67 71 GetE('txtWidth').value = iWidth ; 68 72 GetE('txtHeight').value = GetAttribute( oCell, 'height' ) ; 69 73 GetE('selHAlign').value = GetAttribute( oCell, 'align' ) ; … … 71 75 GetE('txtRowSpan').value = GetAttribute( oCell, 'rowSpan' ) ; 72 76 GetE('txtCollSpan').value = GetAttribute( oCell, 'colSpan' ) ; 73 77 GetE('txtBackColor').value = GetAttribute( oCell, 'bgColor' ) ; 74 GetE('txtBorderColor').value = GetAttribute( oCell, 'borderColor' );78 GetE('txtBorderColor').value = sBorderColor ; 75 79 // GetE('cmbFontStyle').value = oCell.className ; 76 80 } 77 81 } … … 97 101 SetAttribute( aCells[i], 'rowSpan' , GetE('txtRowSpan').value ) ; 98 102 SetAttribute( aCells[i], 'colSpan' , GetE('txtCollSpan').value ) ; 99 103 SetAttribute( aCells[i], 'bgColor' , GetE('txtBackColor').value ) ; 100 SetAttribute( aCells[i], 'borderColor' , GetE('txtBorderColor').value ) ; 104 105 var sBorderColor = GetE( 'txtBorderColor' ).value ; 106 if ( sBorderColor.length > 0 ) 107 { 108 var borderStyle = {'borderColor' : sBorderColor} ; 109 var presentStyle = oEditor.FCKDomTools.GetCurrentElementStyle( oEditor.FCKTools.GetElementWindow( aCells[i] ), aCells[i] , 'borderTopStyle' ) ; 110 if ( presentStyle.match( /^(none|.*inset.*)$/ ) ) 111 { 112 borderStyle.borderWidth = '1px' ; 113 borderStyle.borderStyle = 'solid' ; 114 } 115 oEditor.FCKDomTools.SetElementStyles( aCells[i], borderStyle ) ; 116 } 117 else 118 aCells[i].style.border = 'default' ; 101 119 // SetAttribute( aCells[i], 'className' , GetE('cmbFontStyle').value ) ; 102 120 } 103 121