From 6b2eabf4714416ad4d7f46d37c0d49172f27390c Mon Sep 17 00:00:00 2001 From: Lauri Eskola <lauri.eskola@acquia.com> Date: Tue, 22 Mar 2022 08:39:29 +0200 Subject: [PATCH] Issue #3263384 by nod_, Wim Leers: Add ckeditor5-code-block package and CodeBlock plugin --- .../vendor/ckeditor5/code-block/code-block.js | 5 ++++ .../ckeditor5/code-block/translations/az.js | 1 + .../ckeditor5/code-block/translations/bs.js | 1 + .../ckeditor5/code-block/translations/cs.js | 1 + .../ckeditor5/code-block/translations/da.js | 1 + .../code-block/translations/de-ch.js | 1 + .../ckeditor5/code-block/translations/de.js | 1 + .../ckeditor5/code-block/translations/el.js | 1 + .../code-block/translations/en-au.js | 1 + .../ckeditor5/code-block/translations/es.js | 1 + .../ckeditor5/code-block/translations/et.js | 1 + .../ckeditor5/code-block/translations/fa.js | 1 + .../ckeditor5/code-block/translations/fr.js | 1 + .../ckeditor5/code-block/translations/gl.js | 1 + .../ckeditor5/code-block/translations/hi.js | 1 + .../ckeditor5/code-block/translations/hr.js | 1 + .../ckeditor5/code-block/translations/hu.js | 1 + .../ckeditor5/code-block/translations/id.js | 1 + .../ckeditor5/code-block/translations/it.js | 1 + .../ckeditor5/code-block/translations/ja.js | 1 + .../ckeditor5/code-block/translations/ko.js | 1 + .../ckeditor5/code-block/translations/ku.js | 1 + .../ckeditor5/code-block/translations/lv.js | 1 + .../ckeditor5/code-block/translations/nl.js | 1 + .../ckeditor5/code-block/translations/no.js | 1 + .../ckeditor5/code-block/translations/pl.js | 1 + .../code-block/translations/pt-br.js | 1 + .../ckeditor5/code-block/translations/ro.js | 1 + .../ckeditor5/code-block/translations/ru.js | 1 + .../ckeditor5/code-block/translations/sk.js | 1 + .../code-block/translations/sr-latn.js | 1 + .../ckeditor5/code-block/translations/sr.js | 1 + .../ckeditor5/code-block/translations/th.js | 1 + .../ckeditor5/code-block/translations/tk.js | 1 + .../ckeditor5/code-block/translations/tr.js | 1 + .../ckeditor5/code-block/translations/ug.js | 1 + .../ckeditor5/code-block/translations/uk.js | 1 + .../ckeditor5/code-block/translations/uz.js | 1 + .../code-block/translations/zh-cn.js | 1 + .../ckeditor5/code-block/translations/zh.js | 1 + core/core.libraries.yml | 13 +++++++++++ .../modules/ckeditor5/ckeditor5.ckeditor5.yml | 23 +++++++++++++++++++ .../modules/ckeditor5/ckeditor5.libraries.yml | 10 ++++++++ .../ckeditor5/css/code-block.admin.css | 3 +++ core/modules/ckeditor5/icons/code-block.svg | 1 + .../src/Plugin/CKEditor4To5Upgrade/Core.php | 9 +++++--- ...itor5_plugin_conditions_test.ckeditor5.yml | 13 ----------- .../src/Kernel/SmartDefaultSettingsTest.php | 7 +++--- core/package.json | 1 + core/yarn.lock | 7 ++++++ 50 files changed, 112 insertions(+), 19 deletions(-) create mode 100644 core/assets/vendor/ckeditor5/code-block/code-block.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/az.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/bs.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/cs.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/da.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/de-ch.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/de.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/el.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/en-au.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/es.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/et.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/fa.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/fr.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/gl.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/hi.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/hr.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/hu.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/id.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/it.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/ja.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/ko.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/ku.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/lv.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/nl.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/no.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/pl.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/pt-br.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/ro.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/ru.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/sk.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/sr-latn.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/sr.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/th.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/tk.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/tr.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/ug.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/uk.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/uz.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/zh-cn.js create mode 100644 core/assets/vendor/ckeditor5/code-block/translations/zh.js create mode 100644 core/modules/ckeditor5/css/code-block.admin.css create mode 100644 core/modules/ckeditor5/icons/code-block.svg diff --git a/core/assets/vendor/ckeditor5/code-block/code-block.js b/core/assets/vendor/ckeditor5/code-block/code-block.js new file mode 100644 index 000000000000..556cf3fa3038 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/code-block.js @@ -0,0 +1,5 @@ +!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Insert code block","Plain text":"Plain text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})), +/*! + * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md. + */(()=>{var e={67:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=n(609),i=n.n(o)()((function(e){return e[1]}));i.push([e.id,".ck-content pre{padding:1em;color:#353535;background:hsla(0,0%,78%,.3);border:1px solid #c4c4c4;border-radius:2px;text-align:left;direction:ltr;tab-size:4;white-space:pre-wrap;font-style:normal;min-width:200px}.ck-content pre code{background:unset;padding:0;border-radius:0}.ck.ck-editor__editable pre{position:relative}.ck.ck-editor__editable pre[data-language]:after{content:attr(data-language);position:absolute}:root{--ck-color-code-block-label-background:#757575}.ck.ck-editor__editable pre[data-language]:after{top:-1px;right:10px;background:var(--ck-color-code-block-label-background);font-size:10px;font-family:var(--ck-font-face);line-height:16px;padding:var(--ck-spacing-tiny) var(--ck-spacing-medium);color:#fff;white-space:nowrap}.ck.ck-code-block-dropdown .ck-dropdown__panel{max-height:250px;overflow-y:auto;overflow-x:hidden}",""]);const r=i},609:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,o){"string"==typeof e&&(e=[[null,e,""]]);var i={};if(o)for(var r=0;r<this.length;r++){var a=this[r][0];null!=a&&(i[a]=!0)}for(var c=0;c<e.length;c++){var s=[].concat(e[c]);o&&i[s[0]]||(n&&(s[2]?s[2]="".concat(n," and ").concat(s[2]):s[2]=n),t.push(s))}},t}},62:(e,t,n)=>{"use strict";var o,i=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},r=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),a=[];function c(e){for(var t=-1,n=0;n<a.length;n++)if(a[n].identifier===e){t=n;break}return t}function s(e,t){for(var n={},o=[],i=0;i<e.length;i++){var r=e[i],s=t.base?r[0]+t.base:r[0],l=n[s]||0,d="".concat(s," ").concat(l);n[s]=l+1;var u=c(d),g={css:r[1],media:r[2],sourceMap:r[3]};-1!==u?(a[u].references++,a[u].updater(g)):a.push({identifier:d,updater:h(g,t),references:1}),o.push(d)}return o}function l(e){var t=document.createElement("style"),o=e.attributes||{};if(void 0===o.nonce){var i=n.nc;i&&(o.nonce=i)}if(Object.keys(o).forEach((function(e){t.setAttribute(e,o[e])})),"function"==typeof e.insert)e.insert(t);else{var a=r(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function g(e,t,n,o){var i=n?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(e.styleSheet)e.styleSheet.cssText=u(t,i);else{var r=document.createTextNode(i),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(r,a[t]):e.appendChild(r)}}function f(e,t,n){var o=n.css,i=n.media,r=n.sourceMap;if(i?e.setAttribute("media",i):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=o;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(o))}}var m=null,p=0;function h(e,t){var n,o,i;if(t.singleton){var r=p++;n=m||(m=l(t)),o=g.bind(null,n,r,!1),i=g.bind(null,n,r,!0)}else n=l(t),o=f.bind(null,n,t),i=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else i()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=i());var n=s(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var o=0;o<n.length;o++){var i=c(n[o]);a[i].references--}for(var r=s(e,t),l=0;l<n.length;l++){var d=c(n[l]);0===a[d].references&&(a[d].updater(),a.splice(d,1))}n=r}}}},704:(e,t,n)=>{e.exports=n(79)("./src/core.js")},492:(e,t,n)=>{e.exports=n(79)("./src/engine.js")},331:(e,t,n)=>{e.exports=n(79)("./src/enter.js")},273:(e,t,n)=>{e.exports=n(79)("./src/ui.js")},209:(e,t,n)=>{e.exports=n(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={id:o,exports:{}};return e[o](r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{CodeBlock:()=>_,CodeBlockEditing:()=>v,CodeBlockUI:()=>A});var e=n(704),t=n(331),i=n(492),r=n(209);function a(e){const t=e.t,n=e.config.get("codeBlock.languages");for(const e of n)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return n}function c(e,t,n){const o={};for(const i of e)"class"===t?o[i[t].split(" ").shift()]=i[n]:o[i[t]]=i[n];return o}function s(e){return e.data.match(/^(\s*)/)[0]}function l(e){const t=e.document.selection,n=[];if(t.isCollapsed)n.push(t.anchor);else{const o=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of o)if(t.is("$textProxy")&&t.parent.is("element","codeBlock")){const o=s(t.textNode),{parent:i,startOffset:r}=t.textNode,a=e.createPositionAt(i,r+o.length);n.push(a)}}return n}function d(e){const t=(0,r.first)(e.getSelectedBlocks());return t&&t.is("element","codeBlock")}class u extends e.Command{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,n=t.model,o=n.document.selection,i=a(t)[0],r=Array.from(o.getSelectedBlocks()),c=void 0===e.forceValue?!this.value:e.forceValue,s=function(e,t,n){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return n}(e,this._lastLanguage,i.language);n.change((e=>{c?this._applyCodeBlock(e,r,s):this._removeCodeBlock(e,r)}))}_getValue(){const e=this.editor.model.document.selection,t=(0,r.first)(e.getSelectedBlocks());return!!!(!t||!t.is("element","codeBlock"))&&t.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=(0,r.first)(e.getSelectedBlocks());return!!n&&g(t,n)}_applyCodeBlock(e,t,n){this._lastLanguage=n;const o=this.editor.model.schema,i=t.filter((e=>g(o,e)));for(const t of i)e.rename(t,"codeBlock"),e.setAttribute("language",n,t),o.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!o.checkChild(t,e))).forEach((t=>e.remove(t)));i.reverse().forEach(((t,n)=>{const o=i[n+1];t.previousSibling===o&&(e.appendElement("softBreak",o),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const n=t.filter((e=>e.is("element","codeBlock")));for(const t of n){const n=e.createRangeOn(t);for(const t of Array.from(n.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:n}=e.split(e.createPositionBefore(t));e.rename(n.nodeAfter,"paragraph"),e.removeAttribute("language",n.nodeAfter),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}function g(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class f extends e.Command{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const n=l(e);for(const e of n)t.insertText(this._indentSequence,e)}))}_checkEnabled(){return!!this._indentSequence&&d(this.editor.model.document.selection)}}class m extends e.Command{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const n=l(e);for(const e of n){const n=p(this.editor.model,e,this._indentSequence);n&&t.remove(n)}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!d(e.document.selection)&&l(e).some((t=>p(e,t,this._indentSequence)))}}function p(e,t,n){const o=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}(t);if(!o)return null;const i=s(o),r=i.lastIndexOf(n);if(r+n.length!==i.length)return null;if(-1===r)return null;const{parent:a,startOffset:c}=o;return e.createRange(e.createPositionAt(a,c+r),e.createPositionAt(a,c+r+n.length))}function h(e,t,n=!1){const o=c(t,"language","class"),i=c(t,"language","label");return(t,r,a)=>{const{writer:c,mapper:s,consumable:l}=a;if(!l.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=s.toViewPosition(e.createPositionBefore(r.item)),g={};n&&(g["data-language"]=i[d],g.spellcheck="false");const f=c.createContainerElement("code",{class:o[d]||null}),m=c.createContainerElement("pre",g,f);c.insert(u,m),s.bindElements(r.item,f)}}const b="paragraph";class v extends e.Plugin{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[t.ShiftEnter]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,n=e.model,o=(e.editing.view,a(e));e.commands.add("codeBlock",new u(e)),e.commands.add("indentCodeBlock",new f(e)),e.commands.add("outdentCodeBlock",new m(e));const r=e=>(t,n)=>{this.editor.commands.get(e).isEnabled&&(this.editor.execute(e),n())};e.keystrokes.set("Tab",r("indentCodeBlock")),e.keystrokes.set("Shift+Tab",r("outdentCodeBlock")),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck((e=>{if(e.endsWith("codeBlock $text"))return!1})),e.model.schema.addChildCheck(((e,t)=>{if(e.endsWith("codeBlock")&&t.isObject)return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",h(n,o,!0)),e.data.downcastDispatcher.on("insert:codeBlock",h(n,o)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,n,o)=>{if("codeBlock"!==n.item.parent.name)return;const{writer:i,mapper:r,consumable:a}=o;if(!a.consume(n.item,"insert"))return;const c=r.toViewPosition(e.createPositionBefore(n.item));i.insert(c,i.createText("\n"))}}(n),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const n=c(t,"class","language"),o=t[0].language;return(e,t,i)=>{const r=t.viewItem,a=r.parent;if(!a||!a.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:c,writer:s}=i;if(!c.test(r,{name:!0}))return;const l=s.createElement("codeBlock"),d=[...r.getClassNames()];d.length||d.push("");for(const e of d){const t=n[e];if(t){s.setAttribute("language",t,l);break}}l.hasAttribute("language")||s.setAttribute("language",o,l),i.convertChildren(r,l),i.safeInsert(l,t.modelCursor)&&(c.consume(r,{name:!0}),i.updateConversionResult(l,t))}}(0,o)),e.data.upcastDispatcher.on("text",((e,t,{consumable:n,writer:o})=>{let i=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.findAncestor("codeBlock"))return;n.consume(t.viewItem);const r=t.viewItem.data.split("\n").map((e=>o.createText(e))),a=r[r.length-1];for(const e of r)if(o.insert(e,i),i=i.getShiftedBy(e.offsetSize),e!==a){const e=o.createElement("softBreak");o.insert(e,i),i=o.createPositionAfter(e)}t.modelRange=o.createRange(t.modelCursor,i),t.modelCursor=i})),this.listenTo(e.editing.view.document,"clipboardInput",((t,o)=>{let r=n.createRange(n.document.selection.anchor);if(o.targetRanges&&(r=e.editing.mapper.toModelRange(o.targetRanges[0])),!r.start.parent.is("element","codeBlock"))return;const a=o.dataTransfer.getData("text/plain"),c=new i.UpcastWriter(e.editing.view.document);o.content=function(e,t){const n=e.createDocumentFragment(),o=t.split("\n"),i=o.reduce(((t,n,i)=>(t.push(n),i<o.length-1&&t.push(e.createElement("br")),t)),[]);return e.appendChild(i,n),n}(c,a)})),this.listenTo(n,"getSelectedContent",((e,[o])=>{const i=o.anchor;!o.isCollapsed&&i.parent.is("element","codeBlock")&&i.hasSameParentAs(o.focus)&&n.change((n=>{const r=e.return;if(r.childCount>1||o.containsEntireContent(i.parent)){const t=n.createElement("codeBlock",i.parent.getAttributes());n.append(r,t);const o=n.createDocumentFragment();n.append(t,o),e.return=o}else{const e=r.getChild(0);t.checkAttribute(e,"code")&&n.setAttribute("code",!0,e)}}))}))}afterInit(){const e=this.editor,t=e.commands,n=t.get("indent"),o=t.get("outdent");n&&n.registerChildCommand(t.get("indentCodeBlock")),o&&o.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,n)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const n=e.model.document,o=e.editing.view,i=n.selection.getLastPosition(),r=i.nodeAfter;if(t||!n.selection.isCollapsed||!i.isAtStart)return!1;if(!B(r))return!1;return e.model.change((t=>{e.execute("enter");const o=n.selection.anchor.parent.previousSibling;t.rename(o,b),t.setSelection(o,"in"),e.model.schema.removeDisallowedAttributes([o],t),t.remove(r)})),o.scrollToTheSelection(),!0}(e,n.isSoft)||function(e,t){const n=e.model,o=n.document,i=e.editing.view,r=o.selection.getLastPosition(),a=r.nodeBefore;let c;if(t||!o.selection.isCollapsed||!r.isAtEnd||!a||!a.previousSibling)return!1;if(B(a)&&B(a.previousSibling))c=n.createRange(n.createPositionBefore(a.previousSibling),n.createPositionAfter(a));else if(k(a)&&B(a.previousSibling)&&B(a.previousSibling.previousSibling))c=n.createRange(n.createPositionBefore(a.previousSibling.previousSibling),n.createPositionAfter(a));else{if(!(k(a)&&B(a.previousSibling)&&k(a.previousSibling.previousSibling)&&B(a.previousSibling.previousSibling.previousSibling)))return!1;c=n.createRange(n.createPositionBefore(a.previousSibling.previousSibling.previousSibling),n.createPositionAfter(a))}return e.model.change((t=>{t.remove(c),e.execute("enter");const n=o.selection.anchor.parent;t.rename(n,b),e.model.schema.removeDisallowedAttributes([n],t)})),i.scrollToTheSelection(),!0}(e,n.isSoft)||function(e){const t=e.model.document,n=t.selection.getLastPosition(),o=n.nodeBefore||n.textNode;let i;o&&o.is("$text")&&(i=s(o));e.model.change((n=>{e.execute("shiftEnter"),i&&n.insertText(i,t.selection.anchor)}))}(e),n.preventDefault(),t.stop())}),{context:"pre"})}}function k(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function B(e){return e&&e.is("element","softBreak")}var w=n(273);var x=n(62),C=n.n(x),S=n(67),y={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};C()(S.Z,y);S.Z.locals;class A extends e.Plugin{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,n=e.ui.componentFactory,o=a(e);n.add("codeBlock",(n=>{const i=e.commands.get("codeBlock"),r=(0,w.createDropdown)(n,w.SplitButtonView),a=r.buttonView;return a.set({label:t("Insert code block"),tooltip:!0,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.87 12.61a.75.75 0 0 1-.089.976l-.085.07-3.154 2.254 3.412 2.414a.75.75 0 0 1 .237.95l-.057.095a.75.75 0 0 1-.95.237l-.096-.058-4.272-3.022-.003-1.223 4.01-2.867a.75.75 0 0 1 1.047.174zm2.795-.231.095.057 4.011 2.867-.003 1.223-4.272 3.022-.095.058a.75.75 0 0 1-.88-.151l-.07-.086-.058-.095a.75.75 0 0 1 .15-.88l.087-.07 3.412-2.414-3.154-2.253-.085-.071a.75.75 0 0 1 .862-1.207zM16 0a2 2 0 0 1 2 2v9.354l-.663-.492-.837-.001V2a.5.5 0 0 0-.5-.5H2a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h3.118L7.156 19H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h14zM5.009 15l.003 1H3v-1h2.009zm2.188-2-1.471 1H5v-1h2.197zM10 11v.095L8.668 12H7v-1h3zm4-2v1H7V9h7zm0-2v1H7V7h7zm-4-2v1H5V5h5zM6 3v1H3V3h3z"/></svg>',isToggleable:!0}),a.bind("isOn").to(i,"value",(e=>!!e)),a.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),r.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),r.class="ck-code-block-dropdown",r.bind("isEnabled").to(i),(0,w.addListToDropdown)(r,this._getLanguageListItemDefinitions(o)),r}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),n=new r.Collection;for(const o of e){const e={type:"button",model:new w.Model({_codeBlockLanguage:o.language,label:o.label,withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),n.add(e)}return n}}class _ extends e.Plugin{static get requires(){return[v,A]}static get pluginName(){return"CodeBlock"}}})(),(window.CKEditor5=window.CKEditor5||{}).codeBlock=o})(); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/az.js b/core/assets/vendor/ckeditor5/code-block/translations/az.js new file mode 100644 index 000000000000..a58c23ef865c --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/az.js @@ -0,0 +1 @@ +!function(n){const o=n.az=n.az||{};o.dictionary=Object.assign(o.dictionary||{},{"Insert code block":"Kod blokunu É™lavÉ™ et","Plain text":"SadÉ™ mÉ™tn"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/bs.js b/core/assets/vendor/ckeditor5/code-block/translations/bs.js new file mode 100644 index 000000000000..cb2ca052f2ad --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/bs.js @@ -0,0 +1 @@ +!function(n){const i=n.bs=n.bs||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Umetni kod blok","Plain text":"Tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/cs.js b/core/assets/vendor/ckeditor5/code-block/translations/cs.js new file mode 100644 index 000000000000..57ba74da22c1 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/cs.js @@ -0,0 +1 @@ +!function(o){const t=o.cs=o.cs||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Vložit blok zdrojového kódu","Plain text":"Prostý text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/da.js b/core/assets/vendor/ckeditor5/code-block/translations/da.js new file mode 100644 index 000000000000..1afe3fc553e2 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/da.js @@ -0,0 +1 @@ +!function(n){const t=n.da=n.da||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Indsæt kodeblok","Plain text":"Plain tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/de-ch.js b/core/assets/vendor/ckeditor5/code-block/translations/de-ch.js new file mode 100644 index 000000000000..84bfa488b7a1 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/de-ch.js @@ -0,0 +1 @@ +!function(n){const c=n["de-ch"]=n["de-ch"]||{};c.dictionary=Object.assign(c.dictionary||{},{"Insert code block":"Code-Block einfügen","Plain text":"Nur Text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/de.js b/core/assets/vendor/ckeditor5/code-block/translations/de.js new file mode 100644 index 000000000000..3b89849cb328 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/de.js @@ -0,0 +1 @@ +!function(n){const e=n.de=n.de||{};e.dictionary=Object.assign(e.dictionary||{},{"Insert code block":"Code-Block einfügen","Plain text":"Nur Text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/el.js b/core/assets/vendor/ckeditor5/code-block/translations/el.js new file mode 100644 index 000000000000..925a685d0002 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/el.js @@ -0,0 +1 @@ +!function(n){const i=n.el=n.el||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Εισαγωγή τμήματος κώδικα","Plain text":"Απλό κÎιμενο"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/en-au.js b/core/assets/vendor/ckeditor5/code-block/translations/en-au.js new file mode 100644 index 000000000000..8d42b1138a7f --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/en-au.js @@ -0,0 +1 @@ +!function(n){const t=n["en-au"]=n["en-au"]||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Insert code block","Plain text":"Plain text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/es.js b/core/assets/vendor/ckeditor5/code-block/translations/es.js new file mode 100644 index 000000000000..1cb52a133e74 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/es.js @@ -0,0 +1 @@ +!function(n){const o=n.es=n.es||{};o.dictionary=Object.assign(o.dictionary||{},{"Insert code block":"Insertar bloque de código","Plain text":"Texto plano"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/et.js b/core/assets/vendor/ckeditor5/code-block/translations/et.js new file mode 100644 index 000000000000..c9da9a19fdcb --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/et.js @@ -0,0 +1 @@ +!function(t){const i=t.et=t.et||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Sisesta koodiplokk","Plain text":"Lihtsalt tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/fa.js b/core/assets/vendor/ckeditor5/code-block/translations/fa.js new file mode 100644 index 000000000000..d7fafa97cb30 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/fa.js @@ -0,0 +1 @@ +!function(n){const i=n.fa=n.fa||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"درج بلوک کد","Plain text":"متن ساده"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/fr.js b/core/assets/vendor/ckeditor5/code-block/translations/fr.js new file mode 100644 index 000000000000..2a9ce271e67f --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/fr.js @@ -0,0 +1 @@ +!function(n){const o=n.fr=n.fr||{};o.dictionary=Object.assign(o.dictionary||{},{"Insert code block":"Insérer un bloc de code","Plain text":"Texte brut"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/gl.js b/core/assets/vendor/ckeditor5/code-block/translations/gl.js new file mode 100644 index 000000000000..189b28bfa3cb --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/gl.js @@ -0,0 +1 @@ +!function(i){const n=i.gl=i.gl||{};n.dictionary=Object.assign(n.dictionary||{},{"Insert code block":"Inserir bloque de código","Plain text":"Texto simple"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/hi.js b/core/assets/vendor/ckeditor5/code-block/translations/hi.js new file mode 100644 index 000000000000..09d5fd025053 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/hi.js @@ -0,0 +1 @@ +!function(i){const n=i.hi=i.hi||{};n.dictionary=Object.assign(n.dictionary||{},{"Insert code block":"Insert code block","Plain text":"Plain text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/hr.js b/core/assets/vendor/ckeditor5/code-block/translations/hr.js new file mode 100644 index 000000000000..4f8831c7853a --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/hr.js @@ -0,0 +1 @@ +!function(n){const i=n.hr=n.hr||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Umetni blok koda","Plain text":"ObiÄan tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/hu.js b/core/assets/vendor/ckeditor5/code-block/translations/hu.js new file mode 100644 index 000000000000..74179088d835 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/hu.js @@ -0,0 +1 @@ +!function(n){const i=n.hu=n.hu||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Kód blokk beszúrása","Plain text":"Egyszerű szöveg"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/id.js b/core/assets/vendor/ckeditor5/code-block/translations/id.js new file mode 100644 index 000000000000..ac6aeb600b08 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/id.js @@ -0,0 +1 @@ +!function(i){const n=i.id=i.id||{};n.dictionary=Object.assign(n.dictionary||{},{"Insert code block":"Sisipkan blok kode","Plain text":"Teks mentah"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/it.js b/core/assets/vendor/ckeditor5/code-block/translations/it.js new file mode 100644 index 000000000000..a6f06833f107 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/it.js @@ -0,0 +1 @@ +!function(i){const c=i.it=i.it||{};c.dictionary=Object.assign(c.dictionary||{},{"Insert code block":"Inserisci blocco di codice","Plain text":"Testo semplice"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/ja.js b/core/assets/vendor/ckeditor5/code-block/translations/ja.js new file mode 100644 index 000000000000..73594cd382b9 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/ja.js @@ -0,0 +1 @@ +!function(n){const i=n.ja=n.ja||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"コードブãƒãƒƒã‚¯ã®æŒ¿å…¥","Plain text":"プレインテã‚スト"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/ko.js b/core/assets/vendor/ckeditor5/code-block/translations/ko.js new file mode 100644 index 000000000000..5997e731a4ee --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/ko.js @@ -0,0 +1 @@ +!function(n){const o=n.ko=n.ko||{};o.dictionary=Object.assign(o.dictionary||{},{"Insert code block":"코드 ë¸”ëŸ ì‚½ìž…","Plain text":"í‰ë¬¸"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/ku.js b/core/assets/vendor/ckeditor5/code-block/translations/ku.js new file mode 100644 index 000000000000..610398fd3cf3 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/ku.js @@ -0,0 +1 @@ +!function(n){const i=n.ku=n.ku||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"دانانی خشتەی کۆد","Plain text":"تێکستی سادە"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/lv.js b/core/assets/vendor/ckeditor5/code-block/translations/lv.js new file mode 100644 index 000000000000..e7612947c44c --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/lv.js @@ -0,0 +1 @@ +!function(t){const i=t.lv=t.lv||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Ievietot koda bloku","Plain text":"VienkÄrÅ¡s teksts"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/nl.js b/core/assets/vendor/ckeditor5/code-block/translations/nl.js new file mode 100644 index 000000000000..d4a3171a299e --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/nl.js @@ -0,0 +1 @@ +!function(n){const t=n.nl=n.nl||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Codeblok invoegen","Plain text":"Platte tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/no.js b/core/assets/vendor/ckeditor5/code-block/translations/no.js new file mode 100644 index 000000000000..e4d6bd8951bf --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/no.js @@ -0,0 +1 @@ +!function(n){const o=n.no=n.no||{};o.dictionary=Object.assign(o.dictionary||{},{"Insert code block":"Sett inn kodeblokk","Plain text":"Ren tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/pl.js b/core/assets/vendor/ckeditor5/code-block/translations/pl.js new file mode 100644 index 000000000000..4316f987063c --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/pl.js @@ -0,0 +1 @@ +!function(t){const n=t.pl=t.pl||{};n.dictionary=Object.assign(n.dictionary||{},{"Insert code block":"Wstaw blok kodu","Plain text":"ZwykÅ‚y tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/pt-br.js b/core/assets/vendor/ckeditor5/code-block/translations/pt-br.js new file mode 100644 index 000000000000..9b468470991c --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/pt-br.js @@ -0,0 +1 @@ +!function(o){const t=o["pt-br"]=o["pt-br"]||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Inserir bloco de código","Plain text":"Texto sem formatação"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/ro.js b/core/assets/vendor/ckeditor5/code-block/translations/ro.js new file mode 100644 index 000000000000..eb399d957258 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/ro.js @@ -0,0 +1 @@ +!function(n){const o=n.ro=n.ro||{};o.dictionary=Object.assign(o.dictionary||{},{"Insert code block":"Inserează un bloc code","Plain text":"Text simplu"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/ru.js b/core/assets/vendor/ckeditor5/code-block/translations/ru.js new file mode 100644 index 000000000000..c26c7852a007 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/ru.js @@ -0,0 +1 @@ +!function(n){const i=n.ru=n.ru||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Ð’Ñтавить код","Plain text":"ПроÑтой текÑÑ‚"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/sk.js b/core/assets/vendor/ckeditor5/code-block/translations/sk.js new file mode 100644 index 000000000000..48f3a08352dc --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/sk.js @@ -0,0 +1 @@ +!function(t){const i=t.sk=t.sk||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Vložte blok kódu","Plain text":"ÄŒistý text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/sr-latn.js b/core/assets/vendor/ckeditor5/code-block/translations/sr-latn.js new file mode 100644 index 000000000000..6ea795e3f7e3 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/sr-latn.js @@ -0,0 +1 @@ +!function(n){const t=n["sr-latn"]=n["sr-latn"]||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Dodaj blok koda","Plain text":"ObiÄan tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/sr.js b/core/assets/vendor/ckeditor5/code-block/translations/sr.js new file mode 100644 index 000000000000..81c12d130f41 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/sr.js @@ -0,0 +1 @@ +!function(n){const i=n.sr=n.sr||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Додај блок кода","Plain text":"Обичан текÑÑ‚"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/th.js b/core/assets/vendor/ckeditor5/code-block/translations/th.js new file mode 100644 index 000000000000..4683ade889fd --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/th.js @@ -0,0 +1 @@ +!function(n){const t=n.th=n.th||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"เพิ่มโค้ดบล็à¸à¸","Plain text":"ข้à¸à¸„วามธรรมดา"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/tk.js b/core/assets/vendor/ckeditor5/code-block/translations/tk.js new file mode 100644 index 000000000000..89d4e7231ce0 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/tk.js @@ -0,0 +1 @@ +!function(t){const n=t.tk=t.tk||{};n.dictionary=Object.assign(n.dictionary||{},{"Insert code block":"Kod blogyna goýuň","Plain text":"Düz tekst"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/tr.js b/core/assets/vendor/ckeditor5/code-block/translations/tr.js new file mode 100644 index 000000000000..0291aa1d8104 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/tr.js @@ -0,0 +1 @@ +!function(n){const t=n.tr=n.tr||{};t.dictionary=Object.assign(t.dictionary||{},{"Insert code block":"Kod bloÄŸu ekle","Plain text":"Düz metin"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/ug.js b/core/assets/vendor/ckeditor5/code-block/translations/ug.js new file mode 100644 index 000000000000..401b2fbee331 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/ug.js @@ -0,0 +1 @@ +!function(n){const i=n.ug=n.ug||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"","Plain text":"ساپ تÛكىست"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/uk.js b/core/assets/vendor/ckeditor5/code-block/translations/uk.js new file mode 100644 index 000000000000..5854a4ac5f23 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/uk.js @@ -0,0 +1 @@ +!function(n){const i=n.uk=n.uk||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"Ð’Ñтавте блок коду","Plain text":"ПроÑтий текÑÑ‚"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/uz.js b/core/assets/vendor/ckeditor5/code-block/translations/uz.js new file mode 100644 index 000000000000..9169e1c55220 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/uz.js @@ -0,0 +1 @@ +!function(i){const n=i.uz=i.uz||{};n.dictionary=Object.assign(n.dictionary||{},{"Insert code block":"Kodni kiritish","Plain text":"Oddiy matn"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/zh-cn.js b/core/assets/vendor/ckeditor5/code-block/translations/zh-cn.js new file mode 100644 index 000000000000..858a1e5ef1e3 --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/zh-cn.js @@ -0,0 +1 @@ +!function(n){const c=n["zh-cn"]=n["zh-cn"]||{};c.dictionary=Object.assign(c.dictionary||{},{"Insert code block":"æ’入代ç å—","Plain text":"纯文本"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/assets/vendor/ckeditor5/code-block/translations/zh.js b/core/assets/vendor/ckeditor5/code-block/translations/zh.js new file mode 100644 index 000000000000..a29bc0d147bd --- /dev/null +++ b/core/assets/vendor/ckeditor5/code-block/translations/zh.js @@ -0,0 +1 @@ +!function(n){const i=n.zh=n.zh||{};i.dictionary=Object.assign(i.dictionary||{},{"Insert code block":"æ’入程å¼ç¢¼å€å¡Š","Plain text":"純文å—"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})); \ No newline at end of file diff --git a/core/core.libraries.yml b/core/core.libraries.yml index f4a26ee1e223..6a16429a4525 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -284,6 +284,19 @@ ckeditor5.language: - core/ckeditor5 - core/ckeditor5.translations +ckeditor5.codeBlock: + remote: https://github.com/ckeditor/ckeditor5 + version: "33.0.0" + license: + name: GNU-GPL-2.0-or-later + url: https://github.com/ckeditor/ckeditor5/blob/v33.0.0/LICENSE.md + gpl-compatible: true + js: + assets/vendor/ckeditor5/code-block/code-block.js: { minified: true } + dependencies: + - core/ckeditor5 + - core/ckeditor5.translations + ckeditor5.translations: # No sensible version can be specified, since the translations may change at # any time. diff --git a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml index d57aa63fb625..8e9a5f87fc13 100644 --- a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml +++ b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml @@ -178,6 +178,29 @@ ckeditor5_code: elements: - <code> +ckeditor5_codeBlock: + ckeditor5: + plugins: + - codeBlock.CodeBlock + - htmlSupport.GeneralHtmlSupport + config: + # The CodeBlock plugin supports only `<pre><code>…</code></pre>`. + # Configure GHS to support `<pre>…</pre>` markup as well. + htmlSupport: + allow: + - + name: pre + drupal: + label: Code Block + library: ckeditor5/drupal.ckeditor5.codeBlock + admin_library: ckeditor5/admin.codeBlock + toolbar_items: + codeBlock: + label: Code Block + elements: + - <pre> + - <code class="language-*"> + ckeditor5_strikethrough: ckeditor5: plugins: [basicStyles.Strikethrough] diff --git a/core/modules/ckeditor5/ckeditor5.libraries.yml b/core/modules/ckeditor5/ckeditor5.libraries.yml index 57a5a0b472a7..782b8c398005 100644 --- a/core/modules/ckeditor5/ckeditor5.libraries.yml +++ b/core/modules/ckeditor5/ckeditor5.libraries.yml @@ -47,6 +47,11 @@ drupal.ckeditor5.quickedit-temporary-work-around: theme: css/quickedit-override.css: {} +drupal.ckeditor5.codeBlock: + dependencies: + - core/ckeditor5.codeBlock + - core/ckeditor5.htmlSupport + drupal.ckeditor5.image: js: js/build/drupalImage.js: { minified: true } @@ -206,3 +211,8 @@ admin.table: css: theme: css/table.admin.css: { } + +admin.codeBlock: + css: + theme: + css/code-block.admin.css: { } diff --git a/core/modules/ckeditor5/css/code-block.admin.css b/core/modules/ckeditor5/css/code-block.admin.css new file mode 100644 index 000000000000..c6c5bc6c7663 --- /dev/null +++ b/core/modules/ckeditor5/css/code-block.admin.css @@ -0,0 +1,3 @@ +.ckeditor5-toolbar-button-codeBlock { + background-image: url(../icons/code-block.svg); +} diff --git a/core/modules/ckeditor5/icons/code-block.svg b/core/modules/ckeditor5/icons/code-block.svg new file mode 100644 index 000000000000..96d55a0b2441 --- /dev/null +++ b/core/modules/ckeditor5/icons/code-block.svg @@ -0,0 +1 @@ +<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.87 12.61a.75.75 0 0 1-.089.976l-.085.07-3.154 2.254 3.412 2.414a.75.75 0 0 1 .237.95l-.057.095a.75.75 0 0 1-.95.237l-.096-.058-4.272-3.022-.003-1.223 4.01-2.867a.75.75 0 0 1 1.047.174zm2.795-.231.095.057 4.011 2.867-.003 1.223-4.272 3.022-.095.058a.75.75 0 0 1-.88-.151l-.07-.086-.058-.095a.75.75 0 0 1 .15-.88l.087-.07 3.412-2.414-3.154-2.253-.085-.071a.75.75 0 0 1 .862-1.207zM16 0a2 2 0 0 1 2 2v9.354l-.663-.492-.837-.001V2a.5.5 0 0 0-.5-.5H2a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h3.118L7.156 19H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h14zM5.009 15l.003 1H3v-1h2.009zm2.188-2-1.471 1H5v-1h2.197zM10 11v.095L8.668 12H7v-1h3zm4-2v1H7V9h7zm0-2v1H7V7h7zm-4-2v1H5V5h5zM6 3v1H3V3h3z"/></svg> diff --git a/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php b/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php index d227a1166b79..cb69059d3408 100644 --- a/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php +++ b/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php @@ -119,17 +119,20 @@ public function mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem(string $cke4_but if ($text_format_html_restrictions->isUnrestricted()) { // When no restrictions exist, all tags possibly supported by "Format" // in CKEditor 4 must be supported. - return ['heading']; + return ['heading', 'codeBlock']; } - $allowed_elements = $text_format_html_restrictions->getAllowedElements(); - // Check if <h*> is supported. // Merely checking the existence of the array key is sufficient; this // plugin does not set or need any additional attributes. // @see \Drupal\filter\Plugin\FilterInterface::getHTMLRestrictions() $intersect = array_intersect(['h2', 'h3', 'h4', 'h5', 'h6'], array_keys($allowed_elements)); + // Do not return the 'codeBlock' toolbar item, not even when `<pre>` is + // allowed in the text format. This ensures that SmartDefaultSettings: + // - first adds the `code` toolbar item (for inline `<code>`) + // - then adds `codeBlock` toolbar item (for code blocks: `<pre><code>`) + // @see https://www.drupal.org/project/drupal/issues/3263384#comment-14446315 return count($intersect) > 0 ? ['heading'] : NULL; case 'Table': diff --git a/core/modules/ckeditor5/tests/modules/ckeditor5_plugin_conditions_test/ckeditor5_plugin_conditions_test.ckeditor5.yml b/core/modules/ckeditor5/tests/modules/ckeditor5_plugin_conditions_test/ckeditor5_plugin_conditions_test.ckeditor5.yml index 0e42f722d659..6319b3c588e0 100644 --- a/core/modules/ckeditor5/tests/modules/ckeditor5_plugin_conditions_test/ckeditor5_plugin_conditions_test.ckeditor5.yml +++ b/core/modules/ckeditor5/tests/modules/ckeditor5_plugin_conditions_test/ckeditor5_plugin_conditions_test.ckeditor5.yml @@ -12,16 +12,3 @@ ckeditor5_plugin_conditions_test_plugins_condition: - ckeditor5_table elements: - <foo> - -# @todo remove in https://www.drupal.org/project/drupal/issues/3263384 -ckeditor5_plugin_conditions_test_codeBlock_until_3263384_lands: - ckeditor5: - plugins: [] - drupal: - label: TEST until #3263384 lands - toolbar_items: - codeBlockPlaceholder: - label: TODO - elements: - - <pre> - - <code class="lang-*"> diff --git a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php index 4cc42b67c1cc..b12170a8c550 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php @@ -568,15 +568,15 @@ public function provider() { 'toolbar' => [ 'items' => array_merge( $basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'], - ['codeBlockPlaceholder'], + ['codeBlock'], ), ], 'plugins' => $basic_html_test_case['expected_ckeditor5_settings']['plugins'], ], - 'expected_superset' => '<code class="lang-*"> ' . $basic_html_test_case['expected_superset'], + 'expected_superset' => '<code class="language-*"> ' . $basic_html_test_case['expected_superset'], 'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'], 'expected_messages' => [ - 'The following plugins were enabled to support tags that are allowed by this text format: <em class="placeholder">Code (for tags: <code>) Language (for tags: <span>) TEST until (for tags: <pre>)</em>.', + 'The following plugins were enabled to support tags that are allowed by this text format: <em class="placeholder">Code (for tags: <code>) Language (for tags: <span>) Code Block (for tags: <pre>)</em>.', $basic_html_test_case['expected_messages'][1], 'This format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: <a hreflang> <blockquote cite> <ul type> <ol start type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>.', ], @@ -767,6 +767,7 @@ public function provider() { 'horizontalLine', '|', 'heading', + 'codeBlock', '|', 'sourceEditing', ], diff --git a/core/package.json b/core/package.json index c0c3c2f49580..66f985d7b4fd 100644 --- a/core/package.json +++ b/core/package.json @@ -40,6 +40,7 @@ "@ckeditor/ckeditor5-alignment": "~33.0.0", "@ckeditor/ckeditor5-basic-styles": "~33.0.0", "@ckeditor/ckeditor5-block-quote": "~33.0.0", + "@ckeditor/ckeditor5-code-block": "^33.0.0", "@ckeditor/ckeditor5-dev-utils": "^25.4.5", "@ckeditor/ckeditor5-editor-classic": "~33.0.0", "@ckeditor/ckeditor5-editor-decoupled": "~33.0.0", diff --git a/core/yarn.lock b/core/yarn.lock index ad10677a96b8..9d739fa7a8cb 100644 --- a/core/yarn.lock +++ b/core/yarn.lock @@ -938,6 +938,13 @@ "@ckeditor/ckeditor5-widget" "^33.0.0" lodash-es "^4.17.11" +"@ckeditor/ckeditor5-code-block@^33.0.0": + version "33.0.0" + resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-code-block/-/ckeditor5-code-block-33.0.0.tgz#53f163984bfa01968f3cb08e6ccd33ded5d307ca" + integrity sha512-Dj4xfNrV6gUArcEaOEhBeSss3c5E4DkpM7qxlKepD2TUsQbbf9sg8k6AJeLKgXLo10K4gEKGw+Cz5YHeFRPKFQ== + dependencies: + ckeditor5 "^33.0.0" + "@ckeditor/ckeditor5-core@^33.0.0": version "33.0.0" resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-core/-/ckeditor5-core-33.0.0.tgz#0960d9b975700c3df1037578e919e2c081d94935" -- GitLab