@ckeditor/ckeditor5-style 36.0.0 → 37.0.0-alpha.0
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 +1 -1
- package/package.json +44 -38
- package/src/index.d.ts +11 -0
- package/src/index.js +1 -2
- package/src/style.d.ts +29 -0
- package/src/style.js +12 -101
- package/src/stylecommand.d.ts +87 -0
- package/src/stylecommand.js +194 -249
- package/src/styleconfig.d.ts +97 -0
- package/src/styleconfig.js +5 -0
- package/src/styleediting.d.ts +41 -0
- package/src/styleediting.js +45 -59
- package/src/styleui.d.ts +35 -0
- package/src/styleui.js +76 -86
- package/src/styleutils.d.ts +54 -0
- package/src/styleutils.js +62 -0
- package/src/ui/stylegridbuttonview.d.ts +42 -0
- package/src/ui/stylegridbuttonview.js +67 -108
- package/src/ui/stylegridview.d.ts +63 -0
- package/src/ui/stylegridview.js +77 -140
- package/src/ui/stylegroupview.d.ts +35 -0
- package/src/ui/stylegroupview.js +29 -57
- package/src/ui/stylepanelview.d.ts +80 -0
- package/src/ui/stylepanelview.js +84 -180
- package/src/utils.js +0 -57
package/build/style.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
/*!
|
|
3
3
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
4
4
|
* For licensing, see LICENSE.md.
|
|
5
|
-
*/(()=>{var e={529:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var i=s(609),n=s.n(i)()((function(e){return e[1]}));n.push([e.id,".ck.ck-dropdown.ck-style-dropdown.ck-style-dropdown_multiple-active>.ck-button>.ck-button__label{font-style:italic}",""]);const l=n},945:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var i=s(609),n=s.n(i)()((function(e){return e[1]}));n.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 l=n},561:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var i=s(609),n=s.n(i)()((function(e){return e[1]}));n.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 l=n},662:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var i=s(609),n=s.n(i)()((function(e){return e[1]}));n.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 l=n},609:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var s=e(t);return t[2]?"@media ".concat(t[2]," {").concat(s,"}"):s})).join("")},t.i=function(e,s,i){"string"==typeof e&&(e=[[null,e,""]]);var n={};if(i)for(var l=0;l<this.length;l++){var o=this[l][0];null!=o&&(n[o]=!0)}for(var r=0;r<e.length;r++){var c=[].concat(e[r]);i&&n[c[0]]||(s&&(c[2]?c[2]="".concat(s," and ").concat(c[2]):c[2]=s),t.push(c))}},t}},62:(e,t,s)=>{"use strict";var i,n=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},l=function(){var e={};return function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}e[t]=s}return e[t]}}(),o=[];function r(e){for(var t=-1,s=0;s<o.length;s++)if(o[s].identifier===e){t=s;break}return t}function c(e,t){for(var s={},i=[],n=0;n<e.length;n++){var l=e[n],c=t.base?l[0]+t.base:l[0],a=s[c]||0,d="".concat(c," ").concat(a);s[c]=a+1;var u=r(d),h={css:l[1],media:l[2],sourceMap:l[3]};-1!==u?(o[u].references++,o[u].updater(h)):o.push({identifier:d,updater:g(h,t),references:1}),i.push(d)}return i}function a(e){var t=document.createElement("style"),i=e.attributes||{};if(void 0===i.nonce){var n=s.nc;n&&(i.nonce=n)}if(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),"function"==typeof e.insert)e.insert(t);else{var o=l(e.insert||"head");if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function h(e,t,s,i){var n=s?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(e.styleSheet)e.styleSheet.cssText=u(t,n);else{var l=document.createTextNode(n),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(l,o[t]):e.appendChild(l)}}function k(e,t,s){var i=s.css,n=s.media,l=s.sourceMap;if(n?e.setAttribute("media",n):e.removeAttribute("media"),l&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(l))))," */")),e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}var y=null,b=0;function g(e,t){var s,i,n;if(t.singleton){var l=b++;s=y||(y=a(t)),i=h.bind(null,s,l,!1),n=h.bind(null,s,l,!0)}else s=a(t),i=k.bind(null,s,t),n=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(s)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else n()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=n());var s=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var i=0;i<s.length;i++){var n=r(s[i]);o[n].references--}for(var l=c(e,t),a=0;a<s.length;a++){var d=r(s[a]);0===o[d].references&&(o[d].updater(),o.splice(d,1))}s=l}}}},704:(e,t,s)=>{e.exports=s(79)("./src/core.js")},273:(e,t,s)=>{e.exports=s(79)("./src/ui.js")},209:(e,t,s)=>{e.exports=s(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function s(i){var n=t[i];if(void 0!==n)return n.exports;var l=t[i]={id:i,exports:{}};return e[i](l,l.exports,s),l.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})},s.nc=void 0;var i={};(()=>{"use strict";s.r(i),s.d(i,{Style:()=>V,StyleEditing:()=>x,StyleUI:()=>w});var e=s(704),t=s(273),n=s(209);const l=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class o extends t.ButtonView{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{element:e,classes:s}=this.styleDefinition,i=new t.View(this.locale);return i.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[{tag:this._isPreviewable(e)?e:"div",attributes:{class:s},children:[{text:"AaBbCcDdEeFfGgHhIiJj"}]}]}),i}_isPreviewable(e){return!l.includes(e)}}var r=s(62),c=s.n(r),a=s(945),d={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(a.Z,d);a.Z.locals;class u extends t.View{constructor(e,t){super(e),this.focusTracker=new n.FocusTracker,this.keystrokes=new n.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 o(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 h=s(561),k={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(h.Z,k);h.Z.locals;class y extends t.View{constructor(e,s,i){super(e),this.labelView=new t.LabelView(e),this.labelView.text=s,this.gridView=new u(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 b=s(662),g={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(b.Z,g);b.Z.locals;class p extends t.View{constructor(e,s){super(e);const i=e.t;this.focusTracker=new n.FocusTracker,this.keystrokes=new n.KeystrokeHandler,this.children=this.createCollection(),this.blockStylesGroupView=new y(e,i("Block styles"),s.block),this.inlineStylesGroupView=new y(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),this.inlineStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this),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()}}function f(e,t=[]){const s={block:[],inline:[]};for(const i of t){const t=[],n=[];for(const s of e.getDefinitionsForView(i.element))s.isBlock?t.push(s.model):n.push(s.model);t.length?s.block.push({...i,modelElements:t,isBlock:!0}):s.inline.push({...i,ghsAttributes:n})}return s}var m=s(529),v={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(m.Z,v);m.Z.locals;class w extends e.Plugin{static get pluginName(){return"StyleUI"}init(){const e=this.editor,s=f(e.plugins.get("DataSchema"),e.config.get("style.definitions"));e.ui.componentFactory.add("style",(i=>{const n=i.t,l=(0,t.createDropdown)(i),o=e.commands.get("style");return l.once("change:isOpen",(()=>{const e=new p(i,s);l.panelView.children.add(e),e.delegate("execute").to(l),e.bind("activeStyles").to(o,"value"),e.bind("enabledStyles").to(o,"enabledStyles")})),l.bind("isEnabled").to(o),l.buttonView.withText=!0,l.buttonView.bind("label").to(o,"value",(e=>e.length>1?n("Multiple styles"):1===e.length?e[0]:n("Styles"))),l.bind("class").to(o,"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 _ extends e.Command{constructor(e,t){super(e),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=t}refresh(){const e=this.editor.model,t=e.document.selection,s=new Set,i=new Set;for(const n of this._styleDefinitions.inline)for(const l of n.ghsAttributes){e.schema.checkAttributeInSelection(t,l)&&i.add(n.name);S(this._getValueFromFirstAllowedNode(l),n.classes)&&s.add(n.name)}const l=(0,n.first)(t.getSelectedBlocks());if(l){const t=l.getAncestors({includeSelf:!0,parentFirst:!0});for(const n of t){if(e.schema.isLimit(n))break;if(e.schema.checkAttribute(n,"htmlAttributes"))for(const e of this._styleDefinitions.block){if(!e.modelElements.includes(n.name))continue;i.add(e.name);S(n.getAttribute("htmlAttributes"),e.classes)&&s.add(e.name)}}}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,n.logWarning)("style-command-executed-with-incorrect-style-name");const s=this.editor.model,i=s.document.selection,l=this.editor.plugins.get("GeneralHtmlSupport"),o=[...this._styleDefinitions.inline,...this._styleDefinitions.block].find((({name:t})=>t==e)),r=void 0===t?!this.value.includes(o.name):t;s.change((()=>{let e;e=o.isBlock?function(e,t,s){const i=new Set;for(const n of e){const e=n.getAncestors({includeSelf:!0,parentFirst:!0});for(const n of e){if(s.isLimit(n))break;if(t.includes(n.name)){i.add(n);break}}}return i}(i.getSelectedBlocks(),o.modelElements,s.schema):[i];for(const t of e)r?l.addModelHtmlClass(o.element,o.classes,t):l.removeModelHtmlClass(o.element,o.classes,t)}))}_getValueFromFirstAllowedNode(e){const t=this.editor.model,s=t.schema,i=t.document.selection;if(i.isCollapsed)return i.getAttribute(e);for(const t of i.getRanges())for(const i of t.getItems())if(s.checkAttribute(i,e))return i.getAttribute(e);return null}}function S(e,t){return!(!e||!e.classes)&&t.every((t=>e.classes.includes(t)))}class x extends e.Plugin{static get pluginName(){return"StyleEditing"}static get requires(){return["GeneralHtmlSupport"]}init(){const e=this.editor,t=f(e.plugins.get("DataSchema"),e.config.get("style.definitions"));e.commands.add("style",new _(e,t)),this._configureGHSDataFilter(t)}_configureGHSDataFilter({block:e,inline:t}){const s=this.editor.plugins.get("DataFilter");s.loadAllowedConfig(e.map(T)),s.loadAllowedConfig(t.map(T))}}function T({element:e,classes:t}){return{name:e,classes:t}}class V extends e.Plugin{static get pluginName(){return"Style"}static get requires(){return[x,w]}}})(),(window.CKEditor5=window.CKEditor5||{}).style=i})();
|
|
5
|
+
*/(()=>{var e={529:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var n=s(609),i=s.n(n)()((function(e){return e[1]}));i.push([e.id,".ck.ck-dropdown.ck-style-dropdown.ck-style-dropdown_multiple-active>.ck-button>.ck-button__label{font-style:italic}",""]);const l=i},945:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var n=s(609),i=s.n(n)()((function(e){return e[1]}));i.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 l=i},561:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var n=s(609),i=s.n(n)()((function(e){return e[1]}));i.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 l=i},662:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var n=s(609),i=s.n(n)()((function(e){return e[1]}));i.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 l=i},609:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var s=e(t);return t[2]?"@media ".concat(t[2]," {").concat(s,"}"):s})).join("")},t.i=function(e,s,n){"string"==typeof e&&(e=[[null,e,""]]);var i={};if(n)for(var l=0;l<this.length;l++){var r=this[l][0];null!=r&&(i[r]=!0)}for(var o=0;o<e.length;o++){var c=[].concat(e[o]);n&&i[c[0]]||(s&&(c[2]?c[2]="".concat(s," and ").concat(c[2]):c[2]=s),t.push(c))}},t}},62:(e,t,s)=>{"use strict";var n,i=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},l=function(){var e={};return function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}e[t]=s}return e[t]}}(),r=[];function o(e){for(var t=-1,s=0;s<r.length;s++)if(r[s].identifier===e){t=s;break}return t}function c(e,t){for(var s={},n=[],i=0;i<e.length;i++){var l=e[i],c=t.base?l[0]+t.base:l[0],a=s[c]||0,d="".concat(c," ").concat(a);s[c]=a+1;var u=o(d),h={css:l[1],media:l[2],sourceMap:l[3]};-1!==u?(r[u].references++,r[u].updater(h)):r.push({identifier:d,updater:b(h,t),references:1}),n.push(d)}return n}function a(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var i=s.nc;i&&(n.nonce=i)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var r=l(e.insert||"head");if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function h(e,t,s,n){var i=s?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=u(t,i);else{var l=document.createTextNode(i),r=e.childNodes;r[t]&&e.removeChild(r[t]),r.length?e.insertBefore(l,r[t]):e.appendChild(l)}}function y(e,t,s){var n=s.css,i=s.media,l=s.sourceMap;if(i?e.setAttribute("media",i):e.removeAttribute("media"),l&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(l))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var k=null,g=0;function b(e,t){var s,n,i;if(t.singleton){var l=g++;s=k||(k=a(t)),n=h.bind(null,s,l,!1),i=h.bind(null,s,l,!0)}else s=a(t),n=y.bind(null,s,t),i=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(s)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else i()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=i());var s=c(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<s.length;n++){var i=o(s[n]);r[i].references--}for(var l=c(e,t),a=0;a<s.length;a++){var d=o(s[a]);0===r[d].references&&(r[d].updater(),r.splice(d,1))}s=l}}}},704:(e,t,s)=>{e.exports=s(79)("./src/core.js")},273:(e,t,s)=>{e.exports=s(79)("./src/ui.js")},209:(e,t,s)=>{e.exports=s(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function s(n){var i=t[n];if(void 0!==i)return i.exports;var l=t[n]={id:n,exports:{}};return e[n](l,l.exports,s),l.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 n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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})},s.nc=void 0;var n={};(()=>{"use strict";s.r(n),s.d(n,{Style:()=>C,StyleEditing:()=>T,StyleUI:()=>w,StyleUtils:()=>p});var e=s(704),t=s(273),i=s(209);const l=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class r extends t.ButtonView{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{element:e,classes:s}=this.styleDefinition,n=new t.View(this.locale);return n.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[{tag:this._isPreviewable(e)?e:"div",attributes:{class:s},children:[{text:"AaBbCcDdEeFfGgHhIiJj"}]}]}),n}_isPreviewable(e){return!l.includes(e)}}var o=s(62),c=s.n(o),a=s(945),d={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(a.Z,d);a.Z.locals;class u extends t.View{constructor(e,t){super(e),this.focusTracker=new i.FocusTracker,this.keystrokes=new i.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 r(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 h=s(561),y={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(h.Z,y);h.Z.locals;class k extends t.View{constructor(e,s,n){super(e),this.labelView=new t.LabelView(e),this.labelView.text=s,this.gridView=new u(e,n),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 g=s(662),b={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(g.Z,b);g.Z.locals;class f extends t.View{constructor(e,s){super(e);const n=e.t;this.focusTracker=new i.FocusTracker,this.keystrokes=new i.KeystrokeHandler,this.children=this.createCollection(),this.blockStylesGroupView=new k(e,n("Block styles"),s.block),this.inlineStylesGroupView=new k(e,n("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()}}class p extends e.Plugin{static get pluginName(){return"StyleUtils"}normalizeConfig(e,t=[]){const s={block:[],inline:[]};for(const n of t){const t=[],i=[];for(const s of e.getDefinitionsForView(n.element))s.isBlock?t.push(s.model):i.push(s.model);t.length?s.block.push({...n,modelElements:t,isBlock:!0}):s.inline.push({...n,ghsAttributes:i})}return s}}var m=s(529),v={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};c()(m.Z,v);m.Z.locals;class w extends e.Plugin{static get pluginName(){return"StyleUI"}static get requires(){return[p]}init(){const e=this.editor,s=e.plugins.get("DataSchema"),n=e.plugins.get("StyleUtils"),i=e.config.get("style.definitions"),l=n.normalizeConfig(s,i);e.ui.componentFactory.add("style",(s=>{const n=s.t,i=(0,t.createDropdown)(s),r=e.commands.get("style");return i.once("change:isOpen",(()=>{const e=new f(s,l);i.panelView.children.add(e),e.delegate("execute").to(i),e.bind("activeStyles").to(r,"value"),e.bind("enabledStyles").to(r,"enabledStyles")})),i.bind("isEnabled").to(r),i.buttonView.withText=!0,i.buttonView.bind("label").to(r,"value",(e=>e.length>1?n("Multiple styles"):1===e.length?e[0]:n("Styles"))),i.bind("class").to(r,"value",(e=>{const t=["ck-style-dropdown"];return e.length>1&&t.push("ck-style-dropdown_multiple-active"),t.join(" ")})),i.on("execute",(t=>{e.execute("style",{styleName:t.source.styleDefinition.name}),e.editing.view.focus()})),i}))}}const _=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};class S extends e.Command{constructor(e,t){super(e),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=t}refresh(){const e=this.editor.model,t=e.document.selection,s=new Set,n=new Set;for(const i of this._styleDefinitions.inline)for(const l of i.ghsAttributes){e.schema.checkAttributeInSelection(t,l)&&n.add(i.name);x(this._getValueFromFirstAllowedNode(l),i.classes)&&s.add(i.name)}const l=(0,i.first)(t.getSelectedBlocks());if(l){const t=l.getAncestors({includeSelf:!0,parentFirst:!0});for(const i of t){if(e.schema.isLimit(i))break;if(e.schema.checkAttribute(i,"htmlAttributes"))for(const e of this._styleDefinitions.block){if(!e.modelElements.includes(i.name))continue;n.add(e.name);x(i.getAttribute("htmlAttributes"),e.classes)&&s.add(e.name)}}}this.enabledStyles=Array.from(n).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,i.logWarning)("style-command-executed-with-incorrect-style-name");const s=this.editor.model,n=s.document.selection,l=this.editor.plugins.get("GeneralHtmlSupport"),r=[...this._styleDefinitions.inline,...this._styleDefinitions.block].find((({name:t})=>t==e)),o=void 0===t?!this.value.includes(r.name):t;s.change((()=>{let e;e=function(e){return"isBlock"in e}(r)?function(e,t,s){const n=new Set;for(const i of e){const e=i.getAncestors({includeSelf:!0,parentFirst:!0});for(const i of e){if(s.isLimit(i))break;if(t.includes(i.name)){n.add(i);break}}}return n}(n.getSelectedBlocks(),r.modelElements,s.schema):[n];for(const t of e)o?l.addModelHtmlClass(r.element,r.classes,t):l.removeModelHtmlClass(r.element,r.classes,t)}))}_getValueFromFirstAllowedNode(e){const t=this.editor.model,s=t.schema,n=t.document.selection;if(n.isCollapsed)return n.getAttribute(e);for(const t of n.getRanges())for(const n of t.getItems())if(s.checkAttribute(n,e))return n.getAttribute(e);return null}}function x(e,t){return _(e)&&(s=e,Boolean(s.classes)&&Array.isArray(s.classes))&&t.every((t=>e.classes.includes(t)));var s}class T extends e.Plugin{static get pluginName(){return"StyleEditing"}static get requires(){return["GeneralHtmlSupport",p]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),s=e.plugins.get("StyleUtils"),n=e.config.get("style.definitions"),i=s.normalizeConfig(t,n);e.commands.add("style",new S(e,i)),this._configureGHSDataFilter(i)}_configureGHSDataFilter({block:e,inline:t}){const s=this.editor.plugins.get("DataFilter");s.loadAllowedConfig(e.map(V)),s.loadAllowedConfig(t.map(V))}}function V({element:e,classes:t}){return{name:e,classes:t}}class C extends e.Plugin{static get pluginName(){return"Style"}static get requires(){return[T,w]}}})(),(window.CKEditor5=window.CKEditor5||{}).style=n})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-style",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0-alpha.0",
|
|
4
4
|
"description": "Style feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,42 +12,44 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "^
|
|
15
|
+
"ckeditor5": "^37.0.0-alpha.0",
|
|
16
|
+
"lodash-es": "^4.17.15"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@ckeditor/ckeditor5-alignment": "^
|
|
19
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
20
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
21
|
-
"@ckeditor/ckeditor5-cloud-services": "^
|
|
22
|
-
"@ckeditor/ckeditor5-code-block": "^
|
|
23
|
-
"@ckeditor/ckeditor5-core": "^
|
|
24
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
25
|
-
"@ckeditor/ckeditor5-easy-image": "^
|
|
26
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
27
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
28
|
-
"@ckeditor/ckeditor5-font": "^
|
|
29
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
30
|
-
"@ckeditor/ckeditor5-highlight": "^
|
|
31
|
-
"@ckeditor/ckeditor5-horizontal-line": "^
|
|
32
|
-
"@ckeditor/ckeditor5-html-embed": "^
|
|
33
|
-
"@ckeditor/ckeditor5-html-support": "^
|
|
34
|
-
"@ckeditor/ckeditor5-image": "^
|
|
35
|
-
"@ckeditor/ckeditor5-indent": "^
|
|
36
|
-
"@ckeditor/ckeditor5-language": "^
|
|
37
|
-
"@ckeditor/ckeditor5-link": "^
|
|
38
|
-
"@ckeditor/ckeditor5-list": "^
|
|
39
|
-
"@ckeditor/ckeditor5-mention": "^
|
|
40
|
-
"@ckeditor/ckeditor5-page-break": "^
|
|
41
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
42
|
-
"@ckeditor/ckeditor5-paste-from-office": "^
|
|
43
|
-
"@ckeditor/ckeditor5-remove-format": "^
|
|
44
|
-
"@ckeditor/ckeditor5-source-editing": "^
|
|
45
|
-
"@ckeditor/ckeditor5-table": "^
|
|
46
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
47
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
48
|
-
"@ckeditor/ckeditor5-ui": "^
|
|
49
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
50
|
-
"@ckeditor/ckeditor5-word-count": "^
|
|
19
|
+
"@ckeditor/ckeditor5-alignment": "^37.0.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-cloud-services": "^37.0.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-code-block": "^37.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
|
25
|
+
"@ckeditor/ckeditor5-dev-utils": "^34.0.0",
|
|
26
|
+
"@ckeditor/ckeditor5-easy-image": "^37.0.0-alpha.0",
|
|
27
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
|
|
28
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
|
29
|
+
"@ckeditor/ckeditor5-font": "^37.0.0-alpha.0",
|
|
30
|
+
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
|
|
31
|
+
"@ckeditor/ckeditor5-highlight": "^37.0.0-alpha.0",
|
|
32
|
+
"@ckeditor/ckeditor5-horizontal-line": "^37.0.0-alpha.0",
|
|
33
|
+
"@ckeditor/ckeditor5-html-embed": "^37.0.0-alpha.0",
|
|
34
|
+
"@ckeditor/ckeditor5-html-support": "^37.0.0-alpha.0",
|
|
35
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
|
|
36
|
+
"@ckeditor/ckeditor5-indent": "^37.0.0-alpha.0",
|
|
37
|
+
"@ckeditor/ckeditor5-language": "^37.0.0-alpha.0",
|
|
38
|
+
"@ckeditor/ckeditor5-link": "^37.0.0-alpha.0",
|
|
39
|
+
"@ckeditor/ckeditor5-list": "^37.0.0-alpha.0",
|
|
40
|
+
"@ckeditor/ckeditor5-mention": "^37.0.0-alpha.0",
|
|
41
|
+
"@ckeditor/ckeditor5-page-break": "^37.0.0-alpha.0",
|
|
42
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
|
43
|
+
"@ckeditor/ckeditor5-paste-from-office": "^37.0.0-alpha.0",
|
|
44
|
+
"@ckeditor/ckeditor5-remove-format": "^37.0.0-alpha.0",
|
|
45
|
+
"@ckeditor/ckeditor5-source-editing": "^37.0.0-alpha.0",
|
|
46
|
+
"@ckeditor/ckeditor5-table": "^37.0.0-alpha.0",
|
|
47
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
|
|
48
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
|
49
|
+
"@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0",
|
|
50
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
|
|
51
|
+
"@ckeditor/ckeditor5-word-count": "^37.0.0-alpha.0",
|
|
52
|
+
"typescript": "^4.8.4",
|
|
51
53
|
"webpack": "^5.58.1",
|
|
52
54
|
"webpack-cli": "^4.9.0"
|
|
53
55
|
},
|
|
@@ -66,13 +68,17 @@
|
|
|
66
68
|
},
|
|
67
69
|
"files": [
|
|
68
70
|
"lang",
|
|
69
|
-
"src",
|
|
71
|
+
"src/**/*.js",
|
|
72
|
+
"src/**/*.d.ts",
|
|
70
73
|
"theme",
|
|
71
74
|
"build",
|
|
72
75
|
"ckeditor5-metadata.json",
|
|
73
76
|
"CHANGELOG.md"
|
|
74
77
|
],
|
|
75
78
|
"scripts": {
|
|
76
|
-
"dll:build": "webpack"
|
|
77
|
-
|
|
79
|
+
"dll:build": "webpack",
|
|
80
|
+
"build": "tsc -p ./tsconfig.release.json",
|
|
81
|
+
"postversion": "npm run build"
|
|
82
|
+
},
|
|
83
|
+
"types": "src/index.d.ts"
|
|
78
84
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module style
|
|
7
|
+
*/
|
|
8
|
+
export { default as Style } from './style';
|
|
9
|
+
export { default as StyleEditing } from './styleediting';
|
|
10
|
+
export { default as StyleUI } from './styleui';
|
|
11
|
+
export { default as StyleUtils } from './styleutils';
|
package/src/index.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module style
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
export { default as Style } from './style';
|
|
11
9
|
export { default as StyleEditing } from './styleediting';
|
|
12
10
|
export { default as StyleUI } from './styleui';
|
|
11
|
+
export { default as StyleUtils } from './styleutils';
|
package/src/style.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module style/style
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The style plugin.
|
|
11
|
+
*
|
|
12
|
+
* This is a "glue" plugin that loads the {@link module:style/styleediting~StyleEditing style editing feature}
|
|
13
|
+
* and {@link module:style/styleui~StyleUI style UI feature}.
|
|
14
|
+
*/
|
|
15
|
+
export default class Style extends Plugin {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static get pluginName(): 'Style';
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get requires(): PluginDependencies;
|
|
24
|
+
}
|
|
25
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
26
|
+
interface PluginsMap {
|
|
27
|
+
[Style.pluginName]: Style;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/style.js
CHANGED
|
@@ -2,118 +2,29 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module style/style
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import StyleUI from './styleui';
|
|
13
10
|
import StyleEditing from './styleediting';
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* The style plugin.
|
|
17
13
|
*
|
|
18
14
|
* This is a "glue" plugin that loads the {@link module:style/styleediting~StyleEditing style editing feature}
|
|
19
15
|
* and {@link module:style/styleui~StyleUI style UI feature}.
|
|
20
|
-
*
|
|
21
|
-
* @extends module:core/plugin~Plugin
|
|
22
16
|
*/
|
|
23
17
|
export default class Style extends Plugin {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName() {
|
|
22
|
+
return 'Style';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires() {
|
|
28
|
+
return [StyleEditing, StyleUI];
|
|
29
|
+
}
|
|
37
30
|
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The configuration of the {@link module:style/style~Style} feature.
|
|
41
|
-
*
|
|
42
|
-
* Read more in {@link module:style/style~StyleConfig}.
|
|
43
|
-
*
|
|
44
|
-
* @member {module:style/style~StyleConfig} module:core/editor/editorconfig~EditorConfig#style
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The configuration of the style feature.
|
|
49
|
-
*
|
|
50
|
-
* ClassicEditor
|
|
51
|
-
* .create( {
|
|
52
|
-
* style: ... // Style feature config.
|
|
53
|
-
* } )
|
|
54
|
-
* .then( ... )
|
|
55
|
-
* .catch( ... );
|
|
56
|
-
*
|
|
57
|
-
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
58
|
-
*
|
|
59
|
-
* @interface StyleConfig
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The available style definitions.
|
|
64
|
-
*
|
|
65
|
-
* Style definitions are displayed in the `'style'` UI dropdown and get applied by the
|
|
66
|
-
* {@link module:style/stylecommand~StyleCommand style command} to the content of the document.
|
|
67
|
-
*
|
|
68
|
-
* In the `'style'` UI dropdown, definitions are automatically grouped into two categories based on the of the `element` property:
|
|
69
|
-
*
|
|
70
|
-
* * **Block styles**: Can be applied to entire {@link module:html-support/dataschema~DataSchema#registerBlockElement block elements}
|
|
71
|
-
* only (e.g. headings, paragraphs, divs).
|
|
72
|
-
* * **Text styles**: Can by applied to any {@link module:html-support/dataschema~DataSchema#registerInlineElement text} in any element
|
|
73
|
-
* in the document.
|
|
74
|
-
*
|
|
75
|
-
* An example configuration:
|
|
76
|
-
*
|
|
77
|
-
* [
|
|
78
|
-
* // Definitions of block styles.
|
|
79
|
-
* {
|
|
80
|
-
* name: 'Red heading',
|
|
81
|
-
* element: 'h2',
|
|
82
|
-
* classes: [ 'red-heading' ]
|
|
83
|
-
* },
|
|
84
|
-
* {
|
|
85
|
-
* name: 'Vibrant code',
|
|
86
|
-
* element: 'pre',
|
|
87
|
-
* classes: [ 'vibrant-code' ]
|
|
88
|
-
* },
|
|
89
|
-
*
|
|
90
|
-
* // Definitions of text (inline) styles.
|
|
91
|
-
* {
|
|
92
|
-
* name: 'Marker',
|
|
93
|
-
* element: 'span',
|
|
94
|
-
* classes: [ 'marker' ]
|
|
95
|
-
* },
|
|
96
|
-
* // ...
|
|
97
|
-
* ]
|
|
98
|
-
*
|
|
99
|
-
* **Note**: Configuring style definitions will automatically configure the
|
|
100
|
-
* {@glink features/general-html-support General HTML Support feature}. **You do not need to repeat the configuration in
|
|
101
|
-
* {@link module:html-support/generalhtmlsupport~GeneralHtmlSupportConfig}**.
|
|
102
|
-
*
|
|
103
|
-
* @member {Array.<module:style/style~StyleDefinition>} module:style/style~StyleConfig#definitions
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Style definition.
|
|
108
|
-
*
|
|
109
|
-
* An object describing a style definition. It contains the style `name`, `element` name and an array of CSS `classes`.
|
|
110
|
-
*
|
|
111
|
-
* // This style will create <h2 class="foo">...</h2> in the document data.
|
|
112
|
-
* {
|
|
113
|
-
* name: 'Example style',
|
|
114
|
-
* element: 'h2',
|
|
115
|
-
* classes: [ 'foo' ]
|
|
116
|
-
* }
|
|
117
|
-
*
|
|
118
|
-
* @typedef {Object} module:style/style~StyleDefinition
|
|
119
|
-
*/
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
6
|
+
import type { NormalizedStyleDefinitions } from './styleutils';
|
|
7
|
+
/**
|
|
8
|
+
* Style command.
|
|
9
|
+
*
|
|
10
|
+
* Applies and removes styles from selection and elements.
|
|
11
|
+
*/
|
|
12
|
+
export default class StyleCommand extends Command {
|
|
13
|
+
/**
|
|
14
|
+
* Set of currently applied styles on the current selection.
|
|
15
|
+
*
|
|
16
|
+
* Names of styles correspond to the `name` property of
|
|
17
|
+
* {@link module:style/styleconfig~StyleDefinition configured definitions}.
|
|
18
|
+
*
|
|
19
|
+
* @observable
|
|
20
|
+
*/
|
|
21
|
+
value: Array<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Names of enabled styles (styles that can be applied to the current selection).
|
|
24
|
+
*
|
|
25
|
+
* Names of enabled styles correspond to the `name` property of
|
|
26
|
+
* {@link module:style/styleconfig~StyleDefinition configured definitions}.
|
|
27
|
+
*
|
|
28
|
+
* @observable
|
|
29
|
+
*/
|
|
30
|
+
enabledStyles: Array<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Normalized definitions of the styles.
|
|
33
|
+
*/
|
|
34
|
+
private readonly _styleDefinitions;
|
|
35
|
+
/**
|
|
36
|
+
* Creates an instance of the command.
|
|
37
|
+
*
|
|
38
|
+
* @param editor Editor on which this command will be used.
|
|
39
|
+
* @param styleDefinitions Normalized definitions of the styles.
|
|
40
|
+
*/
|
|
41
|
+
constructor(editor: Editor, styleDefinitions: NormalizedStyleDefinitions);
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
45
|
+
refresh(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Executes the command — applies the style classes to the selection or removes it from the selection.
|
|
48
|
+
*
|
|
49
|
+
* If the command value already contains the requested style, it will remove the style classes. Otherwise, it will set it.
|
|
50
|
+
*
|
|
51
|
+
* The execution result differs, depending on the {@link module:engine/model/document~Document#selection} and the
|
|
52
|
+
* style type (inline or block):
|
|
53
|
+
*
|
|
54
|
+
* * When applying inline styles:
|
|
55
|
+
* * If the selection is on a range, the command applies the style classes to all nodes in that range.
|
|
56
|
+
* * If the selection is collapsed in a non-empty node, the command applies the style classes to the
|
|
57
|
+
* {@link module:engine/model/document~Document#selection}.
|
|
58
|
+
*
|
|
59
|
+
* * When applying block styles:
|
|
60
|
+
* * If the selection is on a range, the command applies the style classes to the nearest block parent element.
|
|
61
|
+
*
|
|
62
|
+
* @fires execute
|
|
63
|
+
* @param options Command options.
|
|
64
|
+
* @param options.styleName Style name matching the one defined in the
|
|
65
|
+
* {@link module:style/styleconfig~StyleConfig#definitions configuration}.
|
|
66
|
+
* @param options.forceValue Whether the command should add given style (`true`) or remove it (`false`) from the selection.
|
|
67
|
+
* If not set (default), the command will toggle the style basing on the first selected node. Note, that this will not force
|
|
68
|
+
* setting a style on an element that cannot receive given style.
|
|
69
|
+
*/
|
|
70
|
+
execute({ styleName, forceValue }: {
|
|
71
|
+
styleName: string;
|
|
72
|
+
forceValue?: boolean;
|
|
73
|
+
}): void;
|
|
74
|
+
/**
|
|
75
|
+
* Checks the attribute value of the first node in the selection that allows the attribute.
|
|
76
|
+
* For the collapsed selection, returns the selection attribute.
|
|
77
|
+
*
|
|
78
|
+
* @param attributeName Name of the GHS attribute.
|
|
79
|
+
* @returns The attribute value.
|
|
80
|
+
*/
|
|
81
|
+
private _getValueFromFirstAllowedNode;
|
|
82
|
+
}
|
|
83
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
84
|
+
interface CommandsMap {
|
|
85
|
+
style: StyleCommand;
|
|
86
|
+
}
|
|
87
|
+
}
|