Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/processors/getAlloyEditorProcessor",["module","exports","require","frontend-js-web","../config/index","../utils/isNullOrUndefined"],(function(e,t,n){var r;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,n=m,r=p){let o,a,l,s={};return{createEditor:(r,u,b,m)=>{if(s.changeCallback=u,s.destroyCallback=b,o)return;const{editorConfig:p}=c.config.defaultEditorConfigurations[t];l=r;const E="".concat(c.config.portletNamespace,"FragmentEntryLinkEditable_").concat(r.id),O=n(r);O.setAttribute("id",E),O.setAttribute("name",E),r.addEventListener("keyup",y),o=AlloyEditor.editable(O,d(d({},p),{},{documentBrowseLinkCallback:(e,t,n)=>{(0,i.openSelectionModal)({onSelect:n,selectEventName:E+"selectItem",title:Liferay.Language.get("select-item"),url:t})},documentBrowseLinkUrl:p.documentBrowseLinkUrl.replace("_EDITOR_NAME_",E),filebrowserImageBrowseLinkUrl:p.filebrowserImageBrowseLinkUrl.replace("_EDITOR_NAME_",E),filebrowserImageBrowseUrl:p.filebrowserImageBrowseUrl.replace("_EDITOR_NAME_",E),title:""}));const C=o.get("nativeEditor"),k=e=>{e.target.closest('[name="'.concat(E,'"]'))||!e.target.closest(".page-editor__toolbar")&&!e.target.closest(".page-editor__wrapper")||w()},w=()=>{s.changeCallback?s.changeCallback(C.getData()).then((()=>{s.destroyCallback&&s.destroyCallback()})).catch((()=>{s.destroyCallback&&s.destroyCallback()})):s.destroyCallback&&requestAnimationFrame((()=>s.destroyCallback()))};a=[{removeListener:()=>document.removeEventListener("click",k)},C.on("key",(t=>{t.data.keyCode!==e&&t.data.keyCode!==g||!l||"text"!==l.getAttribute("type")&&"text"!==l.dataset.lfrEditableType||t.cancel()})),C.on("blur",(()=>{o._mainUI.state.hidden?w():document.addEventListener("click",k)})),C.on("instanceReady",(()=>{C.focus(),m?function(e,t){const n=t.getSelection().getRanges()[0];if(document.caretPositionFromPoint){const t=document.caretPositionFromPoint(e.clientX,e.clientY),r=t.offsetNode;f(r)&&(n.setStart(CKEDITOR.dom.node(r),t.offset),n.setEnd(CKEDITOR.dom.node(r),t.offset))}else if(document.caretRangeFromPoint){const t=document.caretRangeFromPoint(e.clientX,e.clientY),r=t.startOffset||0;f(t.startContainer)&&f(t.endContainer)&&(n.setStart(CKEDITOR.dom.node(t.startContainer),r),n.setEnd(CKEDITOR.dom.node(t.endContainer),r))}t.getSelection().selectRanges([n])}(m,C):C.execCommand("selectAll")})),C.on("saveSnapshot",(0,i.debounce)((()=>{s.changeCallback&&s.changeCallback(C.getData())}),100))]},destroyEditor:(e,t)=>{if(o){const e=o.get("nativeEditor").getData();o.destroy(),a.forEach((e=>{e.removeListener()})),r(l,e,t),o=null,a=null,l=null,s={}}e&&e.removeEventListener("keyup",y)},render:(e,t,n)=>{e!==l&&r(e,t,n)}}};var o,a,i=n("frontend-js-web"),c=n("../config/index"),l=(r=n("../utils/isNullOrUndefined"))&&r.__esModule?r:{default:r};function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const e=13,b=32,g=(null!==(o=null===(a=window.CKEDITOR)||void 0===a?void 0:a.SHIFT)&&void 0!==o?o:0)+e,m=e=>{const t=document.createElement("div");return t.innerHTML=e.innerHTML,e.innerHTML="",e.appendChild(t),t},p=(e,t)=>{(0,l.default)(t)||(e.innerHTML=t)},y=e=>{e.keyCode===b&&e.preventDefault()};function f(e){return e.nodeType===Node.TEXT_NODE}}}));
//# sourceMappingURL=getAlloyEditorProcessor.js.map