Changeset 5784
- Timestamp:
- 08/02/10 20:36:50 (3 years ago)
- Location:
- CKEditor/branches/versions/3.4.x
- Files:
-
- 4 edited
-
CHANGES.html (modified) (1 diff)
-
_source/core/config.js (modified) (1 diff)
-
_source/plugins/bidi/plugin.js (modified) (3 diffs)
-
_source/plugins/justify/plugin.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/branches/versions/3.4.x/CHANGES.html
r5774 r5784 46 46 <li><a href="http://dev.fckeditor.net/ticket/5737">#5737</a> : Added support for the <a href="http://www.w3.org/TR/html5/editing.html#contenteditable">HTML5 contenteditable attribute</a>, making it possible to define read only regions into the editor contents.</li> 47 47 <li><a href="http://dev.fckeditor.net/ticket/5418">#5418</a> : New "Advanced" tab introduced for tables. It's based on the new dialogadvtab plugin.</li> 48 <li><a href="http://dev.fckeditor.net/ticket/6082">#6082</a> : Introduce the <a href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.useComputedState">useComputedState</a> setting, making it possible to control whether toolbar features, like alignment and direction, should reflect the "computed" selection states, even when the effective feature value is not applied.</li> 48 49 </ul> 49 50 <p> -
CKEditor/branches/versions/3.4.x/_source/core/config.js
r5753 r5784 331 331 }; 332 332 333 /** 334 * Indicates that some of the editor features, like alignement and text 335 * direction, should used the "computed value" of the feature to indicate it's 336 * on/off state, instead of using the "real value". 337 * 338 * If enabled, in a left to right written document, the "Left Justify" 339 * alignment button will show as active, even if the aligment style is not 340 * explicitly applied to the current paragraph in the editor. 341 * @name CKEDITOR.config.useComputedState 342 * @type Boolean 343 * @default true 344 * @since 3.4 345 * @example 346 * config.useComputedState = false; 347 */ 348 333 349 // PACKAGER_RENAME( CKEDITOR.config ) -
CKEditor/branches/versions/3.4.x/_source/plugins/bidi/plugin.js
r5767 r5784 18 18 function getState( editor, path, dir ) 19 19 { 20 var selection = editor.getSelection(), 21 ranges = selection.getRanges(); 22 23 var selectedElement = ranges && ranges[ 0 ].getEnclosedNode(); 24 25 // If this is not our element of interest, apply to fully selected elements from guardElements. 26 if ( !selectedElement || selectedElement 27 && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements ) 28 ) 29 selectedElement = getFullySelected( selection, guardElements ); 20 var useComputedState = editor.config.useComputedState, 21 selectedElement; 22 23 useComputedState = useComputedState === undefined || useComputedState; 24 25 if ( useComputedState ) 26 { 27 var selection = editor.getSelection(), 28 ranges = selection.getRanges(); 29 30 selectedElement = ranges && ranges[ 0 ].getEnclosedNode(); 31 32 // If this is not our element of interest, apply to fully selected elements from guardElements. 33 if ( !selectedElement || selectedElement 34 && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements ) 35 ) 36 selectedElement = getFullySelected( selection, guardElements ); 37 } 30 38 31 39 selectedElement = selectedElement || path.block || path.blockLimit; … … 34 42 return CKEDITOR.TRISTATE_OFF; 35 43 36 return ( selectedElement.getComputedStyle( 'direction' ) == dir ) ? 44 selectedElement = useComputedState ? 45 selectedElement.getComputedStyle( 'direction' ) : 46 selectedElement.getStyle( 'direction' ) || selectedElement.getAttribute( 'dir' ); 47 48 return ( selectedElement == dir ) ? 37 49 CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF; 38 50 } … … 40 52 function switchDir( element, dir, editor ) 41 53 { 42 var dirBefore = element.getComputedStyle( 'direction' ); 43 44 if ( element.hasAttribute( 'dir' ) && element.getAttribute( 'dir' ).toLowerCase() == dir ) 54 var dirBefore = element.getComputedStyle( 'direction' ), 55 currentDir = element.getStyle( 'direction' ) || element.getAttribute( 'dir' ) || ''; 56 57 element.removeStyle( 'direction' ); 58 59 if ( currentDir.toLowerCase() == dir ) 45 60 element.removeAttribute( 'dir' ); 46 61 else -
CKEditor/branches/versions/3.4.x/_source/plugins/justify/plugin.js
r5767 r5784 10 10 (function() 11 11 { 12 var alignRemoveRegex = /(-moz-|-webkit-|start|auto)/i;13 14 12 function getState( editor, path ) 15 13 { … … 19 17 return CKEDITOR.TRISTATE_OFF; 20 18 21 var currentAlign = firstBlock.getComputedStyle( 'text-align' ).replace( alignRemoveRegex, '' ); 22 if ( ( !currentAlign && isDefaultAlign( this, firstBlock ) ) || currentAlign == this.value ) 23 return CKEDITOR.TRISTATE_ON; 24 return CKEDITOR.TRISTATE_OFF; 19 return ( getAlignment( firstBlock, editor.config.useComputedState ) == this.value ) ? 20 CKEDITOR.TRISTATE_ON : 21 CKEDITOR.TRISTATE_OFF; 22 } 23 24 function getAlignment( element, useComputedState ) 25 { 26 useComputedState = useComputedState === undefined || useComputedState; 27 28 var align = useComputedState ? 29 element.getComputedStyle( 'text-align' ) : 30 element.getStyle( 'text-align' ) || element.getAttribute( 'align' ) || ''; 31 32 align && ( align = align.replace( /-moz-|-webkit-|start|auto/i, '' ) ); 33 34 !align && useComputedState && ( align = element.getComputedStyle( 'direction' ) == 'rtl' ? 'right' : 'left' ); 35 36 return align; 25 37 } 26 38 … … 30 42 command.state = getState.call( this, evt.editor, evt.data.path ); 31 43 command.fire( 'state' ); 32 }33 34 function isDefaultAlign( command, element )35 {36 var direction = element.getComputedStyle( 'direction' ),37 val = command.value;38 return ( direction == 'rtl' && val == 'right' ) || ( direction == 'ltr' && val == 'left' );39 40 44 } 41 45 … … 80 84 ranges = selection.getRanges( true ); 81 85 82 83 86 var cssClassName = this.cssClassName, 84 87 iterator, 85 88 block; 89 90 var useComputedState = editor.config.useComputedState; 91 useComputedState = useComputedState === undefined || useComputedState; 92 86 93 for ( var i = ranges.length - 1 ; i >= 0 ; i-- ) 87 94 { … … 92 99 { 93 100 block.removeAttribute( 'align' ); 101 block.removeStyle( 'text-align' ); 94 102 95 var isDefault = isDefaultAlign( this, block ); 103 // Remove any of the alignment classes from the className. 104 var className = cssClassName && ( block.$.className = 105 CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) ) ); 106 107 var apply = 108 ( this.state == CKEDITOR.TRISTATE_OFF ) && 109 ( !useComputedState || ( getAlignment( block, true ) != this.value ) ); 96 110 97 111 if ( cssClassName ) 98 112 { 99 // Remove any of the alignment classes from the className.100 var className = block.$.className =101 CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) );102 103 113 // Append the desired class name. 104 if ( this.state == CKEDITOR.TRISTATE_OFF && !isDefault)114 if ( apply ) 105 115 block.addClass( cssClassName ); 106 116 else if ( !className ) 107 117 block.removeAttribute( 'class' ); 108 118 } 109 else 110 { 111 if ( this.state == CKEDITOR.TRISTATE_OFF && !isDefault ) 112 block.setStyle( 'text-align', this.value ); 113 else 114 block.removeStyle( 'text-align' ); 115 } 119 else if ( apply ) 120 block.setStyle( 'text-align', this.value ); 116 121 } 117 122
Note: See TracChangeset
for help on using the changeset viewer.
