Index: /CKEditor/branches/versions/3.4.x/CHANGES.html
===================================================================
--- /CKEditor/branches/versions/3.4.x/CHANGES.html (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/CHANGES.html (revision 5678)
@@ -42,4 +42,5 @@
#5628 : Port 'DragResizeTable' plugin from FCKEditor 2.x.
#979 : New configuration 'enableTabKeyTools' to allow using 'Tab' key to navigate through table cells.
+ #5909 : BiDi: Support for switching base language.
Index: /CKEditor/branches/versions/3.4.x/_source/core/config.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/core/config.js (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/_source/core/config.js (revision 5678)
@@ -244,5 +244,5 @@
* @example
*/
- 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',
+ 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',
/**
Index: /CKEditor/branches/versions/3.4.x/_source/lang/en.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/lang/en.js (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/_source/lang/en.js (revision 5678)
@@ -745,4 +745,10 @@
toolbarCollapse : 'Collapse Toolbar',
- toolbarExpand : 'Expand Toolbar'
+ toolbarExpand : 'Expand Toolbar',
+
+ bidi :
+ {
+ ltr :"Text direction from left to right",
+ rtl : "Text direction from right to left"
+ }
};
Index: /CKEditor/branches/versions/3.4.x/_source/plugins/bidi/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/plugins/bidi/plugin.js (revision 5678)
+++ /CKEditor/branches/versions/3.4.x/_source/plugins/bidi/plugin.js (revision 5678)
@@ -0,0 +1,198 @@
+/*
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+(function(){
+
+ var guardElements = { table:1, ul:1, ol:1, blockquote:1, div:1 };
+ var directSelectionGuardElements = {};
+ CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { tr:1, p:1, div:1, li:1 } );
+
+ function onSelectionChange( evt )
+ {
+ evt.editor.getCommand( 'bidirtl' ).setState( getState( evt.editor, evt.data.path, 'rtl' ) );
+ evt.editor.getCommand( 'bidiltr' ).setState( getState( evt.editor, evt.data.path, 'ltr' ) );
+ }
+
+ function getState( editor, path, dir )
+ {
+ var selection = editor.getSelection(),
+ ranges = selection.getRanges();
+
+ var selectedElement = ranges && ranges[ 0 ].getEnclosedNode();
+
+ // If this is not our element of interest, apply to fully selected elements from guardElements.
+ if ( !selectedElement || selectedElement
+ && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
+ )
+ selectedElement = getFullySelected( selection, guardElements );
+
+ selectedElement = selectedElement || path.block || path.blockLimit;
+
+ if ( !selectedElement || selectedElement.getName() == 'body' )
+ return CKEDITOR.TRISTATE_OFF;
+
+ return ( selectedElement.getAttribute( 'dir' ) == dir ) ?
+ CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF;
+ }
+
+ /**
+ *
+ * @param {!CKEDITOR.dom.element} element
+ */
+ function switchDir( element, dir, editor )
+ {
+ if ( element.hasAttribute( 'dir' ) && element.getAttribute( 'dir' ).toLowerCase() == dir )
+ element.removeAttribute( 'dir' );
+ else
+ element.setAttribute( 'dir', dir );
+
+ editor.forceNextSelectionCheck();
+ }
+
+ /**
+ *
+ * @param {CKEDITOR.dom.selection} selection
+ * @param {Object} elements
+ *
+ * @return {?CKEDITOR.dom.element} Fully selected element.
+ */
+ function getFullySelected( selection, elements )
+ {
+ var selectedElement = selection.getCommonAncestor();
+ while( selectedElement.type == CKEDITOR.NODE_ELEMENT
+ && !( selectedElement.getName() in elements )
+ && selectedElement.getParent().getChildCount() == 1
+ )
+ selectedElement = selectedElement.getParent();
+
+ return selectedElement.type == CKEDITOR.NODE_ELEMENT
+ && ( selectedElement.getName() in elements )
+ && selectedElement;
+ }
+
+ function bidiCommand( dir )
+ {
+ return function( editor )
+ {
+ var selection = editor.getSelection(),
+ enterMode = editor.config.enterMode,
+ ranges = selection.getRanges();
+
+ if ( ranges )
+ {
+ // Apply do directly selected elements from guardElements.
+ var selectedElement = ranges[ 0 ].getEnclosedNode();
+
+ // If this is not our element of interest, apply to fully selected elements from guardElements.
+ if ( !selectedElement || selectedElement
+ && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
+ )
+ selectedElement = getFullySelected( selection, guardElements );
+
+ if ( selectedElement )
+ {
+ switchDir( selectedElement, dir, editor );
+ }
+ else
+ {
+ // Creates bookmarks for selection, as we may split some blocks.
+ var bookmarks = selection.createBookmarks();
+
+ var iterator,
+ block;
+
+ for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
+ {
+ // Array of elements processed as guardElements.
+ var processedElements = [];
+ // Walker searching for guardElements.
+ var walker = new CKEDITOR.dom.walker( ranges[ i ] );
+ walker.evaluator = function( node ){
+ return node.type == CKEDITOR.NODE_ELEMENT
+ && node.getName() in guardElements
+ && !( node.getName() == ( enterMode == CKEDITOR.ENTER_P ) ? 'p' : 'div'
+ && node.getParent().type == CKEDITOR.NODE_ELEMENT
+ && node.getParent().getName() == 'blockquote'
+ );
+ };
+
+ while ( block = walker.next() )
+ {
+ switchDir( block, dir, editor );
+ processedElements.push( block );
+ }
+
+ iterator = ranges[ i ].createIterator();
+ iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
+
+ while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
+ {
+ var _break = 0;
+
+ // Check if block have been already processed by the walker above.
+ for ( var ii = 0; ii < processedElements.length; ii++ )
+ {
+ var parent = block.getParent();
+
+ while( parent && parent.getName() != 'body' )
+ {
+ if ( ( parent.$.isSameNode && parent.$.isSameNode( processedElements[ ii ].$ ) )
+ || parent.$ == processedElements[ ii ].$ )
+ {
+ _break = 1;
+ break;
+ }
+ parent = parent.getParent();
+ }
+
+ if ( _break )
+ break;
+ }
+
+ if ( !_break )
+ {
+ switchDir( block, dir, editor );
+ }
+ }
+ }
+
+ editor.forceNextSelectionCheck();
+ // Restore selection position.
+ selection.selectBookmarks( bookmarks );
+ }
+
+ editor.focus();
+ }
+ };
+ }
+
+ CKEDITOR.plugins.add( 'bidi',
+ {
+ requires : [ 'styles', 'button' ],
+
+ init : function( editor )
+ {
+ // All buttons use the same code to register. So, to avoid
+ // duplications, let's use this tool function.
+ var addButtonCommand = function( buttonName, buttonLabel, commandName, commandExec )
+ {
+ editor.addCommand( commandName, new CKEDITOR.command( editor, { exec : commandExec }) );
+
+ editor.ui.addButton( buttonName,
+ {
+ label : buttonLabel,
+ command : commandName
+ });
+ };
+
+ var lang = editor.lang.bidi;
+
+ addButtonCommand( 'BidiLtr', lang.rtl, 'bidiltr', bidiCommand( 'ltr' ) );
+ addButtonCommand( 'BidiRtl', lang.ltr, 'bidirtl', bidiCommand( 'rtl' ) );
+
+ editor.on( 'selectionChange', onSelectionChange );
+ }
+ });
+
+})();
Index: /CKEditor/branches/versions/3.4.x/_source/plugins/link/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/plugins/link/plugin.js (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/_source/plugins/link/plugin.js (revision 5678)
@@ -59,5 +59,5 @@
*/
var command = editor.getCommand( 'unlink' ),
- element = evt.data.path.lastElement.getAscendant( 'a', true );
+ element = evt.data.path.lastElement && evt.data.path.lastElement.getAscendant( 'a', true );
if ( element && element.getName() == 'a' && element.getAttribute( 'href' ) )
command.setState( CKEDITOR.TRISTATE_OFF );
Index: /CKEditor/branches/versions/3.4.x/_source/plugins/toolbar/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/plugins/toolbar/plugin.js (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/_source/plugins/toolbar/plugin.js (revision 5678)
@@ -434,4 +434,5 @@
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
+ ['BidiLtr', 'BidiRtl'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
Index: /CKEditor/branches/versions/3.4.x/_source/skins/kama/icons.css
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/skins/kama/icons.css (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/_source/skins/kama/icons.css (revision 5678)
@@ -321,6 +321,17 @@
background-position: 0 -1040px;
}
-.cke_skin_office2003 .cke_button_editdiv .cke_icon
+
+.cke_skin_kama .cke_button_editdiv .cke_icon
{
background-position: 0 -1184px;
}
+
+.cke_skin_kama .cke_button_bidirtl .cke_icon
+{
+ background-position: 0 -1072px;
+}
+
+.cke_skin_kama .cke_button_bidiltr .cke_icon
+{
+ background-position: 0 -1056px;
+}
Index: /CKEditor/branches/versions/3.4.x/_source/skins/office2003/icons.css
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/skins/office2003/icons.css (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/_source/skins/office2003/icons.css (revision 5678)
@@ -323,2 +323,12 @@
background-position: 0 -1200px;
}
+
+.cke_skin_office2003 .cke_button_bidirtl .cke_icon
+{
+ background-position: 0 -1072px;
+}
+
+.cke_skin_office2003 .cke_button_bidiltr .cke_icon
+{
+ background-position: 0 -1056px;
+}
Index: /CKEditor/branches/versions/3.4.x/_source/skins/v2/icons.css
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/skins/v2/icons.css (revision 5677)
+++ /CKEditor/branches/versions/3.4.x/_source/skins/v2/icons.css (revision 5678)
@@ -323,2 +323,12 @@
background-position: 0 -1200px;
}
+
+.cke_skin_v2 .cke_button_bidirtl .cke_icon
+{
+ background-position: 0 -1072px;
+}
+
+.cke_skin_v2 .cke_button_bidiltr .cke_icon
+{
+ background-position: 0 -1056px;
+}