From 1794320dcfdfcd19572fb1676294f9853a6bbc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 4 Dec 2017 18:55:29 +0100 Subject: Update to 4.7.3 --- sources/plugins/justify/lang/es-mx.js | 10 +++++++++ sources/plugins/justify/plugin.js | 41 ++++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 sources/plugins/justify/lang/es-mx.js (limited to 'sources/plugins/justify') diff --git a/sources/plugins/justify/lang/es-mx.js b/sources/plugins/justify/lang/es-mx.js new file mode 100644 index 0000000..96443e0 --- /dev/null +++ b/sources/plugins/justify/lang/es-mx.js @@ -0,0 +1,10 @@ +/* +Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.md or http://ckeditor.com/license +*/ +CKEDITOR.plugins.setLang( 'justify', 'es-mx', { + block: 'Justificar', + center: 'Centrar', + left: 'Alinear a la izquierda', + right: 'Alinear a la derecha' +} ); diff --git a/sources/plugins/justify/plugin.js b/sources/plugins/justify/plugin.js index ce5cab3..21b9221 100644 --- a/sources/plugins/justify/plugin.js +++ b/sources/plugins/justify/plugin.js @@ -37,7 +37,6 @@ this.name = name; this.value = value; this.context = 'p'; - var classes = editor.config.justifyClasses, blockTag = editor.config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div'; @@ -150,6 +149,17 @@ if ( block.isReadOnly() ) continue; + // Check if style or class might be applied to currently processed element (#455). + var tag = block.getName(), + isAllowedTextAlign, isAllowedCssClass; + + isAllowedTextAlign = editor.activeFilter.check( tag + '{text-align}' ); + isAllowedCssClass = editor.activeFilter.check( tag + '(' + cssClassName + ')' ); + + if ( !isAllowedCssClass && !isAllowedTextAlign ) { + continue; + } + block.removeAttribute( 'align' ); block.removeStyle( 'text-align' ); @@ -158,13 +168,13 @@ var apply = ( this.state == CKEDITOR.TRISTATE_OFF ) && ( !useComputedState || ( getAlignment( block, true ) != this.value ) ); - if ( cssClassName ) { + if ( cssClassName && isAllowedCssClass ) { // Append the desired class name. if ( apply ) block.addClass( cssClassName ); else if ( !className ) block.removeAttribute( 'class' ); - } else if ( apply ) { + } else if ( apply && isAllowedTextAlign ) { block.setStyle( 'text-align', this.value ); } } @@ -177,15 +187,31 @@ }, refresh: function( editor, path ) { - var firstBlock = path.block || path.blockLimit; - - this.setState( firstBlock.getName() != 'body' && getAlignment( firstBlock, this.editor.config.useComputedState ) == this.value ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); + var firstBlock = path.block || path.blockLimit, + name = firstBlock.getName(), + isEditable = firstBlock.equals( editor.editable() ), + isStylable = this.cssClassName ? editor.activeFilter.check( name + '(' + this.cssClassName + ')' ) : + editor.activeFilter.check( name + '{text-align}' ); + + // #455 + // 1. Check if we are directly in editbale. Justification should be always allowed, and not highlighted. + // Checking path.elements.length is required to filter out situation `body > ul` where ul is selected and path.blockLimit returns editable. + // 2. Check if current element can have applied specific class. + // 3. Check if current element can have applied text-align style. + if ( isEditable && path.elements.length === 1 ) { + this.setState( CKEDITOR.TRISTATE_OFF ); + } else if ( !isEditable && isStylable ) { + // 2 & 3 in one condition. + this.setState( getAlignment( firstBlock, this.editor.config.useComputedState ) == this.value ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); + } else { + this.setState( CKEDITOR.TRISTATE_DISABLED ); + } } }; CKEDITOR.plugins.add( 'justify', { // jscs:disable maximumLineLength - lang: 'af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,oc,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE% + lang: 'af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,es-mx,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,oc,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE% // jscs:enable maximumLineLength icons: 'justifyblock,justifycenter,justifyleft,justifyright', // %REMOVE_LINE_CORE% hidpi: true, // %REMOVE_LINE_CORE% @@ -225,7 +251,6 @@ toolbar: 'align,40' } ); } - editor.on( 'dirChanged', onDirChanged ); } } ); -- cgit v1.2.3