editorjs-indent-tune
Version:
Block tune for Editor.js
1 lines • 24.4 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.IndentPlugin=e():t.IndentPlugin=e()}(self,(()=>(()=>{"use strict";var t={523:(t,e,n)=>{n.d(e,{A:()=>r});var i=n(314),o=n.n(i)()((function(t){return t[1]}));o.push([t.id,'.ce-popover-indent-item {\r\n cursor: default !important;\r\n display: flex;\r\n align-items: center;\r\n padding: 3px;\r\n}\r\n\r\n.ce-popover-indent-item[version^="2.26"] {\r\n gap: 10px;\r\n}\r\n\r\n.ce-popover-indent-item:hover {\r\n background-color: transparent !important;\r\n}\r\n\r\n.ce-popover-indent-item .ce-popover-item__icon {\r\n width: 26px;\r\n height: 26px;\r\n cursor: pointer;\r\n will-change: background-color, color;\r\n transition: 0.3s background-color, 0.3s color;\r\n padding-block: 0px;\r\n padding-inline: 0px;\r\n border-width: 0px;\r\n color: var(--color-text-primary, black);\r\n background-color: #fff;\r\n border-radius: 5px;\r\n -webkit-border-radius: 5px;\r\n -moz-border-radius: 5px;\r\n -ms-border-radius: 5px;\r\n -o-border-radius: 5px;\r\n -webkit-transition: 0.3s background-color, 0.3s color;\r\n -moz-transition: 0.3s background-color, 0.3s color;\r\n -ms-transition: 0.3s background-color, 0.3s color;\r\n -o-transition: 0.3s background-color, 0.3s color;\r\n}\r\n\r\n.ce-popover-indent-item .ce-popover-item--disabled {\r\n color: var(--color-text-secondary, #707684);\r\n cursor: default;\r\n}\r\n\r\n.ce-popover-indent-item .ce-popover-item__icon:focus {\r\n outline: none;\r\n}\r\n\r\n.ce-popover-indent-item:is([version^="2.26"], [version^="2.27"], [version^="2.28"], [version^="2.29"]):hover .ce-popover-item__icon {\r\n box-shadow: 0 0 0 1px var(--color-border-icon, rgba(201, 201, 204, 0.48)) !important;\r\n -webkit-box-shadow: 0 0 0 1px var(--color-border-icon, rgba(201, 201, 204, 0.48)) !important;\r\n}\r\n\r\n.ce-popover-indent-item:is([version^="2.26"], [version^="2.27"], [version^="2.28"], [version^="2.29"]) .ce-popover-item__icon {\r\n box-shadow: 0 0 0 1px var(--color-border-icon, rgba(201, 201, 204, 0.48)) !important;\r\n -webkit-box-shadow: 0 0 0 1px var(--color-border-icon, rgba(201, 201, 204, 0.48)) !important;\r\n}\r\n\r\n.ce-popover-indent-item:is([version^="2.26"], [version^="2.27"], [version^="2.28"], [version^="2.29"]) .ce-popover-item__icon:hover {\r\n background-color: var(--color-background-item-hover, #eff2f5);\r\n}\r\n\r\n[data-block-indent-wrapper] {\r\n /* will-change: padding-left, padding-right;\r\n transition: padding-left .4s, padding-right .4s;\r\n -webkit-transition: padding-left .4s, padding-right .4s;\r\n -moz-transition: padding-left .4s, padding-right .4s;\r\n -ms-transition: padding-left .4s, padding-right .4s;\r\n -o-transition: padding-left .4s, padding-right .4s; */\r\n}\r\n\r\n.ce-highlight-indent {\r\n display: inline-block;\r\n height: 1.6em;\r\n top: 50%;\r\n position: absolute;\r\n transform: translate(0px, -50%);\r\n -webkit-transform: translate(0px, -50%);\r\n -moz-transform: translate(0px, -50%);\r\n -ms-transform: translate(0px, -50%);\r\n -o-transform: translate(0px, -50%);\r\n}\r\n\r\n\r\n.ce-popover-indent-item[version^="2.3"] .ce-popover-item__title {\r\n margin-left: 4px;\r\n}',""]);const r=o},314:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=t(e);return e[2]?"@media ".concat(e[2]," {").concat(n,"}"):n})).join("")},e.i=function(t,n,i){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(i)for(var r=0;r<this.length;r++){var a=this[r][0];null!=a&&(o[a]=!0)}for(var c=0;c<t.length;c++){var l=[].concat(t[c]);i&&o[l[0]]||(n&&(l[2]?l[2]="".concat(n," and ").concat(l[2]):l[2]=n),e.push(l))}},e}},72:(t,e,n)=>{var i,o=function(){var t={};return function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}t[e]=n}return t[e]}}(),r=[];function a(t){for(var e=-1,n=0;n<r.length;n++)if(r[n].identifier===t){e=n;break}return e}function c(t,e){for(var n={},i=[],o=0;o<t.length;o++){var c=t[o],l=e.base?c[0]+e.base:c[0],s=n[l]||0,d="".concat(l," ").concat(s);n[l]=s+1;var u=a(d),p={css:c[1],media:c[2],sourceMap:c[3]};-1!==u?(r[u].references++,r[u].updater(p)):r.push({identifier:d,updater:v(p,e),references:1}),i.push(d)}return i}function l(t){var e=document.createElement("style"),i=t.attributes||{};if(void 0===i.nonce){var r=n.nc;r&&(i.nonce=r)}if(Object.keys(i).forEach((function(t){e.setAttribute(t,i[t])})),"function"==typeof t.insert)t.insert(e);else{var a=o(t.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(e)}return e}var s,d=(s=[],function(t,e){return s[t]=e,s.filter(Boolean).join("\n")});function u(t,e,n,i){var o=n?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(t.styleSheet)t.styleSheet.cssText=d(e,o);else{var r=document.createTextNode(o),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(r,a[e]):t.appendChild(r)}}function p(t,e,n){var i=n.css,o=n.media,r=n.sourceMap;if(o?t.setAttribute("media",o):t.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),t.styleSheet)t.styleSheet.cssText=i;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(i))}}var h=null,f=0;function v(t,e){var n,i,o;if(e.singleton){var r=f++;n=h||(h=l(e)),i=u.bind(null,n,r,!1),o=u.bind(null,n,r,!0)}else n=l(e),i=p.bind(null,n,e),o=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(n)};return i(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;i(t=e)}else o()}}t.exports=function(t,e){(e=e||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=(void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i));var n=c(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var i=0;i<n.length;i++){var o=a(n[i]);r[o].references--}for(var l=c(t,e),s=0;s<n.length;s++){var d=a(n[s]);0===r[d].references&&(r[d].updater(),r.splice(d,1))}n=l}}}}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={id:i,exports:{}};return t[i](r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},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.nc=void 0;var i={};return(()=>{n.d(i,{default:()=>d});const t='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M14.5 17.5L9.64142 12.6414C9.56331 12.5633 9.56331 12.4367 9.64142 12.3586L14.5 7.5"/></svg>',e='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9.58284 17.5L14.4414 12.6414C14.5195 12.5633 14.5195 12.4367 14.4414 12.3586L9.58284 7.5"/></svg>';var o=n(72),r=n.n(o),a=n(523);r()(a.A,{insert:"head",singleton:!1}),a.A.locals;var c=function(){return c=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},c.apply(this,arguments)},l={orientation:!1},s=function(){function n(t){var e,n,i,o,r,a,l=this,s=t.api,d=t.data,u=t.config,p=t.block,h=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);o<i.length;o++)e.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(n[i[o]]=t[i[o]])}return n}(t,["api","data","config","block"]);this.wrapper=document.createElement("div"),this.DEFAULT_INDENT_KEY="Tab",this.lastResizeTimeout=null,this.cachedMaxWidthForContent=null,this.api=s,this.block=p;u||(u=null!==(e=null==h?void 0:h.settings)&&void 0!==e?e:{}),this.config=c(c({},{indentSize:24,maxIndent:8,minIndent:0,multiblock:!1,autoIndent:!1,tuneName:null,orientation:"horizontal",customBlockIndentLimits:{},handleShortcut:void 0,direction:"ltr",directionChangeHandler:null,version:"2.29"}),null!=u?u:{}),this.changeConfigBasedOnVersionIfNeeded(),(null===(n=this.config)||void 0===n?void 0:n.directionChangeHandler)&&this.config.directionChangeHandler(this.alignmentChangeListener.bind(this));var f=null!==(a=null===(r=this.config.customBlockIndentLimits[null!==(o=null===(i=this.block)||void 0===i?void 0:i.name)&&void 0!==o?o:""])||void 0===r?void 0:r.min)&&void 0!==a?a:this.config.minIndent;this.data=c({indentLevel:f},null!=d?d:{}),this.config.multiblock&&!this.config.tuneName&&console.error("IndentTune config 'tuneName' was not provided, this is required for multiblock option to work."),window.addEventListener("resize",(function(t){return l.onResize.call(l,t)})),this.api.events.on("block changed",(function(t){var e,n=t.event.detail.target.id;(null===(e=l.block)||void 0===e?void 0:e.id)===n&&l.shouldApplyAutoIndent&&queueMicrotask((function(){return l.autoIndentBlock()}))}))}return Object.defineProperty(n,"isTune",{get:function(){return!0},enumerable:!1,configurable:!0}),n.prototype.prepare=function(){},n.prototype.reset=function(){},n.prototype.render=function(){var n,i,o,r,a=this,c=function(){var t;return a.data.indentLevel==a.maxIndent&&(null==(t=a.getTuneButton("indent"))||t.classList.add(a.CSS.disabledItem),!t)||(a.data.indentLevel==a.minIndent&&(null==(t=a.getTuneButton("unindent"))||t.classList.add(a.CSS.disabledItem),!t)||void 0)};if(queueMicrotask((function(){c()&&setTimeout(c,300)})),"vertical"===this.config.orientation){var l="".concat(this.TuneNames.indentLeft,"-").concat(null===(n=this.block)||void 0===n?void 0:n.id),s="".concat(this.TuneNames.indentRight,"-").concat(null===(i=this.block)||void 0===i?void 0:i.id);return[{title:this.rightText,onActivate:function(t,e){a.handleIndentRight(),t.title=a.rightText},icon:e,name:s},{title:this.leftText,onActivate:function(t,e){a.handleIndentLeft(),t.title=a.leftText},icon:t,name:l}]}var d='\n\t\t\t<div class="'.concat(this.CSS.popoverItem," ").concat(this.CSS.customPopoverItem,"\" data-item-name='indent' version=").concat(this.config.version,'>\n\t\t\t\t<button type="button" class="').concat(this.CSS.popoverItemIcon,'" data-').concat(this.TuneNames.indentLeft,">").concat(t,'</button>\n\t\t\t\t<span class="').concat(this.CSS.popoverItemTitle,'">').concat(this.api.sanitizer.clean(this.api.i18n.t("Indent"),{}),'</span>\n\t\t\t\t<button type="button" class="').concat(this.CSS.popoverItemIcon,'" data-').concat(this.TuneNames.indentRight,' style="margin-left:10px;">').concat(e,"</button>\n\t\t\t</div>\n\t\t"),u=this.createElementFromTemplate(d);return null===(o=u.querySelector("[data-".concat(this.TuneNames.indentRight,"]")))||void 0===o||o.addEventListener("click",(function(){return a.handleIndentRight()})),null===(r=u.querySelector("[data-".concat(this.TuneNames.indentLeft,"]")))||void 0===r||r.addEventListener("click",(function(){return a.handleIndentLeft()})),u},n.prototype.wrap=function(t){var e,i,o,r,a,c=this;this.wrapper.appendChild(t),this.wrapper.setAttribute(n.DATA_WRAPPER_NAME,"");var l=Boolean(this.config.highlightIndent);if((null===(e=this.config.highlightIndent)||void 0===e?void 0:e.tuneNames)&&!this.config.highlightIndent.tuneNames.includes(null!==(o=null===(i=this.block)||void 0===i?void 0:i.name)&&void 0!==o?o:"")&&(l=!1),l){var s=this.createElementFromTemplate('\n <div class="'.concat(null!==(a=null===(r=this.config.highlightIndent)||void 0===r?void 0:r.className)&&void 0!==a?a:""," ").concat(this.CSS.highlightIndent,'">\n </div>\n ')),d=t.classList.contains(this.EditorCSS.content)?t:t.querySelector(".".concat(this.EditorCSS.content));null==d||d.appendChild(s)}return this.applyStylesToWrapper(this.wrapper,this.data.indentLevel),this.wrapper.addEventListener("keydown",(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return c.onKeyDown.apply(c,t)}),{capture:!0}),this.wrapper.addEventListener("focus",(function(t){return c.onFocus.call(c,t)}),{capture:!0}),this.wrapper.addEventListener("blur",(function(t){return c.onBlur.call(c,t)}),{capture:!0}),this.wrapper},n.prototype.save=function(){return this.data},Object.defineProperty(n.prototype,"CSS",{get:function(){return{customPopoverItem:"ce-popover-indent-item",popoverItem:"ce-popover-item",popoverItemIcon:"ce-popover-item__icon",popoverItemTitle:"ce-popover-item__title",disabledItem:"ce-popover-item--disabled",highlightIndent:"ce-highlight-indent"}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"EditorCSS",{get:function(){return{block:"ce-block",content:"ce-block__content",redactor:"codex-editor__redactor"}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"TuneNames",{get:function(){return{indentLeft:"tune-indent-left",indentRight:"tune-indent-right"}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"customInterval",{get:function(){var t,e,n;return null!==(n=this.config.customBlockIndentLimits[null!==(e=null===(t=this.block)||void 0===t?void 0:t.name)&&void 0!==e?e:""])&&void 0!==n?n:{}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"maxIndent",{get:function(){var t;return null!==(t=this.customInterval.max)&&void 0!==t?t:this.config.maxIndent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"minIndent",{get:function(){var t;return null!==(t=this.customInterval.min)&&void 0!==t?t:this.config.minIndent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDirectionInverted",{get:function(){return"ltr"!==this.config.direction},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rightText",{get:function(){return this.api.i18n.t(this.isDirectionInverted?"Un Indent":"Indent")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"leftText",{get:function(){return this.api.i18n.t(this.isDirectionInverted?"Indent":"Un Indent")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shouldApplyAutoIndent",{get:function(){var t;if(!this.config.autoIndent)return!1;if("boolean"==typeof this.config.autoIndent)return this.config.autoIndent;var e=this.api.blocks.getCurrentBlockIndex();if(e<0)return!1;var n=this.api.blocks.getBlockByIndex(e);if(!n)return!1;var i=n.name;return!(null===(t=this.config.autoIndent.tuneNames)||void 0===t?void 0:t.length)||this.config.autoIndent.tuneNames.includes(i)},enumerable:!1,configurable:!0}),n.prototype.onKeyDown=function(t){var e,n,i,o,r,a=this;if((null===(e=this.block)||void 0===e?void 0:e.id)&&!1!==this.config.handleShortcut){var c=t.key==this.DEFAULT_INDENT_KEY,l="function"==typeof this.config.handleShortcut;if(l||c){var s=null===(i=(n=this.config).handleShortcut)||void 0===i?void 0:i.call(n,t,this.block.id);if(s||!l){var d;switch(s){case"indent":d=!0;break;case"unindent":d=!1;break;default:if(!c)return;d=!t.shiftKey}t.stopPropagation(),t.preventDefault(),this.api.inlineToolbar.close();var u=this.getGlobalSelectedBlocks();if(!this.config.multiblock||u.length<2)return d?this.indentBlock():this.unIndentBlock(),void(null===(r=(o=this.block).dispatchChange)||void 0===r||r.call(o));Boolean(this.config.tuneName)?u.forEach((function(t){return e=a,n=void 0,o=function(){var e,n,i,o,r,a,c;return function(t,e){var n,i,o,r,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function c(c){return function(l){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,c[0]&&(a=0)),a;)try{if(n=1,i&&(o=2&c[0]?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,i=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],i=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,l])}}}(this,(function(l){switch(l.label){case 0:return[4,t.save()];case 1:return(e=l.sent())?"tunes"in e&&"object"==typeof e.tunes&&e.tunes?(n=e.tunes[null!==(o=this.config.tuneName)&&void 0!==o?o:""])?(n.indentLevel=d?Math.min(this.config.maxIndent,(null!==(r=n.indentLevel)&&void 0!==r?r:0)+1):Math.max(0,(null!==(a=n.indentLevel)&&void 0!==a?a:0)-1),null===(c=t.dispatchChange)||void 0===c||c.call(t),(i=this.getWrapperBlockById(t.id))instanceof HTMLElement&&this.applyStylesToWrapper(i,n.indentLevel),[2]):(console.error("'tuneName' is invalid, no tune was found for block ".concat(t.name)),[2]):(console.error("Multiblock indenting is not supported for this editor version. "),[2]):[2]}}))},new((i=void 0)||(i=Promise))((function(t,r){function a(t){try{l(o.next(t))}catch(t){r(t)}}function c(t){try{l(o.throw(t))}catch(t){r(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(a,c)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o})):console.error("'tuneName' is empty.")}}}},n.prototype.handleIndentLeft=function(){var t,e;this.isDirectionInverted?this.indentBlock():this.unIndentBlock(),null===(e=null===(t=this.block)||void 0===t?void 0:t.dispatchChange)||void 0===e||e.call(t)},n.prototype.handleIndentRight=function(){var t,e;this.isDirectionInverted?this.unIndentBlock():this.indentBlock(),null===(e=null===(t=this.block)||void 0===t?void 0:t.dispatchChange)||void 0===e||e.call(t)},n.prototype.indentBlock=function(){this.wrapper&&(this.data.indentLevel=Math.min(this.data.indentLevel+1,this.maxIndent),this.applyStylesToWrapper(this.wrapper,this.data.indentLevel),this.toggleDisableStateForButtons())},n.prototype.unIndentBlock=function(){this.wrapper&&(this.data.indentLevel=Math.max(this.data.indentLevel-1,this.minIndent),this.applyStylesToWrapper(this.wrapper,this.data.indentLevel),this.toggleDisableStateForButtons())},n.prototype.autoIndentBlock=function(){var t,e,i=this.api.blocks.getBlockIndex(this.block.id),o=this.api.blocks.getBlockByIndex(i-1);if(o){var r=null===(e=null===(t=o.holder)||void 0===t?void 0:t.querySelector("[".concat(n.DATA_WRAPPER_NAME,"]")))||void 0===e?void 0:e.getAttribute(n.DATA_INDENT_LEVEL),a=Number(null!=r?r:0),c=Math.min(Math.max(a,this.minIndent),this.maxIndent);this.data.indentLevel=c,this.applyStylesToWrapper(this.wrapper,this.data.indentLevel)}},n.prototype.toggleDisableStateForButtons=function(){var t,e,n,i;this.data.indentLevel===this.minIndent?null===(t=this.getTuneButton("unindent"))||void 0===t||t.classList.add(this.CSS.disabledItem):null===(e=this.getTuneButton("unindent"))||void 0===e||e.classList.remove(this.CSS.disabledItem),this.data.indentLevel===this.maxIndent?null===(n=this.getTuneButton("indent"))||void 0===n||n.classList.add(this.CSS.disabledItem):null===(i=this.getTuneButton("indent"))||void 0===i||i.classList.remove(this.CSS.disabledItem)},n.prototype.getTuneButton=function(t){var e,n="indent"===t?"indentRight":"indentLeft";return this.isDirectionInverted&&(n="indent"==t?"indentLeft":"indentRight"),"vertical"===this.config.orientation?this.getTuneByName("".concat(this.TuneNames[n],"-").concat(null===(e=this.block)||void 0===e?void 0:e.id)):document.querySelector(".".concat(this.CSS.popoverItemIcon,"[data-").concat(this.TuneNames[n],"]"))},n.prototype.getTuneByName=function(t){return document.querySelector(".".concat(this.CSS.popoverItem,'[data-item-name="').concat(t,'"]'))},n.prototype.getTuneTitleByName=function(t){var e;return null===(e=this.getTuneByName(t))||void 0===e?void 0:e.querySelector(".".concat(this.CSS.popoverItemTitle))},n.prototype.applyStylesToWrapper=function(t,e){var i=this;void 0===e&&(e=parseInt(t.getAttribute(n.DATA_INDENT_LEVEL)||"0"));var o=e*this.config.indentSize;t.setAttribute(n.DATA_INDENT_LEVEL,e.toString());var r=t.querySelector(".".concat(this.EditorCSS.content)),a=this.getBlockForWrapper(t)||document.querySelector(".".concat(this.EditorCSS.redactor));if(r instanceof HTMLElement&&a){var c=a.getBoundingClientRect().width;if(0!==c){var l=(c-this.maxWidthForContent(t))/2,s=Math.max(0,Math.min(l,o)),d="".concat(2*s,"px"),u="".concat(s,"px");this.isDirectionInverted?(t.style.paddingLeft="0px",t.style.paddingRight=d):(t.style.paddingLeft=d,t.style.paddingRight="0px");var p=t.querySelector(".".concat(this.CSS.highlightIndent));p instanceof HTMLElement&&(this.isDirectionInverted?(p.style.width=u,p.style.left="100%",p.style.right=""):(p.style.width=u,p.style.left="",p.style.right="100%"))}else queueMicrotask((function(){return i.applyStylesToWrapper.bind(i)(t,e)}))}},n.prototype.onFocus=function(t){t.target instanceof HTMLElement&&this.wrapper.contains(t.target)&&this.wrapper.setAttribute(n.DATA_FOCUSED,"")},n.prototype.onBlur=function(t){t.target instanceof HTMLElement&&this.wrapper.contains(t.target)&&this.wrapper.removeAttribute(n.DATA_FOCUSED)},n.prototype.onResize=function(t){var e=this;this.lastResizeTimeout&&clearTimeout(this.lastResizeTimeout),this.lastResizeTimeout=setTimeout((function(){document.querySelectorAll("[".concat(n.DATA_WRAPPER_NAME,"]")).forEach((function(t){t instanceof HTMLElement&&e.applyStylesToWrapper(t)}))}),500)},n.prototype.getGlobalSelectedBlocks=function(){var t=this;return new Array(this.api.blocks.getBlocksCount()).fill(0).map((function(e,n){return t.api.blocks.getBlockByIndex(n)})).filter((function(t){return!!(null==t?void 0:t.selected)}))},n.prototype.getWrapperBlockById=function(t){var e,i,o,r=".".concat(this.EditorCSS.block,'[data-id="').concat(t,'"] [').concat(n.DATA_WRAPPER_NAME,"]");return null!==(o=null!==(e=document.querySelector(r))&&void 0!==e?e:null===(i=this.api.blocks.getById(t))||void 0===i?void 0:i.holder.querySelector("[".concat(n.DATA_WRAPPER_NAME,"]")))&&void 0!==o?o:null},n.prototype.getBlockForWrapper=function(t){for(var e=t;!e.classList.contains(this.EditorCSS.block);){if(!e.parentElement||e instanceof HTMLHtmlElement)return null;e=e.parentElement}return e},n.prototype.alignmentChangeListener=function(t,e){var n,i,o;if(t===(null===(n=this.block)||void 0===n?void 0:n.id)&&e!==this.config.direction&&(this.config.direction=e,this.applyStylesToWrapper(this.wrapper,this.data.indentLevel),this.toggleDisableStateForButtons(),"vertical"===this.config.orientation)){var r=this.getTuneTitleByName("".concat(this.TuneNames.indentRight,"-").concat(null===(i=this.block)||void 0===i?void 0:i.id));r&&(r.textContent=this.rightText);var a=this.getTuneTitleByName("".concat(this.TuneNames.indentLeft,"-").concat(null===(o=this.block)||void 0===o?void 0:o.id));a&&(a.textContent=this.leftText)}},n.prototype.createElementFromTemplate=function(t){return(new DOMParser).parseFromString(t,"text/html").body.firstChild},n.prototype.changeConfigBasedOnVersionIfNeeded=function(){this.config.version&&this.config.version<"2.27"&&"vertical"===this.config.orientation&&(this.config.orientation="horizontal",l.orientation||console.warn("Current editor version does not support vertical indent tune 'orientation'. View your config input"),l.orientation=!0)},n.prototype.maxWidthForContent=function(t){var e=t.querySelector(".".concat(this.EditorCSS.content));if(e instanceof HTMLElement){var n=window.getComputedStyle(e).maxWidth;if(n)return this.cachedMaxWidthForContent=parseInt(n),this.cachedMaxWidthForContent}return null!==this.cachedMaxWidthForContent||(this.cachedMaxWidthForContent=650),this.cachedMaxWidthForContent},n.DATA_WRAPPER_NAME="data-block-indent-wrapper",n.DATA_FOCUSED="data-focused",n.DATA_INDENT_LEVEL="data-indent-level",n}();const d=s})(),i.default})()));