From b1c4279aebd7ac9c31f25f596410e6dc114cfda0 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Sat, 14 May 2022 20:12:33 +0200 Subject: [PATCH] Fixed missing text editor plugin files --- .../justify/icons/hidpi/justifyblock.png | Bin 0 -> 533 bytes .../justify/icons/hidpi/justifycenter.png | Bin 0 -> 576 bytes .../justify/icons/hidpi/justifyleft.png | Bin 0 -> 569 bytes .../justify/icons/hidpi/justifyright.png | Bin 0 -> 549 bytes .../plugins/justify/icons/justifyblock.png | Bin 0 -> 315 bytes .../plugins/justify/icons/justifycenter.png | Bin 0 -> 564 bytes .../plugins/justify/icons/justifyleft.png | Bin 0 -> 342 bytes .../plugins/justify/icons/justifyright.png | Bin 0 -> 348 bytes ckeditor/plugins/justify/plugin.js | 265 ++++++++++++++++++ 9 files changed, 265 insertions(+) create mode 100644 ckeditor/plugins/justify/icons/hidpi/justifyblock.png create mode 100644 ckeditor/plugins/justify/icons/hidpi/justifycenter.png create mode 100644 ckeditor/plugins/justify/icons/hidpi/justifyleft.png create mode 100644 ckeditor/plugins/justify/icons/hidpi/justifyright.png create mode 100644 ckeditor/plugins/justify/icons/justifyblock.png create mode 100644 ckeditor/plugins/justify/icons/justifycenter.png create mode 100644 ckeditor/plugins/justify/icons/justifyleft.png create mode 100644 ckeditor/plugins/justify/icons/justifyright.png create mode 100644 ckeditor/plugins/justify/plugin.js diff --git a/ckeditor/plugins/justify/icons/hidpi/justifyblock.png b/ckeditor/plugins/justify/icons/hidpi/justifyblock.png new file mode 100644 index 0000000000000000000000000000000000000000..5c0cf4392e248c653846cb71b7eca1d202153f4f GIT binary patch literal 533 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmUKs7M+SzC{oH>NSwWJ?9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg!ItFh?!xdN1Q+aGJ{c&& zUgGKN%Km_xiC2-KneQA20|TR^r;B4q#Nnr5fqcyd97|K$KmTKIs@0M3%4iIEy=mf% ztOMUZwzM<+&wFdpm&suKU4Kj1C-*jg;|)9uW)*TaEd9<`UHSYL4{OIA?`yyAeeU;o z&EOK5wVzG-d{t_igNwoGKZZeC$7(^gc*LXusBKkewQr`XJ9m_V9@_3F{}m zRGP9Ql+8P~;m69z)y&EQYfTjveco%*kP|lXLxdN^fz<)An2;7p?xhjUH?Or-U4B)tlj*?wb4=^EZ9C7DmM7)m*`;r>Cz_Eh zcEReJu$D*4i$eCK2g`1V%G(;>*0UyX&vNO@dLLZUmNfWOaZw!ef~VI zKbo(u{ODf)bJvT&a8oUDjVMV;EJ?LWE=mPb3`PcqX1a!kx&}rehQ?OL##ROf+6IO| j@;c+1wgTe~DWM4fGkM4E literal 0 HcmV?d00001 diff --git a/ckeditor/plugins/justify/icons/hidpi/justifycenter.png b/ckeditor/plugins/justify/icons/hidpi/justifycenter.png new file mode 100644 index 0000000000000000000000000000000000000000..fd751be5003115acaf6b531dc254a921e1042074 GIT binary patch literal 576 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmUKs7M+SzC{oH>NSwWJ?9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg!ItFh?!xdN1Q+aGJ{c&& zUgGKN%Km_xiC2-KneQA20|TRrr;B4q#Nnsm(S3&%cv9BP(LFV>*y?h>?(PRaT0L&{ z%dYI|;+33zP;Kd-atA({F@R^-9-Qs-l5C8k;4j46RJW6FUI$ECG9mlu8 zOo-uDM85nc#p7LzjHfsBL~sQNr}%eta2YQ*Zm7L~yz%wCb?**tSip1P%z;%q)|9H6 z9CRsiUw=mExmIfM!z6jsHxj!#o7G=6MC5&Bopg- zs)Zsm_9dFvNWC-Mvs-*c^n{re;wFssTg3OUcF#LCA6Ef41&=_>F1piHcBzPuJhb|24X_$<{UDTSVHQ{r_@*Fgay^ zdK&ZCDhwFJswJ)wB`Jv|saDBFsX&Us$iUD{*U(Vcz$nDf*vi=0%D_O|zz|4YXI%3Z eMMG|WN@iLmZVk&~L;`^t7(8A5T-G@yGywppBHxt& literal 0 HcmV?d00001 diff --git a/ckeditor/plugins/justify/icons/hidpi/justifyleft.png b/ckeditor/plugins/justify/icons/hidpi/justifyleft.png new file mode 100644 index 0000000000000000000000000000000000000000..a109ad3c9ac5ed9c75eadf3b49a187b08ba4324b GIT binary patch literal 569 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmUKs7M+SzC{oH>NSwWJ?9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg!ItFh?!xdN1Q+aGJ{c&& zUgGKN%Km_xiC2-KneQA20|TS2r;B4q#NnsmxA~eCcyc@Er!CsQMxMRez*JUyFGDfE z^~ptjUi{0qxHi8ex^d~t5|JcAk4 z4{jT5PEc}54c26R70+$?yjyXzbg01=&fs0I!eZH@R9@|RsP-Us>eB;CH6;NpVcyb0+Nx^V!Lu$0YQ7T60v8f6vyR3=9Ra*ZEn0==p2jeJOs#J%2*S zjK~WwW9E1tx)LW)%J-o_f5M>;Df$a|yXPGF^0{Ft!+s_czNLF^X3U;&tmvFxHD{LW z0+SqBua%Y;uWp+Ds%;i)(8R#*u0;J_`(KGlD`k}gd?Wk+p0__67vTHqer99&Gho=N zmbgZgq$HN4S|t~y0x1R~14A=iLqlByqYy)5D`R6T0|RXXLm+vbam`y44Y~O#nQ4`{ VH7tt}2?T0j@O1TaS?83{1OP$?(m?NSwWJ?9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg!ItFh?!xdN1Q+aGJ{c&& zUgGKN%Km_xiC2-KneQA20|TR`r;B4q#Nnsm7x@k=aIkE)&%X5KzkSDTXJ=>G;0gG=tt+dEt!5`%}3L(y-WcD^Ai&6?pOC@ zHgxcnM%%`uDsN?3`ljOTw#$3p`%Rtc@}y!tXF`ga?c>1sjH`Ku7eXspO7x#k5>9L2 zVKz7__~lpJk#kKNdvyidF6f;8wC}Uc<;Z;k-y5y>?C+bvmR40Sb-+i>=3^B@-cwnI zXocV!1;ZaJRjZVps&8zuTffEM#p!39&7QAo_kT25Zl+|LvgPg5>U|G&8KV_u&i2>8 z|N8%nqeqghSrvB6D*ue%Kg*VJ&ZG^?Z0nM>fZ?cG;u=wsl30>zm0Xkxq!^4049#>6 z4RsBSLJW!lvI6-E$sR$z z3=CDO3=9p;3=BX21L>Cx45bDP46hOx7_4S6Fo@?*ia+WGRLhp+?e4UO_QmvAU zQh^kMk%6I^u7SC(p=F4nv6Zobm5GtIfsvJgfy9LJ3KR{w`6-!cmAExzo;`mAsDZ)L L)z4*}Q$iB}Sjbk! literal 0 HcmV?d00001 diff --git a/ckeditor/plugins/justify/icons/justifycenter.png b/ckeditor/plugins/justify/icons/justifycenter.png new file mode 100644 index 0000000000000000000000000000000000000000..8b5b40fd762f2aa2f99673af16bb106fa2e06087 GIT binary patch literal 564 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CDO3=9p;3=BX21L>Cx45bDP46hOx7_4S6Fo@?*ia+WGRLhp+?e4|tJy(d zO`f}o7vG^nbqDsVT(42J|0I4g*`|W?i0u;vsmaIQ$uv0&T`^^4J!}#jB5J$k{`-q2 zysvg0`&!l7;Sg%bro<%p)0kn$s#OX~JMO>#w{d17*WokVCcey}uJ^z1h|%+ybcEkt zQK@6m3*Qb`mfHJ=&rC>-Jafj)WpU4<6LxnutV&9l_x$aI;-2;V?CkHpChfj^=*+Rd z{tb)?d*l8yZP5QIGD9mzQ^xpliPhZ47R#0TQmVfEEl%X4qrr~O-I&&1&FlJG3y+^-m! zw6rOym3m!GyVfnf{nqUCy4NoXEPnKCx&2n`?;%Ya2FcBrV>iCK35qM#64!{5l*E!$ ztK_0oAjM#0U}&amV6JOu8DeN`Wo%$&Vx(KyMMG|WN@iLmZVj1d&mRG5 OVDNPHb6Mw<&;$TcrqNRX literal 0 HcmV?d00001 diff --git a/ckeditor/plugins/justify/icons/justifyleft.png b/ckeditor/plugins/justify/icons/justifyleft.png new file mode 100644 index 0000000000000000000000000000000000000000..a60d07938f24b89f980fa47a79cf9ae434f5b94c GIT binary patch literal 342 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CDO3=9p;3=BX21L>Cx45bDP46hOx7_4S6Fo@?*ia+WGRLhp+?e4!lvI6-E$sR$z z3=CDO3=9p;3=BX21L>Cx45bDP46hOx7_4S6Fo@?*ia+WGRLhp+?e4|TcpCy%r-8pbWm)e(3rn!@bS z$#|=x@rlHOE^Y>qP}avMYL2b~8mn638c~vxSdwa$T$Bo=7>o=I&2$aSbqy^;42`Xf s4XjLzv<-}`3=AYDlvki=$jwj5OsmALA@l6{BR~xdp00i_>zopr00lZ>CjbBd literal 0 HcmV?d00001 diff --git a/ckeditor/plugins/justify/plugin.js b/ckeditor/plugins/justify/plugin.js new file mode 100644 index 0000000..51d2ed5 --- /dev/null +++ b/ckeditor/plugins/justify/plugin.js @@ -0,0 +1,265 @@ +/** + * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license + */ + +/** + * @fileOverview Justify commands. + */ + +( function() { + function getAlignment( element, useComputedState ) { + + var align; + if ( useComputedState ) + align = element.getComputedStyle( 'text-align' ); + else { + while ( !element.hasAttribute || !( element.hasAttribute( 'align' ) || element.getStyle( 'text-align' ) ) ) { + var parent = element.getParent(); + if ( !parent ) + break; + element = parent; + } + align = element.getStyle( 'text-align' ) || element.getAttribute( 'align' ) || ''; + } + + // Sometimes computed values doesn't tell. + align && ( align = align.replace( /(?:-(?:moz|webkit)-)?(?:start|auto)/i, '' ) ); + + !align && useComputedState && ( align = element.getComputedStyle( 'direction' ) == 'rtl' ? 'right' : 'left' ); + + return align; + } + + function justifyCommand( editor, name, value ) { + this.editor = editor; + this.name = name; + this.value = value; + this.context = 'p'; + var classes = editor.config.justifyClasses, + blockTag = editor.config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div'; + + if ( classes ) { + switch ( value ) { + case 'left': + this.cssClassName = classes[ 0 ]; + break; + case 'center': + this.cssClassName = classes[ 1 ]; + break; + case 'right': + this.cssClassName = classes[ 2 ]; + break; + case 'justify': + this.cssClassName = classes[ 3 ]; + break; + } + + this.cssClassRegex = new RegExp( '(?:^|\\s+)(?:' + classes.join( '|' ) + ')(?=$|\\s)' ); + this.requiredContent = blockTag + '(' + this.cssClassName + ')'; + } + else { + this.requiredContent = blockTag + '{text-align}'; + } + + this.allowedContent = { + 'caption div h1 h2 h3 h4 h5 h6 p pre td th li': { + // Do not add elements, but only text-align style if element is validated by other rule. + propertiesOnly: true, + styles: this.cssClassName ? null : 'text-align', + classes: this.cssClassName || null + } + }; + + // In enter mode BR we need to allow here for div, because when non other + // feature allows div justify is the only plugin that uses it. + if ( editor.config.enterMode == CKEDITOR.ENTER_BR ) + this.allowedContent.div = true; + } + + function onDirChanged( e ) { + var editor = e.editor; + + var range = editor.createRange(); + range.setStartBefore( e.data.node ); + range.setEndAfter( e.data.node ); + + var walker = new CKEDITOR.dom.walker( range ), + node; + + while ( ( node = walker.next() ) ) { + if ( node.type == CKEDITOR.NODE_ELEMENT ) { + // A child with the defined dir is to be ignored. + if ( !node.equals( e.data.node ) && node.getDirection() ) { + range.setStartAfter( node ); + walker = new CKEDITOR.dom.walker( range ); + continue; + } + + // Switch the alignment. + var classes = editor.config.justifyClasses; + if ( classes ) { + // The left align class. + if ( node.hasClass( classes[ 0 ] ) ) { + node.removeClass( classes[ 0 ] ); + node.addClass( classes[ 2 ] ); + } + // The right align class. + else if ( node.hasClass( classes[ 2 ] ) ) { + node.removeClass( classes[ 2 ] ); + node.addClass( classes[ 0 ] ); + } + } + + // Always switch CSS margins. + var style = 'text-align'; + var align = node.getStyle( style ); + + if ( align == 'left' ) + node.setStyle( style, 'right' ); + else if ( align == 'right' ) + node.setStyle( style, 'left' ); + } + } + } + + justifyCommand.prototype = { + exec: function( editor ) { + var selection = editor.getSelection(), + enterMode = editor.config.enterMode; + + if ( !selection ) + return; + + var bookmarks = selection.createBookmarks(), + ranges = selection.getRanges(); + + var cssClassName = this.cssClassName, + iterator, block; + + var useComputedState = editor.config.useComputedState; + + for ( var i = ranges.length - 1; i >= 0; i-- ) { + iterator = ranges[ i ].createIterator(); + iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR; + + while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) ) { + 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' ); + + // Remove any of the alignment classes from the className. + var className = cssClassName && ( block.$.className = CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) ) ); + + var apply = ( this.state == CKEDITOR.TRISTATE_OFF ) && ( !useComputedState || ( getAlignment( block, true ) != this.value ) ); + + if ( cssClassName && isAllowedCssClass ) { + // Append the desired class name. + if ( apply ) + block.addClass( cssClassName ); + else if ( !className ) + block.removeAttribute( 'class' ); + } else if ( apply && isAllowedTextAlign ) { + block.setStyle( 'text-align', this.value ); + } + } + + } + + editor.focus(); + editor.forceNextSelectionCheck(); + selection.selectBookmarks( bookmarks ); + }, + + refresh: function( editor, path ) { + 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 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 && !CKEDITOR.dtd.$list[ path.lastElement.getName() ] ) { + 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', { + icons: 'justifyblock,justifycenter,justifyleft,justifyright', // %REMOVE_LINE_CORE% + hidpi: true, // %REMOVE_LINE_CORE% + init: function( editor ) { + if ( editor.blockless ) + return; + + var left = new justifyCommand( editor, 'justifyleft', 'left' ), + center = new justifyCommand( editor, 'justifycenter', 'center' ), + right = new justifyCommand( editor, 'justifyright', 'right' ), + justify = new justifyCommand( editor, 'justifyblock', 'justify' ); + + editor.addCommand( 'justifyleft', left ); + editor.addCommand( 'justifycenter', center ); + editor.addCommand( 'justifyright', right ); + editor.addCommand( 'justifyblock', justify ); + + if ( editor.ui.addButton ) { + editor.ui.addButton( 'JustifyLeft', { + label: editor.lang.common.alignLeft, + command: 'justifyleft', + toolbar: 'align,10' + } ); + editor.ui.addButton( 'JustifyCenter', { + label: editor.lang.common.center, + command: 'justifycenter', + toolbar: 'align,20' + } ); + editor.ui.addButton( 'JustifyRight', { + label: editor.lang.common.alignRight, + command: 'justifyright', + toolbar: 'align,30' + } ); + editor.ui.addButton( 'JustifyBlock', { + label: editor.lang.common.justify, + command: 'justifyblock', + toolbar: 'align,40' + } ); + } + editor.on( 'dirChanged', onDirChanged ); + } + } ); +} )(); + +/** + * List of classes to use for aligning the contents. If it's `null`, no classes will be used + * and instead the corresponding CSS values will be used. + * + * The array should contain 4 members, in the following order: left, center, right, justify. + * + * // Use the classes 'AlignLeft', 'AlignCenter', 'AlignRight', 'AlignJustify' + * config.justifyClasses = [ 'AlignLeft', 'AlignCenter', 'AlignRight', 'AlignJustify' ]; + * + * @cfg {Array} [justifyClasses=null] + * @member CKEDITOR.config + */