Skip to content

Commit

Permalink
Merge branch 't/7987' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Sep 12, 2013
2 parents b7b070d + 72ec649 commit 32d0257
Show file tree
Hide file tree
Showing 14 changed files with 437 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -3,6 +3,7 @@ CKEditor 4 Changelog

## CKEditor 4.3 beta

* [#7987](https://dev.ckeditor.com/ticket/7987): Implement Language toolbar button to support WCAG 3.1.2 Language of Parts.
* [#10708](http://dev.ckeditor.com/ticket/10708): New smileys.

## CKEditor 4.2.1
Expand Down
1 change: 1 addition & 0 deletions config.js
Expand Up @@ -37,6 +37,7 @@ CKEDITOR.editorConfig = function( config ) {
'indentlist,' +
'indentblock,' +
'justify,' +
'languages,' +
'link,' +
'list,' +
'liststyle,' +
Expand Down
5 changes: 5 additions & 0 deletions contents.css
Expand Up @@ -101,3 +101,8 @@ pre
.marker {
background-color: Yellow;
}

span[lang]
{
font-style: italic;
}
3 changes: 0 additions & 3 deletions plugins/bidi/plugin.js
Expand Up @@ -221,9 +221,6 @@

var lang = editor.lang.bidi;

if ( editor.ui.addToolbarGroup )
editor.ui.addToolbarGroup( 'bidi', 'align', 'paragraph' );

addButtonCommand( 'BidiLtr', lang.ltr, 'bidiltr', bidiCommand( 'ltr' ), 10 );
addButtonCommand( 'BidiRtl', lang.rtl, 'bidirtl', bidiCommand( 'rtl' ), 20 );

Expand Down
Binary file added plugins/languages/icons/hidpi/languages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugins/languages/icons/languages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions plugins/languages/lang/en.js
@@ -0,0 +1,8 @@
/**
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/

CKEDITOR.plugins.setLang( 'languages', 'en', {
button: 'Set language'
} );
117 changes: 117 additions & 0 deletions plugins/languages/plugin.js
@@ -0,0 +1,117 @@
/**
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/

/**
* @fileOverview Languages plugin.
*/

'use strict';

(function() {

var languagesButtonsGroup = 'languages',
allowedContent = 'span[!lang,!dir]',
requiredContent = 'span[lang,dir]';

CKEDITOR.plugins.add( 'languages', {
requires: 'menubutton',
lang: 'en', // %REMOVE_LINE_CORE%
icons: 'languages', // %REMOVE_LINE_CORE%
hidpi: true, // %REMOVE_LINE_CORE%

init: function( editor ) {
var languagesConfigStrings = ( editor.config.languages || [ 'ar:Arabic:rtl', 'fr:French', 'es:Spanish' ] ),
items = {},
parts,
curLanguageId, // 2-letter lanugage identifier.
i;

// Registers command.
editor.addCommand( 'language', {
allowedContent: allowedContent,
requiredContent: requiredContent,
exec: function( editor, languageId ) {
if ( items[ languageId ] )
editor.applyStyle( items[ languageId ].style );
}
} );

// Parse languagesConfigStrings, and create items entry for each lang.
for ( i = 0; i < languagesConfigStrings.length; i++ ) {
parts = languagesConfigStrings[ i ].split( ':' );
curLanguageId = parts[ 0 ];

items[ curLanguageId ] = {
label: parts[ 1 ],
langId: curLanguageId,
group: languagesButtonsGroup,
order: i,
// Tells if this language is left-to-right oriented (default: true).
ltr: ( String( parts[ 2 ] ).toLowerCase() != 'rtl' ),
// Style property will be assigned after object initialization.
style: null,
onClick: function() {
editor.execCommand( 'language', this.langId );
}
};

// Init style property.
items[ curLanguageId ].style = new CKEDITOR.style( {
element: 'span',
attributes: {
lang: curLanguageId,
dir: items[ curLanguageId ].ltr ? 'ltr' : 'rtl'
}
} );
}

// Initialize group/button.
editor.addMenuGroup( languagesButtonsGroup, 1 );
editor.addMenuItems( items );

editor.ui.add( 'Languages', CKEDITOR.UI_MENUBUTTON, {
label: editor.lang.languages.button,
// MenuButtons do not (yet) has toFeature method, so we cannot do this:
// toFeature: function( editor ) { return editor.getCommand( 'language' ); }
// Set feature's properties directly on button.
allowedContent: allowedContent,
requiredContent: requiredContent,
toolbar: 'bidi,30',
modes: { wysiwyg: 1 },
className: 'cke_button_languages',
onMenu: function() {
var activeItems = {};

for ( var prop in items )
activeItems[ prop ] = CKEDITOR.TRISTATE_ON;

return activeItems;
}
} );
}
} );

}());

/**
* Specifies the list of languages available in the languages plugin. Each entry
* should be a string in the following format:
*
* <languageCode>:<languageLabel>[:<textDirection>]
*
* * _languageCode_: language code used for the lang attribute in ISO 639 format.
* Codes can be found at http://www.loc.gov/standards/iso639-2/php/English_list.php.
* * _languageLabel_: label to show for this language in the list.
* * _textDirection_: (optional) one of following values `rtl` or `ltr`,
* indicating the reading direction for the language text direction. Defaults
* to `ltr`.
*
* For example:
*
* config.languages = [ 'ar:Arabic:rtl', 'fr:French', 'de:Spanish' ];
*
* @cfg {Array} [languages = [ 'ar:Arabic:rtl', 'fr:French', 'de:Spanish' ]]
* @member CKEDITOR.config
*/
4 changes: 2 additions & 2 deletions plugins/toolbar/plugin.js
Expand Up @@ -615,7 +615,7 @@
{ name: 'forms' },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
{ name: 'links' },
{ name: 'insert' },
'/',
Expand Down Expand Up @@ -693,7 +693,7 @@ CKEDITOR.config.toolbarLocation = 'top';
* { name: 'forms' },
* '/',
* { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
* { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align' ] },
* { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
* { name: 'links' },
* { name: 'insert' },
* '/',
Expand Down
Binary file modified skins/moono/dev/icons16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 32d0257

Please sign in to comment.