Layout Grid Block - Version 1.2.1

Version Description

  • 10th June 2020 =
  • Fix block inserter to show inside a grid column
  • Fix vertical margin in editor so it better matches the display
  • Fix CSS loading so it is only added when block is used
  • Fix grid lines appearing when inner block is selected
Download this release

Release Info

Developer johnny5
Plugin Icon 128x128 Layout Grid Block
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2 to 1.2.1

Files changed (7) hide show
  1. blocks/layout-grid.php +10 -2
  2. editor.css +11 -13
  3. index.asset.php +1 -1
  4. index.js +1 -1
  5. index.php +1 -1
  6. readme.txt +9 -3
  7. style.css +2 -1
blocks/layout-grid.php CHANGED
@@ -3,14 +3,22 @@
3
  add_action( 'init', function() {
4
  register_block_type( 'jetpack/layout-grid', [
5
  'editor_script' => 'jetpack-layout-grid',
6
- 'style' => 'jetpack-layout-grid',
7
  'editor_style' => 'jetpack-layout-grid-editor',
 
 
 
 
 
8
  ] );
9
 
10
  register_block_type( 'jetpack/layout-grid-column', [
11
  'editor_script' => 'jetpack-layout-grid',
12
- 'style' => 'jetpack-layout-grid',
13
  'editor_style' => 'jetpack-layout-grid-editor',
 
 
 
 
 
14
  ] );
15
 
16
  wp_set_script_translations( 'jetpack/layout-grid', 'layout-grid' );
3
  add_action( 'init', function() {
4
  register_block_type( 'jetpack/layout-grid', [
5
  'editor_script' => 'jetpack-layout-grid',
 
6
  'editor_style' => 'jetpack-layout-grid-editor',
7
+ 'render_callback' => function( $attribs, $content ) {
8
+ wp_enqueue_style( 'jetpack-layout-grid' );
9
+ wp_enqueue_style( 'wpcom-layout-grid-front' );
10
+ return $content;
11
+ }
12
  ] );
13
 
14
  register_block_type( 'jetpack/layout-grid-column', [
15
  'editor_script' => 'jetpack-layout-grid',
 
16
  'editor_style' => 'jetpack-layout-grid-editor',
17
+ 'render_callback' => function( $attribs, $content ) {
18
+ wp_enqueue_style( 'jetpack-layout-grid' );
19
+ wp_enqueue_style( 'wpcom-layout-grid-front' );
20
+ return $content;
21
+ }
22
  ] );
23
 
24
  wp_set_script_translations( 'jetpack/layout-grid', 'layout-grid' );
editor.css CHANGED
@@ -14,32 +14,20 @@
14
  padding-right: 24px;
15
  z-index: 0;
16
  color: rgba(0, 0, 0, 0.03); }
17
- .is-hovered .wpcom-overlay-grid,
18
- .is-selected .wpcom-overlay-grid,
19
- .has-child-selected .wpcom-overlay-grid {
20
  position: absolute; }
21
  .is-dark-theme .wpcom-overlay-grid {
22
  color: rgba(255, 255, 255, 0.15); }
23
  .wpcom-overlay-grid .wpcom-overlay-grid__column {
24
  transition: border .4s ease; }
25
- .has-child-selected .wpcom-overlay-grid .wpcom-overlay-grid__column,
26
- .is-hovered .wpcom-overlay-grid .wpcom-overlay-grid__column,
27
  .is-selected .wpcom-overlay-grid .wpcom-overlay-grid__column {
28
  box-shadow: -12px 0 0 0 currentColor, 12px 0 0 0 currentColor; }
29
- .has-child-selected .wp-block-jetpack-layout-gutter__none .wpcom-overlay-grid .wpcom-overlay-grid__column,
30
- .is-hovered .wp-block-jetpack-layout-gutter__none .wpcom-overlay-grid .wpcom-overlay-grid__column,
31
  .is-selected .wp-block-jetpack-layout-gutter__none .wpcom-overlay-grid .wpcom-overlay-grid__column {
32
  box-shadow: -1px 0 0 0 currentColor, 1px 0 0 0 currentColor; }
33
- .has-child-selected .wp-block-jetpack-layout-gutter__small .wpcom-overlay-grid .wpcom-overlay-grid__column,
34
- .is-hovered .wp-block-jetpack-layout-gutter__small .wpcom-overlay-grid .wpcom-overlay-grid__column,
35
  .is-selected .wp-block-jetpack-layout-gutter__small .wpcom-overlay-grid .wpcom-overlay-grid__column {
36
  box-shadow: -4px 0 0 0 currentColor, 4px 0 0 0 currentColor; }
37
- .has-child-selected .wp-block-jetpack-layout-gutter__medium .wpcom-overlay-grid .wpcom-overlay-grid__column,
38
- .is-hovered .wp-block-jetpack-layout-gutter__medium .wpcom-overlay-grid .wpcom-overlay-grid__column,
39
  .is-selected .wp-block-jetpack-layout-gutter__medium .wpcom-overlay-grid .wpcom-overlay-grid__column {
40
  box-shadow: -8px 0 0 0 currentColor, 8px 0 0 0 currentColor; }
41
- .has-child-selected .wp-block-jetpack-layout-gutter__huge .wpcom-overlay-grid .wpcom-overlay-grid__column,
42
- .is-hovered .wp-block-jetpack-layout-gutter__huge .wpcom-overlay-grid .wpcom-overlay-grid__column,
43
  .is-selected .wp-block-jetpack-layout-gutter__huge .wpcom-overlay-grid .wpcom-overlay-grid__column {
44
  box-shadow: -24px 0 0 0 currentColor, 24px 0 0 0 currentColor; }
45
 
@@ -582,6 +570,10 @@ body.is-resizing [data-type="jetpack/layout-grid"] {
582
  /**
583
  * Margins & Paddings
584
  */
 
 
 
 
585
  [data-type="jetpack/layout-grid"] > .block-editor-block-list__block-edit > [data-block] {
586
  margin-top: 0;
587
  margin-bottom: 0; }
@@ -611,6 +603,12 @@ body.is-resizing [data-type="jetpack/layout-grid"] {
611
  .wp-block-jetpack-layout-grid-column > .block-editor-inner-blocks > .block-editor-block-list__layout > .block-list-appender {
612
  margin: 28px 0; }
613
 
 
 
 
 
 
 
614
  /**
615
  * Inspector Controls
616
  */
14
  padding-right: 24px;
15
  z-index: 0;
16
  color: rgba(0, 0, 0, 0.03); }
17
+ .is-selected .wpcom-overlay-grid {
 
 
18
  position: absolute; }
19
  .is-dark-theme .wpcom-overlay-grid {
20
  color: rgba(255, 255, 255, 0.15); }
21
  .wpcom-overlay-grid .wpcom-overlay-grid__column {
22
  transition: border .4s ease; }
 
 
23
  .is-selected .wpcom-overlay-grid .wpcom-overlay-grid__column {
24
  box-shadow: -12px 0 0 0 currentColor, 12px 0 0 0 currentColor; }
 
 
25
  .is-selected .wp-block-jetpack-layout-gutter__none .wpcom-overlay-grid .wpcom-overlay-grid__column {
26
  box-shadow: -1px 0 0 0 currentColor, 1px 0 0 0 currentColor; }
 
 
27
  .is-selected .wp-block-jetpack-layout-gutter__small .wpcom-overlay-grid .wpcom-overlay-grid__column {
28
  box-shadow: -4px 0 0 0 currentColor, 4px 0 0 0 currentColor; }
 
 
29
  .is-selected .wp-block-jetpack-layout-gutter__medium .wpcom-overlay-grid .wpcom-overlay-grid__column {
30
  box-shadow: -8px 0 0 0 currentColor, 8px 0 0 0 currentColor; }
 
 
31
  .is-selected .wp-block-jetpack-layout-gutter__huge .wpcom-overlay-grid .wpcom-overlay-grid__column {
32
  box-shadow: -24px 0 0 0 currentColor, 24px 0 0 0 currentColor; }
33
 
570
  /**
571
  * Margins & Paddings
572
  */
573
+ [data-type="jetpack/layout-grid"] {
574
+ margin-top: 0;
575
+ margin-bottom: 0; }
576
+
577
  [data-type="jetpack/layout-grid"] > .block-editor-block-list__block-edit > [data-block] {
578
  margin-top: 0;
579
  margin-bottom: 0; }
603
  .wp-block-jetpack-layout-grid-column > .block-editor-inner-blocks > .block-editor-block-list__layout > .block-list-appender {
604
  margin: 28px 0; }
605
 
606
+ .wp-block:not(.is-selected):not(.has-child-selected) .block-editor-default-block-appender {
607
+ display: inherit; }
608
+
609
+ [data-type="jetpack/layout-grid"]:not(.is-selected):not(.has-child-selected) .block-editor-default-block-appender {
610
+ display: none; }
611
+
612
  /**
613
  * Inspector Controls
614
  */
index.asset.php CHANGED
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('lodash', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives'), 'version' => '10f3c440a209c7d5c2811893a774bdac');
1
+ <?php return array('dependencies' => array('lodash', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives'), 'version' => '860374c4af0c08fc9b4eb6df25eb07c8');
index.js CHANGED
@@ -3,4 +3,4 @@
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 o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r)&&r.length){var a=o.apply(null,r);a&&e.push(a)}else if("object"===c)for(var i in r)n.call(r,i)&&r[i]&&e.push(i)}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},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){!function(){e.exports=this.wp.primitives}()},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(24);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(25),o=n(5);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t}},function(e,t){!function(){e.exports=this.wp.blocks}()},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(20),o=n(21),c=n(22),a=n(23);e.exports=function(e){return r(e)||o(e)||c(e)||a()}},function(e,t){!function(){e.exports=this.lodash}()},function(e,t){!function(){e.exports=this.wp.keycodes}()},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,n){var r=n(19);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,n){var r=n(19);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(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}},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){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"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,n){"use strict";n.r(t);var r=n(3),o=n.n(r),c=n(13),a=n(1),i=n(16),u=n.n(i),l=n(9),s=n.n(l),f=n(10),d=n.n(f),p=n(5),b=n.n(p),h=n(11),g=n.n(h),m=n(12),v=n.n(m),y=n(7),O=n.n(y),j=n(0),k=n(17),w=n(6),_=n.n(w),E=n(4),S=n(2),x=n(18),C=n(14),P=n(15),M=n(8),z=Object(j.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(j.createElement)(M.Path,{d:"M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"})),B=Object(j.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(j.createElement)(M.Path,{d:"M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"})),R=Object(j.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(j.createElement)(M.Path,{d:"M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"}));function D(){return[{value:"small",label:Object(a.__)("Small","layout-grid")},{value:"medium",label:Object(a.__)("Medium","layout-grid")},{value:"large",label:Object(a.__)("Large","layout-grid")},{value:"huge",label:Object(a.__)("Huge","layout-grid")}]}var A=function(){return[{label:Object(a.__)("1 column","layout-grid"),value:1},{label:Object(a.__)("2 columns","layout-grid"),value:2},{label:Object(a.__)("3 columns","layout-grid"),value:3},{label:Object(a.__)("4 columns","layout-grid"),value:4}]},V=function(){return[{value:"Desktop",label:Object(a.__)("Desktop","layout-grid"),icon:z},{value:"Tablet",label:Object(a.__)("Tablet","layout-grid"),icon:B},{value:"Mobile",label:Object(a.__)("Mobile","layout-grid"),icon:R}]},N=["Desktop","Tablet","Mobile"];function G(e,t){return"column".concat(e+1).concat(t,"Span")}function L(e,t){return"column".concat(e+1).concat(t,"Offset")}var T=function(e){return"Tablet"===e?8:"Mobile"===e?4:12};function I(e,t,n){return"Tablet"===e?3===t&&2===n?T(e):t>1?T(e)/2:T(e):"Mobile"===e?T(e):T(e)/t}function H(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 U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?H(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var X=function(e,t){return"column".concat(e+1,"-grid__span-").concat(t)},F=function(e,t){return"column".concat(e+1,"-grid__start-").concat(t)},K=function(e,t){return"column".concat(e+1,"-grid__row-").concat(t)},W=function(e,t,n){return"column".concat(e+1,"-").concat(n.toLowerCase(),"-grid__span-").concat(t)},$=function(e,t,n){return"column".concat(e+1,"-").concat(n.toLowerCase(),"-grid__start-").concat(t)},q=function(e,t,n){return"column".concat(e+1,"-").concat(n.toLowerCase(),"-grid__row-").concat(t)};function J(e,t){return Math.floor(e/t)}function Q(e,t){return e%t}function Y(e,t,n,r){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return{name:e,column:t,value:n,device:r,enabled:o}}function Z(e,t,n){for(var r=[],o=T(e),c=function(e,t,n){for(var r=[],o=0,c=0;c<e;c++){var a=G(c,t),i=L(c,t),u=n[a]||I(t,e,c),l=n[i]||0;r.push({position:o+l,span:u}),o+=l,o+=u}return r}(t,e,n),a=0;a<c.length;a++){var i=c[a],u=i.span,l=i.position,s=J(l,o),f=Q(l,o);r.push(Y("span",a,u,e)),r.push(Y("offset",a,f+1,e,f>0)),r.push(Y("row",a,s+1,e))}return r}function ee(e,t){var n={};return e.filter((function(e){return e.enabled&&t[e.name]})).map((function(e){return n[t[e.name](e.column,e.value,e.device)]=!0})),n}function te(e){return e?e.replace(/column\d-\w*-grid__\w*-\d*/g,"").replace(/column\d-grid__\w*-\d*/g,"").replace(/\s{2,}/,"").replace(/wp-block-jetpack-layout-gutter__\w*/,""):e}function ne(e){var t=e.gutterSize;return{"wp-block-jetpack-layout-gutter__nowrap":!e.addGutterEnds,"wp-block-jetpack-layout-gutter__none":"none"===t,"wp-block-jetpack-layout-gutter__small":"small"===t,"wp-block-jetpack-layout-gutter__medium":"medium"===t,"wp-block-jetpack-layout-gutter__huge":"huge"===t}}var re=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(j.createElement)(S.Path,{d:"M19 6H6c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7.5 11.5H6c-.3 0-.5-.2-.5-.5V8c0-.3.2-.5.5-.5h5.5v10zm4 0H13v-10h2.5v10zm4-.5c0 .3-.2.5-.5.5h-2v-10h2c.3 0 .5.2.5.5v9z"}))},oe=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(j.createElement)(S.Path,{d:"M19 6H6c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zM5.5 17V8c0-.3.2-.5.5-.5h5.5v10H6c-.3 0-.5-.2-.5-.5zm14 0c0 .3-.2.5-.5.5h-2v-10h2c.3 0 .5.2.5.5v9z"}))},ce=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7 12v24h34V12H7zm32 22H9V14h30v20z"}))},ae=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7,12v24h34V12H7z M23,34H9V14h14V34z M39,34H25V14h14V34z"}))},ie=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7 12v24h34V12H7zm23 2h9v20h-9V14zm-2 20h-8V14h8v20zM9 14h9v20H9V14z"}))},ue=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7 12v24h34V12H7zm8 22H9V14h6v20zm8 0h-6V14h6v20zm8 0h-6V14h6v20zm8 0h-6V14h6v20z"}))},le=function(e){var t=e.columns;return 4===t?Object(j.createElement)(ue,null):3===t?Object(j.createElement)(ie,null):2===t?Object(j.createElement)(ae,null):Object(j.createElement)(ce,null)};var se=function(e){var t=e.direction,n=e.height,r=e.xPos,o=e.top,c=e.isSelected,a=_()("wpcom-overlay-resize__handle","components-resizable-box__container",{"is-selected":c}),i={height:n+"px",width:r+"px",top:o+"px"},u={left:r+"px"},l=_()("components-resizable-box__handle","components-resizable-box__side-handle",{"components-resizable-box__handle-left":"left"===t,"components-resizable-box__handle-right":"right"===t});return Object(j.createElement)("div",{className:a,style:i},Object(j.createElement)("span",null,Object(j.createElement)("div",{className:l,style:u})))};function fe(){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}}var de=function(e){g()(r,e);var t,n=(t=r,function(){var e,n=O()(t);if(fe()){var r=O()(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return v()(this,e)});function r(e){var t;return s()(this,r),t=n.call(this,e),o()(b()(t),"onMouseDown",(function(e){var n=e.target;if((0===e.button||e.touches)&&(n.dataset.resizeRight||n.dataset.resizeLeft)){t.block=n.closest(".wp-block");var r=t.block.getBoundingClientRect(),o=r.height,c=r.right,a=r.left,i=r.top,u=n.getBoundingClientRect().width,l=t.getChildPosition(t.block),s=n.dataset.resizeLeft;t.setState({resizingColumn:l,xPos:t.getAdjustedOffset(t.getMouseX(e),u),height:o,width:u,top:t.getAdjustedTop(i),direction:s?"left":"right",max:s?t.getAdjustedOffset(c,u):t.getAdjustedOffset(a,u)}),0===e.button?(document.addEventListener("mousemove",t.onMouseMove),document.addEventListener("mouseup",t.onMouseUp),e.preventDefault()):(document.addEventListener("touchmove",t.onMouseMove),document.addEventListener("touchend",t.onMouseUp)),e.stopPropagation()}})),o()(b()(t),"onMouseMove",(function(e){e.stopPropagation(),void 0===e.touches&&e.preventDefault();var n=t.block.getBoundingClientRect().height;t.setState({xPos:t.getRestrictedOffset(t.getAdjustedOffset(t.getMouseX(e))),height:n});var r=t.getNearestColumn(t.state.direction,e);r&&t.props.onResize(t.state.resizingColumn,r)})),o()(b()(t),"onMouseUp",(function(e){t.setState({resizingColumn:-1}),document.removeEventListener("mousemove",t.onMouseMove),document.removeEventListener("mouseup",t.onMouseUp),document.removeEventListener("touchmove",t.onMouseMove),document.removeEventListener("touchend",t.onMouseUp)})),t.containerRef=Object(j.createRef)(),t.state={resizingColumn:-1,xPos:0,height:0},t}return d()(r,[{key:"getNearestColumn",value:function(e,t){var n=this.props,r=n.totalColumns,o=n.layoutGrid,c=o.getStart(this.state.resizingColumn),a=o.getSpan(this.state.resizingColumn),i=Math.min(r,Math.max(0,function(e,t,n,r){var o=e.getBoundingClientRect(),c=o.width/r,a=t-o.x,i=Math.floor(a/c),u=a%c;return"left"===n?u<=c/2?i:i+1:u<c/2?i:i+1}(this.containerRef.current,this.getMouseX(t),e,r)));if("left"===e){if(i===c)return null;var u=Math.abs(i-c),l={start:i,span:i>c?a-u:a+u,direction:e};return l.start>=c+a?null:(l.span=Math.max(1,l.span),l)}return{span:Math.max(1,i-c),direction:e}}},{key:"getMouseX",value:function(e){var t=e.clientX,n=e.targetTouches;return t||n&&n[0].clientX}},{key:"getAdjustedOffset",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.state.width,r=t>0?t:n;return e-this.containerRef.current.getBoundingClientRect().left-r/2}},{key:"getAdjustedTop",value:function(e){return e-this.containerRef.current.getBoundingClientRect().top}},{key:"getRestrictedOffset",value:function(e){var t=this.state,n=t.direction,r=t.max,o=t.width;return"left"===n?Math.min(r-o,e):Math.max(r+o,e)}},{key:"getChildPosition",value:function(e){for(var t=0;null!==e.previousSibling;)e=e.previousSibling,t++;return t}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.children,r=e.isSelected,o=this.state,c=o.resizingColumn,a=o.xPos,i=o.height,u=_()(t,-1!==c?"wp-block-jetpack-layout-grid__resizing":null);return Object(j.createElement)("div",{className:u,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,ref:this.containerRef},-1!==c&&Object(j.createElement)(se,{direction:this.state.direction,height:i,xPos:a,top:this.state.top,isSelected:r}),n)}}]),r}(j.Component);function pe(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 be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pe(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var he=function(){function e(t,n,r){s()(this,e),this.attributes=t,this.device=n,this.columnCount=r}return d()(e,[{key:"getGridValues",value:function(){for(var e={},t=0;t<this.columnCount;t++){var n=I(this.device,this.columnCount,t);e[G(t,this.device)]=this.getSpan(t)||n,e[L(t,this.device)]=this.getOffset(t)}return e}},{key:"applyAdjustments",value:function(e){for(var t=this.getGridValues(),n=0;n<e.length;n++)t=be({},t,{},e[n]);return t}},{key:"getSpanAdjustment",value:function(e,t){return o()({},G(e,this.device),t)}},{key:"getAdjustOffset",value:function(e,t){return o()({},L(e,this.device),t)}},{key:"getShrinkOffset",value:function(e,t){var n=this.getOffset(e),r=t>=n?n:t;return{adjustment:this.getAdjustOffset(e,n-r),offsetUsed:r}}},{key:"hasOverlaps",value:function(e){for(var t=0;t<e.length;t++)for(var n=e[t],r=t+1;r<e.length;r++){var o=e[r];if(n.start>o.start&&n.start<o.end)return!0;if(n.end>o.start&&n.end<o.end)return!0}return!1}},{key:"validateGrid",value:function(e){for(var t,n,r=[],o=T(this.device),c=0,a=0,i=0;i<this.columnCount;i++){var u=e[G(i,this.device)],l=e[L(i,this.device)];if((a+=l)>=o&&(a-=o),(a+=u)>o)return!1;r.push({start:c+l,end:c+l+u}),c+=u+l}return!(c>(t=this.device,n=this.columnCount,"Tablet"===t&&n>2?2*T(t):"Mobile"===t?T(t)*n:T(t)))&&!this.hasOverlaps(r)}},{key:"getEndAdjustments",value:function(e,t){var n=[];if(t<0)return[this.getAdjustOffset(e,this.getOffset(e)+Math.abs(t))];if(t>0)for(var r=e;r<this.columnCount&&t>0;r++){var o=this.getShrinkOffset(r,Math.abs(t));n.push(o.adjustment),t-=o.offsetUsed}return n}},{key:"getStartMovedLeft",value:function(e,t){for(var n=[],r=e;r>=0&&t>0;r--){var o=this.getShrinkOffset(r,t);n.push(o.adjustment),t-=o.offsetUsed}return n}},{key:"getStartAdjustments",value:function(e,t){var n=this.getOffset(e),r=this.getOffsetFromStart(e,t),o=r-n;return o<0?this.getStartMovedLeft(e,Math.abs(o)):[this.getAdjustOffset(e,r)]}},{key:"getSpan",value:function(e){return this.attributes[G(e,this.device)]}},{key:"getOffset",value:function(e){return this.attributes[L(e,this.device)]}},{key:"getStart",value:function(e){for(var t=0,n=0;n<e;n++)t+=this.getSpan(n)+this.getOffset(n);var r=Math.max(1,Math.floor(t/T(this.device)));return(t+this.getOffset(e))%(r*T(this.device))}},{key:"getOffsetFromStart",value:function(e,t){if(0===e)return t;var n=t-this.getStart(e);return this.getOffset(e)+n}},{key:"convertOffsetToStart",value:function(e,t){return this.getStart(e)+(t-this.getOffset(e))}},{key:"getAdjustedGrid",value:function(e,t){var n=t.start,r=void 0===n?this.getStart(e):n,o=t.span,c=void 0===o?this.getSpan(e):o,a=[];r!==this.getStart(e)&&c!==this.getSpan(e)?a=(a=a.concat(this.getStartAdjustments(e,r))).concat(this.getSpanAdjustment(e,c)):c!==this.getSpan(e)?a=(a=a.concat(this.getSpanAdjustment(e,c))).concat(this.getEndAdjustments(e+1,c-this.getSpan(e))):r!==this.getStart(e)&&(a=(a=a.concat(this.getStartAdjustments(e,r))).concat(this.getEndAdjustments(e+1,r-this.getStart(e))));var i=this.applyAdjustments(a);return a.length>0&&this.validateGrid(i)?i:null}}]),e}();function ge(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 me(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ge(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ve(){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}}var ye=["jetpack/layout-grid-column"],Oe=function(e){g()(r,e);var t,n=(t=r,function(){var e,n=O()(t);if(ve()){var r=O()(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return v()(this,e)});function r(e){var t;return s()(this,r),t=n.call(this,e),o()(b()(t),"onChangeLayout",(function(e){for(var n={},r=0;r<e;r++)for(var o=0;o<N.length;o++){var c=I(N[o],e,r);n[G(r,N[o])]=c,n[L(r,N[o])]=0}t.props.updateColumns(t.props.columns,e,n)})),o()(b()(t),"onChangeDevice",(function(e){t.setState({selectedDevice:e})})),o()(b()(t),"onResize",(function(e,n){var r=t.props,o=r.attributes,c=r.columns,a=new he(o,t.state.selectedDevice,c).getAdjustedGrid(e,n);a&&t.adjustGrid(a)})),o()(b()(t),"onChangeSpan",(function(e,n,r){var o=t.props,c=o.attributes,a=o.columns,i=new he(c,n,a).getAdjustedGrid(e,{span:parseInt(r,10)});i&&t.adjustGrid(i)})),o()(b()(t),"onChangeOffset",(function(e,n,r){var o=t.props,c=o.attributes,a=o.columns,i=new he(c,n,a),u=i.getAdjustedGrid(e,{start:i.convertOffsetToStart(e,parseInt(r,10))});u&&t.adjustGrid(u)})),t.overlayRef=Object(j.createRef)(),t.state={selectedDevice:V()[0].value},t}return d()(r,[{key:"adjustGrid",value:function(e){var t=this.props;(0,t.setAttributes)(me({},e,{className:te(t.attributes.className)}))}},{key:"renderDeviceSettings",value:function(e,t,n){for(var r=this,o=new he(n,t,this.props.columns),c=[],i=function(n){var i=o.getSpan(n)||I(t,e,n),u=o.getOffset(n)||0;c.push(Object(j.createElement)("div",{className:"jetpack-layout-grid-settings",key:n},Object(j.createElement)("strong",null,Object(a.__)("Column","layout-grid")," ",n+1),Object(j.createElement)("div",{className:"jetpack-layout-grid-settings__group"},Object(j.createElement)(S.TextControl,{type:"number",label:Object(a.__)("Offset","layout-grid"),value:u||0,min:0,max:T(t)-1,onChange:function(e){return r.onChangeOffset(n,t,e)}}),Object(j.createElement)(S.TextControl,{type:"number",label:Object(a.__)("Span","layout-grid"),value:i,min:1,max:T(t),onChange:function(e){return r.onChangeSpan(n,t,e)}}))))},u=0;u<e;u++)i(u);return c}},{key:"canResizeBreakpoint",value:function(e){return!(!this.overlayRef||!this.overlayRef.current)&&this.overlayRef.current.getBoundingClientRect().width/T(e)>50}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,r=t.attributes,o=void 0===r?{}:r,c=t.isSelected,i=t.columns,u=t.setAttributes,l=this.state.selectedDevice,s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Z(e,t,n),o={span:X,offset:F,row:K};return ee(r,o)}(l,i,o),f=o.gutterSize,d=o.addGutterEnds,p=new he(o,l,i),b=_()(te(n),s,{"wp-block-jetpack-layout-tablet":"Tablet"===l,"wp-block-jetpack-layout-desktop":"Desktop"===l,"wp-block-jetpack-layout-mobile":"Mobile"===l,"wp-block-jetpack-layout-resizable":this.canResizeBreakpoint(l)},ne(o));if(0===i)return Object(j.createElement)(S.Placeholder,{icon:"layout",label:Object(a.__)("Choose Layout","layout-grid"),instructions:Object(a.__)("Select a layout to start with:","layout-grid"),className:b},Object(j.createElement)("ul",{className:"block-editor-inner-blocks__template-picker-options"},A().map((function(t){return Object(j.createElement)("li",{key:t.value},Object(j.createElement)(S.IconButton,{isSecondary:!0,icon:Object(j.createElement)(le,{columns:t.value}),onClick:function(){return e.onChangeLayout(t.value)},className:"block-editor-inner-blocks__template-picker-option",label:t.label}))}))));var h=Object(j.createElement)(S.ToggleControl,{label:Object(a.__)("Add end gutters","layout-grid"),help:d?Object(a.__)("Toggle off to remove the spacing left and right of the grid.","layout-grid"):Object(a.__)("Toggle on to add space left and right of the layout grid. ","layout-grid"),checked:d,onChange:function(e){return u({addGutterEnds:e})}});return Object(j.createElement)(j.Fragment,null,Object(j.createElement)(S.IsolatedEventContainer,null,Object(j.createElement)(de,{className:b,onResize:this.onResize,totalColumns:T(l),layoutGrid:p,isSelected:c},Object(j.createElement)("div",{className:"wpcom-overlay-grid",ref:this.overlayRef},Object(k.times)(T(l)).map((function(e){return Object(j.createElement)("div",{className:"wpcom-overlay-grid__column",key:e})}))),Object(j.createElement)(E.InnerBlocks,{template:null,templateLock:"all",allowedBlocks:ye}),Object(j.createElement)(E.InspectorControls,null,Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Layout","layout-grid")},Object(j.createElement)("div",{className:"jetpack-layout-grid-columns block-editor-block-styles"},A().map((function(t){return Object(j.createElement)("div",{key:t.value,className:_()("block-editor-block-styles__item",{"is-active":i===t.value}),onClick:function(){return e.onChangeLayout(t.value)},onKeyDown:function(n){x.ENTER!==n.keyCode&&x.SPACE!==n.keyCode||(n.preventDefault(),e.onChangeLayout(t.value))},role:"button",tabIndex:"0","aria-label":t.label},Object(j.createElement)("div",{className:"block-editor-block-styles__item-preview"},Object(j.createElement)(le,{columns:t.value})),Object(j.createElement)("div",{className:"editor-block-styles__item-label block-editor-block-styles__item-label"},t.label))}))),Object(j.createElement)("p",null,Object(j.createElement)("em",null,Object(a.__)("Changing the number of columns will reset your layout and could remove content.","layout-grid")))),Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Responsive Breakpoints","layout-grid")},Object(j.createElement)("p",null,Object(j.createElement)("em",null,Object(a.__)("Note that previewing your post will show your browser's breakpoint, not the currently selected one.","layout-grid"))),Object(j.createElement)(S.ButtonGroup,null,V().map((function(t){return Object(j.createElement)(S.Button,{key:t.value,isPrimary:t.value===l,onClick:function(){return e.onChangeDevice(t.value)}},t.label)}))),this.renderDeviceSettings(i,l,o)),Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Gutter","layout-grid")},Object(j.createElement)("p",null,Object(a.__)("Gutter size","layout-grid")),Object(j.createElement)(S.SelectControl,{value:f,onChange:function(e){return u({gutterSize:e,addGutterEnds:"none"!==e&&d})},options:[{value:"none",label:Object(a.__)("No gutter","layout-grid")}].concat(D())}),"none"===f?Object(j.createElement)(S.Disabled,null,h):h)))),Object(j.createElement)(E.BlockControls,null,Object(j.createElement)(S.Dropdown,{renderToggle:function(e){var t=e.isOpen,n=e.onToggle;return Object(j.createElement)(S.ToolbarGroup,null,Object(j.createElement)(S.Button,{"aria-expanded":t,onClick:n,icon:V().find((function(e){return e.value===l})).icon}))},renderContent:function(t){t.onClose;return Object(j.createElement)(S.MenuGroup,null,V().map((function(t){return Object(j.createElement)(S.MenuItem,{key:t.value,isSelected:t.value===l,onClick:function(){return e.setState({selectedDevice:t.value})},icon:t.icon},t.label)})))}})))}}]),r}(j.Component);var je=Object(P.compose)([Object(C.withDispatch)((function(e,t,n){return{updateColumns:function(r,o,a){var i=t.clientId,l=e("core/block-editor").replaceBlock,s=function(e,t,n){if(n>t)return[].concat(u()(e),u()(Object(k.times)(n-t,(function(){return Object(c.createBlock)("jetpack/layout-grid-column")}))));var r=u()(e),o=0;return r.reverse(),(r=r.filter((function(e){return!(o<t-n&&0===e.innerBlocks.length)||(o++,!1)}))).slice(Math.max(0,t-n-o)).reverse()}((0,n.select("core/block-editor").getBlocks)(i),r,o);l(i,Object(c.createBlock)(t.name,me({},t.attributes,{},a,{className:te(t.attributes.className)}),s))}}})),Object(C.withSelect)((function(e,t){var n=t.clientId;return{columns:e("core/block-editor").getBlockCount(n)}}))])(Oe),ke=function(e){var t=e.attributes,n=e.innerBlocks,r=t.className,o=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={},r={span:W,offset:$,row:q},o=0;o<N.length;o++)n=U({},n,{},ee(Z(N[o],e,t),r));return t.addGutterEnds||(n["wp-block-jetpack-layout-gutter__nowrap"]=!0),n}(n.length,t),c=_()(te(r),o,ne(t));return Object(j.createElement)("div",{className:c},Object(j.createElement)(E.InnerBlocks.Content,null))};function we(){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}}var _e=function(e){g()(r,e);var t,n=(t=r,function(){var e,n=O()(t);if(we()){var r=O()(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return v()(this,e)});function r(e){var t;return s()(this,r),t=n.call(this,e),o()(b()(t),"onLeftIn",(function(){t.setState({direction:"left"}),document.addEventListener("mouseup",t.onLeftOut)})),o()(b()(t),"onLeftOut",(function(){t.setState({direction:null}),document.removeEventListener("mouseup",t.onLeftOut)})),o()(b()(t),"onRightIn",(function(){t.setState({direction:"right"}),document.addEventListener("mouseup",t.onRightOut)})),o()(b()(t),"onRightOut",(function(){t.setState({direction:null}),document.removeEventListener("mouseup",t.onRightOut)})),t.state={direction:null},t}return d()(r,[{key:"render",value:function(){var e,t=this.props,n=t.className,r=t.hasChildBlocks,c=t.backgroundColor,i=t.setBackgroundColor,u=t.attributes,l=t.setAttributes,s=u.padding,f=this.state.direction,d=_()(n,c.class,(e={},o()(e,"wp-block-jetpack-layout-grid__padding-"+s,!0),o()(e,"has-background",c.color),o()(e,"components-resizable-box__container",!0),o()(e,c.class,c.class),o()(e,"wp-blocks-jetpack-layout-grid__showleft","right"===f),o()(e,"wp-blocks-jetpack-layout-grid__showright","left"===f),e)),p={backgroundColor:c.color};return Object(j.createElement)("div",{className:d,style:p},Object(j.createElement)("span",{className:"wp-blocks-jetpack-layout-grid__resize-handles"},Object(j.createElement)("div",{className:"components-resizable-box__handle components-resizable-box__side-handle components-resizable-box__handle-right",onMouseDown:this.onRightIn,"data-resize-right":!0}),Object(j.createElement)("div",{className:"components-resizable-box__handle components-resizable-box__side-handle components-resizable-box__handle-left",onMouseDown:this.onLeftIn,"data-resize-left":!0})),Object(j.createElement)(E.InnerBlocks,{templateLock:!1,renderAppender:r?void 0:function(){return Object(j.createElement)(E.InnerBlocks.ButtonBlockAppender,null)}}),Object(j.createElement)(E.InspectorControls,null,Object(j.createElement)(E.PanelColorSettings,{title:Object(a.__)("Column Color","layout-grid"),initialOpen:!0,colorSettings:[{value:c.color,onChange:i,label:Object(a.__)("Background","layout-grid")}]}),Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Column Padding","layout-grid")},Object(j.createElement)("p",null,Object(a.__)("Choose padding for this column:","layout-grid")),Object(j.createElement)(S.SelectControl,{value:s,onChange:function(e){return l({padding:e})},options:[{value:"none",label:Object(a.__)("No padding","layout-grid")}].concat(D())}))))}}]),r}(j.Component),Ee=Object(P.compose)(Object(E.withColors)("backgroundColor"),Object(C.withSelect)((function(e,t){var n=t.clientId;return{hasChildBlocks:(0,e("core/block-editor").getBlockOrder)(n).length>0}})))(_e),Se=function(e){var t,n=e.attributes,r=void 0===n?{}:n,c=r.className,a=r.backgroundColor,i=r.customBackgroundColor,u=r.padding,l=Object(E.getColorClassName)("background-color",a),s=_()(c,(t={},o()(t,"wp-block-jetpack-layout-grid__padding-"+u,!0),o()(t,"has-background",a),o()(t,l,l),t)),f={backgroundColor:l?void 0:i};return Object(j.createElement)("div",{className:s,style:f},Object(j.createElement)(E.InnerBlocks.Content,null))};function xe(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 Ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xe(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Pe(e,t){for(var n={},r=function(e){t.map((function(t){n[G(e,t)]={type:"number"},n[L(e,t)]={type:"number",default:0}}))},o=0;o<e;o++)r(o);return n}Object(c.registerBlockType)("jetpack/layout-grid",{title:Object(a.__)("Layout Grid","layout-grid"),description:Object(a.__)("Align blocks to a global grid, with support for responsive breakpoints.","layout-grid"),icon:re,category:"layout",supports:{align:["full"],html:!1},example:{attributes:{columns:2},innerBlocks:[{name:"jetpack/layout-grid-column",innerBlocks:[{name:"core/paragraph",attributes:{customFontSize:32,content:Object(a.__)("<strong>Snow Patrol</strong>","layout-grid"),align:"center"}}]},{name:"jetpack/layout-grid-column",innerBlocks:[{name:"core/image",attributes:{url:"https://s.w.org/images/core/5.3/Windbuchencom.jpg"}}]}]},attributes:Ce({align:{type:"string",default:"full"},gutterSize:{type:"string",default:"large"},addGutterEnds:{type:"boolean",default:!0}},Pe(4,N)),edit:je,save:ke}),Object(c.registerBlockType)("jetpack/layout-grid-column",{description:Object(a.__)("A column used inside a Layout Grid block.","layout-grid"),title:Object(a.__)("Column","layout-grid"),icon:oe,category:"layout",parent:["jetpack/layout-grid"],supports:{inserter:!1,reusable:!1,html:!1},attributes:{backgroundColor:{type:"string"},customBackgroundColor:{type:"string"},padding:{type:"string",default:"none"}},edit:Ee,save:Se})}]);
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 o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r)&&r.length){var a=o.apply(null,r);a&&e.push(a)}else if("object"===c)for(var i in r)n.call(r,i)&&r[i]&&e.push(i)}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},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){!function(){e.exports=this.wp.primitives}()},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(24);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(25),o=n(5);e.exports=function(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?o(e):t}},function(e,t){!function(){e.exports=this.wp.blocks}()},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(20),o=n(21),c=n(22),a=n(23);e.exports=function(e){return r(e)||o(e)||c(e)||a()}},function(e,t){!function(){e.exports=this.lodash}()},function(e,t){!function(){e.exports=this.wp.keycodes}()},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,n){var r=n(19);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,n){var r=n(19);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(){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){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"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,n){"use strict";n.r(t);var r=n(3),o=n.n(r),c=n(13),a=n(1),i=n(16),u=n.n(i),l=n(9),s=n.n(l),f=n(10),d=n.n(f),p=n(5),b=n.n(p),h=n(11),g=n.n(h),m=n(12),v=n.n(m),y=n(7),O=n.n(y),j=n(0),k=n(17),w=n(6),_=n.n(w),E=n(4),S=n(2),x=n(18),C=n(14),P=n(15),M=n(8),z=Object(j.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(j.createElement)(M.Path,{d:"M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"})),B=Object(j.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(j.createElement)(M.Path,{d:"M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"})),R=Object(j.createElement)(M.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(j.createElement)(M.Path,{d:"M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"}));function D(){return[{value:"small",label:Object(a.__)("Small","layout-grid")},{value:"medium",label:Object(a.__)("Medium","layout-grid")},{value:"large",label:Object(a.__)("Large","layout-grid")},{value:"huge",label:Object(a.__)("Huge","layout-grid")}]}var A=function(){return[{label:Object(a.__)("1 column","layout-grid"),value:1},{label:Object(a.__)("2 columns","layout-grid"),value:2},{label:Object(a.__)("3 columns","layout-grid"),value:3},{label:Object(a.__)("4 columns","layout-grid"),value:4}]},V=function(){return[{value:"Desktop",label:Object(a.__)("Desktop","layout-grid"),icon:z},{value:"Tablet",label:Object(a.__)("Tablet","layout-grid"),icon:B},{value:"Mobile",label:Object(a.__)("Mobile","layout-grid"),icon:R}]},N=["Desktop","Tablet","Mobile"];function G(e,t){return"column".concat(e+1).concat(t,"Span")}function L(e,t){return"column".concat(e+1).concat(t,"Offset")}var T=function(e){return"Tablet"===e?8:"Mobile"===e?4:12};function I(e,t,n){return"Tablet"===e?3===t&&2===n?T(e):t>1?T(e)/2:T(e):"Mobile"===e?T(e):T(e)/t}function H(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 U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?H(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var X=function(e,t){return"column".concat(e+1,"-grid__span-").concat(t)},F=function(e,t){return"column".concat(e+1,"-grid__start-").concat(t)},K=function(e,t){return"column".concat(e+1,"-grid__row-").concat(t)},W=function(e,t,n){return"column".concat(e+1,"-").concat(n.toLowerCase(),"-grid__span-").concat(t)},$=function(e,t,n){return"column".concat(e+1,"-").concat(n.toLowerCase(),"-grid__start-").concat(t)},q=function(e,t,n){return"column".concat(e+1,"-").concat(n.toLowerCase(),"-grid__row-").concat(t)};function J(e,t){return Math.floor(e/t)}function Q(e,t){return e%t}function Y(e,t,n,r){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return{name:e,column:t,value:n,device:r,enabled:o}}function Z(e,t,n){for(var r=[],o=T(e),c=function(e,t,n){for(var r=[],o=0,c=0;c<e;c++){var a=G(c,t),i=L(c,t),u=n[a]||I(t,e,c),l=n[i]||0;r.push({position:o+l,span:u}),o+=l,o+=u}return r}(t,e,n),a=0;a<c.length;a++){var i=c[a],u=i.span,l=i.position,s=J(l,o),f=Q(l,o);r.push(Y("span",a,u,e)),r.push(Y("offset",a,f+1,e,f>0)),r.push(Y("row",a,s+1,e))}return r}function ee(e,t){var n={};return e.filter((function(e){return e.enabled&&t[e.name]})).map((function(e){return n[t[e.name](e.column,e.value,e.device)]=!0})),n}function te(e){return e?e.replace(/column\d-\w*-grid__\w*-\d*/g,"").replace(/column\d-grid__\w*-\d*/g,"").replace(/\s{2,}/,"").replace(/wp-block-jetpack-layout-gutter__\w*/,""):e}function ne(e){var t=e.gutterSize;return{"wp-block-jetpack-layout-gutter__nowrap":!e.addGutterEnds,"wp-block-jetpack-layout-gutter__none":"none"===t,"wp-block-jetpack-layout-gutter__small":"small"===t,"wp-block-jetpack-layout-gutter__medium":"medium"===t,"wp-block-jetpack-layout-gutter__huge":"huge"===t}}var re=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(j.createElement)(S.Path,{d:"M19 6H6c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7.5 11.5H6c-.3 0-.5-.2-.5-.5V8c0-.3.2-.5.5-.5h5.5v10zm4 0H13v-10h2.5v10zm4-.5c0 .3-.2.5-.5.5h-2v-10h2c.3 0 .5.2.5.5v9z"}))},oe=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},Object(j.createElement)(S.Path,{d:"M19 6H6c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zM5.5 17V8c0-.3.2-.5.5-.5h5.5v10H6c-.3 0-.5-.2-.5-.5zm14 0c0 .3-.2.5-.5.5h-2v-10h2c.3 0 .5.2.5.5v9z"}))},ce=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7 12v24h34V12H7zm32 22H9V14h30v20z"}))},ae=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7,12v24h34V12H7z M23,34H9V14h14V34z M39,34H25V14h14V34z"}))},ie=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7 12v24h34V12H7zm23 2h9v20h-9V14zm-2 20h-8V14h8v20zM9 14h9v20H9V14z"}))},ue=function(){return Object(j.createElement)(S.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48"},Object(j.createElement)(S.Path,{d:"M7 12v24h34V12H7zm8 22H9V14h6v20zm8 0h-6V14h6v20zm8 0h-6V14h6v20zm8 0h-6V14h6v20z"}))},le=function(e){var t=e.columns;return 4===t?Object(j.createElement)(ue,null):3===t?Object(j.createElement)(ie,null):2===t?Object(j.createElement)(ae,null):Object(j.createElement)(ce,null)};var se=function(e){var t=e.direction,n=e.height,r=e.xPos,o=e.top,c=e.isSelected,a=_()("wpcom-overlay-resize__handle","components-resizable-box__container",{"is-selected":c}),i={height:n+"px",width:r+"px",top:o+"px"},u={left:r+"px"},l=_()("components-resizable-box__handle","components-resizable-box__side-handle",{"components-resizable-box__handle-left":"left"===t,"components-resizable-box__handle-right":"right"===t});return Object(j.createElement)("div",{className:a,style:i},Object(j.createElement)("span",null,Object(j.createElement)("div",{className:l,style:u})))};function fe(e){var t=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}}();return function(){var n,r=O()(e);if(t){var o=O()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return v()(this,n)}}var de=function(e){g()(n,e);var t=fe(n);function n(e){var r;return s()(this,n),r=t.call(this,e),o()(b()(r),"onMouseDown",(function(e){var t=e.target;if((0===e.button||e.touches)&&(t.dataset.resizeRight||t.dataset.resizeLeft)){r.block=t.closest(".wp-block");var n=r.block.getBoundingClientRect(),o=n.height,c=n.right,a=n.left,i=n.top,u=t.getBoundingClientRect().width,l=r.getChildPosition(r.block),s=t.dataset.resizeLeft;r.setState({resizingColumn:l,xPos:r.getAdjustedOffset(r.getMouseX(e),u),height:o,width:u,top:r.getAdjustedTop(i),direction:s?"left":"right",max:s?r.getAdjustedOffset(c,u):r.getAdjustedOffset(a,u)}),0===e.button?(document.addEventListener("mousemove",r.onMouseMove),document.addEventListener("mouseup",r.onMouseUp),e.preventDefault()):(document.addEventListener("touchmove",r.onMouseMove),document.addEventListener("touchend",r.onMouseUp)),e.stopPropagation()}})),o()(b()(r),"onMouseMove",(function(e){e.stopPropagation(),void 0===e.touches&&e.preventDefault();var t=r.block.getBoundingClientRect().height;r.setState({xPos:r.getRestrictedOffset(r.getAdjustedOffset(r.getMouseX(e))),height:t});var n=r.getNearestColumn(r.state.direction,e);n&&r.props.onResize(r.state.resizingColumn,n)})),o()(b()(r),"onMouseUp",(function(e){r.setState({resizingColumn:-1}),document.removeEventListener("mousemove",r.onMouseMove),document.removeEventListener("mouseup",r.onMouseUp),document.removeEventListener("touchmove",r.onMouseMove),document.removeEventListener("touchend",r.onMouseUp)})),r.containerRef=Object(j.createRef)(),r.state={resizingColumn:-1,xPos:0,height:0},r}return d()(n,[{key:"getNearestColumn",value:function(e,t){var n=this.props,r=n.totalColumns,o=n.layoutGrid,c=o.getStart(this.state.resizingColumn),a=o.getSpan(this.state.resizingColumn),i=Math.min(r,Math.max(0,function(e,t,n,r){var o=e.getBoundingClientRect(),c=o.width/r,a=t-o.x,i=Math.floor(a/c),u=a%c;return"left"===n?u<=c/2?i:i+1:u<c/2?i:i+1}(this.containerRef.current,this.getMouseX(t),e,r)));if("left"===e){if(i===c)return null;var u=Math.abs(i-c),l={start:i,span:i>c?a-u:a+u,direction:e};return l.start>=c+a?null:(l.span=Math.max(1,l.span),l)}return{span:Math.max(1,i-c),direction:e}}},{key:"getMouseX",value:function(e){var t=e.clientX,n=e.targetTouches;return t||n&&n[0].clientX}},{key:"getAdjustedOffset",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.state.width,r=t>0?t:n;return e-this.containerRef.current.getBoundingClientRect().left-r/2}},{key:"getAdjustedTop",value:function(e){return e-this.containerRef.current.getBoundingClientRect().top}},{key:"getRestrictedOffset",value:function(e){var t=this.state,n=t.direction,r=t.max,o=t.width;return"left"===n?Math.min(r-o,e):Math.max(r+o,e)}},{key:"getChildPosition",value:function(e){for(var t=0;null!==e.previousSibling;)e=e.previousSibling,t++;return t}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.children,r=e.isSelected,o=this.state,c=o.resizingColumn,a=o.xPos,i=o.height,u=_()(t,-1!==c?"wp-block-jetpack-layout-grid__resizing":null);return Object(j.createElement)("div",{className:u,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,ref:this.containerRef},-1!==c&&Object(j.createElement)(se,{direction:this.state.direction,height:i,xPos:a,top:this.state.top,isSelected:r}),n)}}]),n}(j.Component);function pe(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 be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pe(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var he=function(){function e(t,n,r){s()(this,e),this.attributes=t,this.device=n,this.columnCount=r}return d()(e,[{key:"getGridValues",value:function(){for(var e={},t=0;t<this.columnCount;t++){var n=I(this.device,this.columnCount,t);e[G(t,this.device)]=this.getSpan(t)||n,e[L(t,this.device)]=this.getOffset(t)}return e}},{key:"applyAdjustments",value:function(e){for(var t=this.getGridValues(),n=0;n<e.length;n++)t=be(be({},t),e[n]);return t}},{key:"getSpanAdjustment",value:function(e,t){return o()({},G(e,this.device),t)}},{key:"getAdjustOffset",value:function(e,t){return o()({},L(e,this.device),t)}},{key:"getShrinkOffset",value:function(e,t){var n=this.getOffset(e),r=t>=n?n:t;return{adjustment:this.getAdjustOffset(e,n-r),offsetUsed:r}}},{key:"hasOverlaps",value:function(e){for(var t=0;t<e.length;t++)for(var n=e[t],r=t+1;r<e.length;r++){var o=e[r];if(n.start>o.start&&n.start<o.end)return!0;if(n.end>o.start&&n.end<o.end)return!0}return!1}},{key:"validateGrid",value:function(e){for(var t,n,r=[],o=T(this.device),c=0,a=0,i=0;i<this.columnCount;i++){var u=e[G(i,this.device)],l=e[L(i,this.device)];if((a+=l)>=o&&(a-=o),(a+=u)>o)return!1;r.push({start:c+l,end:c+l+u}),c+=u+l}return!(c>(t=this.device,n=this.columnCount,"Tablet"===t&&n>2?2*T(t):"Mobile"===t?T(t)*n:T(t)))&&!this.hasOverlaps(r)}},{key:"getEndAdjustments",value:function(e,t){var n=[];if(t<0)return[this.getAdjustOffset(e,this.getOffset(e)+Math.abs(t))];if(t>0)for(var r=e;r<this.columnCount&&t>0;r++){var o=this.getShrinkOffset(r,Math.abs(t));n.push(o.adjustment),t-=o.offsetUsed}return n}},{key:"getStartMovedLeft",value:function(e,t){for(var n=[],r=e;r>=0&&t>0;r--){var o=this.getShrinkOffset(r,t);n.push(o.adjustment),t-=o.offsetUsed}return n}},{key:"getStartAdjustments",value:function(e,t){var n=this.getOffset(e),r=this.getOffsetFromStart(e,t),o=r-n;return o<0?this.getStartMovedLeft(e,Math.abs(o)):[this.getAdjustOffset(e,r)]}},{key:"getSpan",value:function(e){return this.attributes[G(e,this.device)]}},{key:"getOffset",value:function(e){return this.attributes[L(e,this.device)]}},{key:"getStart",value:function(e){for(var t=0,n=0;n<e;n++)t+=this.getSpan(n)+this.getOffset(n);var r=Math.max(1,Math.floor(t/T(this.device)));return(t+this.getOffset(e))%(r*T(this.device))}},{key:"getOffsetFromStart",value:function(e,t){if(0===e)return t;var n=t-this.getStart(e);return this.getOffset(e)+n}},{key:"convertOffsetToStart",value:function(e,t){return this.getStart(e)+(t-this.getOffset(e))}},{key:"getAdjustedGrid",value:function(e,t){var n=t.start,r=void 0===n?this.getStart(e):n,o=t.span,c=void 0===o?this.getSpan(e):o,a=[];r!==this.getStart(e)&&c!==this.getSpan(e)?a=(a=a.concat(this.getStartAdjustments(e,r))).concat(this.getSpanAdjustment(e,c)):c!==this.getSpan(e)?a=(a=a.concat(this.getSpanAdjustment(e,c))).concat(this.getEndAdjustments(e+1,c-this.getSpan(e))):r!==this.getStart(e)&&(a=(a=a.concat(this.getStartAdjustments(e,r))).concat(this.getEndAdjustments(e+1,r-this.getStart(e))));var i=this.applyAdjustments(a);return a.length>0&&this.validateGrid(i)?i:null}}]),e}();function ge(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 me(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ge(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ve(e){var t=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}}();return function(){var n,r=O()(e);if(t){var o=O()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return v()(this,n)}}var ye=["jetpack/layout-grid-column"],Oe=function(e){g()(n,e);var t=ve(n);function n(e){var r;return s()(this,n),r=t.call(this,e),o()(b()(r),"onChangeLayout",(function(e){for(var t={},n=0;n<e;n++)for(var o=0;o<N.length;o++){var c=I(N[o],e,n);t[G(n,N[o])]=c,t[L(n,N[o])]=0}r.props.updateColumns(r.props.columns,e,t)})),o()(b()(r),"onChangeDevice",(function(e){r.setState({selectedDevice:e})})),o()(b()(r),"onResize",(function(e,t){var n=r.props,o=n.attributes,c=n.columns,a=new he(o,r.state.selectedDevice,c).getAdjustedGrid(e,t);a&&r.adjustGrid(a)})),o()(b()(r),"onChangeSpan",(function(e,t,n){var o=r.props,c=o.attributes,a=o.columns,i=new he(c,t,a).getAdjustedGrid(e,{span:parseInt(n,10)});i&&r.adjustGrid(i)})),o()(b()(r),"onChangeOffset",(function(e,t,n){var o=r.props,c=o.attributes,a=o.columns,i=new he(c,t,a),u=i.getAdjustedGrid(e,{start:i.convertOffsetToStart(e,parseInt(n,10))});u&&r.adjustGrid(u)})),r.overlayRef=Object(j.createRef)(),r.state={selectedDevice:V()[0].value},r}return d()(n,[{key:"adjustGrid",value:function(e){var t=this.props,n=t.setAttributes,r=t.attributes;n(me(me({},e),{},{className:te(r.className)}))}},{key:"renderDeviceSettings",value:function(e,t,n){for(var r=this,o=new he(n,t,this.props.columns),c=[],i=function(n){var i=o.getSpan(n)||I(t,e,n),u=o.getOffset(n)||0;c.push(Object(j.createElement)("div",{className:"jetpack-layout-grid-settings",key:n},Object(j.createElement)("strong",null,Object(a.__)("Column","layout-grid")," ",n+1),Object(j.createElement)("div",{className:"jetpack-layout-grid-settings__group"},Object(j.createElement)(S.TextControl,{type:"number",label:Object(a.__)("Offset","layout-grid"),value:u||0,min:0,max:T(t)-1,onChange:function(e){return r.onChangeOffset(n,t,e)}}),Object(j.createElement)(S.TextControl,{type:"number",label:Object(a.__)("Span","layout-grid"),value:i,min:1,max:T(t),onChange:function(e){return r.onChangeSpan(n,t,e)}}))))},u=0;u<e;u++)i(u);return c}},{key:"canResizeBreakpoint",value:function(e){return!(!this.overlayRef||!this.overlayRef.current)&&this.overlayRef.current.getBoundingClientRect().width/T(e)>50}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,r=t.attributes,o=void 0===r?{}:r,c=t.isSelected,i=t.columns,u=t.setAttributes,l=this.state.selectedDevice,s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Z(e,t,n),o={span:X,offset:F,row:K};return ee(r,o)}(l,i,o),f=o.gutterSize,d=o.addGutterEnds,p=new he(o,l,i),b=_()(te(n),s,{"wp-block-jetpack-layout-tablet":"Tablet"===l,"wp-block-jetpack-layout-desktop":"Desktop"===l,"wp-block-jetpack-layout-mobile":"Mobile"===l,"wp-block-jetpack-layout-resizable":this.canResizeBreakpoint(l)},ne(o));if(0===i)return Object(j.createElement)(S.Placeholder,{icon:"layout",label:Object(a.__)("Choose Layout","layout-grid"),instructions:Object(a.__)("Select a layout to start with:","layout-grid"),className:b},Object(j.createElement)("ul",{className:"block-editor-inner-blocks__template-picker-options"},A().map((function(t){return Object(j.createElement)("li",{key:t.value},Object(j.createElement)(S.IconButton,{isSecondary:!0,icon:Object(j.createElement)(le,{columns:t.value}),onClick:function(){return e.onChangeLayout(t.value)},className:"block-editor-inner-blocks__template-picker-option",label:t.label}))}))));var h=Object(j.createElement)(S.ToggleControl,{label:Object(a.__)("Add end gutters","layout-grid"),help:d?Object(a.__)("Toggle off to remove the spacing left and right of the grid.","layout-grid"):Object(a.__)("Toggle on to add space left and right of the layout grid. ","layout-grid"),checked:d,onChange:function(e){return u({addGutterEnds:e})}});return Object(j.createElement)(j.Fragment,null,Object(j.createElement)(S.IsolatedEventContainer,null,Object(j.createElement)(de,{className:b,onResize:this.onResize,totalColumns:T(l),layoutGrid:p,isSelected:c},Object(j.createElement)("div",{className:"wpcom-overlay-grid",ref:this.overlayRef},Object(k.times)(T(l)).map((function(e){return Object(j.createElement)("div",{className:"wpcom-overlay-grid__column",key:e})}))),Object(j.createElement)(E.InnerBlocks,{template:null,templateLock:"all",allowedBlocks:ye}),Object(j.createElement)(E.InspectorControls,null,Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Layout","layout-grid")},Object(j.createElement)("div",{className:"jetpack-layout-grid-columns block-editor-block-styles"},A().map((function(t){return Object(j.createElement)("div",{key:t.value,className:_()("block-editor-block-styles__item",{"is-active":i===t.value}),onClick:function(){return e.onChangeLayout(t.value)},onKeyDown:function(n){x.ENTER!==n.keyCode&&x.SPACE!==n.keyCode||(n.preventDefault(),e.onChangeLayout(t.value))},role:"button",tabIndex:"0","aria-label":t.label},Object(j.createElement)("div",{className:"block-editor-block-styles__item-preview"},Object(j.createElement)(le,{columns:t.value})),Object(j.createElement)("div",{className:"editor-block-styles__item-label block-editor-block-styles__item-label"},t.label))}))),Object(j.createElement)("p",null,Object(j.createElement)("em",null,Object(a.__)("Changing the number of columns will reset your layout and could remove content.","layout-grid")))),Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Responsive Breakpoints","layout-grid")},Object(j.createElement)("p",null,Object(j.createElement)("em",null,Object(a.__)("Note that previewing your post will show your browser's breakpoint, not the currently selected one.","layout-grid"))),Object(j.createElement)(S.ButtonGroup,null,V().map((function(t){return Object(j.createElement)(S.Button,{key:t.value,isPrimary:t.value===l,onClick:function(){return e.onChangeDevice(t.value)}},t.label)}))),this.renderDeviceSettings(i,l,o)),Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Gutter","layout-grid")},Object(j.createElement)("p",null,Object(a.__)("Gutter size","layout-grid")),Object(j.createElement)(S.SelectControl,{value:f,onChange:function(e){return u({gutterSize:e,addGutterEnds:"none"!==e&&d})},options:[{value:"none",label:Object(a.__)("No gutter","layout-grid")}].concat(D())}),"none"===f?Object(j.createElement)(S.Disabled,null,h):h)))),Object(j.createElement)(E.BlockControls,null,Object(j.createElement)(S.Dropdown,{renderToggle:function(e){var t=e.isOpen,n=e.onToggle;return Object(j.createElement)(S.ToolbarGroup,null,Object(j.createElement)(S.Button,{"aria-expanded":t,onClick:n,icon:V().find((function(e){return e.value===l})).icon}))},renderContent:function(t){t.onClose;return Object(j.createElement)(S.MenuGroup,null,V().map((function(t){return Object(j.createElement)(S.MenuItem,{key:t.value,isSelected:t.value===l,onClick:function(){return e.setState({selectedDevice:t.value})},icon:t.icon},t.label)})))}})))}}]),n}(j.Component);var je=Object(P.compose)([Object(C.withDispatch)((function(e,t,n){return{updateColumns:function(r,o,a){var i=t.clientId,l=e("core/block-editor").replaceBlock,s=function(e,t,n){if(n>t)return[].concat(u()(e),u()(Object(k.times)(n-t,(function(){return Object(c.createBlock)("jetpack/layout-grid-column")}))));var r=u()(e),o=0;return r.reverse(),(r=r.filter((function(e){return!(o<t-n&&0===e.innerBlocks.length)||(o++,!1)}))).slice(Math.max(0,t-n-o)).reverse()}((0,n.select("core/block-editor").getBlocks)(i),r,o);l(i,Object(c.createBlock)(t.name,me(me(me({},t.attributes),a),{},{className:te(t.attributes.className)}),s))}}})),Object(C.withSelect)((function(e,t){var n=t.clientId;return{columns:e("core/block-editor").getBlockCount(n)}}))])(Oe),ke=function(e){var t=e.attributes,n=e.innerBlocks,r=t.className,o=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={},r={span:W,offset:$,row:q},o=0;o<N.length;o++)n=U(U({},n),ee(Z(N[o],e,t),r));return t.addGutterEnds||(n["wp-block-jetpack-layout-gutter__nowrap"]=!0),n}(n.length,t),c=_()(te(r),o,ne(t));return Object(j.createElement)("div",{className:c},Object(j.createElement)(E.InnerBlocks.Content,null))};function we(e){var t=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}}();return function(){var n,r=O()(e);if(t){var o=O()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return v()(this,n)}}var _e=function(e){g()(n,e);var t=we(n);function n(e){var r;return s()(this,n),r=t.call(this,e),o()(b()(r),"onLeftIn",(function(){r.setState({direction:"left"}),document.addEventListener("mouseup",r.onLeftOut)})),o()(b()(r),"onLeftOut",(function(){r.setState({direction:null}),document.removeEventListener("mouseup",r.onLeftOut)})),o()(b()(r),"onRightIn",(function(){r.setState({direction:"right"}),document.addEventListener("mouseup",r.onRightOut)})),o()(b()(r),"onRightOut",(function(){r.setState({direction:null}),document.removeEventListener("mouseup",r.onRightOut)})),r.state={direction:null},r}return d()(n,[{key:"render",value:function(){var e,t=this.props,n=t.className,r=t.hasChildBlocks,c=t.backgroundColor,i=t.setBackgroundColor,u=t.attributes,l=t.setAttributes,s=u.padding,f=this.state.direction,d=_()(n,c.class,(e={},o()(e,"wp-block-jetpack-layout-grid__padding-"+s,!0),o()(e,"has-background",c.color),o()(e,"components-resizable-box__container",!0),o()(e,c.class,c.class),o()(e,"wp-blocks-jetpack-layout-grid__showleft","right"===f),o()(e,"wp-blocks-jetpack-layout-grid__showright","left"===f),e)),p={backgroundColor:c.color};return Object(j.createElement)("div",{className:d,style:p},Object(j.createElement)("span",{className:"wp-blocks-jetpack-layout-grid__resize-handles"},Object(j.createElement)("div",{className:"components-resizable-box__handle components-resizable-box__side-handle components-resizable-box__handle-right",onMouseDown:this.onRightIn,"data-resize-right":!0}),Object(j.createElement)("div",{className:"components-resizable-box__handle components-resizable-box__side-handle components-resizable-box__handle-left",onMouseDown:this.onLeftIn,"data-resize-left":!0})),Object(j.createElement)(E.InnerBlocks,{templateLock:!1,renderAppender:r?void 0:function(){return Object(j.createElement)(E.InnerBlocks.ButtonBlockAppender,null)}}),Object(j.createElement)(E.InspectorControls,null,Object(j.createElement)(E.PanelColorSettings,{title:Object(a.__)("Column Color","layout-grid"),initialOpen:!0,colorSettings:[{value:c.color,onChange:i,label:Object(a.__)("Background","layout-grid")}]}),Object(j.createElement)(S.PanelBody,{title:Object(a.__)("Column Padding","layout-grid")},Object(j.createElement)("p",null,Object(a.__)("Choose padding for this column:","layout-grid")),Object(j.createElement)(S.SelectControl,{value:s,onChange:function(e){return l({padding:e})},options:[{value:"none",label:Object(a.__)("No padding","layout-grid")}].concat(D())}))))}}]),n}(j.Component),Ee=Object(P.compose)(Object(E.withColors)("backgroundColor"),Object(C.withSelect)((function(e,t){var n=t.clientId;return{hasChildBlocks:(0,e("core/block-editor").getBlockOrder)(n).length>0}})))(_e),Se=function(e){var t,n=e.attributes,r=void 0===n?{}:n,c=r.className,a=r.backgroundColor,i=r.customBackgroundColor,u=r.padding,l=Object(E.getColorClassName)("background-color",a),s=_()(c,(t={},o()(t,"wp-block-jetpack-layout-grid__padding-"+u,!0),o()(t,"has-background",a),o()(t,l,l),t)),f={backgroundColor:l?void 0:i};return Object(j.createElement)("div",{className:s,style:f},Object(j.createElement)(E.InnerBlocks.Content,null))};function xe(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 Ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xe(Object(n),!0).forEach((function(t){o()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Pe(e,t){for(var n={},r=function(e){t.map((function(t){n[G(e,t)]={type:"number"},n[L(e,t)]={type:"number",default:0}}))},o=0;o<e;o++)r(o);return n}Object(c.registerBlockType)("jetpack/layout-grid",{title:Object(a.__)("Layout Grid","layout-grid"),description:Object(a.__)("Align blocks to a global grid, with support for responsive breakpoints.","layout-grid"),icon:re,category:"layout",supports:{align:["full"],html:!1},example:{attributes:{columns:2},innerBlocks:[{name:"jetpack/layout-grid-column",innerBlocks:[{name:"core/paragraph",attributes:{customFontSize:32,content:Object(a.__)("<strong>Snow Patrol</strong>","layout-grid"),align:"center"}}]},{name:"jetpack/layout-grid-column",innerBlocks:[{name:"core/image",attributes:{url:"https://s.w.org/images/core/5.3/Windbuchencom.jpg"}}]}]},attributes:Ce({align:{type:"string",default:"full"},gutterSize:{type:"string",default:"large"},addGutterEnds:{type:"boolean",default:!0}},Pe(4,N)),edit:je,save:ke}),Object(c.registerBlockType)("jetpack/layout-grid-column",{description:Object(a.__)("A column used inside a Layout Grid block.","layout-grid"),title:Object(a.__)("Column","layout-grid"),icon:oe,category:"layout",parent:["jetpack/layout-grid"],supports:{inserter:!1,reusable:!1,html:!1},attributes:{backgroundColor:{type:"string"},customBackgroundColor:{type:"string"},padding:{type:"string",default:"none"}},edit:Ee,save:Se})}]);
index.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Layout Grid
4
  * Description: Let any blocks align to a global grid
5
- * Version: 1.2
6
  * Author: Automattic
7
  * Author URI: https://automattic.com
8
  * License: GPL v2 or later
2
  /**
3
  * Plugin Name: Layout Grid
4
  * Description: Let any blocks align to a global grid
5
+ * Version: 1.2.1
6
  * Author: Automattic
7
  * Author URI: https://automattic.com
8
  * License: GPL v2 or later
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Layout Grid Block ===
2
  Contributors: automattic, jasmussen, johnny5, mkaz
3
- Stable tag: 1.2
4
- Tested up to: 5.4
5
  Requires at least: 5.4
6
  License: GPLv2 or later
7
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -23,7 +23,13 @@ You can follow development, file an issue, suggest features, and view the source
23
 
24
  == Changelog ==
25
 
26
- = 1.2 - 29th April 2020
 
 
 
 
 
 
27
  * Move the selected breakpoint to the toolbar and allow it to be toggled
28
  * Bump minimum WordPress version to 5.4
29
  * Improve drag handle behaviour
1
  === Layout Grid Block ===
2
  Contributors: automattic, jasmussen, johnny5, mkaz
3
+ Stable tag: 1.2.1
4
+ Tested up to: 5.4.2
5
  Requires at least: 5.4
6
  License: GPLv2 or later
7
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
23
 
24
  == Changelog ==
25
 
26
+ = 1.2.1 - 10th June 2020 =
27
+ * Fix block inserter to show inside a grid column
28
+ * Fix vertical margin in editor so it better matches the display
29
+ * Fix CSS loading so it is only added when block is used
30
+ * Fix grid lines appearing when inner block is selected
31
+
32
+ = 1.2 - 29th April 2020 =
33
  * Move the selected breakpoint to the toolbar and allow it to be toggled
34
  * Bump minimum WordPress version to 5.4
35
  * Improve drag handle behaviour
style.css CHANGED
@@ -8,7 +8,8 @@
8
  /* autoprefixer grid: no-autoplace */
9
  .wp-block-jetpack-layout-grid {
10
  padding-left: 24px;
11
- padding-right: 24px; }
 
12
  .wp-block-jetpack-layout-grid.wp-block-jetpack-layout-gutter__none {
13
  padding-left: 0px;
14
  padding-right: 0px; }
8
  /* autoprefixer grid: no-autoplace */
9
  .wp-block-jetpack-layout-grid {
10
  padding-left: 24px;
11
+ padding-right: 24px;
12
+ box-sizing: border-box; }
13
  .wp-block-jetpack-layout-grid.wp-block-jetpack-layout-gutter__none {
14
  padding-left: 0px;
15
  padding-right: 0px; }