Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-alignment

Package Overview
Dependencies
Maintainers
1
Versions
639
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-alignment - npm Package Compare versions

Comparing version 27.1.0 to 28.0.0

2

build/alignment.js

@@ -5,2 +5,2 @@ /*!

*/
window.CKEditor5=window.CKEditor5||{},window.CKEditor5.alignment=function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){t.exports=n(3)("./src/core.js")},function(t,e,n){t.exports=n(3)("./src/utils.js")},function(t,e,n){t.exports=n(3)("./src/ui.js")},function(t,e){t.exports=CKEditor5.dll},function(t,e,n){"use strict";n.r(e);var i=n(0),o=n(1);const r=["left","right","center","justify"];function a(t){return r.includes(t)}function l(t,e){return"rtl"==e.contentLanguageDirection?"right"===t:"left"===t}function s(t){const e=t.map(t=>{let e;return e="string"==typeof t?{name:t}:t,e}).filter(t=>{const e=!!r.includes(t.name);return e||Object(o.logWarning)("alignment-config-name-not-recognized",{option:t}),e}),n=e.filter(t=>!!t.className).length;if(n&&n<e.length)throw new o.CKEditorError("alignment-config-classnames-are-missing",{configuredOptions:t});return e.forEach((e,n,i)=>{const r=i.slice(n+1);if(r.some(t=>t.name==e.name))throw new o.CKEditorError("alignment-config-name-already-defined",{option:e,configuredOptions:t});if(e.className){if(r.some(t=>t.className==e.className))throw new o.CKEditorError("alignment-config-classname-already-defined",{option:e,configuredOptions:t})}}),e}class c extends i.Command{refresh(){const t=this.editor.locale,e=Object(o.first)(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!e&&this._canBeAligned(e),this.isEnabled&&e.hasAttribute("alignment")?this.value=e.getAttribute("alignment"):this.value="rtl"===t.contentLanguageDirection?"right":"left"}execute(t={}){const e=this.editor,n=e.locale,i=e.model,o=i.document,r=t.value;i.change(t=>{const e=Array.from(o.selection.getSelectedBlocks()).filter(t=>this._canBeAligned(t)),i=e[0].getAttribute("alignment");l(r,n)||i===r||!r?function(t,e){for(const n of t)e.removeAttribute("alignment",n)}(e,t):function(t,e,n){for(const i of t)e.setAttribute("alignment",n,i)}(e,t,r)})}_canBeAligned(t){return this.editor.model.schema.checkAttribute(t,"alignment")}}class u extends i.Plugin{static get pluginName(){return"AlignmentEditing"}constructor(t){super(t),t.config.define("alignment",{options:[...r.map(t=>({name:t}))]})}init(){const t=this.editor,e=t.locale,n=t.model.schema,i=s(t.config.get("alignment.options")).filter(t=>a(t.name)&&!l(t.name,e)),o=i.some(t=>!!t.className);n.extend("$block",{allowAttributes:"alignment"}),t.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),o?t.conversion.attributeToAttribute(function(t){const e={model:{key:"alignment",values:t.map(t=>t.name)},view:{}};for(const n of t)e.view[n.name]={key:"class",value:n.className};return e}(i)):t.conversion.for("downcast").attributeToAttribute(function(t){const e={model:{key:"alignment",values:t.map(t=>t.name)},view:{}};for(const{name:n}of t)e.view[n]={key:"style",value:{"text-align":n}};return e}(i));const r=function(t){const e=[];for(const{name:n}of t)e.push({view:{key:"style",value:{"text-align":n}},model:{key:"alignment",value:n}});return e}(i);for(const e of r)t.conversion.for("upcast").attributeToAttribute(e);t.commands.add("alignment",new c(t))}}var g=n(2);const d=new Map([["left",i.icons.alignLeft],["right",i.icons.alignRight],["center",i.icons.alignCenter],["justify",i.icons.alignJustify]]);class m extends i.Plugin{get localizedOptionTitles(){const t=this.editor.t;return{left:t("Align left"),right:t("Align right"),center:t("Align center"),justify:t("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const t=this.editor,e=t.ui.componentFactory,n=t.t,i=s(t.config.get("alignment.options"));i.map(t=>t.name).filter(a).forEach(t=>this._addButton(t)),e.add("alignment",t=>{const o=Object(g.createDropdown)(t),r=i.map(t=>e.create("alignment:"+t.name));Object(g.addToolbarToDropdown)(o,r),o.buttonView.set({label:n("Text alignment"),tooltip:!0}),o.toolbarView.isVertical=!0,o.toolbarView.ariaLabel=n("Text alignment toolbar"),o.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const a="rtl"===t.contentLanguageDirection?d.get("right"):d.get("left");return o.buttonView.bind("icon").toMany(r,"isOn",(...t)=>{const e=t.findIndex(t=>t);return e<0?a:r[e].icon}),o.bind("isEnabled").toMany(r,"isEnabled",(...t)=>t.some(t=>t)),o})}_addButton(t){const e=this.editor;e.ui.componentFactory.add("alignment:"+t,n=>{const i=e.commands.get("alignment"),o=new g.ButtonView(n);return o.set({label:this.localizedOptionTitles[t],icon:d.get(t),tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(i),o.bind("isOn").to(i,"value",e=>e===t),this.listenTo(o,"execute",()=>{e.execute("alignment",{value:t}),e.editing.view.focus()}),o})}}class f extends i.Plugin{static get requires(){return[u,m]}static get pluginName(){return"Alignment"}}e.default={Alignment:f,AlignmentEditing:u,AlignmentUI:m}}]).default;
window.CKEditor5=window.CKEditor5||{},window.CKEditor5.alignment=function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){t.exports=n(3)("./src/core.js")},function(t,e,n){t.exports=n(3)("./src/utils.js")},function(t,e,n){t.exports=n(3)("./src/ui.js")},function(t,e){t.exports=CKEditor5.dll},function(t,e,n){"use strict";n.r(e);var i=n(0),o=n(1);const r=["left","right","center","justify"];function a(t){return r.includes(t)}function l(t,e){return"rtl"==e.contentLanguageDirection?"right"===t:"left"===t}function s(t){const e=t.map(t=>{let e;return e="string"==typeof t?{name:t}:t,e}).filter(t=>{const e=!!r.includes(t.name);return e||Object(o.logWarning)("alignment-config-name-not-recognized",{option:t}),e}),n=e.filter(t=>!!t.className).length;if(n&&n<e.length)throw new o.CKEditorError("alignment-config-classnames-are-missing",{configuredOptions:t});return e.forEach((e,n,i)=>{const r=i.slice(n+1);if(r.some(t=>t.name==e.name))throw new o.CKEditorError("alignment-config-name-already-defined",{option:e,configuredOptions:t});if(e.className){if(r.some(t=>t.className==e.className))throw new o.CKEditorError("alignment-config-classname-already-defined",{option:e,configuredOptions:t})}}),e}class c extends i.Command{refresh(){const t=this.editor.locale,e=Object(o.first)(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!e&&this._canBeAligned(e),this.isEnabled&&e.hasAttribute("alignment")?this.value=e.getAttribute("alignment"):this.value="rtl"===t.contentLanguageDirection?"right":"left"}execute(t={}){const e=this.editor,n=e.locale,i=e.model,o=i.document,r=t.value;i.change(t=>{const e=Array.from(o.selection.getSelectedBlocks()).filter(t=>this._canBeAligned(t)),i=e[0].getAttribute("alignment");l(r,n)||i===r||!r?function(t,e){for(const n of t)e.removeAttribute("alignment",n)}(e,t):function(t,e,n){for(const i of t)e.setAttribute("alignment",n,i)}(e,t,r)})}_canBeAligned(t){return this.editor.model.schema.checkAttribute(t,"alignment")}}class u extends i.Plugin{static get pluginName(){return"AlignmentEditing"}constructor(t){super(t),t.config.define("alignment",{options:[...r.map(t=>({name:t}))]})}init(){const t=this.editor,e=t.locale,n=t.model.schema,i=s(t.config.get("alignment.options")).filter(t=>a(t.name)&&!l(t.name,e)),o=i.some(t=>!!t.className);n.extend("$block",{allowAttributes:"alignment"}),t.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),o?t.conversion.attributeToAttribute(function(t){const e={model:{key:"alignment",values:t.map(t=>t.name)},view:{}};for(const n of t)e.view[n.name]={key:"class",value:n.className};return e}(i)):t.conversion.for("downcast").attributeToAttribute(function(t){const e={model:{key:"alignment",values:t.map(t=>t.name)},view:{}};for(const{name:n}of t)e.view[n]={key:"style",value:{"text-align":n}};return e}(i));const r=function(t){const e=[];for(const{name:n}of t)e.push({view:{key:"style",value:{"text-align":n}},model:{key:"alignment",value:n}});return e}(i);for(const e of r)t.conversion.for("upcast").attributeToAttribute(e);const u=function(t){const e=[];for(const{name:n}of t)e.push({view:{key:"align",value:n},model:{key:"alignment",value:n}});return e}(i);for(const e of u)t.conversion.for("upcast").attributeToAttribute(e);t.commands.add("alignment",new c(t))}}var g=n(2);const d=new Map([["left",i.icons.alignLeft],["right",i.icons.alignRight],["center",i.icons.alignCenter],["justify",i.icons.alignJustify]]);class m extends i.Plugin{get localizedOptionTitles(){const t=this.editor.t;return{left:t("Align left"),right:t("Align right"),center:t("Align center"),justify:t("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const t=this.editor,e=t.ui.componentFactory,n=t.t,i=s(t.config.get("alignment.options"));i.map(t=>t.name).filter(a).forEach(t=>this._addButton(t)),e.add("alignment",t=>{const o=Object(g.createDropdown)(t),r=i.map(t=>e.create("alignment:"+t.name));Object(g.addToolbarToDropdown)(o,r),o.buttonView.set({label:n("Text alignment"),tooltip:!0}),o.toolbarView.isVertical=!0,o.toolbarView.ariaLabel=n("Text alignment toolbar"),o.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const a="rtl"===t.contentLanguageDirection?d.get("right"):d.get("left");return o.buttonView.bind("icon").toMany(r,"isOn",(...t)=>{const e=t.findIndex(t=>t);return e<0?a:r[e].icon}),o.bind("isEnabled").toMany(r,"isEnabled",(...t)=>t.some(t=>t)),o})}_addButton(t){const e=this.editor;e.ui.componentFactory.add("alignment:"+t,n=>{const i=e.commands.get("alignment"),o=new g.ButtonView(n);return o.set({label:this.localizedOptionTitles[t],icon:d.get(t),tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(i),o.bind("isOn").to(i,"value",e=>e===t),this.listenTo(o,"execute",()=>{e.execute("alignment",{value:t}),e.editing.view.focus()}),o})}}class f extends i.Plugin{static get requires(){return[u,m]}static get pluginName(){return"Alignment"}}e.default={Alignment:f,AlignmentEditing:u,AlignmentUI:m}}]).default;
{
"name": "@ckeditor/ckeditor5-alignment",
"version": "27.1.0",
"version": "28.0.0",
"description": "Text alignment feature for CKEditor 5.",

@@ -14,17 +14,17 @@ "keywords": [

"dependencies": {
"ckeditor5": "^27.1.0"
"ckeditor5": "^28.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-block-quote": "^27.1.0",
"@ckeditor/ckeditor5-core": "^27.1.0",
"@ckeditor/ckeditor5-dev-utils": "^24.0.0",
"@ckeditor/ckeditor5-editor-classic": "^27.1.0",
"@ckeditor/ckeditor5-engine": "^27.1.0",
"@ckeditor/ckeditor5-enter": "^27.1.0",
"@ckeditor/ckeditor5-heading": "^27.1.0",
"@ckeditor/ckeditor5-image": "^27.1.0",
"@ckeditor/ckeditor5-list": "^27.1.0",
"@ckeditor/ckeditor5-paragraph": "^27.1.0",
"@ckeditor/ckeditor5-theme-lark": "^27.1.0",
"@ckeditor/ckeditor5-typing": "^27.1.0",
"@ckeditor/ckeditor5-block-quote": "^28.0.0",
"@ckeditor/ckeditor5-core": "^28.0.0",
"@ckeditor/ckeditor5-dev-utils": "^25.0.0",
"@ckeditor/ckeditor5-editor-classic": "^28.0.0",
"@ckeditor/ckeditor5-engine": "^28.0.0",
"@ckeditor/ckeditor5-enter": "^28.0.0",
"@ckeditor/ckeditor5-heading": "^28.0.0",
"@ckeditor/ckeditor5-image": "^28.0.0",
"@ckeditor/ckeditor5-list": "^28.0.0",
"@ckeditor/ckeditor5-paragraph": "^28.0.0",
"@ckeditor/ckeditor5-theme-lark": "^28.0.0",
"@ckeditor/ckeditor5-typing": "^28.0.0",
"webpack": "^4.43.0",

@@ -31,0 +31,0 @@ "webpack-cli": "^3.3.11"

@@ -10,10 +10,4 @@ /**

import Alignment from './alignment';
import AlignmentEditing from './alignmentediting';
import AlignmentUI from './alignmentui';
export default {
Alignment,
AlignmentEditing,
AlignmentUI
};
export { default as Alignment } from './alignment';
export { default as AlignmentEditing } from './alignmentediting';
export { default as AlignmentUI } from './alignmentui';

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc