Ticket #5909: 5909_6.patch

File 5909_6.patch, 10.7 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/skins/office2003/icons.css

     
    322322{
    323323        background-position: 0 -1200px;
    324324}
     325
     326.cke_skin_office2003 .cke_button_bidirtl .cke_icon
     327{
     328        background-position: 0 -1072px;
     329}
     330
     331.cke_skin_office2003 .cke_button_bidiltr .cke_icon
     332{
     333        background-position: 0 -1056px;
     334}
     335 No newline at end of file
  • _source/plugins/toolbar/plugin.js

     
    433433        ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    434434        ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
    435435        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
     436        ['BidiLtr', 'BidiRtl'],
    436437        ['Link','Unlink','Anchor'],
    437438        ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
    438439        '/',
  • _source/plugins/link/plugin.js

     
    5858                                 * for this in Firefox. So we must detect the state by element paths.
    5959                                 */
    6060                                var command = editor.getCommand( 'unlink' ),
    61                                         element = evt.data.path.lastElement.getAscendant( 'a', true );
     61                                        element = evt.data.path.lastElement && evt.data.path.lastElement.getAscendant( 'a', true );
    6262                                if ( element && element.getName() == 'a' && element.getAttribute( 'href' ) )
    6363                                        command.setState( CKEDITOR.TRISTATE_OFF );
    6464                                else
  • _source/lang/en.js

     
    744744        },
    745745
    746746        toolbarCollapse : 'Collapse Toolbar',
    747         toolbarExpand   : 'Expand Toolbar'
     747        toolbarExpand   : 'Expand Toolbar',
     748
     749        bidi :
     750        {
     751                ltr :"Text direction from left to right",
     752                rtl : "Text direction from right to left"
     753        }
    748754};
  • _source/skins/v2/icons.css

     
    322322{
    323323        background-position: 0 -1200px;
    324324}
     325
     326.cke_skin_v2 .cke_button_bidirtl .cke_icon
     327{
     328        background-position: 0 -1072px;
     329}
     330
     331.cke_skin_v2 .cke_button_bidiltr .cke_icon
     332{
     333        background-position: 0 -1056px;
     334}
     335 No newline at end of file
  • _source/plugins/bidi/plugin.js

     
     1/*
     2Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5(function(){
     6
     7        var guardElements = { table:1, ul:1, ol:1, blockquote:1, div:1 };
     8        var directSelectionGuardElements = {};
     9        CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { tr:1, p:1, div:1, li:1 } );
     10
     11        function onSelectionChange( evt )
     12        {
     13                evt.editor.getCommand( 'bidirtl' ).setState( getState( evt.editor, evt.data.path, 'rtl' ) );
     14                evt.editor.getCommand( 'bidiltr' ).setState( getState( evt.editor, evt.data.path, 'ltr' ) );
     15        }
     16       
     17        function getState( editor, path, dir )
     18        {
     19                var selection = editor.getSelection(),
     20                        ranges = selection.getRanges();
     21
     22                var selectedElement = ranges && ranges[ 0 ].getEnclosedNode();
     23
     24                // If this is not our element of interest, apply to fully selected elements from guardElements.
     25                if ( !selectedElement || selectedElement
     26                                && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
     27                        )
     28                        selectedElement = getFullySelected( selection, guardElements );
     29               
     30                selectedElement = selectedElement || path.block || path.blockLimit;
     31
     32                if ( !selectedElement || selectedElement.getName() == 'body' )
     33                        return CKEDITOR.TRISTATE_OFF;
     34
     35                return ( selectedElement.getAttribute( 'dir' ) == dir ) ?
     36                        CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF;
     37        }
     38
     39        /**
     40         *
     41         * @param {CKEDITOR.dom.selection} selection
     42         * @param {Object<name,int>} elements
     43         *
     44         * @return {?CKEDITOR.dom.element} Fully selected element.
     45         */
     46        function getFullySelected( selection, elements )
     47        {
     48                var selectedElement = selection.getCommonAncestor();
     49                while( selectedElement.type == CKEDITOR.NODE_ELEMENT
     50                                && !( selectedElement.getName() in elements )
     51                                && selectedElement.getParent().getChildCount() == 1
     52                        )
     53                        selectedElement = selectedElement.getParent();
     54
     55                return selectedElement.type == CKEDITOR.NODE_ELEMENT
     56                        && ( selectedElement.getName() in elements )
     57                        && selectedElement;
     58        }
     59
     60        function bidiCommand( dir )
     61        {
     62                return function( editor )
     63                {
     64                        var selection = editor.getSelection(),
     65                                enterMode = editor.config.enterMode,
     66                                ranges = selection.getRanges();
     67
     68                        if ( ranges )
     69                        {
     70                                // Apply do directly selected elements from guardElements.
     71                                var selectedElement = ranges[ 0 ].getEnclosedNode();
     72
     73                                // If this is not our element of interest, apply to fully selected elements from guardElements.
     74                                if ( !selectedElement || selectedElement
     75                                                && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
     76                                        )
     77                                        selectedElement = getFullySelected( selection, guardElements );
     78                               
     79                                if ( selectedElement )
     80                                {
     81                                        if ( selectedElement.hasAttribute( 'dir' ) && selectedElement.getAttribute( 'dir' ).toLowerCase()  == dir )
     82                                                selectedElement.removeAttribute( 'dir' );
     83                                        else
     84                                                selectedElement.setAttribute( 'dir', dir );
     85                                       
     86                                        editor.forceNextSelectionCheck();
     87                                }
     88                                else
     89                                {
     90                                        // Creates bookmarks for selection, as we may split some blocks.
     91                                        var bookmarks = selection.createBookmarks();
     92
     93                                        var iterator,
     94                                                block;
     95
     96                                        for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
     97                                        {
     98                                                // Array of elements processed as guardElements.
     99                                                var processedElements = [];
     100                                                // Walker searching for guardElements.
     101                                                var walker = new CKEDITOR.dom.walker( ranges[ i ] );
     102                                                walker.evaluator = function( node ){
     103                                                        return node.type == CKEDITOR.NODE_ELEMENT
     104                                                                && node.getName() in guardElements
     105                                                                && !( node.getName() == ( enterMode == CKEDITOR.ENTER_P ) ? 'p' : 'div'
     106                                                                        && node.getParent().type == CKEDITOR.NODE_ELEMENT
     107                                                                        && node.getParent().getName() == 'blockquote'
     108                                                                );
     109                                                };
     110
     111                                                while ( block = walker.next() )
     112                                                {
     113                                                        processedElements.push( block );
     114                                                        if ( block.hasAttribute( 'dir' ) && block.getAttribute( 'dir' ).toLowerCase()  == dir )
     115                                                                block.removeAttribute( 'dir' );
     116                                                        else
     117                                                                block.setAttribute( 'dir', dir );
     118                                                }
     119
     120                                                iterator = ranges[ i ].createIterator();
     121                                                iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
     122
     123                                                while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
     124                                                {
     125                                                        var _break;
     126
     127                                                        // Check if block have been already processed by the walker above.
     128                                                        for ( var ii = 0; ii < processedElements.length; ii++ )
     129                                                        {
     130                                                                var     parent = block.getParent();
     131                                                               
     132                                                                while( parent && parent.getName() != 'body' )
     133                                                                {
     134                                                                        if ( ( parent.$.isSameNode && parent.$.isSameNode( processedElements[ ii ].$ ) )
     135                                                                                        || parent.$ == processedElements[ ii ].$ )
     136                                                                        {
     137                                                                                _break = 1;
     138                                                                                break;
     139                                                                        }
     140                                                                        parent = parent.getParent();
     141                                                                }
     142
     143                                                                if ( _break )
     144                                                                        break;
     145                                                        }
     146
     147                                                        if ( !_break )
     148                                                        {
     149                                                                if ( block.hasAttribute( 'dir' ) && block.getAttribute( 'dir' ).toLowerCase()  == dir )
     150                                                                        block.removeAttribute( 'dir' );
     151                                                                else
     152                                                                        block.setAttribute( 'dir', dir );
     153                                                        }
     154                                                }
     155                                        }
     156                                       
     157                                        editor.forceNextSelectionCheck();
     158                                        // Restore selection position.
     159                                        selection.selectBookmarks( bookmarks );
     160                                }
     161
     162                                editor.focus();
     163                        }
     164                };
     165        }
     166
     167        CKEDITOR.plugins.add( 'bidi',
     168        {
     169                requires : [ 'styles', 'button' ],
     170
     171                init : function( editor )
     172                {
     173                        // All buttons use the same code to register. So, to avoid
     174                        // duplications, let's use this tool function.
     175                        var addButtonCommand = function( buttonName, buttonLabel, commandName, commandExec )
     176                        {
     177                                editor.addCommand( commandName, new CKEDITOR.command( editor, { exec : commandExec }) );
     178
     179                                editor.ui.addButton( buttonName,
     180                                        {
     181                                                label : buttonLabel,
     182                                                command : commandName
     183                                        });
     184                        };
     185
     186                        var lang = editor.lang.bidi;
     187
     188                        addButtonCommand( 'BidiLtr', lang.rtl, 'bidiltr', bidiCommand( 'ltr' ) );
     189                        addButtonCommand( 'BidiRtl', lang.ltr, 'bidirtl', bidiCommand( 'rtl' ) );
     190
     191                        editor.on( 'selectionChange', onSelectionChange );
     192                }
     193        });
     194       
     195})();
  • _source/skins/kama/icons.css

     
    320320{
    321321        background-position: 0 -1040px;
    322322}
    323 .cke_skin_office2003 .cke_button_editdiv .cke_icon
     323
     324.cke_skin_kama .cke_button_editdiv .cke_icon
    324325{
    325326        background-position: 0 -1184px;
    326327}
     328
     329.cke_skin_kama .cke_button_bidirtl .cke_icon
     330{
     331        background-position: 0 -1072px;
     332}
     333
     334.cke_skin_kama .cke_button_bidiltr .cke_icon
     335{
     336        background-position: 0 -1056px;
     337}
  • _source/core/config.js

     
    243243         * @type String
    244244         * @example
    245245         */
    246         plugins : 'about,a11yhelp,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     246        plugins : 'about,a11yhelp,basicstyles,bidi,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    247247
    248248        /**
    249249         * List of additional plugins to be loaded. This is a tool setting which
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy