Version Description
- Page layout selector: Fixed an issue where the wrong close button would appear in certain circumstances. (https://github.com/Automattic/wp-calypso/pull/48469)
Download this release
Release Info
Developer | addiestavlo |
Plugin | Full Site Editing |
Version | 2.8.16 |
Comparing to | |
See all releases |
Code changes from version 2.8.15 to 2.8.16
- full-site-editing-plugin.php +2 -2
- readme.txt +4 -1
- starter-page-templates/dist/starter-page-templates.asset.php +1 -1
- starter-page-templates/dist/starter-page-templates.js +2 -2
- starter-page-templates/index.js +15 -21
- starter-page-templates/page-template-modal/components/sidebar-modal-opener.js +9 -29
- starter-page-templates/page-template-modal/index.js +17 -15
- starter-page-templates/store.js +6 -5
full-site-editing-plugin.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: WordPress.com Editing Toolkit
|
4 |
* Description: Enhances your page creation workflow within the Block Editor.
|
5 |
-
* Version: 2.8.
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
@@ -35,7 +35,7 @@ namespace A8C\FSE;
|
|
35 |
*
|
36 |
* @var string
|
37 |
*/
|
38 |
-
define( 'PLUGIN_VERSION', '2.8.
|
39 |
|
40 |
// Always include these helper files for dotcom FSE.
|
41 |
require_once __DIR__ . '/dotcom-fse/helpers.php';
|
2 |
/**
|
3 |
* Plugin Name: WordPress.com Editing Toolkit
|
4 |
* Description: Enhances your page creation workflow within the Block Editor.
|
5 |
+
* Version: 2.8.16
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
35 |
*
|
36 |
* @var string
|
37 |
*/
|
38 |
+
define( 'PLUGIN_VERSION', '2.8.16' );
|
39 |
|
40 |
// Always include these helper files for dotcom FSE.
|
41 |
require_once __DIR__ . '/dotcom-fse/helpers.php';
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: alexislloyd, allancole, automattic, bartkalisz, codebykat, copons,
|
|
3 |
Tags: block, blocks, editor, gutenberg, page
|
4 |
Requires at least: 5.0
|
5 |
Tested up to: 5.5
|
6 |
-
Stable tag: 2.8.
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -40,6 +40,9 @@ This plugin is experimental, so we don't provide any support for it outside of w
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
43 |
= 2.8.15 =
|
44 |
* Page layout selector: Use description of the templates as label for screen readers (https://github.com/Automattic/wp-calypso/pull/48128)
|
45 |
* Remove usages of lodash trimEnd() (https://github.com/Automattic/wp-calypso/pull/48255)
|
3 |
Tags: block, blocks, editor, gutenberg, page
|
4 |
Requires at least: 5.0
|
5 |
Tested up to: 5.5
|
6 |
+
Stable tag: 2.8.16
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
40 |
|
41 |
== Changelog ==
|
42 |
|
43 |
+
= 2.8.16 =
|
44 |
+
* Page layout selector: Fixed an issue where the wrong close button would appear in certain circumstances. (https://github.com/Automattic/wp-calypso/pull/48469)
|
45 |
+
|
46 |
= 2.8.15 =
|
47 |
* Page layout selector: Use description of the templates as label for screen readers (https://github.com/Automattic/wp-calypso/pull/48128)
|
48 |
* Remove usages of lodash trimEnd() (https://github.com/Automattic/wp-calypso/pull/48255)
|
starter-page-templates/dist/starter-page-templates.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array('lodash', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-nux', 'wp-plugins', 'wp-polyfill', 'wp-url'), 'version' => '
|
1 |
+
<?php return array('dependencies' => array('lodash', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-nux', 'wp-plugins', 'wp-polyfill', 'wp-url'), 'version' => 'd6a549c5d24cfe56861e1f7a9cd97ad5');
|
starter-page-templates/dist/starter-page-templates.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.lodash}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t){!function(){e.exports=this.wp.
|
2 |
/*!
|
3 |
Copyright (c) 2017 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
-
*/!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var a=i.apply(null,r);a&&e.push(a)}else if("object"===o)for(var s in r)n.call(r,s)&&r[s]&&e.push(s)}}return e.join(" ")}e.exports?(i.default=i,e.exports=i):void 0===(r=function(){return i}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t,n){var r=n(29);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},function(e,t,n){var r=n(30),i=n(31),o=n(32);e.exports=function(e){var t=i();return function(){var n,i=r(e);if(t){var a=r(this).constructor;n=Reflect.construct(i,arguments,a)}else n=i.apply(this,arguments);return o(this,n)}}},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t){!function(){e.exports=this.wp.plugins}()},function(e,t){!function(){e.exports=this.wp.hooks}()},function(e,t,n){var r=n(36),i=n(37),o=n(21),a=n(38);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()}},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){function n(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(i,o){var a=e.apply(t,r);function s(e){n(a,i,o,s,c,"next",e)}function c(e){n(a,i,o,s,c,"throw",e)}s(void 0)}))}}},function(e,t,n){var r=n(39),i=n(40),o=n(21),a=n(41);e.exports=function(e){return r(e)||i(e)||o(e)||a()}},function(e,t,n){var r=n(22);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},n.apply(this,arguments)}e.exports=n},function(e,t){!function(){e.exports=this.wp.editPost}()},function(e,t){!function(){e.exports=this.wp.editor}()},function(e,t){!function(){e.exports=this.wp.apiFetch}()},function(e,t){!function(){e.exports=this.wp.url}()},function(e,t,n){var r=n(42);e.exports=function(e,t){if(null==e)return{};var n,i,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}},function(e,t,n){var r=n(33),i=n(4);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t){!function(){e.exports=this.wp.nux}()},function(e,t,n){},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],_n=!0,r=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(_n=(o=a.next()).done)&&(n.push(o.value),!t||n.length!==t);_n=!0);}catch(s){r=!0,i=s}finally{try{_n||null==a.return||a.return()}finally{if(r)throw i}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t,n){var r=n(22);e.exports=function(e){if(Array.isArray(e))return r(e)}},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}},function(e,t,n){"use strict";n.r(t);var r=n(23),i=n.n(r),o=n(0),a=n(2),s=n(15),c=n(5),l=n(24),u=n(7),p=n.n(u),m=n(10),d=n.n(m),f=n(11),b=n.n(f),g=n(4),O=n.n(g),v=n(12),h=n.n(v),y=n(13),j=n.n(y),_=n(3),w=n.n(_),T=n(1),k=n(9),P=n.n(k),E=(n(34),n(8)),S=n(6),x=n(14),B=n(16),I=(n(35),n(17)),C=n.n(I),N=n(18),L=n(25),A=function(e){var t=e.blocks,n=e.settings,r=e.hidePageTitle,i=e.recomputeBlockListKey;return Object(o.createElement)(N.BlockEditorProvider,{value:t,settings:n},Object(o.createElement)(S.Disabled,{key:i},!r&&Object(o.createElement)("div",{className:"block-iframe-preview__template-title edit-post-visual-editor__post-title-wrapper"},Object(o.createElement)(L.PostTitle,null)),Object(o.createElement)(N.BlockList,null)))},D=Object(E.compose)(E.withSafeTimeout,Object(c.withSelect)((function(e){var t=e("core/block-editor");return{settings:t?t.getSettings():{}}})))((function(e){var t,n,r=e.className,i=void 0===r?"block-iframe-preview":r,s=e.bodyClassName,c=void 0===s?"block-iframe-preview-body":s,l=e.viewportWidth,u=e.blocks,p=e.settings,m=e.setTimeout,d=void 0===m?T.noop:m,f=e.title,b=Object(o.useRef)(),g=Object(o.useRef)(),O=Object(o.useState)({transform:"scale( 1 )"}),v=C()(O,2),h=v[0],y=v[1],j=Object(o.useMemo)((function(){return Object(T.castArray)(u)}),[u]),_=Object(o.useReducer)((function(e){return e+1}),0),w=C()(_,2),k=w[0],E=w[1];Object(o.useLayoutEffect)(E,[u]);var S=Object(o.useCallback)((function(){var e=Object(T.get)(b,["current","parentNode"]);if(e){var t=l||b.current.offsetWidth,n=e.offsetWidth/l,r=e.offsetHeight/n;y({width:t,height:r,transform:"scale( ".concat(n," )")})}}),[l]);return Object(o.useEffect)((function(){if(f){var e=Object(T.get)(g,["current","contentDocument","body"]);if(e){var t=e.querySelector(".editor-post-title .editor-post-title__input");t&&(t.value=f)}}}),[k]),Object(o.useEffect)((function(){d((function(){var e,t,n,r;e=window.document,t=g.current.contentDocument,n=["link","style"],r={head:document.createDocumentFragment(),body:document.createDocumentFragment()},Object(T.each)(Object.keys(r),(function(t){return Object(T.each)(Object(T.filter)(e[t].children,(function(e){var t=e.localName;return n.includes(t)})),(function(e){r[t].appendChild(e.cloneNode(!0))}))})),t.head.appendChild(r.head),t.body.appendChild(r.body),g.current.contentDocument.body.classList.add(c,"editor-styles-wrapper","block-editor__container"),g.current.contentDocument.head.innerHTML+="<style>.editor-post-title .editor-post-title__input { height: auto !important; }</style>",S()}),0)}),[d,c,S]),Object(o.useEffect)((function(){var e=Object(T.get)(g,["current","contentDocument","body"]);e&&(e.scrollTop=0)}),[k]),Object(o.useEffect)((function(){var e=Object(T.debounce)(S,300);return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[S]),Object(o.useEffect)((function(){return window.jQuery&&window.jQuery(window.document).on("wp-collapse-menu",S),function(){window.jQuery&&window.jQuery(window.document).off("wp-collapse-menu",S)}}),[S]),Object(o.createElement)("div",{ref:b},Object(o.createElement)("iframe",{ref:g,title:Object(a.__)("Preview","full-site-editing"),className:P()("editor-styles-wrapper",i),style:h,tabIndex:-1},(null===(t=g.current)||void 0===t||null===(n=t.contentDocument)||void 0===n?void 0:n.body)&&Object(o.createPortal)(Object(o.createElement)("div",{className:"block-editor"},Object(o.createElement)("div",{className:"edit-post-visual-editor"},Object(o.createElement)("div",{className:"editor-styles-wrapper"},Object(o.createElement)("div",{className:"editor-writing-flow"},Object(o.createElement)(A,{blocks:j,settings:p,hidePageTitle:!f,recomputeBlockListKey:k}))))),g.current.contentDocument.body)))})),M=function(e){var t=e.id,n=e.value,r=e.onSelect,i=e.title,a=e.description,s=e.useDynamicPreview,c=void 0!==s&&s,l=e.staticPreviewImg,u=e.staticPreviewImgAlt,p=void 0===u?"":u,m=e.blocks,d=void 0===m?[]:m,f=e.isSelected;if(Object(T.isNil)(t)||Object(T.isNil)(i)||Object(T.isNil)(n))return null;if(c&&(Object(T.isNil)(d)||Object(T.isEmpty)(d)))return null;var b=c?Object(o.createElement)(D,{blocks:d,viewportWidth:960}):Object(o.createElement)("img",{className:"template-selector-item__media",src:l,alt:p});return Object(o.createElement)("button",{type:"button",className:P()("template-selector-item__label",{"is-selected":f}),value:n,onClick:function(){r(n)},"aria-label":a},Object(o.createElement)("span",{className:"template-selector-item__preview-wrap"},b))},F={Address:Object(a._x)("123 Main St","default address","full-site-editing"),Phone:Object(a._x)("555-555-5555","default phone number","full-site-editing"),CompanyName:Object(a._x)("Your Company Name","default company name","full-site-editing"),Vertical:Object(a._x)("Business","default vertical name","full-site-editing")},W={CompanyName:"title",Address:"address",Phone:"phone",Vertical:"vertical"},R=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?e.replace(/{{(\w+)}}/g,(function(e,n){var r=F[n];return t[W[n]]||r||n})):""},G=Object(E.compose)(o.memo,E.withInstanceId)((function(e){var t=e.label,n=e.legendLabel,r=e.className,i=e.help,a=e.instanceId,s=e.templates,c=void 0===s?[]:s,l=e.blocksByTemplates,u=void 0===l?{}:l,p=e.useDynamicPreview,m=void 0!==p&&p,d=e.onTemplateSelect,f=void 0===d?T.noop:d,b=e.siteInformation,g=void 0===b?{}:b,O=e.selectedTemplate;if(Object(T.isEmpty)(c)||!Object(T.isArray)(c))return null;if(!0===m&&Object(T.isEmpty)(u))return null;var v="template-selector-control-".concat(a);return Object(o.createElement)(S.BaseControl,{label:t,id:v,help:i,className:P()(r,"template-selector-control")},Object(o.createElement)("ul",{className:"template-selector-control__options","data-testid":"template-selector-control-options","aria-label":n},Object(T.map)(c,(function(e){var t=e.slug,n=e.title,r=e.description,a=e.preview,s=e.previewAlt;return Object(o.createElement)("li",{key:"".concat(v,"-").concat(t),className:"template-selector-control__template"},Object(o.createElement)(M,{id:v,value:t,title:R(n,g),description:r,help:i,onSelect:f,staticPreviewImg:a,staticPreviewImgAlt:s,blocks:u.hasOwnProperty(t)?u[t]:[],useDynamicPreview:m,isSelected:t===O}))}))))})),q=function(e){var t=e.blocks,n=void 0===t?[]:t,r=e.viewportWidth,i=e.title,s=!n.length;return Object(o.createElement)("div",{className:"template-selector-preview ".concat(s?"not-selected":"")},s&&Object(o.createElement)("div",{className:"editor-styles-wrapper"},Object(o.createElement)("div",{className:"template-selector-preview__empty-state"},Object(a.__)("Select a layout to preview.","full-site-editing"))),Object(o.createElement)(D,{blocks:n,viewportWidth:r,title:i}))};window._tkq=window._tkq||[];var U=null,z=function(e,t){U&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_dismiss",{blog_id:U.blogid,segment_id:e,vertical_id:t}])},V=function(e,t,n){U&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_template_selected",{blog_id:U.blogid,segment_id:e,vertical_id:t,template:n}])},Q=n(19),H=n.n(Q),K=n(20),Y=n.n(K),$=n(26),J=n.n($),X=n(27),Z=function(e,t,n){var r=e[t=Object(X.removeQueryArgs)(t,"w","s")]||{url:t,usages:[]};return p()(p()({},e),{},w()({},t,p()(p()({},r),{},{usages:[].concat(Y()(r.usages),Y()(n))})))},ee=function e(t,n){switch(t.blocksByClientId[n.clientId]=n,n.name){case"core/cover":case"core/image":var r=n.attributes.url;r&&(t.assets=Z(t.assets,r,[{prop:"url",path:[n.clientId,"attributes","url"]},{prop:"id",path:[n.clientId,"attributes","id"]}]));case"core/media-text":var i=n.attributes.mediaUrl;i&&"image"===n.attributes.mediaType&&(t.assets=Z(t.assets,i,[{prop:"url",path:[n.clientId,"attributes","mediaUrl"]},{prop:"id",path:[n.clientId,"attributes","mediaId"]}]));case"core/gallery":Object(T.forEach)(n.attributes.images,(function(e,r){t.assets=Z(t.assets,e.url,[{prop:"url",path:[n.clientId,"attributes","images",r,"url"]},{prop:"url",path:[n.clientId,"attributes","images",r,"link"]},{prop:"id",path:[n.clientId,"attributes","images",r,"id"]},{prop:"id",path:[n.clientId,"attributes","ids",r]}])}))}return Object(T.isEmpty)(n.innerBlocks)?t:Object(T.reduce)(n.innerBlocks,e,t)},te=function(){var e=H()(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J()({method:"POST",path:"/fse/v1/sideload/image/batch",data:{resources:Object(T.map)(t)}}).then((function(e){return Object(T.reduce)(t,(function(t,n){var r=e.shift(),i=r.id,o=r.source_url;return p()(p()({},t),{},w()({},n.url,{id:i,url:o}))}),{})}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),ne=function(e,t){return Object(T.forEach)(e.assets,(function(n){var r=t[n.url];r&&Object(T.forEach)(n.usages,(function(t){Object(T.set)(e.blocksByClientId,t.path,r[t.prop])}))})),e.blocks},re=function(){var e=H()(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Object(T.reduce)(t,ee,{assets:{},blocksByClientId:{},blocks:t}),!Object(T.isEmpty)(n.assets)){e.next=3;break}return e.abrupt("return",t);case 3:return e.abrupt("return",te(n.assets).then((function(e){return ne(n,e)})));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var ie=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T.identity;return t.map((function(t){return(t=n(Object(x.cloneBlock)(t))).innerBlocks&&t.innerBlocks.length&&(t.innerBlocks=e(t.innerBlocks,n)),t}))};var oe=function e(t){return!!t.find((function(t){return"core/missing"===t.name||!(!t.innerBlocks||!t.innerBlocks.length)&&e(t.innerBlocks)}))},ae="isInsertingPageTemplate",se="automattic/full-site-editing/inserting-template",ce=function(e){h()(n,e);var t=j()(n);function n(){var e;d()(this,n);for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return e=t.call.apply(t,[this].concat(i)),w()(O()(e),"state",{isLoading:!1,previewedTemplate:null,error:null}),w()(O()(e),"getTitlesByTemplateSlugs",Object(T.memoize)((function(e){return Object(T.mapValues)(Object(T.keyBy)(e,"slug"),"title")}))),w()(O()(e),"getBlocksByTemplateSlugs",Object(T.memoize)((function(t){var n=Object(T.reduce)(t,(function(t,n){var r=n.slug,i=n.content;return t[r]=i?Object(x.parse)(R(i,e.props.siteInformation)):[],t}),{});return e.filterTemplatesWithMissingBlocks(n)}))),w()(O()(e),"getBlocksForPreview",Object(T.memoize)((function(t){var n=e.getBlocksByTemplateSlug(t);return ie(n,(function(e){return"jetpack/contact-form"===e.name&&void 0!==e.attributes.hasFormSettingsSet&&(e.attributes.hasFormSettingsSet=!0),e}))}))),w()(O()(e),"getBlocksForSelection",(function(t){var n=e.getBlocksByTemplateSlug(t);return ie(n,(function(e){return"core/button"===e.name&&void 0!==e.attributes.url&&(e.attributes.url="#"),e}))})),w()(O()(e),"setTemplate",(function(t){if(V(e.props.segment.id,e.props.vertical.id,t),e.props.saveTemplateChoice(t),"current"!==t){if("blank"===t)return e.props.insertTemplate("",[]),void e.props.setIsOpen(!1);var n=Object(T.find)(e.props.templates,{slug:t,category:"home"}),r=e.getBlocksForSelection(t),i=n?null:e.getTitleByTemplateSlug(t);r&&r.length?(e.setState({error:null,isLoading:!0}),e.maybePrefetchAssets(r).then((function(t){e.setState({isLoading:!1}),e.props.isOpen&&(e.props.insertTemplate(i,t),e.props.setIsOpen(!1))})).catch((function(t){e.setState({isLoading:!1,error:t})}))):e.props.setIsOpen(!1)}else e.props.setIsOpen(!1)})),w()(O()(e),"maybePrefetchAssets",(function(t){return e.props.shouldPrefetchAssets?re(t):Promise.resolve(t)})),w()(O()(e),"handleConfirmation",(function(t){"string"!=typeof t&&(t=e.state.previewedTemplate),e.setTemplate(t),e.props.isPromptedFromSidebar&&e.props.toggleTemplateModal()})),w()(O()(e),"previewTemplate",(function(t){e.setState({previewedTemplate:t}),window.matchMedia("(min-width: 660px)").matches||e.handleConfirmation(t)})),w()(O()(e),"closeModal",(function(t){if(t.target.matches("button.template-selector-item__label"))return!1;z(e.props.segment.id,e.props.vertical.id);var n=Object(T.get)(window,["calypsoifyGutenberg","closeUrl"]);window.top.location=n||"edit.php?post_type=page"})),w()(O()(e),"getTemplateGroups",(function(){return{blankTemplate:Object(T.filter)(e.props.templates,{slug:"blank"}),currentTemplate:Object(T.filter)(e.props.templates,{slug:"current"}),aboutTemplates:Object(T.filter)(e.props.templates,{category:"about"}),blogTemplates:Object(T.filter)(e.props.templates,{category:"blog"}),contactTemplates:Object(T.filter)(e.props.templates,{category:"contact"}),eventTemplates:Object(T.filter)(e.props.templates,{category:"event"}),menuTemplates:Object(T.filter)(e.props.templates,{category:"menu"}),portfolioTemplates:Object(T.filter)(e.props.templates,{category:"portfolio"}),productTemplates:Object(T.filter)(e.props.templates,{category:"product"}),servicesTemplates:Object(T.filter)(e.props.templates,{category:"services"}),teamTemplates:Object(T.filter)(e.props.templates,{category:"team"}),homepageTemplates:Object(T.sortBy)(Object(T.filter)(e.props.templates,{category:"home"}),"title"),comingSoonTemplates:Object(T.filter)(e.props.templates,{category:"coming-soon"})}})),w()(O()(e),"renderTemplatesList",(function(t,n){var r,i;if(!t.length)return null;var s,c="current"===(null===(r=t[0])||void 0===r?void 0:r.slug),l=c?{current:e.props.currentBlocks}:e.getBlocksByTemplateSlugs(e.props.templates),u=Object.keys(l),p=(s=u,t.filter((function(e){return s.includes(e.slug)})));return p.length?c&&!(null===(i=l.current)||void 0===i?void 0:i.length)?null:Object(o.createElement)("fieldset",{className:"page-template-modal__list"},Object(o.createElement)("legend",{className:"page-template-modal__form-title"},n),Object(o.createElement)(G,{label:Object(a.__)("Layout","full-site-editing"),legendLabel:n,templates:p,blocksByTemplates:l,onTemplateSelect:e.previewTemplate,useDynamicPreview:c,siteInformation:e.props.siteInformation,selectedTemplate:e.state.previewedTemplate})):null})),e}return b()(n,[{key:"filterTemplatesWithMissingBlocks",value:function(e){return Object(T.reduce)(e,(function(e,t,n){return oe(t)&&t.length||(e[n]=t),e}),{})}},{key:"componentDidMount",value:function(){this.props.isOpen&&this.trackCurrentView()}},{key:"componentDidUpdate",value:function(e){!e.isOpen&&this.props.isOpen&&this.trackCurrentView(),(this.props.isWelcomeGuideActive||this.props.areTipsEnabled)&&this.props.hideWelcomeGuide()}},{key:"trackCurrentView",value:function(){var e,t,n;e=this.props.segment.id,t=this.props.vertical.id,n=this.props.isPromptedFromSidebar?"sidebar":"add-page",U&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_view",{blog_id:U.blogid,segment_id:e,vertical_id:t,source:n}])}},{key:"getBlocksByTemplateSlug",value:function(e){return"current"===e?this.props.currentBlocks:Object(T.get)(this.getBlocksByTemplateSlugs(this.props.templates),[e],[])}},{key:"getTitleByTemplateSlug",value:function(e){return Object(T.get)(this.getTitlesByTemplateSlugs(this.props.templates),[e],"")}},{key:"render",value:function(){var e=this.state,t=e.previewedTemplate,n=e.isLoading,r=this.props,i=r.isPromptedFromSidebar,s=r.hidePageTitle,c=r.isOpen,l=r.currentBlocks;if(!c)return null;var u=this.getBlocksForPreview.cache.get("current");u&&l&&u.length!==l.length&&this.getBlocksForPreview.cache.delete("current");var p=this.getTemplateGroups(),m=p.blankTemplate,d=p.currentTemplate,f=p.aboutTemplates,b=p.blogTemplates,g=p.contactTemplates,O=p.eventTemplates,v=p.menuTemplates,h=p.portfolioTemplates,y=p.productTemplates,j=p.servicesTemplates,_=p.teamTemplates,w=p.homepageTemplates,k=p.comingSoonTemplates;return Object(o.createElement)(S.Modal,{title:Object(a.__)("Select Page Layout","full-site-editing"),className:"page-template-modal",overlayClassName:"page-template-modal-screen-overlay",shouldCloseOnClickOutside:!1,isDismissable:!1,isDismissible:!1},i?Object(o.createElement)(S.IconButton,{className:"page-template-modal__close-button components-icon-button",onClick:this.props.toggleTemplateModal,icon:"no-alt",label:Object(a.__)("Close Layout Selector","full-site-editing")}):Object(o.createElement)(S.IconButton,{className:"page-template-modal__close-button components-icon-button",onClick:this.closeModal,icon:"arrow-left-alt2",label:Object(a.__)("Go back","full-site-editing")}),Object(o.createElement)("div",{className:"page-template-modal__inner"},n?Object(o.createElement)("div",{className:"page-template-modal__loading"},Object(o.createElement)(S.Spinner,null),Object(a.__)("Adding layout…","full-site-editing")):Object(o.createElement)(o.Fragment,null,Object(o.createElement)("form",{className:"page-template-modal__form"},this.renderTemplatesList(d,Object(a.__)("Current","full-site-editing")),this.props.isFrontPage&&this.renderTemplatesList(w,Object(a.__)("Home Pages","full-site-editing")),this.renderTemplatesList(m,Object(a.__)("Blank","full-site-editing")),this.renderTemplatesList(f,Object(a.__)("About Pages","full-site-editing")),this.renderTemplatesList(b,Object(a.__)("Blog Pages","full-site-editing")),this.renderTemplatesList(g,Object(a.__)("Contact Pages","full-site-editing")),this.renderTemplatesList(O,Object(a.__)("Event Pages","full-site-editing")),this.renderTemplatesList(v,Object(a.__)("Menu Pages","full-site-editing")),this.renderTemplatesList(h,Object(a.__)("Portfolio Pages","full-site-editing")),this.renderTemplatesList(y,Object(a.__)("Product Pages","full-site-editing")),this.renderTemplatesList(j,Object(a.__)("Services Pages","full-site-editing")),this.renderTemplatesList(_,Object(a.__)("Team Pages","full-site-editing")),!this.props.isFrontPage&&this.renderTemplatesList(w,Object(a.__)("Home Pages","full-site-editing")),k&&this.renderTemplatesList(k,Object(a.__)("Coming Soon Pages","full-site-editing"))),Object(o.createElement)(q,{blocks:this.getBlocksForPreview(t),viewportWidth:1200,title:s||"current"!==t?this.getTitleByTemplateSlug(t):this.props.currentPostTitle}))),Object(o.createElement)("div",{className:P()("page-template-modal__buttons",{"is-visually-hidden":Object(T.isEmpty)(t)||n})},Object(o.createElement)(S.Button,{isPrimary:!0,disabled:Object(T.isEmpty)(t)||n,onClick:this.handleConfirmation},Object(a.sprintf)(Object(a.__)("Use %s layout","full-site-editing"),this.getTitleByTemplateSlug(t)))))}}],[{key:"getDerivedStateFromProps",value:function(e,t){return t.previewedTemplate||Object(T.isEmpty)(e.templates)?null:{previewedTemplate:n.getDefaultSelectedTemplate(e)}}}]),n}(o.Component);w()(ce,"getDefaultSelectedTemplate",(function(e){var t=Object(T.get)(e.templates,[0,"slug"]),n=e._starter_page_template;return e.isFrontPage||n?"current":t}));var le=Object(E.compose)(Object(c.withSelect)((function(e){var t=function(){return e("core/editor").getEditedPostAttribute("meta")},n=t()._starter_page_template,r=e("automattic/starter-page-layouts").isOpen(),i=e("core/editor").getBlocks();return{isOpen:r,getMeta:t,_starter_page_template:n,currentBlocks:i,currentPostTitle:e("core/editor").getCurrentPost().title,postContentBlock:i.find((function(e){return"a8c/post-content"===e.name})),isWelcomeGuideActive:e("core/edit-post").isFeatureActive("welcomeGuide"),areTipsEnabled:!!e("core/nux")&&e("core/nux").areTipsEnabled()}})),Object(c.withDispatch)((function(e,t){var n=e("core/editor");return{setIsOpen:e("automattic/starter-page-layouts").setIsOpen,saveTemplateChoice:function(e){var r=t.getMeta();n.editPost({meta:p()(p()({},r),{},{_starter_page_template:e})})},insertTemplate:function(r,i){Object(B.addFilter)(ae,se,T.stubTrue),r&&n.editPost({title:r});var o=t.postContentBlock;e("core/block-editor").replaceInnerBlocks(o?o.clientId:"",i,!1),Object(B.removeFilter)(ae,se)},hideWelcomeGuide:function(){t.isWelcomeGuideActive?e("core/edit-post").toggleFeature("welcomeGuide"):t.areTipsEnabled&&e("core/nux").disableTips()}}})))(ce),ue=function(e){h()(n,e);var t=j()(n);function n(){var e;d()(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return e=t.call.apply(t,[this].concat(i)),w()(O()(e),"state",{isWarningOpen:!1}),w()(O()(e),"toggleTemplateModal",(function(){e.props.setIsOpen(!e.props.isOpen)})),w()(O()(e),"toggleWarningModal",(function(){e.setState({isWarningOpen:!e.state.isWarningOpen})})),e}return b()(n,[{key:"render",value:function(){var e=this.props,t=e.templates,n=e.theme,r=e.vertical,i=e.segment,s=e.hidePageTitle,c=e.isFrontPage,l=e.isOpen;return Object(o.createElement)("div",{className:"sidebar-modal-opener"},Object(o.createElement)(S.Button,{isSecondary:!0,onClick:this.toggleWarningModal},Object(a.__)("Change Layout","full-site-editing")),l&&Object(o.createElement)(le,{shouldPrefetchAssets:!1,templates:t,theme:n,vertical:r,segment:i,toggleTemplateModal:this.toggleTemplateModal,hidePageTitle:s,isFrontPage:c,isPromptedFromSidebar:!0}),this.state.isWarningOpen&&Object(o.createElement)(S.Modal,{title:Object(a.__)("Overwrite Page Content?","full-site-editing"),isDismissible:!1,onRequestClose:this.toggleWarningModal,className:"sidebar-modal-opener__warning-modal"},Object(o.createElement)("div",{className:"sidebar-modal-opener__warning-text"},Object(a.__)("Changing the page's layout will remove any customizations or edits you have already made.","full-site-editing")),Object(o.createElement)("div",{className:"sidebar-modal-opener__warning-options"},Object(o.createElement)(S.Button,{isDefault:!0,onClick:this.toggleWarningModal},Object(a.__)("Cancel","full-site-editing")),Object(o.createElement)(S.Button,{isPrimary:!0,onClick:this.toggleTemplateModal},Object(a.__)("Change Layout","full-site-editing")))))}}]),n}(o.Component),pe=Object(E.compose)(Object(c.withSelect)((function(e){return{isOpen:e("automattic/starter-page-layouts").isOpen()}})),Object(c.withDispatch)((function(e){return{setIsOpen:e("automattic/starter-page-layouts").setIsOpen}})))(ue),me=n(28),de=n.n(me);Object(c.registerStore)("automattic/starter-page-layouts",{reducer:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{isOpen:!1},t=arguments.length>1?arguments[1]:void 0,n=t.type,r=de()(t,["type"]);return"SET_IS_OPEN"===n?p()(p()({},e),{},{isOpen:r.isOpen}):e},actions:{setIsOpen:function(e){return{type:"SET_IS_OPEN",isOpen:e}}},selectors:{isOpen:function(e){return e.isOpen}}});var fe,be=window.starterPageTemplatesConfig,ge=be.templates,Oe=void 0===ge?[]:ge,ve=be.vertical,he=be.segment,ye=be.tracksUserData,je=be.screenAction,_e=be.theme,we=be.isFrontPage,Te=be.hideFrontPageTitle;ye&&(U=fe=ye,window._tkq.push(["identifyUser",fe.userid,fe.username]));var ke={segment:he,templates:Oe,theme:_e,vertical:ve,isFrontPage:we,hidePageTitle:Boolean(we&&Te)};"add"===je&&(Object(c.dispatch)("automattic/starter-page-layouts").setIsOpen(!0),Object(s.registerPlugin)("page-templates",{render:function(){return Object(o.createElement)(le,i()({},ke,{shouldPrefetchAssets:!1}))}})),Object(s.registerPlugin)("page-templates-sidebar",{render:function(){return Object(o.createElement)(l.PluginDocumentSettingPanel,{name:"Template Modal Opener",title:Object(a.__)("Page Layout","full-site-editing"),className:"page-template-modal__sidebar",icon:"none"},Object(o.createElement)(pe,ke))}});var Pe=Object(c.subscribe)((function(){Object(c.select)("core/edit-post").isEditorPanelOpened("page-templates-sidebar/Template Modal Opener")||Object(c.dispatch)("core/edit-post").toggleEditorPanelOpened("page-templates-sidebar/Template Modal Opener"),Pe()}))}]));
|
1 |
+
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.lodash}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t){!function(){e.exports=this.wp.components}()},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t){!function(){e.exports=this.wp.compose}()},function(e,t,n){var r=n(3);function i(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}e.exports=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}},function(e,t,n){var r;
|
2 |
/*!
|
3 |
Copyright (c) 2017 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var o=typeof r;if("string"===o||"number"===o)e.push(r);else if(Array.isArray(r)&&r.length){var a=i.apply(null,r);a&&e.push(a)}else if("object"===o)for(var s in r)n.call(r,s)&&r[s]&&e.push(s)}}return e.join(" ")}e.exports?(i.default=i,e.exports=i):void 0===(r=function(){return i}.apply(t,[]))||(e.exports=r)}()},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t,n){var r=n(29);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}},function(e,t,n){var r=n(30),i=n(31),o=n(32);e.exports=function(e){var t=i();return function(){var n,i=r(e);if(t){var a=r(this).constructor;n=Reflect.construct(i,arguments,a)}else n=i.apply(this,arguments);return o(this,n)}}},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t){!function(){e.exports=this.wp.hooks}()},function(e,t,n){var r=n(36),i=n(37),o=n(20),a=n(38);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()}},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){function n(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(i,o){var a=e.apply(t,r);function s(e){n(a,i,o,s,c,"next",e)}function c(e){n(a,i,o,s,c,"throw",e)}s(void 0)}))}}},function(e,t,n){var r=n(39),i=n(40),o=n(20),a=n(41);e.exports=function(e){return r(e)||i(e)||o(e)||a()}},function(e,t,n){var r=n(21);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},n.apply(this,arguments)}e.exports=n},function(e,t){!function(){e.exports=this.wp.plugins}()},function(e,t){!function(){e.exports=this.wp.editPost}()},function(e,t){!function(){e.exports=this.wp.editor}()},function(e,t){!function(){e.exports=this.wp.apiFetch}()},function(e,t){!function(){e.exports=this.wp.url}()},function(e,t,n){var r=n(42);e.exports=function(e,t){if(null==e)return{};var n,i,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}},function(e,t){function n(t,r){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,r)}e.exports=n},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}},function(e,t,n){var r=n(33),i=n(4);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?i(e):t}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t){!function(){e.exports=this.wp.nux}()},function(e,t,n){},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],_n=!0,r=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(_n=(o=a.next()).done)&&(n.push(o.value),!t||n.length!==t);_n=!0);}catch(s){r=!0,i=s}finally{try{_n||null==a.return||a.return()}finally{if(r)throw i}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t,n){var r=n(21);e.exports=function(e){if(Array.isArray(e))return r(e)}},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}},function(e,t,n){"use strict";n.r(t);var r=n(22),i=n.n(r),o=n(0),a=n(2),s=n(23),c=n(6),l=n(24),u=n(8),p=n.n(u),m=n(10),d=n.n(m),f=n(11),b=n.n(f),g=n(4),O=n.n(g),v=n(12),h=n.n(v),y=n(13),j=n.n(y),_=n(3),w=n.n(_),T=n(1),k=n(9),P=n.n(k),S=(n(34),n(7)),E=n(5),x=n(14),B=n(15),C=(n(35),n(16)),N=n.n(C),D=n(17),I=n(25),L=function(e){var t=e.blocks,n=e.settings,r=e.hidePageTitle,i=e.recomputeBlockListKey;return Object(o.createElement)(D.BlockEditorProvider,{value:t,settings:n},Object(o.createElement)(E.Disabled,{key:i},!r&&Object(o.createElement)("div",{className:"block-iframe-preview__template-title edit-post-visual-editor__post-title-wrapper"},Object(o.createElement)(I.PostTitle,null)),Object(o.createElement)(D.BlockList,null)))},A=Object(S.compose)(S.withSafeTimeout,Object(c.withSelect)((function(e){var t=e("core/block-editor");return{settings:t?t.getSettings():{}}})))((function(e){var t,n,r=e.className,i=void 0===r?"block-iframe-preview":r,s=e.bodyClassName,c=void 0===s?"block-iframe-preview-body":s,l=e.viewportWidth,u=e.blocks,p=e.settings,m=e.setTimeout,d=void 0===m?T.noop:m,f=e.title,b=Object(o.useRef)(),g=Object(o.useRef)(),O=Object(o.useState)({transform:"scale( 1 )"}),v=N()(O,2),h=v[0],y=v[1],j=Object(o.useMemo)((function(){return Object(T.castArray)(u)}),[u]),_=Object(o.useReducer)((function(e){return e+1}),0),w=N()(_,2),k=w[0],S=w[1];Object(o.useLayoutEffect)(S,[u]);var E=Object(o.useCallback)((function(){var e=Object(T.get)(b,["current","parentNode"]);if(e){var t=l||b.current.offsetWidth,n=e.offsetWidth/l,r=e.offsetHeight/n;y({width:t,height:r,transform:"scale( ".concat(n," )")})}}),[l]);return Object(o.useEffect)((function(){if(f){var e=Object(T.get)(g,["current","contentDocument","body"]);if(e){var t=e.querySelector(".editor-post-title .editor-post-title__input");t&&(t.value=f)}}}),[k]),Object(o.useEffect)((function(){d((function(){var e,t,n,r;e=window.document,t=g.current.contentDocument,n=["link","style"],r={head:document.createDocumentFragment(),body:document.createDocumentFragment()},Object(T.each)(Object.keys(r),(function(t){return Object(T.each)(Object(T.filter)(e[t].children,(function(e){var t=e.localName;return n.includes(t)})),(function(e){r[t].appendChild(e.cloneNode(!0))}))})),t.head.appendChild(r.head),t.body.appendChild(r.body),g.current.contentDocument.body.classList.add(c,"editor-styles-wrapper","block-editor__container"),g.current.contentDocument.head.innerHTML+="<style>.editor-post-title .editor-post-title__input { height: auto !important; }</style>",E()}),0)}),[d,c,E]),Object(o.useEffect)((function(){var e=Object(T.get)(g,["current","contentDocument","body"]);e&&(e.scrollTop=0)}),[k]),Object(o.useEffect)((function(){var e=Object(T.debounce)(E,300);return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[E]),Object(o.useEffect)((function(){return window.jQuery&&window.jQuery(window.document).on("wp-collapse-menu",E),function(){window.jQuery&&window.jQuery(window.document).off("wp-collapse-menu",E)}}),[E]),Object(o.createElement)("div",{ref:b},Object(o.createElement)("iframe",{ref:g,title:Object(a.__)("Preview","full-site-editing"),className:P()("editor-styles-wrapper",i),style:h,tabIndex:-1},(null===(t=g.current)||void 0===t||null===(n=t.contentDocument)||void 0===n?void 0:n.body)&&Object(o.createPortal)(Object(o.createElement)("div",{className:"block-editor"},Object(o.createElement)("div",{className:"edit-post-visual-editor"},Object(o.createElement)("div",{className:"editor-styles-wrapper"},Object(o.createElement)("div",{className:"editor-writing-flow"},Object(o.createElement)(L,{blocks:j,settings:p,hidePageTitle:!f,recomputeBlockListKey:k}))))),g.current.contentDocument.body)))})),F=function(e){var t=e.id,n=e.value,r=e.onSelect,i=e.title,a=e.description,s=e.useDynamicPreview,c=void 0!==s&&s,l=e.staticPreviewImg,u=e.staticPreviewImgAlt,p=void 0===u?"":u,m=e.blocks,d=void 0===m?[]:m,f=e.isSelected;if(Object(T.isNil)(t)||Object(T.isNil)(i)||Object(T.isNil)(n))return null;if(c&&(Object(T.isNil)(d)||Object(T.isEmpty)(d)))return null;var b=c?Object(o.createElement)(A,{blocks:d,viewportWidth:960}):Object(o.createElement)("img",{className:"template-selector-item__media",src:l,alt:p});return Object(o.createElement)("button",{type:"button",className:P()("template-selector-item__label",{"is-selected":f}),value:n,onClick:function(){r(n)},"aria-label":a},Object(o.createElement)("span",{className:"template-selector-item__preview-wrap"},b))},M={Address:Object(a._x)("123 Main St","default address","full-site-editing"),Phone:Object(a._x)("555-555-5555","default phone number","full-site-editing"),CompanyName:Object(a._x)("Your Company Name","default company name","full-site-editing"),Vertical:Object(a._x)("Business","default vertical name","full-site-editing")},W={CompanyName:"title",Address:"address",Phone:"phone",Vertical:"vertical"},R=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?e.replace(/{{(\w+)}}/g,(function(e,n){var r=M[n];return t[W[n]]||r||n})):""},G=Object(S.compose)(o.memo,S.withInstanceId)((function(e){var t=e.label,n=e.legendLabel,r=e.className,i=e.help,a=e.instanceId,s=e.templates,c=void 0===s?[]:s,l=e.blocksByTemplates,u=void 0===l?{}:l,p=e.useDynamicPreview,m=void 0!==p&&p,d=e.onTemplateSelect,f=void 0===d?T.noop:d,b=e.siteInformation,g=void 0===b?{}:b,O=e.selectedTemplate;if(Object(T.isEmpty)(c)||!Object(T.isArray)(c))return null;if(!0===m&&Object(T.isEmpty)(u))return null;var v="template-selector-control-".concat(a);return Object(o.createElement)(E.BaseControl,{label:t,id:v,help:i,className:P()(r,"template-selector-control")},Object(o.createElement)("ul",{className:"template-selector-control__options","data-testid":"template-selector-control-options","aria-label":n},Object(T.map)(c,(function(e){var t=e.slug,n=e.title,r=e.description,a=e.preview,s=e.previewAlt;return Object(o.createElement)("li",{key:"".concat(v,"-").concat(t),className:"template-selector-control__template"},Object(o.createElement)(F,{id:v,value:t,title:R(n,g),description:r,help:i,onSelect:f,staticPreviewImg:a,staticPreviewImgAlt:s,blocks:u.hasOwnProperty(t)?u[t]:[],useDynamicPreview:m,isSelected:t===O}))}))))})),q=function(e){var t=e.blocks,n=void 0===t?[]:t,r=e.viewportWidth,i=e.title,s=!n.length;return Object(o.createElement)("div",{className:"template-selector-preview ".concat(s?"not-selected":"")},s&&Object(o.createElement)("div",{className:"editor-styles-wrapper"},Object(o.createElement)("div",{className:"template-selector-preview__empty-state"},Object(a.__)("Select a layout to preview.","full-site-editing"))),Object(o.createElement)(A,{blocks:n,viewportWidth:r,title:i}))};window._tkq=window._tkq||[];var U=null,z=function(e,t){U&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_dismiss",{blog_id:U.blogid,segment_id:e,vertical_id:t}])},V=function(e,t,n){U&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_template_selected",{blog_id:U.blogid,segment_id:e,vertical_id:t,template:n}])},Q=n(18),H=n.n(Q),K=n(19),Y=n.n(K),$=n(26),J=n.n($),X=n(27),Z=function(e,t,n){var r=e[t=Object(X.removeQueryArgs)(t,"w","s")]||{url:t,usages:[]};return p()(p()({},e),{},w()({},t,p()(p()({},r),{},{usages:[].concat(Y()(r.usages),Y()(n))})))},ee=function e(t,n){switch(t.blocksByClientId[n.clientId]=n,n.name){case"core/cover":case"core/image":var r=n.attributes.url;r&&(t.assets=Z(t.assets,r,[{prop:"url",path:[n.clientId,"attributes","url"]},{prop:"id",path:[n.clientId,"attributes","id"]}]));case"core/media-text":var i=n.attributes.mediaUrl;i&&"image"===n.attributes.mediaType&&(t.assets=Z(t.assets,i,[{prop:"url",path:[n.clientId,"attributes","mediaUrl"]},{prop:"id",path:[n.clientId,"attributes","mediaId"]}]));case"core/gallery":Object(T.forEach)(n.attributes.images,(function(e,r){t.assets=Z(t.assets,e.url,[{prop:"url",path:[n.clientId,"attributes","images",r,"url"]},{prop:"url",path:[n.clientId,"attributes","images",r,"link"]},{prop:"id",path:[n.clientId,"attributes","images",r,"id"]},{prop:"id",path:[n.clientId,"attributes","ids",r]}])}))}return Object(T.isEmpty)(n.innerBlocks)?t:Object(T.reduce)(n.innerBlocks,e,t)},te=function(){var e=H()(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J()({method:"POST",path:"/fse/v1/sideload/image/batch",data:{resources:Object(T.map)(t)}}).then((function(e){return Object(T.reduce)(t,(function(t,n){var r=e.shift(),i=r.id,o=r.source_url;return p()(p()({},t),{},w()({},n.url,{id:i,url:o}))}),{})}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),ne=function(e,t){return Object(T.forEach)(e.assets,(function(n){var r=t[n.url];r&&Object(T.forEach)(n.usages,(function(t){Object(T.set)(e.blocksByClientId,t.path,r[t.prop])}))})),e.blocks},re=function(){var e=H()(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Object(T.reduce)(t,ee,{assets:{},blocksByClientId:{},blocks:t}),!Object(T.isEmpty)(n.assets)){e.next=3;break}return e.abrupt("return",t);case 3:return e.abrupt("return",te(n.assets).then((function(e){return ne(n,e)})));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var ie=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T.identity;return t.map((function(t){return(t=n(Object(x.cloneBlock)(t))).innerBlocks&&t.innerBlocks.length&&(t.innerBlocks=e(t.innerBlocks,n)),t}))};var oe=function e(t){return!!t.find((function(t){return"core/missing"===t.name||!(!t.innerBlocks||!t.innerBlocks.length)&&e(t.innerBlocks)}))},ae="isInsertingPageTemplate",se="automattic/full-site-editing/inserting-template",ce=function(e){h()(n,e);var t=j()(n);function n(){var e;d()(this,n);for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];return e=t.call.apply(t,[this].concat(i)),w()(O()(e),"state",{isLoading:!1,previewedTemplate:null,error:null}),w()(O()(e),"getTitlesByTemplateSlugs",Object(T.memoize)((function(e){return Object(T.mapValues)(Object(T.keyBy)(e,"slug"),"title")}))),w()(O()(e),"getBlocksByTemplateSlugs",Object(T.memoize)((function(t){var n=Object(T.reduce)(t,(function(t,n){var r=n.slug,i=n.content;return t[r]=i?Object(x.parse)(R(i,e.props.siteInformation)):[],t}),{});return e.filterTemplatesWithMissingBlocks(n)}))),w()(O()(e),"getBlocksForPreview",Object(T.memoize)((function(t){var n=e.getBlocksByTemplateSlug(t);return ie(n,(function(e){return"jetpack/contact-form"===e.name&&void 0!==e.attributes.hasFormSettingsSet&&(e.attributes.hasFormSettingsSet=!0),e}))}))),w()(O()(e),"getBlocksForSelection",(function(t){var n=e.getBlocksByTemplateSlug(t);return ie(n,(function(e){return"core/button"===e.name&&void 0!==e.attributes.url&&(e.attributes.url="#"),e}))})),w()(O()(e),"setTemplate",(function(t){if(V(e.props.segment.id,e.props.vertical.id,t),e.props.saveTemplateChoice(t),"current"!==t){if("blank"===t)return e.props.insertTemplate("",[]),void e.props.setOpenState(!1);var n=Object(T.find)(e.props.templates,{slug:t,category:"home"}),r=e.getBlocksForSelection(t),i=n?null:e.getTitleByTemplateSlug(t);r&&r.length?(e.setState({error:null,isLoading:!0}),e.maybePrefetchAssets(r).then((function(t){e.setState({isLoading:!1}),e.props.isOpen&&(e.props.insertTemplate(i,t),e.props.setOpenState(!1))})).catch((function(t){e.setState({isLoading:!1,error:t})}))):e.props.setOpenState(!1)}else e.props.setOpenState(!1)})),w()(O()(e),"maybePrefetchAssets",(function(t){return e.props.shouldPrefetchAssets?re(t):Promise.resolve(t)})),w()(O()(e),"handleConfirmation",(function(t){"string"!=typeof t&&(t=e.state.previewedTemplate),e.setTemplate(t)})),w()(O()(e),"previewTemplate",(function(t){e.setState({previewedTemplate:t}),window.matchMedia("(min-width: 660px)").matches||e.handleConfirmation(t)})),w()(O()(e),"closeModal",(function(t){if(t.target.matches("button.template-selector-item__label"))return!1;z(e.props.segment.id,e.props.vertical.id);var n=Object(T.get)(window,["calypsoifyGutenberg","closeUrl"]);window.top.location=n||"edit.php?post_type=page"})),w()(O()(e),"getTemplateGroups",(function(){return{blankTemplate:Object(T.filter)(e.props.templates,{slug:"blank"}),currentTemplate:Object(T.filter)(e.props.templates,{slug:"current"}),aboutTemplates:Object(T.filter)(e.props.templates,{category:"about"}),blogTemplates:Object(T.filter)(e.props.templates,{category:"blog"}),contactTemplates:Object(T.filter)(e.props.templates,{category:"contact"}),eventTemplates:Object(T.filter)(e.props.templates,{category:"event"}),menuTemplates:Object(T.filter)(e.props.templates,{category:"menu"}),portfolioTemplates:Object(T.filter)(e.props.templates,{category:"portfolio"}),productTemplates:Object(T.filter)(e.props.templates,{category:"product"}),servicesTemplates:Object(T.filter)(e.props.templates,{category:"services"}),teamTemplates:Object(T.filter)(e.props.templates,{category:"team"}),homepageTemplates:Object(T.sortBy)(Object(T.filter)(e.props.templates,{category:"home"}),"title"),comingSoonTemplates:Object(T.filter)(e.props.templates,{category:"coming-soon"})}})),w()(O()(e),"renderTemplatesList",(function(t,n){var r,i;if(!t.length)return null;var s,c="current"===(null===(r=t[0])||void 0===r?void 0:r.slug),l=c?{current:e.props.currentBlocks}:e.getBlocksByTemplateSlugs(e.props.templates),u=Object.keys(l),p=(s=u,t.filter((function(e){return s.includes(e.slug)})));return p.length?c&&!(null===(i=l.current)||void 0===i?void 0:i.length)?null:Object(o.createElement)("fieldset",{className:"page-template-modal__list"},Object(o.createElement)("legend",{className:"page-template-modal__form-title"},n),Object(o.createElement)(G,{label:Object(a.__)("Layout","full-site-editing"),legendLabel:n,templates:p,blocksByTemplates:l,onTemplateSelect:e.previewTemplate,useDynamicPreview:c,siteInformation:e.props.siteInformation,selectedTemplate:e.state.previewedTemplate})):null})),e}return b()(n,[{key:"filterTemplatesWithMissingBlocks",value:function(e){return Object(T.reduce)(e,(function(e,t,n){return oe(t)&&t.length||(e[n]=t),e}),{})}},{key:"componentDidMount",value:function(){this.props.isOpen&&this.trackCurrentView()}},{key:"componentDidUpdate",value:function(e){!e.isOpen&&this.props.isOpen&&this.trackCurrentView(),(this.props.isWelcomeGuideActive||this.props.areTipsEnabled)&&this.props.hideWelcomeGuide()}},{key:"trackCurrentView",value:function(){var e,t,n;e=this.props.segment.id,t=this.props.vertical.id,n=this.props.isPromptedFromSidebar?"sidebar":"add-page",U&&window._tkq.push(["recordEvent","a8c_full_site_editing_template_selector_view",{blog_id:U.blogid,segment_id:e,vertical_id:t,source:n}])}},{key:"getBlocksByTemplateSlug",value:function(e){return"current"===e?this.props.currentBlocks:Object(T.get)(this.getBlocksByTemplateSlugs(this.props.templates),[e],[])}},{key:"getTitleByTemplateSlug",value:function(e){return Object(T.get)(this.getTitlesByTemplateSlugs(this.props.templates),[e],"")}},{key:"render",value:function(){var e=this.state,t=e.previewedTemplate,n=e.isLoading,r=this.props,i=r.isPromptedFromSidebar,s=r.hidePageTitle,c=r.isOpen,l=r.currentBlocks,u=r.setOpenState;if(!c)return null;var p=this.getBlocksForPreview.cache.get("current");p&&l&&p.length!==l.length&&this.getBlocksForPreview.cache.delete("current");var m=this.getTemplateGroups(),d=m.blankTemplate,f=m.currentTemplate,b=m.aboutTemplates,g=m.blogTemplates,O=m.contactTemplates,v=m.eventTemplates,h=m.menuTemplates,y=m.portfolioTemplates,j=m.productTemplates,_=m.servicesTemplates,w=m.teamTemplates,k=m.homepageTemplates,S=m.comingSoonTemplates;return Object(o.createElement)(E.Modal,{title:Object(a.__)("Select Page Layout","full-site-editing"),className:"page-template-modal",overlayClassName:"page-template-modal-screen-overlay",shouldCloseOnClickOutside:!1,isDismissable:!1,isDismissible:!1},i?Object(o.createElement)(E.IconButton,{className:"page-template-modal__close-button components-icon-button",onClick:function(){return u(!1)},icon:"no-alt",label:Object(a.__)("Close Layout Selector","full-site-editing")}):Object(o.createElement)(E.IconButton,{className:"page-template-modal__close-button components-icon-button",onClick:this.closeModal,icon:"arrow-left-alt2",label:Object(a.__)("Go back","full-site-editing")}),Object(o.createElement)("div",{className:"page-template-modal__inner"},n?Object(o.createElement)("div",{className:"page-template-modal__loading"},Object(o.createElement)(E.Spinner,null),Object(a.__)("Adding layout…","full-site-editing")):Object(o.createElement)(o.Fragment,null,Object(o.createElement)("form",{className:"page-template-modal__form"},this.renderTemplatesList(f,Object(a.__)("Current","full-site-editing")),this.props.isFrontPage&&this.renderTemplatesList(k,Object(a.__)("Home Pages","full-site-editing")),this.renderTemplatesList(d,Object(a.__)("Blank","full-site-editing")),this.renderTemplatesList(b,Object(a.__)("About Pages","full-site-editing")),this.renderTemplatesList(g,Object(a.__)("Blog Pages","full-site-editing")),this.renderTemplatesList(O,Object(a.__)("Contact Pages","full-site-editing")),this.renderTemplatesList(v,Object(a.__)("Event Pages","full-site-editing")),this.renderTemplatesList(h,Object(a.__)("Menu Pages","full-site-editing")),this.renderTemplatesList(y,Object(a.__)("Portfolio Pages","full-site-editing")),this.renderTemplatesList(j,Object(a.__)("Product Pages","full-site-editing")),this.renderTemplatesList(_,Object(a.__)("Services Pages","full-site-editing")),this.renderTemplatesList(w,Object(a.__)("Team Pages","full-site-editing")),!this.props.isFrontPage&&this.renderTemplatesList(k,Object(a.__)("Home Pages","full-site-editing")),S&&this.renderTemplatesList(S,Object(a.__)("Coming Soon Pages","full-site-editing"))),Object(o.createElement)(q,{blocks:this.getBlocksForPreview(t),viewportWidth:1200,title:s||"current"!==t?this.getTitleByTemplateSlug(t):this.props.currentPostTitle}))),Object(o.createElement)("div",{className:P()("page-template-modal__buttons",{"is-visually-hidden":Object(T.isEmpty)(t)||n})},Object(o.createElement)(E.Button,{isPrimary:!0,disabled:Object(T.isEmpty)(t)||n,onClick:this.handleConfirmation},Object(a.sprintf)(Object(a.__)("Use %s layout","full-site-editing"),this.getTitleByTemplateSlug(t)))))}}],[{key:"getDerivedStateFromProps",value:function(e,t){return t.previewedTemplate||Object(T.isEmpty)(e.templates)?null:{previewedTemplate:n.getDefaultSelectedTemplate(e)}}}]),n}(o.Component);w()(ce,"getDefaultSelectedTemplate",(function(e){var t=Object(T.get)(e.templates,[0,"slug"]),n=e._starter_page_template;return e.isFrontPage||n?"current":t}));var le=Object(S.compose)(Object(c.withSelect)((function(e){var t=function(){return e("core/editor").getEditedPostAttribute("meta")},n=t()._starter_page_template,r=e("automattic/starter-page-layouts"),i=r.isOpen,o=r.isPromptedFromSidebar,a=e("core/editor").getBlocks();return{isOpen:i(),isPromptedFromSidebar:o(),getMeta:t,_starter_page_template:n,currentBlocks:a,currentPostTitle:e("core/editor").getCurrentPost().title,postContentBlock:a.find((function(e){return"a8c/post-content"===e.name})),isWelcomeGuideActive:e("core/edit-post").isFeatureActive("welcomeGuide"),areTipsEnabled:!!e("core/nux")&&e("core/nux").areTipsEnabled()}})),Object(c.withDispatch)((function(e,t){var n=e("core/editor");return{setOpenState:e("automattic/starter-page-layouts").setOpenState,saveTemplateChoice:function(e){var r=t.getMeta();n.editPost({meta:p()(p()({},r),{},{_starter_page_template:e})})},insertTemplate:function(r,i){Object(B.addFilter)(ae,se,T.stubTrue),r&&n.editPost({title:r});var o=t.postContentBlock;e("core/block-editor").replaceInnerBlocks(o?o.clientId:"",i,!1),Object(B.removeFilter)(ae,se)},hideWelcomeGuide:function(){t.isWelcomeGuideActive?e("core/edit-post").toggleFeature("welcomeGuide"):t.areTipsEnabled&&e("core/nux").disableTips()}}})))(ce),ue=function(e){h()(n,e);var t=j()(n);function n(){var e;d()(this,n);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return e=t.call.apply(t,[this].concat(i)),w()(O()(e),"state",{isWarningOpen:!1}),w()(O()(e),"openTemplateModal",(function(){e.props.setOpenState("OPEN_FROM_SIDEBAR")})),w()(O()(e),"toggleWarningModal",(function(){e.setState((function(e){return{isWarningOpen:!e.isWarningOpen}}))})),e}return b()(n,[{key:"render",value:function(){return Object(o.createElement)("div",{className:"sidebar-modal-opener"},Object(o.createElement)(E.Button,{isSecondary:!0,onClick:this.toggleWarningModal},Object(a.__)("Change Layout","full-site-editing")),this.state.isWarningOpen&&Object(o.createElement)(E.Modal,{title:Object(a.__)("Overwrite Page Content?","full-site-editing"),isDismissible:!1,onRequestClose:this.toggleWarningModal,className:"sidebar-modal-opener__warning-modal"},Object(o.createElement)("div",{className:"sidebar-modal-opener__warning-text"},Object(a.__)("Changing the page's layout will remove any customizations or edits you have already made.","full-site-editing")),Object(o.createElement)("div",{className:"sidebar-modal-opener__warning-options"},Object(o.createElement)(E.Button,{isDefault:!0,onClick:this.toggleWarningModal},Object(a.__)("Cancel","full-site-editing")),Object(o.createElement)(E.Button,{isPrimary:!0,onClick:this.openTemplateModal},Object(a.__)("Change Layout","full-site-editing")))))}}]),n}(o.Component),pe=Object(S.compose)(Object(c.withDispatch)((function(e){return{setOpenState:e("automattic/starter-page-layouts").setOpenState}})))(ue),me=n(28),de=n.n(me);Object(c.registerStore)("automattic/starter-page-layouts",{reducer:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"CLOSED",t=arguments.length>1?arguments[1]:void 0,n=t.type,r=de()(t,["type"]);return"SET_IS_OPEN"===n?r.openState:e},actions:{setOpenState:function(e){return{type:"SET_IS_OPEN",openState:e||"CLOSED"}}},selectors:{isOpen:function(e){return"CLOSED"!==e},isPromptedFromSidebar:function(e){return"OPEN_FROM_SIDEBAR"===e}}});var fe,be=window.starterPageTemplatesConfig,ge=be.templates,Oe=void 0===ge?[]:ge,ve=be.vertical,he=be.segment,ye=be.tracksUserData,je=be.screenAction,_e=be.theme,we=be.isFrontPage,Te=be.hideFrontPageTitle;ye&&(U=fe=ye,window._tkq.push(["identifyUser",fe.userid,fe.username]));var ke={segment:he,templates:Oe,theme:_e,vertical:ve,isFrontPage:we,hidePageTitle:Boolean(we&&Te)};"add"===je&&Object(c.dispatch)("automattic/starter-page-layouts").setOpenState("OPEN_FROM_ADD_PAGE"),Object(s.registerPlugin)("page-templates",{render:function(){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(le,i()({},ke,{shouldPrefetchAssets:!1})),Object(o.createElement)(l.PluginDocumentSettingPanel,{name:"Template Modal Opener",title:Object(a.__)("Page Layout","full-site-editing"),className:"page-template-modal__sidebar",icon:"none"},Object(o.createElement)(pe,null)))}});var Pe=Object(c.subscribe)((function(){Object(c.select)("core/edit-post").isEditorPanelOpened("page-templates/Template Modal Opener")||Object(c.dispatch)("core/edit-post").toggleEditorPanelOpened("page-templates/Template Modal Opener"),Pe()}))}]));
|
starter-page-templates/index.js
CHANGED
@@ -41,26 +41,24 @@ const templatesPluginSharedProps = {
|
|
41 |
|
42 |
// Open plugin only if we are creating new page.
|
43 |
if ( screenAction === 'add' ) {
|
44 |
-
dispatch( 'automattic/starter-page-layouts' ).
|
45 |
-
registerPlugin( 'page-templates', {
|
46 |
-
render: () => (
|
47 |
-
<PageTemplatesPlugin { ...templatesPluginSharedProps } shouldPrefetchAssets={ false } />
|
48 |
-
),
|
49 |
-
} );
|
50 |
}
|
51 |
|
52 |
// Always register ability to open from document sidebar.
|
53 |
-
registerPlugin( 'page-templates
|
54 |
render: () => {
|
55 |
return (
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
64 |
);
|
65 |
},
|
66 |
} );
|
@@ -68,13 +66,9 @@ registerPlugin( 'page-templates-sidebar', {
|
|
68 |
// Make sidebar plugin open by default.
|
69 |
const unsubscribe = subscribe( () => {
|
70 |
if (
|
71 |
-
! select( 'core/edit-post' ).isEditorPanelOpened(
|
72 |
-
'page-templates-sidebar/Template Modal Opener'
|
73 |
-
)
|
74 |
) {
|
75 |
-
dispatch( 'core/edit-post' ).toggleEditorPanelOpened(
|
76 |
-
'page-templates-sidebar/Template Modal Opener'
|
77 |
-
);
|
78 |
}
|
79 |
unsubscribe();
|
80 |
} );
|
41 |
|
42 |
// Open plugin only if we are creating new page.
|
43 |
if ( screenAction === 'add' ) {
|
44 |
+
dispatch( 'automattic/starter-page-layouts' ).setOpenState( 'OPEN_FROM_ADD_PAGE' );
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
// Always register ability to open from document sidebar.
|
48 |
+
registerPlugin( 'page-templates', {
|
49 |
render: () => {
|
50 |
return (
|
51 |
+
<>
|
52 |
+
<PageTemplatesPlugin { ...templatesPluginSharedProps } shouldPrefetchAssets={ false } />
|
53 |
+
<PluginDocumentSettingPanel
|
54 |
+
name="Template Modal Opener"
|
55 |
+
title={ __( 'Page Layout', 'full-site-editing' ) }
|
56 |
+
className="page-template-modal__sidebar"
|
57 |
+
icon="none"
|
58 |
+
>
|
59 |
+
<SidebarTemplatesPlugin />
|
60 |
+
</PluginDocumentSettingPanel>
|
61 |
+
</>
|
62 |
);
|
63 |
},
|
64 |
} );
|
66 |
// Make sidebar plugin open by default.
|
67 |
const unsubscribe = subscribe( () => {
|
68 |
if (
|
69 |
+
! select( 'core/edit-post' ).isEditorPanelOpened( 'page-templates/Template Modal Opener' )
|
|
|
|
|
70 |
) {
|
71 |
+
dispatch( 'core/edit-post' ).toggleEditorPanelOpened( 'page-templates/Template Modal Opener' );
|
|
|
|
|
72 |
}
|
73 |
unsubscribe();
|
74 |
} );
|
starter-page-templates/page-template-modal/components/sidebar-modal-opener.js
CHANGED
@@ -2,50 +2,33 @@
|
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { Component } from '@wordpress/element';
|
5 |
-
import {
|
6 |
import { Button, Modal } from '@wordpress/components';
|
7 |
import { compose } from '@wordpress/compose';
|
8 |
import { __ } from '@wordpress/i18n';
|
9 |
-
|
10 |
-
* Internal dependencies
|
11 |
-
*/
|
12 |
-
import { PageTemplatesPlugin } from '../index';
|
13 |
class SidebarModalOpener extends Component {
|
14 |
state = {
|
15 |
isWarningOpen: false,
|
16 |
};
|
17 |
|
18 |
-
|
19 |
-
this.props.
|
20 |
};
|
21 |
|
22 |
toggleWarningModal = () => {
|
23 |
-
this.setState(
|
|
|
|
|
24 |
};
|
25 |
|
26 |
render() {
|
27 |
-
const { templates, theme, vertical, segment, hidePageTitle, isFrontPage, isOpen } = this.props;
|
28 |
-
|
29 |
return (
|
30 |
<div className="sidebar-modal-opener">
|
31 |
<Button isSecondary onClick={ this.toggleWarningModal }>
|
32 |
{ __( 'Change Layout', 'full-site-editing' ) }
|
33 |
</Button>
|
34 |
|
35 |
-
{ isOpen && (
|
36 |
-
<PageTemplatesPlugin
|
37 |
-
shouldPrefetchAssets={ false }
|
38 |
-
templates={ templates }
|
39 |
-
theme={ theme }
|
40 |
-
vertical={ vertical }
|
41 |
-
segment={ segment }
|
42 |
-
toggleTemplateModal={ this.toggleTemplateModal }
|
43 |
-
hidePageTitle={ hidePageTitle }
|
44 |
-
isFrontPage={ isFrontPage }
|
45 |
-
isPromptedFromSidebar
|
46 |
-
/>
|
47 |
-
) }
|
48 |
-
|
49 |
{ this.state.isWarningOpen && (
|
50 |
<Modal
|
51 |
title={ __( 'Overwrite Page Content?', 'full-site-editing' ) }
|
@@ -63,7 +46,7 @@ class SidebarModalOpener extends Component {
|
|
63 |
<Button isDefault onClick={ this.toggleWarningModal }>
|
64 |
{ __( 'Cancel', 'full-site-editing' ) }
|
65 |
</Button>
|
66 |
-
<Button isPrimary onClick={ this.
|
67 |
{ __( 'Change Layout', 'full-site-editing' ) }
|
68 |
</Button>
|
69 |
</div>
|
@@ -75,11 +58,8 @@ class SidebarModalOpener extends Component {
|
|
75 |
}
|
76 |
|
77 |
const SidebarTemplatesPlugin = compose(
|
78 |
-
withSelect( ( select ) => ( {
|
79 |
-
isOpen: select( 'automattic/starter-page-layouts' ).isOpen(),
|
80 |
-
} ) ),
|
81 |
withDispatch( ( dispatch ) => ( {
|
82 |
-
|
83 |
} ) )
|
84 |
)( SidebarModalOpener );
|
85 |
|
2 |
* External dependencies
|
3 |
*/
|
4 |
import { Component } from '@wordpress/element';
|
5 |
+
import { withDispatch } from '@wordpress/data';
|
6 |
import { Button, Modal } from '@wordpress/components';
|
7 |
import { compose } from '@wordpress/compose';
|
8 |
import { __ } from '@wordpress/i18n';
|
9 |
+
|
|
|
|
|
|
|
10 |
class SidebarModalOpener extends Component {
|
11 |
state = {
|
12 |
isWarningOpen: false,
|
13 |
};
|
14 |
|
15 |
+
openTemplateModal = () => {
|
16 |
+
this.props.setOpenState( 'OPEN_FROM_SIDEBAR' );
|
17 |
};
|
18 |
|
19 |
toggleWarningModal = () => {
|
20 |
+
this.setState( ( state ) => ( {
|
21 |
+
isWarningOpen: ! state.isWarningOpen,
|
22 |
+
} ) );
|
23 |
};
|
24 |
|
25 |
render() {
|
|
|
|
|
26 |
return (
|
27 |
<div className="sidebar-modal-opener">
|
28 |
<Button isSecondary onClick={ this.toggleWarningModal }>
|
29 |
{ __( 'Change Layout', 'full-site-editing' ) }
|
30 |
</Button>
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
{ this.state.isWarningOpen && (
|
33 |
<Modal
|
34 |
title={ __( 'Overwrite Page Content?', 'full-site-editing' ) }
|
46 |
<Button isDefault onClick={ this.toggleWarningModal }>
|
47 |
{ __( 'Cancel', 'full-site-editing' ) }
|
48 |
</Button>
|
49 |
+
<Button isPrimary onClick={ this.openTemplateModal }>
|
50 |
{ __( 'Change Layout', 'full-site-editing' ) }
|
51 |
</Button>
|
52 |
</div>
|
58 |
}
|
59 |
|
60 |
const SidebarTemplatesPlugin = compose(
|
|
|
|
|
|
|
61 |
withDispatch( ( dispatch ) => ( {
|
62 |
+
setOpenState: dispatch( 'automattic/starter-page-layouts' ).setOpenState,
|
63 |
} ) )
|
64 |
)( SidebarModalOpener );
|
65 |
|
starter-page-templates/page-template-modal/index.js
CHANGED
@@ -182,7 +182,7 @@ class PageTemplateModal extends Component {
|
|
182 |
|
183 |
// Skip setting template if user selects current layout
|
184 |
if ( 'current' === slug ) {
|
185 |
-
this.props.
|
186 |
return;
|
187 |
}
|
188 |
|
@@ -190,7 +190,7 @@ class PageTemplateModal extends Component {
|
|
190 |
// and reset the template if so.
|
191 |
if ( 'blank' === slug ) {
|
192 |
this.props.insertTemplate( '', [] );
|
193 |
-
this.props.
|
194 |
return;
|
195 |
}
|
196 |
|
@@ -205,7 +205,7 @@ class PageTemplateModal extends Component {
|
|
205 |
// Skip inserting if this is not a blank template
|
206 |
// and there's nothing to insert.
|
207 |
if ( ! blocks || ! blocks.length ) {
|
208 |
-
this.props.
|
209 |
return;
|
210 |
}
|
211 |
|
@@ -226,7 +226,7 @@ class PageTemplateModal extends Component {
|
|
226 |
}
|
227 |
|
228 |
this.props.insertTemplate( title, blocksWithAssets );
|
229 |
-
this.props.
|
230 |
} )
|
231 |
.catch( ( error ) => {
|
232 |
this.setState( {
|
@@ -246,11 +246,6 @@ class PageTemplateModal extends Component {
|
|
246 |
}
|
247 |
|
248 |
this.setTemplate( slug );
|
249 |
-
|
250 |
-
// Turn off sidebar's instance of modal
|
251 |
-
if ( this.props.isPromptedFromSidebar ) {
|
252 |
-
this.props.toggleTemplateModal();
|
253 |
-
}
|
254 |
};
|
255 |
|
256 |
previewTemplate = ( slug ) => {
|
@@ -366,7 +361,13 @@ class PageTemplateModal extends Component {
|
|
366 |
|
367 |
render() {
|
368 |
const { previewedTemplate, isLoading } = this.state;
|
369 |
-
const {
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
if ( ! isOpen ) {
|
372 |
return null;
|
@@ -414,7 +415,7 @@ class PageTemplateModal extends Component {
|
|
414 |
{ isPromptedFromSidebar ? (
|
415 |
<IconButton
|
416 |
className="page-template-modal__close-button components-icon-button"
|
417 |
-
onClick={
|
418 |
icon="no-alt"
|
419 |
label={ __( 'Close Layout Selector', 'full-site-editing' ) }
|
420 |
/>
|
@@ -531,10 +532,11 @@ export const PageTemplatesPlugin = compose(
|
|
531 |
withSelect( ( select ) => {
|
532 |
const getMeta = () => select( 'core/editor' ).getEditedPostAttribute( 'meta' );
|
533 |
const { _starter_page_template } = getMeta();
|
534 |
-
const isOpen = select( 'automattic/starter-page-layouts' )
|
535 |
const currentBlocks = select( 'core/editor' ).getBlocks();
|
536 |
return {
|
537 |
-
isOpen,
|
|
|
538 |
getMeta,
|
539 |
_starter_page_template,
|
540 |
currentBlocks,
|
@@ -546,9 +548,9 @@ export const PageTemplatesPlugin = compose(
|
|
546 |
} ),
|
547 |
withDispatch( ( dispatch, ownProps ) => {
|
548 |
const editorDispatcher = dispatch( 'core/editor' );
|
549 |
-
const {
|
550 |
return {
|
551 |
-
|
552 |
saveTemplateChoice: ( slug ) => {
|
553 |
// Save selected template slug in meta.
|
554 |
const currentMeta = ownProps.getMeta();
|
182 |
|
183 |
// Skip setting template if user selects current layout
|
184 |
if ( 'current' === slug ) {
|
185 |
+
this.props.setOpenState( false );
|
186 |
return;
|
187 |
}
|
188 |
|
190 |
// and reset the template if so.
|
191 |
if ( 'blank' === slug ) {
|
192 |
this.props.insertTemplate( '', [] );
|
193 |
+
this.props.setOpenState( false );
|
194 |
return;
|
195 |
}
|
196 |
|
205 |
// Skip inserting if this is not a blank template
|
206 |
// and there's nothing to insert.
|
207 |
if ( ! blocks || ! blocks.length ) {
|
208 |
+
this.props.setOpenState( false );
|
209 |
return;
|
210 |
}
|
211 |
|
226 |
}
|
227 |
|
228 |
this.props.insertTemplate( title, blocksWithAssets );
|
229 |
+
this.props.setOpenState( false );
|
230 |
} )
|
231 |
.catch( ( error ) => {
|
232 |
this.setState( {
|
246 |
}
|
247 |
|
248 |
this.setTemplate( slug );
|
|
|
|
|
|
|
|
|
|
|
249 |
};
|
250 |
|
251 |
previewTemplate = ( slug ) => {
|
361 |
|
362 |
render() {
|
363 |
const { previewedTemplate, isLoading } = this.state;
|
364 |
+
const {
|
365 |
+
isPromptedFromSidebar,
|
366 |
+
hidePageTitle,
|
367 |
+
isOpen,
|
368 |
+
currentBlocks,
|
369 |
+
setOpenState,
|
370 |
+
} = this.props;
|
371 |
|
372 |
if ( ! isOpen ) {
|
373 |
return null;
|
415 |
{ isPromptedFromSidebar ? (
|
416 |
<IconButton
|
417 |
className="page-template-modal__close-button components-icon-button"
|
418 |
+
onClick={ () => setOpenState( false ) }
|
419 |
icon="no-alt"
|
420 |
label={ __( 'Close Layout Selector', 'full-site-editing' ) }
|
421 |
/>
|
532 |
withSelect( ( select ) => {
|
533 |
const getMeta = () => select( 'core/editor' ).getEditedPostAttribute( 'meta' );
|
534 |
const { _starter_page_template } = getMeta();
|
535 |
+
const { isOpen, isPromptedFromSidebar } = select( 'automattic/starter-page-layouts' );
|
536 |
const currentBlocks = select( 'core/editor' ).getBlocks();
|
537 |
return {
|
538 |
+
isOpen: isOpen(),
|
539 |
+
isPromptedFromSidebar: isPromptedFromSidebar(),
|
540 |
getMeta,
|
541 |
_starter_page_template,
|
542 |
currentBlocks,
|
548 |
} ),
|
549 |
withDispatch( ( dispatch, ownProps ) => {
|
550 |
const editorDispatcher = dispatch( 'core/editor' );
|
551 |
+
const { setOpenState } = dispatch( 'automattic/starter-page-layouts' );
|
552 |
return {
|
553 |
+
setOpenState,
|
554 |
saveTemplateChoice: ( slug ) => {
|
555 |
// Save selected template slug in meta.
|
556 |
const currentMeta = ownProps.getMeta();
|
starter-page-templates/store.js
CHANGED
@@ -3,18 +3,19 @@
|
|
3 |
*/
|
4 |
import { registerStore } from '@wordpress/data';
|
5 |
|
6 |
-
const reducer = ( state =
|
7 |
-
'SET_IS_OPEN' === type ?
|
8 |
|
9 |
const actions = {
|
10 |
-
|
11 |
type: 'SET_IS_OPEN',
|
12 |
-
|
13 |
} ),
|
14 |
};
|
15 |
|
16 |
const selectors = {
|
17 |
-
isOpen: ( state ) => state
|
|
|
18 |
};
|
19 |
|
20 |
registerStore( 'automattic/starter-page-layouts', {
|
3 |
*/
|
4 |
import { registerStore } from '@wordpress/data';
|
5 |
|
6 |
+
const reducer = ( state = 'CLOSED', { type, ...action } ) =>
|
7 |
+
'SET_IS_OPEN' === type ? action.openState : state;
|
8 |
|
9 |
const actions = {
|
10 |
+
setOpenState: ( openState ) => ( {
|
11 |
type: 'SET_IS_OPEN',
|
12 |
+
openState: openState || 'CLOSED',
|
13 |
} ),
|
14 |
};
|
15 |
|
16 |
const selectors = {
|
17 |
+
isOpen: ( state ) => 'CLOSED' !== state,
|
18 |
+
isPromptedFromSidebar: ( state ) => 'OPEN_FROM_SIDEBAR' === state,
|
19 |
};
|
20 |
|
21 |
registerStore( 'automattic/starter-page-layouts', {
|