wp-editor.bundle.min.js 6.5 KB

1
  1. !function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=24)}({24:function(e,t,n){"use strict";n(25),n(26)},25:function(e,t,n){"use strict";function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=FLBuilderConfig,s=u.strings,a=wp.blocks,p=a.createBlock,f=a.serialize,d=wp.components.Button,b=wp.compose.compose,h=wp.data,v=h.withDispatch,y=h.withSelect,m=wp.element.Component,g=wp.hooks.addFilter,k=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),l(t,[{key:"render",value:function(){return this.hasBuilderBlock()?null:React.createElement("span",null,React.createElement(d,{className:"components-menu-item__button",onClick:this.convertToBuilder.bind(this)},s.convert))}},{key:"hasBuilderBlock",value:function(){return!!(0,this.props.getBlocks)().filter(function(e){return"fl-builder/layout"===e.name}).length}},{key:"convertToBuilder",value:function(){var e=this.props,t=e.getBlocks,n=e.insertBlock,o=e.removeBlocks,r=t(),i=r.map(function(e){return e.clientId}),c=f(r).replace(/<!--(.*?)-->/g,""),l=p("fl-builder/layout",{content:c});o(i),n(l,0)}}]),t}(m),B=b(v(function(e,t){var n=e("core/editor");return{insertBlock:n.insertBlock,removeBlocks:n.removeBlocks}}),y(function(e){return{getBlocks:e("core/editor").getBlocks}}))(k);g("editPost.MoreMenu.tools","fl-builder/convert-to-builder/button",function(e){return[].concat(o(e),[React.createElement(B,{key:"convert-to-builder"})])})},26:function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();n(27);var l=FLBuilderConfig,u=l.builder,s=l.strings,a=l.urls,p=wp.blocks,f=p.registerBlockType,d=p.rawHandler,b=p.serialize,h=wp.components,v=h.Button,y=h.Placeholder,m=h.Spinner,g=wp.compose.compose,k=wp.data,B=k.subscribe,w=k.withDispatch,O=k.withSelect,_=wp.element,P=_.Component,E=_.RawHTML,C=function(e){function t(){o(this,t);var e=r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.state={launching:!1},e.unsubscribe=B(e.storeDidUpdate.bind(e)),e}return i(t,e),c(t,[{key:"storeDidUpdate",value:function(){var e=this.props.isSavingPost;this.state.launching&&!e()&&(this.unsubscribe(),this.redirectToBuilder())}},{key:"componentDidMount",value:function(){1===(0,this.props.getBlockCount)()&&this.toggleEditor("disable")}},{key:"componentWillUnmount",value:function(){this.unsubscribe(),this.toggleEditor("enable")}},{key:"render",value:function(){var e=this.props,t=e.getBlockCount,n=(e.onReplace,this.state.launching),o=void 0,r=void 0,i=void 0;return 1===t()?(o=u.access?s.launch:s.view,r=this.launchBuilder.bind(this)):(o=s.convert,r=this.convertToBuilder.bind(this)),i=u.enabled?s.active:s.description,React.createElement(y,{key:"placeholder",instructions:i,icon:"welcome-widgets-menus",label:s.title,className:"fl-builder-layout-launch-view"},n&&React.createElement(m,null),!n&&React.createElement(v,{isLarge:!0,isPrimary:!0,type:"submit",onClick:r},o),!n&&React.createElement(v,{isLarge:!0,type:"submit",onClick:this.convertToBlocks.bind(this)},s.editor))}},{key:"toggleEditor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"enable",t=document.body.classList,n="fl-builder-layout-enabled";"enable"===e?t.contains(n)&&t.remove(n):t.contains(n)||t.add(n)}},{key:"redirectToBuilder",value:function(){window.location.href=u.access?a.edit:a.view}},{key:"launchBuilder",value:function(){var e=this.props.savePost;this.setState({launching:!0}),e()}},{key:"convertToBuilder",value:function(){var e=this.props,t=e.clientId,n=e.getBlocks,o=e.setAttributes,r=e.removeBlocks,i=n(),c=b(i),l=i.map(function(e){return e.clientId}).filter(function(e){return e!==t});o({content:c.replace(/<!--(.*?)-->/g,"")}),r(l),this.launchBuilder()}},{key:"convertToBlocks",value:function(){var e=this.props,t=e.attributes,n=e.clientId,o=e.replaceBlocks,r=e.onReplace;t.content&&!confirm(s.warning)||(t.content?o([n],d({HTML:t.content,mode:"BLOCKS"})):r([]))}}]),t}(P),T=g(w(function(e,t){var n=e("core/editor");return{savePost:n.savePost,removeBlocks:n.removeBlocks,replaceBlocks:n.replaceBlocks}}),O(function(e){var t=e("core/editor");return{getBlockCount:t.getBlockCount,getBlocks:t.getBlocks,isSavingPost:t.isSavingPost}}))(C);(u.access&&u.unrestricted||u.enabled)&&f("fl-builder/layout",{title:s.title,description:s.description,icon:"welcome-widgets-menus",category:"layout",useOnce:!0,supports:{customClassName:!1,className:!1,html:!1},attributes:{content:{type:"string",source:"html"}},edit:T,save:function(e){var t=e.attributes;return React.createElement(E,null,t.content)}})},27:function(e,t){}});