Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/common/components/Editor",["module","exports","require","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../app/config/index"],(function(e,t,r){var n;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({autoFocus:e=!1,configurationName:t,id:r,initialValue:n,onChange:c,placeholder:f}){const d=i.config.defaultEditorConfigurations[t].editorConfig,[u,s]=(0,a.useState)(null),p=(0,a.useRef)(null);return(0,a.useEffect)((()=>{if(u){const e=u.get("nativeEditor");e.getData()&&n||e.setData(n)}}),[u,n]),(0,a.useEffect)((()=>{const e=new o.EventHandler;if(u&&c){const t=u.get("nativeEditor");e.add(t.on("change",(()=>c(t.getData())))),e.add(t.on("actionPerformed",(()=>c(t.getData()))))}return()=>{e.removeAllListeners(),e.dispose()}}),[u,c]),(0,a.useEffect)((()=>{const t=AlloyEditor.editable(p.current,l(l({},d),{},{enterMode:1,startupFocus:e,title:!1}));let r=!1;const n=t.get("nativeEditor").once("instanceReady",(()=>{r=!0,s(t)}));return()=>{try{r?(t.destroy(),s(null)):(n.removeListener(),t.get("nativeEditor").once("instanceReady",(()=>{t.destroy()})))}catch(e){}}}),[e,d]),a.default.createElement("div",{className:"alloy-editor-container",id:"".concat(i.config.portletNamespace).concat(r)},a.default.createElement("div",{className:"alloy-editor form-control form-control-sm page-editor__editor page-editor__editor-placeholder",contentEditable:!1,"data-placeholder":f,"data-required":!1,id:"".concat(i.config.portletNamespace).concat(r),name:r,ref:p}))};var o=r("frontend-js-web"),a=((n=r("liferay!frontend-js-react-web$prop-types"))&&n.__esModule,function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=n?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),i=r("../../app/config/index");function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}}));
//# sourceMappingURL=Editor.js.map