aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/justify
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2017-12-04 18:55:29 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2017-12-04 18:55:29 +0100
commit1794320dcfdfcd19572fb1676294f9853a6bbc20 (patch)
treea4c9e978947d6930d50391747382d7f95a5863e3 /sources/plugins/justify
parent7183f6a6a21ad9124e70c997e0168459f377a9f2 (diff)
downloadludivine-ckeditor-component-1794320dcfdfcd19572fb1676294f9853a6bbc20.tar.gz
ludivine-ckeditor-component-1794320dcfdfcd19572fb1676294f9853a6bbc20.tar.zst
ludivine-ckeditor-component-1794320dcfdfcd19572fb1676294f9853a6bbc20.zip
Update to 4.7.3HEAD4.7.3master
Diffstat (limited to 'sources/plugins/justify')
-rw-r--r--sources/plugins/justify/lang/es-mx.js10
-rw-r--r--sources/plugins/justify/plugin.js41
2 files changed, 43 insertions, 8 deletions
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 @@
1/*
2Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3For licensing, see LICENSE.md or http://ckeditor.com/license
4*/
5CKEDITOR.plugins.setLang( 'justify', 'es-mx', {
6 block: 'Justificar',
7 center: 'Centrar',
8 left: 'Alinear a la izquierda',
9 right: 'Alinear a la derecha'
10} );
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 @@
37 this.name = name; 37 this.name = name;
38 this.value = value; 38 this.value = value;
39 this.context = 'p'; 39 this.context = 'p';
40
41 var classes = editor.config.justifyClasses, 40 var classes = editor.config.justifyClasses,
42 blockTag = editor.config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div'; 41 blockTag = editor.config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div';
43 42
@@ -150,6 +149,17 @@
150 if ( block.isReadOnly() ) 149 if ( block.isReadOnly() )
151 continue; 150 continue;
152 151
152 // Check if style or class might be applied to currently processed element (#455).
153 var tag = block.getName(),
154 isAllowedTextAlign, isAllowedCssClass;
155
156 isAllowedTextAlign = editor.activeFilter.check( tag + '{text-align}' );
157 isAllowedCssClass = editor.activeFilter.check( tag + '(' + cssClassName + ')' );
158
159 if ( !isAllowedCssClass && !isAllowedTextAlign ) {
160 continue;
161 }
162
153 block.removeAttribute( 'align' ); 163 block.removeAttribute( 'align' );
154 block.removeStyle( 'text-align' ); 164 block.removeStyle( 'text-align' );
155 165
@@ -158,13 +168,13 @@
158 168
159 var apply = ( this.state == CKEDITOR.TRISTATE_OFF ) && ( !useComputedState || ( getAlignment( block, true ) != this.value ) ); 169 var apply = ( this.state == CKEDITOR.TRISTATE_OFF ) && ( !useComputedState || ( getAlignment( block, true ) != this.value ) );
160 170
161 if ( cssClassName ) { 171 if ( cssClassName && isAllowedCssClass ) {
162 // Append the desired class name. 172 // Append the desired class name.
163 if ( apply ) 173 if ( apply )
164 block.addClass( cssClassName ); 174 block.addClass( cssClassName );
165 else if ( !className ) 175 else if ( !className )
166 block.removeAttribute( 'class' ); 176 block.removeAttribute( 'class' );
167 } else if ( apply ) { 177 } else if ( apply && isAllowedTextAlign ) {
168 block.setStyle( 'text-align', this.value ); 178 block.setStyle( 'text-align', this.value );
169 } 179 }
170 } 180 }
@@ -177,15 +187,31 @@
177 }, 187 },
178 188
179 refresh: function( editor, path ) { 189 refresh: function( editor, path ) {
180 var firstBlock = path.block || path.blockLimit; 190 var firstBlock = path.block || path.blockLimit,
181 191 name = firstBlock.getName(),
182 this.setState( firstBlock.getName() != 'body' && getAlignment( firstBlock, this.editor.config.useComputedState ) == this.value ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 192 isEditable = firstBlock.equals( editor.editable() ),
193 isStylable = this.cssClassName ? editor.activeFilter.check( name + '(' + this.cssClassName + ')' ) :
194 editor.activeFilter.check( name + '{text-align}' );
195
196 // #455
197 // 1. Check if we are directly in editbale. Justification should be always allowed, and not highlighted.
198 // Checking path.elements.length is required to filter out situation `body > ul` where ul is selected and path.blockLimit returns editable.
199 // 2. Check if current element can have applied specific class.
200 // 3. Check if current element can have applied text-align style.
201 if ( isEditable && path.elements.length === 1 ) {
202 this.setState( CKEDITOR.TRISTATE_OFF );
203 } else if ( !isEditable && isStylable ) {
204 // 2 & 3 in one condition.
205 this.setState( getAlignment( firstBlock, this.editor.config.useComputedState ) == this.value ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
206 } else {
207 this.setState( CKEDITOR.TRISTATE_DISABLED );
208 }
183 } 209 }
184 }; 210 };
185 211
186 CKEDITOR.plugins.add( 'justify', { 212 CKEDITOR.plugins.add( 'justify', {
187 // jscs:disable maximumLineLength 213 // jscs:disable maximumLineLength
188 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% 214 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%
189 // jscs:enable maximumLineLength 215 // jscs:enable maximumLineLength
190 icons: 'justifyblock,justifycenter,justifyleft,justifyright', // %REMOVE_LINE_CORE% 216 icons: 'justifyblock,justifycenter,justifyleft,justifyright', // %REMOVE_LINE_CORE%
191 hidpi: true, // %REMOVE_LINE_CORE% 217 hidpi: true, // %REMOVE_LINE_CORE%
@@ -225,7 +251,6 @@
225 toolbar: 'align,40' 251 toolbar: 'align,40'
226 } ); 252 } );
227 } 253 }
228
229 editor.on( 'dirChanged', onDirChanged ); 254 editor.on( 'dirChanged', onDirChanged );
230 } 255 }
231 } ); 256 } );