@ckeditor/ckeditor5-indent 45.2.1-alpha.4 → 45.2.1-alpha.5

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.
Files changed (2) hide show
  1. package/build/indent.js +1 -1
  2. package/package.json +9 -9
package/build/indent.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 t={237:t=>{"use strict";t.exports=CKEditor5.dll},311:(t,e,n)=>{t.exports=n(237)("./src/ui.js")},355:(t,e,n)=>{t.exports=n(237)("./src/icons.js")},584:(t,e,n)=>{t.exports=n(237)("./src/utils.js")},782:(t,e,n)=>{t.exports=n(237)("./src/core.js")},783:(t,e,n)=>{t.exports=n(237)("./src/engine.js")}},e={};function n(i){var s=e[i];if(void 0!==s)return s.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";n.r(i),n.d(i,{Indent:()=>d,IndentBlock:()=>f,IndentEditing:()=>e,IndentUI:()=>r});var t=n(782);class e extends t.Plugin{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new t.MultiCommand(e)),e.commands.add("outdent",new t.MultiCommand(e))}}var s=n(311),o=n(355);class r extends t.Plugin{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale,n=t.t,i="ltr"==e.uiLanguageDirection?o.IconIndent:o.IconOutdent,s="ltr"==e.uiLanguageDirection?o.IconOutdent:o.IconIndent;this._defineButton("indent",n("Increase indent"),i),this._defineButton("outdent",n("Decrease indent"),s)}_defineButton(t,e,n){const i=this.editor;i.ui.componentFactory.add(t,(()=>{const i=this._createButton(s.ButtonView,t,e,n);return i.set({tooltip:!0}),i})),i.ui.componentFactory.add("menuBar:"+t,(()=>this._createButton(s.MenuBarMenuListItemButtonView,t,e,n)))}_createButton(t,e,n,i){const s=this.editor,o=s.commands.get(e),r=new t(s.locale);return r.set({label:n,icon:i}),r.bind("isEnabled").to(o,"isEnabled"),this.listenTo(r,"execute",(()=>{s.execute(e),s.editing.view.focus()})),r}}class d extends t.Plugin{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[e,r]}}var a=n(783),c=n(584);class l extends t.Command{_indentBehavior;constructor(t,e){super(t),this._indentBehavior=e}refresh(){const t=this.editor.model,e=(0,c.first)(t.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const t=this.editor.model,e=this._getBlocksToChange();t.change((t=>{for(const n of e){const e=n.getAttribute("blockIndent"),i=this._indentBehavior.getNextIndent(e);i?t.setAttribute("blockIndent",i,n):t.removeAttribute("blockIndent",n)}}))}_getBlocksToChange(){const t=this.editor.model.document.selection;return Array.from(t.getSelectedBlocks()).filter((t=>this._isIndentationChangeAllowed(t)))}_isIndentationChangeAllowed(t){const e=this.editor;if(!e.model.schema.checkAttribute(t,"blockIndent"))return!1;if(!e.plugins.has("ListUtils"))return!0;if(!this._indentBehavior.isForward)return!0;return!e.plugins.get("ListUtils").isListItemBlock(t)}}class u{isForward;offset;unit;constructor(t){this.isForward="forward"===t.direction,this.offset=t.offset,this.unit=t.unit}checkEnabled(t){const e=parseFloat(t||"0");return this.isForward||e>0}getNextIndent(t){const e=parseFloat(t||"0");if(!(!t||t.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const n=e+(this.isForward?this.offset:-this.offset);return n>0?n+this.unit:void 0}}class g{isForward;classes;constructor(t){this.isForward="forward"===t.direction,this.classes=t.classes}checkEnabled(t){const e=this.classes.indexOf(t);return this.isForward?e<this.classes.length-1:e>=0}getNextIndent(t){const e=this.classes.indexOf(t),n=this.isForward?1:-1;return this.classes[e+n]}}const h=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class f extends t.Plugin{constructor(t){super(t),t.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.config.get("indentBlock");e.classes&&e.classes.length?(this._setupConversionUsingClasses(e.classes),t.commands.add("indentBlock",new l(t,new g({direction:"forward",classes:e.classes}))),t.commands.add("outdentBlock",new l(t,new g({direction:"backward",classes:e.classes})))):(t.data.addStyleProcessorRules(a.addMarginRules),this._setupConversionUsingOffset(),t.commands.add("indentBlock",new l(t,new u({direction:"forward",offset:e.offset,unit:e.unit}))),t.commands.add("outdentBlock",new l(t,new u({direction:"backward",offset:e.offset,unit:e.unit}))))}afterInit(){const t=this.editor,e=t.model.schema,n=t.commands.get("indent"),i=t.commands.get("outdent"),s=t.config.get("heading.options");(s&&s.map((t=>t.model))||h).forEach((t=>{e.isRegistered(t)&&e.extend(t,{allowAttributes:"blockIndent"})})),e.setAttributeProperties("blockIndent",{isFormatting:!0}),n.registerChildCommand(t.commands.get("indentBlock")),i.registerChildCommand(t.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const t=this.editor.conversion,e="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";t.for("upcast").attributeToAttribute({view:{styles:{[e]:/[\s\S]+/}},model:{key:"blockIndent",value:t=>{if(!t.is("element","li"))return t.getStyle(e)}}}),t.for("downcast").attributeToAttribute({model:"blockIndent",view:t=>({key:"style",value:{[e]:t}})})}_setupConversionUsingClasses(t){const e={model:{key:"blockIndent",values:[]},view:{}};for(const n of t)e.model.values.push(n),e.view[n]={key:"class",value:[n]};this.editor.conversion.attributeToAttribute(e)}}})(),(window.CKEditor5=window.CKEditor5||{}).indent=i})();
5
+ */(()=>{var t={237:t=>{"use strict";t.exports=CKEditor5.dll},311:(t,e,n)=>{t.exports=n(237)("./src/ui.js")},355:(t,e,n)=>{t.exports=n(237)("./src/icons.js")},584:(t,e,n)=>{t.exports=n(237)("./src/utils.js")},782:(t,e,n)=>{t.exports=n(237)("./src/core.js")},783:(t,e,n)=>{t.exports=n(237)("./src/engine.js")}},e={};function n(i){var s=e[i];if(void 0!==s)return s.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";n.r(i),n.d(i,{Indent:()=>d,IndentBlock:()=>f,IndentEditing:()=>e,IndentUI:()=>r});var t=n(782);class e extends t.Plugin{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new t.MultiCommand(e)),e.commands.add("outdent",new t.MultiCommand(e))}}var s=n(311),o=n(355);class r extends t.Plugin{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale,n=t.t,i="ltr"==e.uiLanguageDirection?o.IconIndent:o.IconOutdent,s="ltr"==e.uiLanguageDirection?o.IconOutdent:o.IconIndent;this._defineButton("indent",n("Increase indent"),i),this._defineButton("outdent",n("Decrease indent"),s)}_defineButton(t,e,n){const i=this.editor;i.ui.componentFactory.add(t,()=>{const i=this._createButton(s.ButtonView,t,e,n);return i.set({tooltip:!0}),i}),i.ui.componentFactory.add("menuBar:"+t,()=>this._createButton(s.MenuBarMenuListItemButtonView,t,e,n))}_createButton(t,e,n,i){const s=this.editor,o=s.commands.get(e),r=new t(s.locale);return r.set({label:n,icon:i}),r.bind("isEnabled").to(o,"isEnabled"),this.listenTo(r,"execute",()=>{s.execute(e),s.editing.view.focus()}),r}}class d extends t.Plugin{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[e,r]}}var a=n(783),c=n(584);class l extends t.Command{_indentBehavior;constructor(t,e){super(t),this._indentBehavior=e}refresh(){const t=this.editor.model,e=(0,c.first)(t.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const t=this.editor.model,e=this._getBlocksToChange();t.change(t=>{for(const n of e){const e=n.getAttribute("blockIndent"),i=this._indentBehavior.getNextIndent(e);i?t.setAttribute("blockIndent",i,n):t.removeAttribute("blockIndent",n)}})}_getBlocksToChange(){const t=this.editor.model.document.selection;return Array.from(t.getSelectedBlocks()).filter(t=>this._isIndentationChangeAllowed(t))}_isIndentationChangeAllowed(t){const e=this.editor;if(!e.model.schema.checkAttribute(t,"blockIndent"))return!1;if(!e.plugins.has("ListUtils"))return!0;if(!this._indentBehavior.isForward)return!0;return!e.plugins.get("ListUtils").isListItemBlock(t)}}class u{isForward;offset;unit;constructor(t){this.isForward="forward"===t.direction,this.offset=t.offset,this.unit=t.unit}checkEnabled(t){const e=parseFloat(t||"0");return this.isForward||e>0}getNextIndent(t){const e=parseFloat(t||"0");if(!(!t||t.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const n=e+(this.isForward?this.offset:-this.offset);return n>0?n+this.unit:void 0}}class g{isForward;classes;constructor(t){this.isForward="forward"===t.direction,this.classes=t.classes}checkEnabled(t){const e=this.classes.indexOf(t);return this.isForward?e<this.classes.length-1:e>=0}getNextIndent(t){const e=this.classes.indexOf(t),n=this.isForward?1:-1;return this.classes[e+n]}}const h=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class f extends t.Plugin{constructor(t){super(t),t.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.config.get("indentBlock");e.classes&&e.classes.length?(this._setupConversionUsingClasses(e.classes),t.commands.add("indentBlock",new l(t,new g({direction:"forward",classes:e.classes}))),t.commands.add("outdentBlock",new l(t,new g({direction:"backward",classes:e.classes})))):(t.data.addStyleProcessorRules(a.addMarginRules),this._setupConversionUsingOffset(),t.commands.add("indentBlock",new l(t,new u({direction:"forward",offset:e.offset,unit:e.unit}))),t.commands.add("outdentBlock",new l(t,new u({direction:"backward",offset:e.offset,unit:e.unit}))))}afterInit(){const t=this.editor,e=t.model.schema,n=t.commands.get("indent"),i=t.commands.get("outdent"),s=t.config.get("heading.options");(s&&s.map(t=>t.model)||h).forEach(t=>{e.isRegistered(t)&&e.extend(t,{allowAttributes:"blockIndent"})}),e.setAttributeProperties("blockIndent",{isFormatting:!0}),n.registerChildCommand(t.commands.get("indentBlock")),i.registerChildCommand(t.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const t=this.editor.conversion,e="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";t.for("upcast").attributeToAttribute({view:{styles:{[e]:/[\s\S]+/}},model:{key:"blockIndent",value:t=>{if(!t.is("element","li"))return t.getStyle(e)}}}),t.for("downcast").attributeToAttribute({model:"blockIndent",view:t=>({key:"style",value:{[e]:t}})})}_setupConversionUsingClasses(t){const e={model:{key:"blockIndent",values:[]},view:{}};for(const n of t)e.model.values.push(n),e.view[n]={key:"class",value:[n]};this.editor.conversion.attributeToAttribute(e)}}})(),(window.CKEditor5=window.CKEditor5||{}).indent=i})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-indent",
3
- "version": "45.2.1-alpha.4",
3
+ "version": "45.2.1-alpha.5",
4
4
  "description": "Block indentation feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,14 +13,14 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "45.2.1-alpha.4",
17
- "@ckeditor/ckeditor5-engine": "45.2.1-alpha.4",
18
- "@ckeditor/ckeditor5-icons": "45.2.1-alpha.4",
19
- "@ckeditor/ckeditor5-heading": "45.2.1-alpha.4",
20
- "@ckeditor/ckeditor5-list": "45.2.1-alpha.4",
21
- "@ckeditor/ckeditor5-ui": "45.2.1-alpha.4",
22
- "@ckeditor/ckeditor5-utils": "45.2.1-alpha.4",
23
- "ckeditor5": "45.2.1-alpha.4"
16
+ "@ckeditor/ckeditor5-core": "45.2.1-alpha.5",
17
+ "@ckeditor/ckeditor5-engine": "45.2.1-alpha.5",
18
+ "@ckeditor/ckeditor5-icons": "45.2.1-alpha.5",
19
+ "@ckeditor/ckeditor5-heading": "45.2.1-alpha.5",
20
+ "@ckeditor/ckeditor5-list": "45.2.1-alpha.5",
21
+ "@ckeditor/ckeditor5-ui": "45.2.1-alpha.5",
22
+ "@ckeditor/ckeditor5-utils": "45.2.1-alpha.5",
23
+ "ckeditor5": "45.2.1-alpha.5"
24
24
  },
25
25
  "author": "CKSource (http://cksource.com/)",
26
26
  "license": "SEE LICENSE IN LICENSE.md",