Ticket #5909: 5909_7.patch

File 5909_7.patch, 10.6 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/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/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.element} element
     42         */
     43        function switchDir( element, dir, editor )
     44        {
     45                if ( element.hasAttribute( 'dir' ) && element.getAttribute( 'dir' ).toLowerCase()  == dir )
     46                {
     47                        dirSwitch = 1;
     48                        element.removeAttribute( 'dir' );
     49                }
     50                else
     51                        element.setAttribute( 'dir', dir );
     52
     53                editor.forceNextSelectionCheck();
     54        }
     55
     56        /**
     57         *
     58         * @param {CKEDITOR.dom.selection} selection
     59         * @param {Object<name,int>} elements
     60         *
     61         * @return {?CKEDITOR.dom.element} Fully selected element.
     62         */
     63        function getFullySelected( selection, elements )
     64        {
     65                var selectedElement = selection.getCommonAncestor();
     66                while( selectedElement.type == CKEDITOR.NODE_ELEMENT
     67                                && !( selectedElement.getName() in elements )
     68                                && selectedElement.getParent().getChildCount() == 1
     69                        )
     70                        selectedElement = selectedElement.getParent();
     71
     72                return selectedElement.type == CKEDITOR.NODE_ELEMENT
     73                        && ( selectedElement.getName() in elements )
     74                        && selectedElement;
     75        }
     76
     77        function bidiCommand( dir )
     78        {
     79                return function( editor )
     80                {
     81                        var selection = editor.getSelection(),
     82                                enterMode = editor.config.enterMode,
     83                                ranges = selection.getRanges();
     84
     85                        if ( ranges )
     86                        {
     87                                // Apply do directly selected elements from guardElements.
     88                                var selectedElement = ranges[ 0 ].getEnclosedNode();
     89
     90                                // If this is not our element of interest, apply to fully selected elements from guardElements.
     91                                if ( !selectedElement || selectedElement
     92                                                && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
     93                                        )
     94                                        selectedElement = getFullySelected( selection, guardElements );
     95                               
     96                                if ( selectedElement )
     97                                {
     98                                        switchDir( selectedElement, dir, editor );
     99                                }
     100                                else
     101                                {
     102                                        // Creates bookmarks for selection, as we may split some blocks.
     103                                        var bookmarks = selection.createBookmarks();
     104
     105                                        var iterator,
     106                                                block;
     107
     108                                        for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
     109                                        {
     110                                                // Array of elements processed as guardElements.
     111                                                var processedElements = [];
     112                                                // Walker searching for guardElements.
     113                                                var walker = new CKEDITOR.dom.walker( ranges[ i ] );
     114                                                walker.evaluator = function( node ){
     115                                                        return node.type == CKEDITOR.NODE_ELEMENT
     116                                                                && node.getName() in guardElements
     117                                                                && !( node.getName() == ( enterMode == CKEDITOR.ENTER_P ) ? 'p' : 'div'
     118                                                                        && node.getParent().type == CKEDITOR.NODE_ELEMENT
     119                                                                        && node.getParent().getName() == 'blockquote'
     120                                                                );
     121                                                };
     122
     123                                                while ( block = walker.next() )
     124                                                {
     125                                                        switchDir( block, dir, editor );
     126                                                        processedElements.push( block );
     127                                                }
     128
     129                                                iterator = ranges[ i ].createIterator();
     130                                                iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
     131
     132                                                while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
     133                                                {
     134                                                        var _break = 0;
     135
     136                                                        // Check if block have been already processed by the walker above.
     137                                                        for ( var ii = 0; ii < processedElements.length; ii++ )
     138                                                        {
     139                                                                var     parent = block.getParent();
     140                                                               
     141                                                                while( parent && parent.getName() != 'body' )
     142                                                                {
     143                                                                        if ( ( parent.$.isSameNode && parent.$.isSameNode( processedElements[ ii ].$ ) )
     144                                                                                        || parent.$ == processedElements[ ii ].$ )
     145                                                                        {
     146                                                                                _break = 1;
     147                                                                                break;
     148                                                                        }
     149                                                                        parent = parent.getParent();
     150                                                                }
     151
     152                                                                if ( _break )
     153                                                                        break;
     154                                                        }
     155
     156                                                        if ( !_break )
     157                                                        {
     158                                                                switchDir( block, dir, editor );
     159                                                        }
     160                                                }
     161                                        }
     162                                       
     163                                        editor.forceNextSelectionCheck();
     164                                        // Restore selection position.
     165                                        selection.selectBookmarks( bookmarks );
     166                                }
     167
     168                                editor.focus();
     169                        }
     170                };
     171        }
     172
     173        CKEDITOR.plugins.add( 'bidi',
     174        {
     175                requires : [ 'styles', 'button' ],
     176
     177                init : function( editor )
     178                {
     179                        // All buttons use the same code to register. So, to avoid
     180                        // duplications, let's use this tool function.
     181                        var addButtonCommand = function( buttonName, buttonLabel, commandName, commandExec )
     182                        {
     183                                editor.addCommand( commandName, new CKEDITOR.command( editor, { exec : commandExec }) );
     184
     185                                editor.ui.addButton( buttonName,
     186                                        {
     187                                                label : buttonLabel,
     188                                                command : commandName
     189                                        });
     190                        };
     191
     192                        var lang = editor.lang.bidi;
     193
     194                        addButtonCommand( 'BidiLtr', lang.rtl, 'bidiltr', bidiCommand( 'ltr' ) );
     195                        addButtonCommand( 'BidiRtl', lang.ltr, 'bidirtl', bidiCommand( 'rtl' ) );
     196
     197                        editor.on( 'selectionChange', onSelectionChange );
     198                }
     199        });
     200       
     201})();
  • _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