@ckeditor/ckeditor5-style 45.2.1 → 46.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/style.js CHANGED
@@ -2,4 +2,4 @@
2
2
  /*!
3
3
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
4
4
  * For licensing, see LICENSE.md.
5
- */(()=>{var e={21:e=>{"use strict";e.exports=function(e,t){Object.keys(t).forEach(function(s){e.setAttribute(s,t[s])})}},51:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},128:e=>{"use strict";var t={};e.exports=function(e,s){var i=function(e){if(void 0===t[e]){var s=document.querySelector(e);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}t[e]=s}return t[e]}(e);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(s)}},237:e=>{"use strict";e.exports=CKEditor5.dll},311:(e,t,s)=>{e.exports=s(237)("./src/ui.js")},374:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,":root{--ck-style-panel-max-height:470px}.ck.ck-style-panel{max-height:var(--ck-style-panel-max-height);overflow-y:auto;padding:var(--ck-spacing-large)}",""]);const o=r},584:(e,t,s)=>{e.exports=s(237)("./src/utils.js")},591:e=>{"use strict";var t=[];function s(e){for(var s=-1,i=0;i<t.length;i++)if(t[i].identifier===e){s=i;break}return s}function i(e,i){for(var n={},r=[],o=0;o<e.length;o++){var c=e[o],a=i.base?c[0]+i.base:c[0],u=n[a]||0,d="".concat(a," ").concat(u);n[a]=u+1;var h=s(d),g={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==h)t[h].references++,t[h].updater(g);else{var p=l(g,i);i.byIndex=o,t.splice(o,0,{identifier:d,updater:p,references:1})}r.push(d)}return r}function l(e,t){var s=t.domAPI(t);s.update(e);return function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;s.update(e=t)}else s.remove()}}e.exports=function(e,l){var n=i(e=e||[],l=l||{});return function(e){e=e||[];for(var r=0;r<n.length;r++){var o=s(n[r]);t[o].references--}for(var c=i(e,l),a=0;a<n.length;a++){var u=s(n[a]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}n=c}}},639:e=>{"use strict";var t,s=(t=[],function(e,s){return t[e]=s,t.filter(Boolean).join("\n")});function i(e,t,i,l){var n;if(i)n="";else{n="",l.supports&&(n+="@supports (".concat(l.supports,") {")),l.media&&(n+="@media ".concat(l.media," {"));var r=void 0!==l.layer;r&&(n+="@layer".concat(l.layer.length>0?" ".concat(l.layer):""," {")),n+=l.css,r&&(n+="}"),l.media&&(n+="}"),l.supports&&(n+="}")}if(e.styleSheet)e.styleSheet.cssText=s(t,n);else{var o=document.createTextNode(n),c=e.childNodes;c[t]&&e.removeChild(c[t]),c.length?e.insertBefore(o,c[t]):e.appendChild(o)}}var l={singleton:null,singletonCounter:0};e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=l.singletonCounter++,s=l.singleton||(l.singleton=e.insertStyleElement(e));return{update:function(e){i(s,t,!1,e)},remove:function(e){i(s,t,!0,e)}}}},702:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,".ck.ck-dropdown.ck-style-dropdown.ck-style-dropdown_multiple-active>.ck-button>.ck-button__label{font-style:italic}",""]);const o=r},758:e=>{"use strict";e.exports=function(e){return e[1]}},782:(e,t,s)=>{e.exports=s(237)("./src/core.js")},834:(e,t,s)=>{e.exports=s(237)("./src/typing.js")},881:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,".ck.ck-style-panel .ck-style-panel__style-group>.ck-label{margin:var(--ck-spacing-large) 0}.ck.ck-style-panel .ck-style-panel__style-group:first-child>.ck-label{margin-top:0}",""]);const o=r},930:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,":root{--ck-style-panel-columns:3}.ck.ck-style-panel .ck-style-grid{display:grid;grid-template-columns:repeat(var(--ck-style-panel-columns),auto);justify-content:start}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button{display:flex;flex-direction:column;justify-content:space-between}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button .ck-style-grid__button__preview{align-content:center;align-items:center;display:flex;flex-basis:100%;flex-grow:1;justify-content:flex-start}:root{--ck-style-panel-button-width:120px;--ck-style-panel-button-height:80px;--ck-style-panel-button-label-background:#f0f0f0;--ck-style-panel-button-hover-label-background:#ebebeb;--ck-style-panel-button-hover-border-color:#b3b3b3}.ck.ck-style-panel .ck-style-grid{column-gap:var(--ck-spacing-large);row-gap:var(--ck-spacing-large)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button{--ck-color-button-default-hover-background:var(--ck-color-base-background);--ck-color-button-default-active-background:var(--ck-color-base-background);height:var(--ck-style-panel-button-height);padding:0;width:var(--ck-style-panel-button-width)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button .ck-button__label{flex-shrink:0;height:22px;line-height:22px;overflow:hidden;padding:0 var(--ck-spacing-medium);text-overflow:ellipsis;width:100%}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button .ck-style-grid__button__preview{background:var(--ck-color-base-background);border:2px solid var(--ck-color-base-background);opacity:.9;overflow:hidden;padding:var(--ck-spacing-medium);width:100%}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-disabled{--ck-color-button-default-disabled-background:var(--ck-color-base-foreground)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-disabled:not(:focus){border-color:var(--ck-style-panel-button-label-background)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-disabled .ck-style-grid__button__preview{border-color:var(--ck-color-base-foreground);filter:saturate(.3);opacity:.4}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-on{border-color:var(--ck-color-base-active)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-on .ck-button__label{box-shadow:0 -1px 0 var(--ck-color-base-active);z-index:1}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-on:hover{border-color:var(--ck-color-base-active-focus)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:not(.ck-on) .ck-button__label{background:var(--ck-style-panel-button-label-background)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:not(.ck-on):hover .ck-button__label{background:var(--ck-style-panel-button-hover-label-background)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:hover:not(.ck-disabled):not(.ck-on){border-color:var(--ck-style-panel-button-hover-border-color)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:hover:not(.ck-disabled):not(.ck-on) .ck-style-grid__button__preview{opacity:1}",""]);const o=r},935:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var s="",i=void 0!==t[5];return t[4]&&(s+="@supports (".concat(t[4],") {")),t[2]&&(s+="@media ".concat(t[2]," {")),i&&(s+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),s+=e(t),i&&(s+="}"),t[2]&&(s+="}"),t[4]&&(s+="}"),s}).join("")},t.i=function(e,s,i,l,n){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(i)for(var o=0;o<this.length;o++){var c=this[o][0];null!=c&&(r[c]=!0)}for(var a=0;a<e.length;a++){var u=[].concat(e[a]);i&&r[u[0]]||(void 0!==n&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=n),s&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=s):u[2]=s),l&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=l):u[4]="".concat(l)),t.push(u))}},t}}},t={};function s(i){var l=t[i];if(void 0!==l)return l.exports;var n=t[i]={id:i,exports:{}};return e[i](n,n.exports,s),n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{"use strict";s.r(i),s.d(i,{Style:()=>O,StyleEditing:()=>N,StyleUI:()=>V,StyleUtils:()=>T});var e=s(782),t=s(311),l=s(584);class n extends t.ButtonView{styleDefinition;previewView;constructor(e,t){super(e),this.styleDefinition=t,this.previewView=this._createPreview(),this.set({label:t.name,class:"ck-style-grid__button",withText:!0}),this.extendTemplate({attributes:{role:"option"}}),this.children.add(this.previewView,0)}_createPreview(){const e=new t.View(this.locale);return e.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[this.styleDefinition.previewTemplate]}),e}}var r=s(591),o=s.n(r),c=s(639),a=s.n(c),u=s(128),d=s.n(u),h=s(21),g=s.n(h),p=s(51),y=s.n(p),f=s(930),k={attributes:{"data-cke":!0}};k.setAttributes=g(),k.insert=d().bind(null,"head"),k.domAPI=a(),k.insertStyleElement=y();o()(f.A,k);f.A&&f.A.locals&&f.A.locals;class b extends t.View{focusTracker;keystrokes;children;constructor(e,t){super(e),this.focusTracker=new l.FocusTracker,this.keystrokes=new l.KeystrokeHandler,this.set("activeStyles",[]),this.set("enabledStyles",[]),this.children=this.createCollection(),this.children.delegate("execute").to(this);for(const s of t){const t=new n(e,s);this.children.add(t)}this.on("change:activeStyles",()=>{for(const e of this.children)e.isOn=this.activeStyles.includes(e.styleDefinition.name)}),this.on("change:enabledStyles",()=>{for(const e of this.children)e.isEnabled=this.enabledStyles.includes(e.styleDefinition.name)}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-grid"],role:"listbox"},children:this.children})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element);(0,t.addKeyboardHandlingForGrid)({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.children,numberOfColumns:3,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection}),this.keystrokes.listenTo(this.element)}focus(){this.children.first.focus()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}var m=s(881),_={attributes:{"data-cke":!0}};_.setAttributes=g(),_.insert=d().bind(null,"head"),_.domAPI=a(),_.insertStyleElement=y();o()(m.A,_);m.A&&m.A.locals&&m.A.locals;class v extends t.View{gridView;labelView;constructor(e,s,i){super(e),this.labelView=new t.LabelView(e),this.labelView.text=s,this.gridView=new b(e,i),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel__style-group"],role:"group","aria-labelledby":this.labelView.id},children:[this.labelView,this.gridView]})}}var S=s(374),w={attributes:{"data-cke":!0}};w.setAttributes=g(),w.insert=d().bind(null,"head"),w.domAPI=a(),w.insertStyleElement=y();o()(S.A,w);S.A&&S.A.locals&&S.A.locals;class A extends t.View{focusTracker;keystrokes;children;blockStylesGroupView;inlineStylesGroupView;_focusables;_focusCycler;constructor(e,s){super(e);const i=e.t;this.focusTracker=new l.FocusTracker,this.keystrokes=new l.KeystrokeHandler,this.children=this.createCollection(),this.blockStylesGroupView=new v(e,i("Block styles"),s.block),this.inlineStylesGroupView=new v(e,i("Text styles"),s.inline),this.set("activeStyles",[]),this.set("enabledStyles",[]),this._focusables=new t.ViewCollection,this._focusCycler=new t.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["shift + tab"],focusNext:["tab"]}}),s.block.length&&this.children.add(this.blockStylesGroupView),s.inline.length&&this.children.add(this.inlineStylesGroupView),this.blockStylesGroupView.gridView.delegate("execute").to(this),this.inlineStylesGroupView.gridView.delegate("execute").to(this),this.blockStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.inlineStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel"]},children:this.children})}render(){super.render(),this._focusables.add(this.blockStylesGroupView.gridView),this._focusables.add(this.inlineStylesGroupView.gridView),this.focusTracker.add(this.blockStylesGroupView.gridView.element),this.focusTracker.add(this.inlineStylesGroupView.gridView.element),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}const x=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class T extends e.Plugin{_htmlSupport;static get pluginName(){return"StyleUtils"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.decorate("isStyleEnabledForBlock"),this.decorate("isStyleActiveForBlock"),this.decorate("getAffectedBlocks"),this.decorate("isStyleEnabledForInlineSelection"),this.decorate("isStyleActiveForInlineSelection"),this.decorate("getAffectedInlineSelectable"),this.decorate("getStylePreview"),this.decorate("configureGHSDataFilter")}init(){this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport")}normalizeConfig(e,t=[]){const s={block:[],inline:[]};for(const i of t){const t=[],l=[];for(const s of e.getDefinitionsForView(i.element)){const e="appliesToBlock"in s&&s.appliesToBlock;if(s.isBlock||e){if("string"==typeof e)t.push(e);else if(s.isBlock){const e=s;t.push(s.model),e.paragraphLikeModel&&t.push(e.paragraphLikeModel)}}else l.push(s.model)}const n=this.getStylePreview(i,[{text:"AaBbCcDdEeFfGgHhIiJj"}]);t.length?s.block.push({...i,previewTemplate:n,modelElements:t,isBlock:!0}):s.inline.push({...i,previewTemplate:n,ghsAttributes:l})}return s}isStyleEnabledForBlock(e,t){const s=this.editor.model,i=this._htmlSupport.getGhsAttributeNameForElement(e.element);return!!s.schema.checkAttribute(t,i)&&e.modelElements.includes(t.name)}isStyleActiveForBlock(e,t){const s=this._htmlSupport.getGhsAttributeNameForElement(e.element),i=t.getAttribute(s);return this.hasAllClasses(i,e.classes)}getAffectedBlocks(e,t){return e.modelElements.includes(t.name)?[t]:null}isStyleEnabledForInlineSelection(e,t){const s=this.editor.model;for(const i of e.ghsAttributes)if(s.schema.checkAttributeInSelection(t,i))return!0;return!1}isStyleActiveForInlineSelection(e,t){for(const s of e.ghsAttributes){const i=this._getValueFromFirstAllowedNode(t,s);if(this.hasAllClasses(i,e.classes))return!0}return!1}getAffectedInlineSelectable(e,t){return t}getStylePreview(e,t){const{element:s,classes:i}=e;return{tag:(l=s,x.includes(l)?"div":s),attributes:{class:i},children:t};var l}hasAllClasses(e,t){return null!==(i=e)&&("object"==typeof i||"function"==typeof i)&&(s=e,Boolean(s.classes)&&Array.isArray(s.classes))&&t.every(t=>e.classes.includes(t));var s,i}configureGHSDataFilter({block:e,inline:t}){const s=this.editor.plugins.get("DataFilter");s.loadAllowedConfig(e.map(F)),s.loadAllowedConfig(t.map(F))}_getValueFromFirstAllowedNode(e,t){const s=this.editor.model.schema;if(e.isCollapsed)return e.getAttribute(t);for(const i of e.getRanges())for(const e of i.getItems())if(s.checkAttribute(e,t))return e.getAttribute(t);return null}}function F({element:e,classes:t}){return{name:e,classes:t}}var E=s(702),B={attributes:{"data-cke":!0}};B.setAttributes=g(),B.insert=d().bind(null,"head"),B.domAPI=a(),B.insertStyleElement=y();o()(E.A,B);E.A&&E.A.locals&&E.A.locals;class V extends e.Plugin{static get pluginName(){return"StyleUI"}static get isOfficialPlugin(){return!0}static get requires(){return[T]}init(){const e=this.editor,s=e.plugins.get("DataSchema"),i=e.plugins.get("StyleUtils"),l=e.config.get("style.definitions"),n=i.normalizeConfig(s,l);e.ui.componentFactory.add("style",s=>{const i=s.t,l=(0,t.createDropdown)(s),r=e.commands.get("style");return l.once("change:isOpen",()=>{const e=new A(s,n);l.panelView.children.add(e),e.delegate("execute").to(l),e.bind("activeStyles").to(r,"value"),e.bind("enabledStyles").to(r,"enabledStyles")}),l.bind("isEnabled").to(r),l.buttonView.withText=!0,l.buttonView.bind("label").to(r,"value",e=>e.length>1?i("Multiple styles"):1===e.length?e[0]:i("Styles")),l.bind("class").to(r,"value",e=>{const t=["ck-style-dropdown"];return e.length>1&&t.push("ck-style-dropdown_multiple-active"),t.join(" ")}),l.on("execute",t=>{e.execute("style",{styleName:t.source.styleDefinition.name}),e.editing.view.focus()}),l})}}class C extends e.Command{_styleDefinitions;_styleUtils;constructor(e,t){super(e),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=t,this._styleUtils=this.editor.plugins.get(T)}refresh(){const e=this.editor.model,t=e.document.selection,s=new Set,i=new Set;for(const e of this._styleDefinitions.inline)this._styleUtils.isStyleEnabledForInlineSelection(e,t)&&i.add(e.name),this._styleUtils.isStyleActiveForInlineSelection(e,t)&&s.add(e.name);const n=(0,l.first)(t.getSelectedBlocks())||t.getFirstPosition().parent;if(n){const t=n.getAncestors({includeSelf:!0,parentFirst:!0});for(const l of t){if(l.is("rootElement"))break;for(const e of this._styleDefinitions.block)this._styleUtils.isStyleEnabledForBlock(e,l)&&(i.add(e.name),this._styleUtils.isStyleActiveForBlock(e,l)&&s.add(e.name));if(e.schema.isObject(l))break}}this.enabledStyles=Array.from(i).sort(),this.isEnabled=this.enabledStyles.length>0,this.value=this.isEnabled?Array.from(s).sort():[]}execute({styleName:e,forceValue:t}){if(!this.enabledStyles.includes(e))return void(0,l.logWarning)("style-command-executed-with-incorrect-style-name");const s=this.editor.model,i=s.document.selection,n=this.editor.plugins.get("GeneralHtmlSupport"),r=[...this._styleDefinitions.inline,...this._styleDefinitions.block],o=r.filter(({name:e})=>this.value.includes(e)),c=r.find(({name:t})=>t==e),a=void 0===t?!this.value.includes(c.name):t;s.change(()=>{let e;e=function(e){return"isBlock"in e}(c)?this._findAffectedBlocks(function(e){const t=Array.from(e.getSelectedBlocks());if(t.length)return t;return[e.getFirstPosition().parent]}(i),c):[this._styleUtils.getAffectedInlineSelectable(c,i)];for(const t of e)a?n.addModelHtmlClass(c.element,c.classes,t):n.removeModelHtmlClass(c.element,U(o,c),t)})}_findAffectedBlocks(e,t){const s=new Set;for(const i of e){const e=i.getAncestors({includeSelf:!0,parentFirst:!0});for(const i of e){if(i.is("rootElement"))break;const e=this._styleUtils.getAffectedBlocks(t,i);if(e){for(const t of e)s.add(t);break}}}return s}}function U(e,t){return e.reduce((e,s)=>s.name===t.name?e:e.filter(e=>!s.classes.includes(e)),t.classes)}class I extends e.Plugin{_listUtils;_styleUtils;_htmlSupport;static get pluginName(){return"ListStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[T,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("ListEditing")&&(this._styleUtils=e.plugins.get(T),this._listUtils=this.editor.plugins.get("ListUtils"),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",(e,[t,s])=>{this._isStyleEnabledForBlock(t,s)&&(e.return=!0,e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForBlock",(e,[t,s])=>{this._isStyleActiveForBlock(t,s)&&(e.return=!0,e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",(e,[t,s])=>{const i=this._getAffectedBlocks(t,s);i&&(e.return=i,e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getStylePreview",(e,[t,s])=>{const i=this._getStylePreview(t,s);i&&(e.return=i,e.stop())},{priority:"high"}))}_isStyleEnabledForBlock(e,t){const s=this.editor.model;if(!["ol","ul","li"].includes(e.element))return!1;if(!this._listUtils.isListItemBlock(t))return!1;const i=this._htmlSupport.getGhsAttributeNameForElement(e.element);if("ol"==e.element||"ul"==e.element){if(!s.schema.checkAttribute(t,i))return!1;const l=this._listUtils.isNumberedListType(t.getAttribute("listType"))?"ol":"ul";return e.element==l}return s.schema.checkAttribute(t,i)}_isStyleActiveForBlock(e,t){const s=this._htmlSupport.getGhsAttributeNameForElement(e.element),i=t.getAttribute(s);return this._styleUtils.hasAllClasses(i,e.classes)}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?"li"==e.element?this._listUtils.expandListBlocksToCompleteItems(t,{withNested:!1}):this._listUtils.expandListBlocksToCompleteList(t):null}_getStylePreview(e,t){const{element:s,classes:i}=e;return"ol"==s||"ul"==s?{tag:s,attributes:{class:i},children:[{tag:"li",children:t}]}:"li"==s?{tag:"ol",children:[{tag:s,attributes:{class:i},children:t}]}:null}}class P extends e.Plugin{_tableUtils;_styleUtils;static get pluginName(){return"TableStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[T]}init(){const e=this.editor;e.plugins.has("TableEditing")&&(this._styleUtils=e.plugins.get(T),this._tableUtils=this.editor.plugins.get("TableUtils"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",(e,[t,s])=>{this._isApplicable(t,s)&&(e.return=this._isStyleEnabledForBlock(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",(e,[t,s])=>{this._isApplicable(t,s)&&(e.return=this._getAffectedBlocks(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"configureGHSDataFilter",(e,[{block:t}])=>{this.editor.plugins.get("DataFilter").loadAllowedConfig(t.filter(e=>"figcaption"==e.element).map(e=>({name:"caption",classes:e.classes})))}))}_isApplicable(e,t){return["td","th"].includes(e.element)?"tableCell"==t.name:!!["thead","tbody"].includes(e.element)&&"table"==t.name}_isStyleEnabledForBlock(e,t){if(["td","th"].includes(e.element)){const s=this._tableUtils.getCellLocation(t),i=t.parent.parent,l=i.getAttribute("headingRows")||0,n=i.getAttribute("headingColumns")||0,r=s.row<l||s.column<n;return"th"==e.element?r:!r}if(["thead","tbody"].includes(e.element)){const s=t.getAttribute("headingRows")||0;return"thead"==e.element?s>0:s<this._tableUtils.getRows(t)}return!1}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?[t]:null}}var G=s(834);class H extends e.Plugin{_styleUtils;_htmlSupport;static get pluginName(){return"LinkStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[T,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("LinkEditing")&&(this._styleUtils=e.plugins.get(T),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForInlineSelection",(e,[t,s])=>{"a"==t.element&&(e.return=this._isStyleEnabled(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForInlineSelection",(e,[t,s])=>{"a"==t.element&&(e.return=this._isStyleActive(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedInlineSelectable",(e,[t,s])=>{if("a"!=t.element)return;const i=this._getAffectedSelectable(t,s);i&&(e.return=i,e.stop())},{priority:"high"}))}_isStyleEnabled(e,t){const s=this.editor.model;if(t.isCollapsed)return t.hasAttribute("linkHref");for(const e of t.getRanges())for(const t of e.getItems())if((t.is("$textProxy")||s.schema.isInline(t))&&t.hasAttribute("linkHref"))return!0;return!1}_isStyleActive(e,t){const s=this.editor.model,i=this._htmlSupport.getGhsAttributeNameForElement(e.element);if(t.isCollapsed){if(t.hasAttribute("linkHref")){const s=t.getAttribute(i);if(this._styleUtils.hasAllClasses(s,e.classes))return!0}return!1}for(const l of t.getRanges())for(const t of l.getItems())if((t.is("$textProxy")||s.schema.isInline(t))&&t.hasAttribute("linkHref")){const s=t.getAttribute(i);return this._styleUtils.hasAllClasses(s,e.classes)}return!1}_getAffectedSelectable(e,t){const s=this.editor.model;if(t.isCollapsed){const e=t.getAttribute("linkHref");return(0,G.findAttributeRange)(t.getFirstPosition(),"linkHref",e,s)}const i=[];for(const e of t.getRanges()){const t=s.createRange(D(e.start,"linkHref",!0,s),D(e.end,"linkHref",!1,s));for(const e of t.getItems())(e.is("$textProxy")||s.schema.isInline(e))&&e.hasAttribute("linkHref")&&i.push(this.editor.model.createRangeOn(e))}return function(e){for(let t=1;t<e.length;t++){const s=e[t-1].getJoined(e[t]);s&&e.splice(--t,2,s)}return e}(i)}}function D(e,t,s,i){const l=e.textNode||(s?e.nodeAfter:e.nodeBefore);if(!l||!l.hasAttribute(t))return e;const n=l.getAttribute(t);return(0,G.findAttributeRangeBound)(e,t,n,s,i)}class N extends e.Plugin{static get pluginName(){return"StyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return["GeneralHtmlSupport",T,I,P,H]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),s=e.plugins.get("StyleUtils"),i=e.config.get("style.definitions"),l=s.normalizeConfig(t,i);e.commands.add("style",new C(e,l)),s.configureGHSDataFilter(l)}}class O extends e.Plugin{static get pluginName(){return"Style"}static get isOfficialPlugin(){return!0}static get requires(){return[N,V]}}})(),(window.CKEditor5=window.CKEditor5||{}).style=i})();
5
+ */(()=>{var e={21:e=>{"use strict";e.exports=function(e,t){Object.keys(t).forEach(function(s){e.setAttribute(s,t[s])})}},51:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},128:e=>{"use strict";var t={};e.exports=function(e,s){var i=function(e){if(void 0===t[e]){var s=document.querySelector(e);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}t[e]=s}return t[e]}(e);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(s)}},237:e=>{"use strict";e.exports=CKEditor5.dll},311:(e,t,s)=>{e.exports=s(237)("./src/ui.js")},374:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,":root{--ck-style-panel-max-height:470px}.ck.ck-style-panel{max-height:var(--ck-style-panel-max-height);overflow-y:auto;padding:var(--ck-spacing-large)}",""]);const o=r},584:(e,t,s)=>{e.exports=s(237)("./src/utils.js")},591:e=>{"use strict";var t=[];function s(e){for(var s=-1,i=0;i<t.length;i++)if(t[i].identifier===e){s=i;break}return s}function i(e,i){for(var n={},r=[],o=0;o<e.length;o++){var c=e[o],a=i.base?c[0]+i.base:c[0],u=n[a]||0,d="".concat(a," ").concat(u);n[a]=u+1;var h=s(d),g={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==h)t[h].references++,t[h].updater(g);else{var p=l(g,i);i.byIndex=o,t.splice(o,0,{identifier:d,updater:p,references:1})}r.push(d)}return r}function l(e,t){var s=t.domAPI(t);s.update(e);return function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;s.update(e=t)}else s.remove()}}e.exports=function(e,l){var n=i(e=e||[],l=l||{});return function(e){e=e||[];for(var r=0;r<n.length;r++){var o=s(n[r]);t[o].references--}for(var c=i(e,l),a=0;a<n.length;a++){var u=s(n[a]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}n=c}}},639:e=>{"use strict";var t,s=(t=[],function(e,s){return t[e]=s,t.filter(Boolean).join("\n")});function i(e,t,i,l){var n;if(i)n="";else{n="",l.supports&&(n+="@supports (".concat(l.supports,") {")),l.media&&(n+="@media ".concat(l.media," {"));var r=void 0!==l.layer;r&&(n+="@layer".concat(l.layer.length>0?" ".concat(l.layer):""," {")),n+=l.css,r&&(n+="}"),l.media&&(n+="}"),l.supports&&(n+="}")}if(e.styleSheet)e.styleSheet.cssText=s(t,n);else{var o=document.createTextNode(n),c=e.childNodes;c[t]&&e.removeChild(c[t]),c.length?e.insertBefore(o,c[t]):e.appendChild(o)}}var l={singleton:null,singletonCounter:0};e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=l.singletonCounter++,s=l.singleton||(l.singleton=e.insertStyleElement(e));return{update:function(e){i(s,t,!1,e)},remove:function(e){i(s,t,!0,e)}}}},702:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,".ck.ck-dropdown.ck-style-dropdown.ck-style-dropdown_multiple-active>.ck-button>.ck-button__label{font-style:italic}",""]);const o=r},758:e=>{"use strict";e.exports=function(e){return e[1]}},782:(e,t,s)=>{e.exports=s(237)("./src/core.js")},834:(e,t,s)=>{e.exports=s(237)("./src/typing.js")},881:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,".ck.ck-style-panel .ck-style-panel__style-group>.ck-label{margin:var(--ck-spacing-large) 0}.ck.ck-style-panel .ck-style-panel__style-group:first-child>.ck-label{margin-top:0}",""]);const o=r},930:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var i=s(758),l=s.n(i),n=s(935),r=s.n(n)()(l());r.push([e.id,":root{--ck-style-panel-columns:3}.ck.ck-style-panel .ck-style-grid{display:grid;grid-template-columns:repeat(var(--ck-style-panel-columns),auto);justify-content:start}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button{display:flex;flex-direction:column;justify-content:space-between}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button .ck-style-grid__button__preview{align-content:center;align-items:center;display:flex;flex-basis:100%;flex-grow:1;justify-content:flex-start}:root{--ck-style-panel-button-width:120px;--ck-style-panel-button-height:80px;--ck-style-panel-button-label-background:#f0f0f0;--ck-style-panel-button-hover-label-background:#ebebeb;--ck-style-panel-button-hover-border-color:#b3b3b3}.ck.ck-style-panel .ck-style-grid{column-gap:var(--ck-spacing-large);row-gap:var(--ck-spacing-large)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button{--ck-color-button-default-hover-background:var(--ck-color-base-background);--ck-color-button-default-active-background:var(--ck-color-base-background);height:var(--ck-style-panel-button-height);padding:0;width:var(--ck-style-panel-button-width)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button .ck-button__label{flex-shrink:0;height:22px;line-height:22px;overflow:hidden;padding:0 var(--ck-spacing-medium);text-overflow:ellipsis;width:100%}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button .ck-style-grid__button__preview{background:var(--ck-color-base-background);border:2px solid var(--ck-color-base-background);opacity:.9;overflow:hidden;padding:var(--ck-spacing-medium);width:100%}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-disabled{--ck-color-button-default-disabled-background:var(--ck-color-base-foreground)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-disabled:not(:focus){border-color:var(--ck-style-panel-button-label-background)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-disabled .ck-style-grid__button__preview{border-color:var(--ck-color-base-foreground);filter:saturate(.3);opacity:.4}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-on{border-color:var(--ck-color-base-active)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-on .ck-button__label{box-shadow:0 -1px 0 var(--ck-color-base-active);z-index:1}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button.ck-on:hover{border-color:var(--ck-color-base-active-focus)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:not(.ck-on) .ck-button__label{background:var(--ck-style-panel-button-label-background)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:not(.ck-on):hover .ck-button__label{background:var(--ck-style-panel-button-hover-label-background)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:hover:not(.ck-disabled):not(.ck-on){border-color:var(--ck-style-panel-button-hover-border-color)}.ck.ck-style-panel .ck-style-grid .ck-style-grid__button:hover:not(.ck-disabled):not(.ck-on) .ck-style-grid__button__preview{opacity:1}",""]);const o=r},935:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var s="",i=void 0!==t[5];return t[4]&&(s+="@supports (".concat(t[4],") {")),t[2]&&(s+="@media ".concat(t[2]," {")),i&&(s+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),s+=e(t),i&&(s+="}"),t[2]&&(s+="}"),t[4]&&(s+="}"),s}).join("")},t.i=function(e,s,i,l,n){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(i)for(var o=0;o<this.length;o++){var c=this[o][0];null!=c&&(r[c]=!0)}for(var a=0;a<e.length;a++){var u=[].concat(e[a]);i&&r[u[0]]||(void 0!==n&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=n),s&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=s):u[2]=s),l&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=l):u[4]="".concat(l)),t.push(u))}},t}}},t={};function s(i){var l=t[i];if(void 0!==l)return l.exports;var n=t[i]={id:i,exports:{}};return e[i](n,n.exports,s),n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{"use strict";s.r(i),s.d(i,{LinkStyleSupport:()=>H,ListStyleSupport:()=>P,Style:()=>L,StyleCommand:()=>C,StyleEditing:()=>N,StyleUI:()=>B,StyleUtils:()=>T,TableStyleSupport:()=>I,_StyleGridButtonView:()=>n,_StyleGridView:()=>b,_StyleGroupView:()=>S,_StylePanelView:()=>A});var e=s(782),t=s(311),l=s(584);class n extends t.ButtonView{styleDefinition;previewView;constructor(e,t){super(e),this.styleDefinition=t,this.previewView=this._createPreview(),this.set({label:t.name,class:"ck-style-grid__button",withText:!0}),this.extendTemplate({attributes:{role:"option"}}),this.children.add(this.previewView,0)}_createPreview(){const e=new t.View(this.locale);return e.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[this.styleDefinition.previewTemplate]}),e}}var r=s(591),o=s.n(r),c=s(639),a=s.n(c),u=s(128),d=s.n(u),h=s(21),g=s.n(h),p=s(51),y=s.n(p),f=s(930),k={attributes:{"data-cke":!0}};k.setAttributes=g(),k.insert=d().bind(null,"head"),k.domAPI=a(),k.insertStyleElement=y();o()(f.A,k);f.A&&f.A.locals&&f.A.locals;class b extends t.View{focusTracker;keystrokes;children;constructor(e,t){super(e),this.focusTracker=new l.FocusTracker,this.keystrokes=new l.KeystrokeHandler,this.set("activeStyles",[]),this.set("enabledStyles",[]),this.children=this.createCollection(),this.children.delegate("execute").to(this);for(const s of t){const t=new n(e,s);this.children.add(t)}this.on("change:activeStyles",()=>{for(const e of this.children)e.isOn=this.activeStyles.includes(e.styleDefinition.name)}),this.on("change:enabledStyles",()=>{for(const e of this.children)e.isEnabled=this.enabledStyles.includes(e.styleDefinition.name)}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-grid"],role:"listbox"},children:this.children})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element);(0,t.addKeyboardHandlingForGrid)({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.children,numberOfColumns:3,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection}),this.keystrokes.listenTo(this.element)}focus(){this.children.first.focus()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}var m=s(881),_={attributes:{"data-cke":!0}};_.setAttributes=g(),_.insert=d().bind(null,"head"),_.domAPI=a(),_.insertStyleElement=y();o()(m.A,_);m.A&&m.A.locals&&m.A.locals;class S extends t.View{gridView;labelView;constructor(e,s,i){super(e),this.labelView=new t.LabelView(e),this.labelView.text=s,this.gridView=new b(e,i),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel__style-group"],role:"group","aria-labelledby":this.labelView.id},children:[this.labelView,this.gridView]})}}var v=s(374),w={attributes:{"data-cke":!0}};w.setAttributes=g(),w.insert=d().bind(null,"head"),w.domAPI=a(),w.insertStyleElement=y();o()(v.A,w);v.A&&v.A.locals&&v.A.locals;class A extends t.View{focusTracker;keystrokes;children;blockStylesGroupView;inlineStylesGroupView;_focusables;_focusCycler;constructor(e,s){super(e);const i=e.t;this.focusTracker=new l.FocusTracker,this.keystrokes=new l.KeystrokeHandler,this.children=this.createCollection(),this.blockStylesGroupView=new S(e,i("Block styles"),s.block),this.inlineStylesGroupView=new S(e,i("Text styles"),s.inline),this.set("activeStyles",[]),this.set("enabledStyles",[]),this._focusables=new t.ViewCollection,this._focusCycler=new t.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["shift + tab"],focusNext:["tab"]}}),s.block.length&&this.children.add(this.blockStylesGroupView),s.inline.length&&this.children.add(this.inlineStylesGroupView),this.blockStylesGroupView.gridView.delegate("execute").to(this),this.inlineStylesGroupView.gridView.delegate("execute").to(this),this.blockStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.inlineStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel"]},children:this.children})}render(){super.render(),this._focusables.add(this.blockStylesGroupView.gridView),this._focusables.add(this.inlineStylesGroupView.gridView),this.focusTracker.add(this.blockStylesGroupView.gridView.element),this.focusTracker.add(this.inlineStylesGroupView.gridView.element),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}const x=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class T extends e.Plugin{_htmlSupport;static get pluginName(){return"StyleUtils"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.decorate("isStyleEnabledForBlock"),this.decorate("isStyleActiveForBlock"),this.decorate("getAffectedBlocks"),this.decorate("isStyleEnabledForInlineSelection"),this.decorate("isStyleActiveForInlineSelection"),this.decorate("getAffectedInlineSelectable"),this.decorate("getStylePreview"),this.decorate("configureGHSDataFilter")}init(){this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport")}normalizeConfig(e,t=[]){const s={block:[],inline:[]};for(const i of t){const t=[],l=[];for(const s of e.getDefinitionsForView(i.element)){const e="appliesToBlock"in s&&s.appliesToBlock;if(s.isBlock||e){if("string"==typeof e)t.push(e);else if(s.isBlock){const e=s;t.push(s.model),e.paragraphLikeModel&&t.push(e.paragraphLikeModel)}}else l.push(s.model)}const n=this.getStylePreview(i,[{text:"AaBbCcDdEeFfGgHhIiJj"}]);t.length?s.block.push({...i,previewTemplate:n,modelElements:t,isBlock:!0}):s.inline.push({...i,previewTemplate:n,ghsAttributes:l})}return s}isStyleEnabledForBlock(e,t){const s=this.editor.model,i=this._htmlSupport.getGhsAttributeNameForElement(e.element);return!!s.schema.checkAttribute(t,i)&&e.modelElements.includes(t.name)}isStyleActiveForBlock(e,t){const s=this._htmlSupport.getGhsAttributeNameForElement(e.element),i=t.getAttribute(s);return this.hasAllClasses(i,e.classes)}getAffectedBlocks(e,t){return e.modelElements.includes(t.name)?[t]:null}isStyleEnabledForInlineSelection(e,t){const s=this.editor.model;for(const i of e.ghsAttributes)if(s.schema.checkAttributeInSelection(t,i))return!0;return!1}isStyleActiveForInlineSelection(e,t){for(const s of e.ghsAttributes){const i=this._getValueFromFirstAllowedNode(t,s);if(this.hasAllClasses(i,e.classes))return!0}return!1}getAffectedInlineSelectable(e,t){return t}getStylePreview(e,t){const{element:s,classes:i}=e;return{tag:(l=s,x.includes(l)?"div":s),attributes:{class:i},children:t};var l}hasAllClasses(e,t){return null!==(i=e)&&("object"==typeof i||"function"==typeof i)&&(s=e,Boolean(s.classes)&&Array.isArray(s.classes))&&t.every(t=>e.classes.includes(t));var s,i}configureGHSDataFilter({block:e,inline:t}){const s=this.editor.plugins.get("DataFilter");s.loadAllowedConfig(e.map(F)),s.loadAllowedConfig(t.map(F))}_getValueFromFirstAllowedNode(e,t){const s=this.editor.model.schema;if(e.isCollapsed)return e.getAttribute(t);for(const i of e.getRanges())for(const e of i.getItems())if(s.checkAttribute(e,t))return e.getAttribute(t);return null}}function F({element:e,classes:t}){return{name:e,classes:t}}var E=s(702),V={attributes:{"data-cke":!0}};V.setAttributes=g(),V.insert=d().bind(null,"head"),V.domAPI=a(),V.insertStyleElement=y();o()(E.A,V);E.A&&E.A.locals&&E.A.locals;class B extends e.Plugin{static get pluginName(){return"StyleUI"}static get isOfficialPlugin(){return!0}static get requires(){return[T]}init(){const e=this.editor,s=e.plugins.get("DataSchema"),i=e.plugins.get("StyleUtils"),l=e.config.get("style.definitions"),n=i.normalizeConfig(s,l);e.ui.componentFactory.add("style",s=>{const i=s.t,l=(0,t.createDropdown)(s),r=e.commands.get("style");return l.once("change:isOpen",()=>{const e=new A(s,n);l.panelView.children.add(e),e.delegate("execute").to(l),e.bind("activeStyles").to(r,"value"),e.bind("enabledStyles").to(r,"enabledStyles")}),l.bind("isEnabled").to(r),l.buttonView.withText=!0,l.buttonView.bind("label").to(r,"value",e=>e.length>1?i("Multiple styles"):1===e.length?e[0]:i("Styles")),l.bind("class").to(r,"value",e=>{const t=["ck-style-dropdown"];return e.length>1&&t.push("ck-style-dropdown_multiple-active"),t.join(" ")}),l.on("execute",t=>{e.execute("style",{styleName:t.source.styleDefinition.name}),e.editing.view.focus()}),l})}}class C extends e.Command{_styleDefinitions;_styleUtils;constructor(e,t){super(e),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=t,this._styleUtils=this.editor.plugins.get(T)}refresh(){const e=this.editor.model,t=e.document.selection,s=new Set,i=new Set;for(const e of this._styleDefinitions.inline)this._styleUtils.isStyleEnabledForInlineSelection(e,t)&&i.add(e.name),this._styleUtils.isStyleActiveForInlineSelection(e,t)&&s.add(e.name);const n=(0,l.first)(t.getSelectedBlocks())||t.getFirstPosition().parent;if(n){const t=n.getAncestors({includeSelf:!0,parentFirst:!0});for(const l of t){if(l.is("rootElement"))break;for(const e of this._styleDefinitions.block)this._styleUtils.isStyleEnabledForBlock(e,l)&&(i.add(e.name),this._styleUtils.isStyleActiveForBlock(e,l)&&s.add(e.name));if(e.schema.isObject(l))break}}this.enabledStyles=Array.from(i).sort(),this.isEnabled=this.enabledStyles.length>0,this.value=this.isEnabled?Array.from(s).sort():[]}execute({styleName:e,forceValue:t}){if(!this.enabledStyles.includes(e))return void(0,l.logWarning)("style-command-executed-with-incorrect-style-name");const s=this.editor.model,i=s.document.selection,n=this.editor.plugins.get("GeneralHtmlSupport"),r=[...this._styleDefinitions.inline,...this._styleDefinitions.block],o=r.filter(({name:e})=>this.value.includes(e)),c=r.find(({name:t})=>t==e),a=void 0===t?!this.value.includes(c.name):t;s.change(()=>{let e;e=function(e){return"isBlock"in e}(c)?this._findAffectedBlocks(function(e){const t=Array.from(e.getSelectedBlocks());if(t.length)return t;return[e.getFirstPosition().parent]}(i),c):[this._styleUtils.getAffectedInlineSelectable(c,i)];for(const t of e)a?n.addModelHtmlClass(c.element,c.classes,t):n.removeModelHtmlClass(c.element,U(o,c),t)})}_findAffectedBlocks(e,t){const s=new Set;for(const i of e){const e=i.getAncestors({includeSelf:!0,parentFirst:!0});for(const i of e){if(i.is("rootElement"))break;const e=this._styleUtils.getAffectedBlocks(t,i);if(e){for(const t of e)s.add(t);break}}}return s}}function U(e,t){return e.reduce((e,s)=>s.name===t.name?e:e.filter(e=>!s.classes.includes(e)),t.classes)}class P extends e.Plugin{_listUtils;_styleUtils;_htmlSupport;static get pluginName(){return"ListStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[T,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("ListEditing")&&(this._styleUtils=e.plugins.get(T),this._listUtils=this.editor.plugins.get("ListUtils"),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",(e,[t,s])=>{this._isStyleEnabledForBlock(t,s)&&(e.return=!0,e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForBlock",(e,[t,s])=>{this._isStyleActiveForBlock(t,s)&&(e.return=!0,e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",(e,[t,s])=>{const i=this._getAffectedBlocks(t,s);i&&(e.return=i,e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getStylePreview",(e,[t,s])=>{const i=this._getStylePreview(t,s);i&&(e.return=i,e.stop())},{priority:"high"}))}_isStyleEnabledForBlock(e,t){const s=this.editor.model;if(!["ol","ul","li"].includes(e.element))return!1;if(!this._listUtils.isListItemBlock(t))return!1;const i=this._htmlSupport.getGhsAttributeNameForElement(e.element);if("ol"==e.element||"ul"==e.element){if(!s.schema.checkAttribute(t,i))return!1;const l=this._listUtils.isNumberedListType(t.getAttribute("listType"))?"ol":"ul";return e.element==l}return s.schema.checkAttribute(t,i)}_isStyleActiveForBlock(e,t){const s=this._htmlSupport.getGhsAttributeNameForElement(e.element),i=t.getAttribute(s);return this._styleUtils.hasAllClasses(i,e.classes)}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?"li"==e.element?this._listUtils.expandListBlocksToCompleteItems(t,{withNested:!1}):this._listUtils.expandListBlocksToCompleteList(t):null}_getStylePreview(e,t){const{element:s,classes:i}=e;return"ol"==s||"ul"==s?{tag:s,attributes:{class:i},children:[{tag:"li",children:t}]}:"li"==s?{tag:"ol",children:[{tag:s,attributes:{class:i},children:t}]}:null}}class I extends e.Plugin{_tableUtils;_styleUtils;static get pluginName(){return"TableStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[T]}init(){const e=this.editor;e.plugins.has("TableEditing")&&(this._styleUtils=e.plugins.get(T),this._tableUtils=this.editor.plugins.get("TableUtils"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",(e,[t,s])=>{this._isApplicable(t,s)&&(e.return=this._isStyleEnabledForBlock(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",(e,[t,s])=>{this._isApplicable(t,s)&&(e.return=this._getAffectedBlocks(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"configureGHSDataFilter",(e,[{block:t}])=>{this.editor.plugins.get("DataFilter").loadAllowedConfig(t.filter(e=>"figcaption"==e.element).map(e=>({name:"caption",classes:e.classes})))}))}_isApplicable(e,t){return["td","th"].includes(e.element)?"tableCell"==t.name:!!["thead","tbody"].includes(e.element)&&"table"==t.name}_isStyleEnabledForBlock(e,t){if(["td","th"].includes(e.element)){const s=this._tableUtils.getCellLocation(t),i=t.parent.parent,l=i.getAttribute("headingRows")||0,n=i.getAttribute("headingColumns")||0,r=s.row<l||s.column<n;return"th"==e.element?r:!r}if(["thead","tbody"].includes(e.element)){const s=t.getAttribute("headingRows")||0;return"thead"==e.element?s>0:s<this._tableUtils.getRows(t)}return!1}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?[t]:null}}var G=s(834);class H extends e.Plugin{_styleUtils;_htmlSupport;static get pluginName(){return"LinkStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[T,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("LinkEditing")&&(this._styleUtils=e.plugins.get(T),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForInlineSelection",(e,[t,s])=>{"a"==t.element&&(e.return=this._isStyleEnabled(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForInlineSelection",(e,[t,s])=>{"a"==t.element&&(e.return=this._isStyleActive(t,s),e.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedInlineSelectable",(e,[t,s])=>{if("a"!=t.element)return;const i=this._getAffectedSelectable(t,s);i&&(e.return=i,e.stop())},{priority:"high"}))}_isStyleEnabled(e,t){const s=this.editor.model;if(t.isCollapsed)return t.hasAttribute("linkHref");for(const e of t.getRanges())for(const t of e.getItems())if((t.is("$textProxy")||s.schema.isInline(t))&&t.hasAttribute("linkHref"))return!0;return!1}_isStyleActive(e,t){const s=this.editor.model,i=this._htmlSupport.getGhsAttributeNameForElement(e.element);if(t.isCollapsed){if(t.hasAttribute("linkHref")){const s=t.getAttribute(i);if(this._styleUtils.hasAllClasses(s,e.classes))return!0}return!1}for(const l of t.getRanges())for(const t of l.getItems())if((t.is("$textProxy")||s.schema.isInline(t))&&t.hasAttribute("linkHref")){const s=t.getAttribute(i);return this._styleUtils.hasAllClasses(s,e.classes)}return!1}_getAffectedSelectable(e,t){const s=this.editor.model;if(t.isCollapsed){const e=t.getAttribute("linkHref");return(0,G.findAttributeRange)(t.getFirstPosition(),"linkHref",e,s)}const i=[];for(const e of t.getRanges()){const t=s.createRange(D(e.start,"linkHref",!0,s),D(e.end,"linkHref",!1,s));for(const e of t.getItems())(e.is("$textProxy")||s.schema.isInline(e))&&e.hasAttribute("linkHref")&&i.push(this.editor.model.createRangeOn(e))}return function(e){for(let t=1;t<e.length;t++){const s=e[t-1].getJoined(e[t]);s&&e.splice(--t,2,s)}return e}(i)}}function D(e,t,s,i){const l=e.textNode||(s?e.nodeAfter:e.nodeBefore);if(!l||!l.hasAttribute(t))return e;const n=l.getAttribute(t);return(0,G.findAttributeRangeBound)(e,t,n,s,i)}class N extends e.Plugin{static get pluginName(){return"StyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return["GeneralHtmlSupport",T,P,I,H]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),s=e.plugins.get("StyleUtils"),i=e.config.get("style.definitions"),l=s.normalizeConfig(t,i);e.commands.add("style",new C(e,l)),s.configureGHSDataFilter(l)}}class L extends e.Plugin{static get pluginName(){return"Style"}static get isOfficialPlugin(){return!0}static get requires(){return[N,B]}}})(),(window.CKEditor5=window.CKEditor5||{}).style=i})();
package/dist/index.js CHANGED
@@ -10,6 +10,8 @@ import { findAttributeRange, findAttributeRangeBound } from '@ckeditor/ckeditor5
10
10
 
11
11
  /**
12
12
  * A class representing an individual button (style) in the grid. Renders a rich preview of the style.
13
+ *
14
+ * @internal
13
15
  */ class StyleGridButtonView extends ButtonView {
14
16
  /**
15
17
  * Definition of the style the button will apply when executed.
@@ -65,6 +67,8 @@ import { findAttributeRange, findAttributeRangeBound } from '@ckeditor/ckeditor5
65
67
  /**
66
68
  * A class representing a grid of styles ({@link module:style/ui/stylegridbuttonview~StyleGridButtonView buttons}).
67
69
  * Allows users to select a style.
70
+ *
71
+ * @internal
68
72
  */ class StyleGridView extends View {
69
73
  /**
70
74
  * Tracks information about the DOM focus in the view.
@@ -149,6 +153,8 @@ import { findAttributeRange, findAttributeRangeBound } from '@ckeditor/ckeditor5
149
153
  * A class representing a group of styles (e.g. "block" or "inline").
150
154
  *
151
155
  * Renders a {@link module:style/ui/stylegridview~StyleGridView style grid} and a label.
156
+ *
157
+ * @internal
152
158
  */ class StyleGroupView extends View {
153
159
  /**
154
160
  * The styles grid of the group.
@@ -188,6 +194,8 @@ import { findAttributeRange, findAttributeRangeBound } from '@ckeditor/ckeditor5
188
194
  /**
189
195
  * A class representing a panel with available content styles. It renders styles in button grids, grouped
190
196
  * in categories.
197
+ *
198
+ * @internal
191
199
  */ class StylePanelView extends View {
192
200
  /**
193
201
  * Tracks information about DOM focus in the panel.
@@ -715,13 +723,13 @@ class StyleUtils extends Plugin {
715
723
  *
716
724
  * If the command value already contains the requested style, it will remove the style classes. Otherwise, it will set it.
717
725
  *
718
- * The execution result differs, depending on the {@link module:engine/model/document~Document#selection} and the
726
+ * The execution result differs, depending on the {@link module:engine/model/document~ModelDocument#selection} and the
719
727
  * style type (inline or block):
720
728
  *
721
729
  * * When applying inline styles:
722
730
  * * If the selection is on a range, the command applies the style classes to all nodes in that range.
723
731
  * * If the selection is collapsed in a non-empty node, the command applies the style classes to the
724
- * {@link module:engine/model/document~Document#selection}.
732
+ * {@link module:engine/model/document~ModelDocument#selection}.
725
733
  *
726
734
  * * When applying block styles:
727
735
  * * If the selection is on a range, the command applies the style classes to the nearest block parent element.
@@ -1332,5 +1340,5 @@ class LinkStyleSupport extends Plugin {
1332
1340
  }
1333
1341
  }
1334
1342
 
1335
- export { Style, StyleEditing, StyleUI, StyleUtils };
1343
+ export { LinkStyleSupport, ListStyleSupport, Style, StyleCommand, StyleEditing, StyleUI, StyleUtils, TableStyleSupport, StyleGridButtonView as _StyleGridButtonView, StyleGridView as _StyleGridView, StyleGroupView as _StyleGroupView, StylePanelView as _StylePanelView };
1336
1344
  //# sourceMappingURL=index.js.map