@ckeditor/ckeditor5-indent 44.2.0 → 44.2.1-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.
Files changed (2) hide show
  1. package/build/indent.js +1 -1
  2. package/package.json +8 -8
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={782:(t,e,n)=>{t.exports=n(237)("./src/core.js")},783:(t,e,n)=>{t.exports=n(237)("./src/engine.js")},311:(t,e,n)=>{t.exports=n(237)("./src/ui.js")},584:(t,e,n)=>{t.exports=n(237)("./src/utils.js")},237:t=>{"use strict";t.exports=CKEditor5.dll}},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:()=>r,IndentBlock:()=>h,IndentEditing:()=>e,IndentUI:()=>o});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);class o extends t.Plugin{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,n=e.locale,i=e.t,s="ltr"==n.uiLanguageDirection?t.icons.indent:t.icons.outdent,o="ltr"==n.uiLanguageDirection?t.icons.outdent:t.icons.indent;this._defineButton("indent",i("Increase indent"),s),this._defineButton("outdent",i("Decrease indent"),o)}_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 r extends t.Plugin{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[e,o]}}var d=n(783),a=n(584);class c extends t.Command{constructor(t,e){super(t),this._indentBehavior=e}refresh(){const t=this.editor.model,e=(0,a.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 l{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 u{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 g=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class h 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 c(t,new u({direction:"forward",classes:e.classes}))),t.commands.add("outdentBlock",new c(t,new u({direction:"backward",classes:e.classes})))):(t.data.addStyleProcessorRules(d.addMarginRules),this._setupConversionUsingOffset(),t.commands.add("indentBlock",new c(t,new l({direction:"forward",offset:e.offset,unit:e.unit}))),t.commands.add("outdentBlock",new c(t,new l({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))||g).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")},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:()=>r,IndentBlock:()=>h,IndentEditing:()=>e,IndentUI:()=>o});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);class o extends t.Plugin{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,n=e.locale,i=e.t,s="ltr"==n.uiLanguageDirection?t.icons.indent:t.icons.outdent,o="ltr"==n.uiLanguageDirection?t.icons.outdent:t.icons.indent;this._defineButton("indent",i("Increase indent"),s),this._defineButton("outdent",i("Decrease indent"),o)}_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 r extends t.Plugin{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[e,o]}}var d=n(783),a=n(584);class c extends t.Command{constructor(t,e){super(t),this._indentBehavior=e}refresh(){const t=this.editor.model,e=(0,a.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 l{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 u{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 g=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class h 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 c(t,new u({direction:"forward",classes:e.classes}))),t.commands.add("outdentBlock",new c(t,new u({direction:"backward",classes:e.classes})))):(t.data.addStyleProcessorRules(d.addMarginRules),this._setupConversionUsingOffset(),t.commands.add("indentBlock",new c(t,new l({direction:"forward",offset:e.offset,unit:e.unit}))),t.commands.add("outdentBlock",new c(t,new l({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))||g).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": "44.2.0",
3
+ "version": "44.2.1-alpha.0",
4
4
  "description": "Block indentation feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,13 +13,13 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "44.2.0",
17
- "@ckeditor/ckeditor5-engine": "44.2.0",
18
- "@ckeditor/ckeditor5-heading": "44.2.0",
19
- "@ckeditor/ckeditor5-list": "44.2.0",
20
- "@ckeditor/ckeditor5-ui": "44.2.0",
21
- "@ckeditor/ckeditor5-utils": "44.2.0",
22
- "ckeditor5": "44.2.0"
16
+ "@ckeditor/ckeditor5-core": "44.2.1-alpha.0",
17
+ "@ckeditor/ckeditor5-engine": "44.2.1-alpha.0",
18
+ "@ckeditor/ckeditor5-heading": "44.2.1-alpha.0",
19
+ "@ckeditor/ckeditor5-list": "44.2.1-alpha.0",
20
+ "@ckeditor/ckeditor5-ui": "44.2.1-alpha.0",
21
+ "@ckeditor/ckeditor5-utils": "44.2.1-alpha.0",
22
+ "ckeditor5": "44.2.1-alpha.0"
23
23
  },
24
24
  "author": "CKSource (http://cksource.com/)",
25
25
  "license": "SEE LICENSE IN LICENSE.md",