IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
48 | 48 | }); |
49 | 49 | } |
50 | 50 | |
| 51 | function getSelectedImage( element ) |
| 52 | { |
| 53 | var selected = element || editor.getSelection().getSelectedElement(); |
| 54 | if ( selected && selected.is( 'img' ) && !selected.data( 'cke-realelement' ) && !selected.isReadOnly() ) |
| 55 | return selected; |
| 56 | } |
| 57 | |
51 | 58 | // If the "contextmenu" plugin is loaded, register the listeners. |
52 | 59 | if ( editor.contextMenu ) |
53 | 60 | { |
54 | 61 | editor.contextMenu.addListener( function( element, selection ) |
55 | 62 | { |
56 | | if ( !element || !element.is( 'img' ) || element.data( 'cke-realelement' ) || element.isReadOnly() ) |
57 | | return null; |
58 | | |
59 | | return { image : CKEDITOR.TRISTATE_OFF }; |
| 63 | if ( getSelectedImage( element ) ) |
| 64 | return { image : CKEDITOR.TRISTATE_OFF }; |
60 | 65 | }); |
| 66 | } |
| 67 | |
| 68 | editor.on( 'beforeCommandExec', function( evt ) |
| 69 | { |
| 70 | var data = evt.data; |
| 71 | var img; |
| 72 | |
| 73 | if ( /^justify(left|right)/.exec( data.name ) && ( img = getSelectedImage() ) ) |
| 74 | { |
| 75 | var value = data.command.value; |
| 76 | var align = getImageAlignment( img ); |
| 77 | align == value ? img.removeStyle( 'float' ) : img.setStyle( 'float', value ) |
| 78 | |
| 79 | evt.cancel(); |
| 80 | } |
| 81 | }); |
| 82 | |
| 83 | editor.on( 'commandState', function( evt ) |
| 84 | { |
| 85 | var cmd = evt.data.command, img; |
| 86 | if ( /^justify/.exec( cmd.name ) && ( img = getSelectedImage() ) ) |
| 87 | { |
| 88 | var value = cmd.value, |
| 89 | align = getImageAlignment( img ); |
| 90 | |
| 91 | evt.data.state = |
| 92 | ( align == value ) ? CKEDITOR.TRISTATE_ON : |
| 93 | ( value == 'right' || value == 'left' ) ? CKEDITOR.TRISTATE_OFF : |
| 94 | CKEDITOR.TRISTATE_DISABLED; |
| 95 | |
| 96 | evt.cancel(); |
| 97 | } |
| 98 | |
| 99 | }, null, null, 10 ); |
| 100 | |
| 101 | |
| 102 | function getImageAlignment( element ) |
| 103 | { |
| 104 | var align = element.getStyle( 'float' ); |
| 105 | if ( align == 'inherit' || align == 'none' ) |
| 106 | align = 0; |
| 107 | |
| 108 | if ( !align ) |
| 109 | align = element.getAttribute( 'align' ); |
| 110 | |
| 111 | return align; |
61 | 112 | } |
62 | 113 | } |
63 | 114 | } ); |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
573 | 573 | }, |
574 | 574 | |
575 | 575 | /** |
| 576 | * Query the state of the specified command name, optionally perform a |
| 577 | * fresh update. |
| 578 | * |
| 579 | * @param {String} commandName The indentifier name of the command. |
| 580 | * @param {Boolean} [doUpdate] If specified it fires a "commandState" |
| 581 | * event on editor to update the state. |
| 582 | */ |
| 583 | queryCommandState : function( commandName, doUpdate ) |
| 584 | { |
| 585 | var command = this.getCommand( commandName ); |
| 586 | |
| 587 | if ( !doUpdate ) |
| 588 | return command.state; |
| 589 | |
| 590 | var sel = this.getSelection(), |
| 591 | start = sel && sel.getStartElement(); |
| 592 | |
| 593 | // Perform a command state update. |
| 594 | var eventData = |
| 595 | { |
| 596 | name: commandName, |
| 597 | state : -1, |
| 598 | command: command, |
| 599 | selection : sel, |
| 600 | path : sel && new CKEDITOR.dom.elementPath( start ) |
| 601 | }; |
| 602 | |
| 603 | this.fire( 'commandState', eventData ); |
| 604 | |
| 605 | if ( eventData.state != -1 ) |
| 606 | command.setState( eventData.state ); |
| 607 | |
| 608 | return command.state; |
| 609 | }, |
| 610 | |
| 611 | /** |
576 | 612 | * Executes a command associated with the editor. |
577 | 613 | * @param {String} commandName The indentifier name of the command. |
578 | 614 | * @param {Object} [data] Data to be passed to the command. |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
40 | 40 | align = element.getStyle( 'text-align' ) || element.getAttribute( 'align' ) || ''; |
41 | 41 | } |
42 | 42 | |
43 | | align && ( align = align.replace( /-moz-|-webkit-|start|auto/i, '' ) ); |
| 43 | // Sometimes computed values doesn't tell. |
| 44 | align && ( align = align.replace( /(?:-(?:moz|webkit)-)?(?:start|auto)/i, '' ) ); |
44 | 45 | |
45 | 46 | !align && useComputedState && ( align = element.getComputedStyle( 'direction' ) == 'rtl' ? 'right' : 'left' ); |
46 | 47 | |
… |
… |
|
49 | 50 | |
50 | 51 | function onSelectionChange( evt ) |
51 | 52 | { |
52 | | if ( evt.editor.readOnly ) |
| 53 | var editor = evt.editor; |
| 54 | if ( editor.readOnly ) |
53 | 55 | return; |
54 | 56 | |
55 | | var command = evt.editor.getCommand( this.name ); |
56 | | command.state = getState.call( this, evt.editor, evt.data.path ); |
57 | | command.fire( 'state' ); |
| 57 | editor.queryCommandState( this.name, 1 ); |
58 | 58 | } |
59 | 59 | |
60 | 60 | function justifyCommand( editor, name, value ) |
… |
… |
|
234 | 234 | editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, right ) ); |
235 | 235 | editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, center ) ); |
236 | 236 | editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, justify ) ); |
| 237 | editor.on( 'commandState', function( evt ) |
| 238 | { |
| 239 | evt.data.state = getState.call( evt.data.command, editor, evt.data.path ); |
| 240 | } ); |
237 | 241 | editor.on( 'dirChanged', onDirChanged ); |
238 | 242 | }, |
239 | 243 | |